#ifndef PPC_TRIVIAL_PTE_MAPPING_H #define PPC_TRIVIAL_PTE_MAPPING_H /* $Id$ */ /* Rudimentary page/hash table support for Powerpc * * A simple, static (i.e. no 'per-process' virtual * address space etc.) page table providing * one-to-one effective <-> virtual <-> physical * address mapping. * * PURPOSE: * 1) allow write-protection of text/read-only data areas * 2) provide more effective-address space in case * the BATs are not enough * LIMITATIONS: * - once activated, the page table cannot be changed * - no PTE replacement (makes no sense in a real-time * environment, anyway) -> the page table just MUST * be big enough!. * - only one page table supported. */ /* Author: Till Straumann , 4/2002 */ /* Abstract handle for a page table */ typedef struct Triv121PgTblRec_ *Triv121PgTbl; /* Initialize a trivial page table * using 2^ldSize bytes of memory starting at * 'base'. * * RETURNS: a handle to the internal data structure * used to manage the page table. NULL on * error. * * NOTES: - 'base' must be aligned to the size * - minimal ldSize is 16 (== 64k) * - this routine maps the page table itself * with read-only access. While this prevents * the CPU from overwriting the page table, * it can still be corrupted by PCI bus masters * (like DMA engines, [VME] bridges etc.) and * even by this CPU if either the MMU is off * or if there is a DBAT mapping granting write * access... */ Triv121PgTbl triv121PgTblInit(unsigned long base, unsigned ldSize); /* get the log2 of the minimal page table size needed * for mapping 'size' bytes. * * EXAMPLE: create a page table which maps the entire * physical memory. The page table itself shall * be allocated at the top of the available * memory (assuming 'memsize' is a power of two): * * ldSize = triv121PgTblLdMinSize(memsize); * memsize -= (1<virtual address mapping */ #define TRIV121_MAP_SUCCESS (-1) /* triv121PgTblMap() returns this on SUCCESS */ /* get a handle to the one and only page table * (must have been initialized/allocated) * * RETURNS: NULL if the page table has not been initialized/allocated. */ Triv121PgTbl triv121PgTblGet(void); /* * compute the SDR1 register value for the page table */ unsigned long triv121PgTblSDR1(Triv121PgTbl pgTbl); /* * Activate the page table: * - set up the segment registers for a 1:1 effective <-> virtual address mapping, * give user and supervisor keys. * - set up the SDR1 register * - flush all tlbs * - 'lock' pgTbl, i.e. prevent all further modifications. * * NOTE: This routine does not change any BATs. Since these * have priority over the page table, the user * may have to switch overlapping BATs OFF in order * for the page table mappings to take effect. */ void triv121PgTblActivate(Triv121PgTbl pgTbl); #endif