]> Joshua Wise's Git repositories - netwatch.git/blob - aseg-paging/pagetable.c
remove old stuff
[netwatch.git] / aseg-paging / pagetable.c
1 #include "vm_flags.h"
2 #include <io.h>
3
4 #define MAP_FLAGS       (PTE_PRESENT | PTE_READ_WRITE)
5
6 void * pt_setup(int smbase) {
7         int i;
8         outb(0x80, 0x51);
9
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);
14
15         /* Clear out the page directory except for one entry pointing to the
16          * page table, and clear the page table entirely. */
17         outb(0x80, 0x52);
18         pagedirectory[0] = (smbase + 0x1000) | PTE_PRESENT | PTE_READ_WRITE;
19         outb(0x80, 0x53);
20         for (i = 1; i < 1024; i++)
21         {
22                 pagedirectory[i] = 0;
23         }
24
25         outb(0x80, 0x54);
26         for (i = 0; i < 1024; i++)
27         {
28                 pagetable[i] = 0;
29         }
30         outb(0x80, 0x55);
31
32         /* The page at 0x10000 - 0x10FFF points to the SMI entry point,
33          * SMBASE + 0x8000. */
34         pagetable[16] = (0x8000 + smbase) | MAP_FLAGS;
35
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
38          * region.  */
39
40         for (i = 0; i < 8; i++)
41         {
42                 pagetable[17 + i] = (i * 0x1000 + smbase) | MAP_FLAGS;
43         }
44
45         for (i = 0; i < 6; i++)
46         {
47                 pagetable[25 + i] = (smbase + 0x9000 + i * 0x1000) | MAP_FLAGS;
48         }
49
50         outb(0x80, 0x56);
51         /* Map 0xA8000 to itself. */
52         pagetable[0xA8] = 0xA8000 | MAP_FLAGS;
53         pagetable[0xA9] = 0xA9000 | MAP_FLAGS;
54
55         /* No TSEG yet. */
56
57         outb(0x80, 0x57);
58         return pagedirectory;
59 }
This page took 0.027162 seconds and 4 git commands to generate.