4 #define MAP_FLAGS (PTE_PRESENT | PTE_READ_WRITE)
6 void * pt_setup(int smbase) {
10 /* The page directory and page table live at SMBASE and SMBASE + 0x1000,
11 * respectively; clear them. */
12 int * pagedirectory = (int *) smbase;
13 int * pagetable = (int *) (smbase + 0x1000);
15 /* Clear out the page directory except for one entry pointing to the
16 * page table, and clear the page table entirely. */
18 pagedirectory[0] = (smbase + 0x1000) | PTE_PRESENT | PTE_READ_WRITE;
20 for (i = 1; i < 1024; i++)
26 for (i = 0; i < 1024; i++)
32 /* The page at 0x10000 - 0x10FFF points to the SMI entry point,
34 pagetable[16] = (0x8000 + smbase) | MAP_FLAGS;
36 /* 0x11000 to 0x1EFFF map to the rest of ASEG up to SMBASE + 0xF000;
37 * the page containing the saved state is not mappped to our code
40 for (i = 0; i < 8; i++)
42 pagetable[17 + i] = (i * 0x1000 + smbase) | MAP_FLAGS;
45 for (i = 0; i < 6; i++)
47 pagetable[25 + i] = (smbase + 0x9000 + i * 0x1000) | MAP_FLAGS;
51 /* Map 0xA8000 to itself. */
52 pagetable[0xA8] = 0xA8000 | MAP_FLAGS;
53 pagetable[0xA9] = 0xA9000 | MAP_FLAGS;