]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/include/arch-x86/mem.h
Initial checkin from Perforce.
[polintos/scott/priv.git] / kernel / include / arch-x86 / mem.h
1 #ifndef _ARCH_MEM_H
2 #define _ARCH_MEM_H
3
4 #include <kern/types.h>
5 #include <arch/paging.h>
6 #include <kernel/region.h>
7
8 extern int _end;
9
10 namespace Mem {
11         class PageAllocZone;
12 };
13
14 namespace Arch {
15         // First and last+1 pages of memory, as page numbers.  Small holes are
16         // ignored; large holes will require discontiguous memory support.
17         
18         static const size_t mem_start = 0;
19         extern u64 mem_end;
20         
21         extern uintptr_t next_free_bootmem;
22         
23         namespace Priv {
24                 // Highzone and DMA32Zone aren't currently used, but will be once high
25                 // memory support is added (PAE support will also be required for
26                 // Highzone).  KZone only goes up to 1.5GiB, to allow 512 MiB for
27                 // kernel virtual mappings.
28                 
29                 static const int num_zones = 2;
30                 
31                 static const System::Mem::Region mem_zone_regions[num_zones] = {
32                         { 0, 16*1024*1024 - 1 }, // ISA DMA zone
33                         { 16*1024*1024, 1536*1024*1024 - 1 }, // Kernel direct mappable (KZone)
34 #if 0
35                         { 1536*1024*1024, 4ULL*1024*1024*1024 - 1 }, // DMA32Zone
36                         { 4ULL*1024*1024*1024, 36ULL*1024*1024*1024 - 1} // HighZone
37 #endif
38                 };
39                 
40                 extern Mem::PageAllocZone pagezones[num_zones];
41         }
42         
43         extern Mem::PageAllocZone **pagezonelists[Priv::num_zones];
44
45         namespace Priv {
46                 struct Descriptor {
47                         u16 limit_low;
48                         u16 base_low;
49                         u8 base_mid;
50                         u8 type:4;
51                         u8 user:1;
52                         u8 dpl:2;
53                         u8 present:1;
54                         u8 limit_high:4;
55                         u8 sw:1;
56                         u8 reserved:1;
57                         u8 opsize:1;
58                         u8 gran:1;
59                         u8 base_high;
60                 };
61
62                 void early_adjust_mappings();
63
64                 // Call after mem_end is set.
65                 void map_physmem();
66         }
67 }
68
69 extern Arch::Priv::Descriptor x86_gdt[1024];
70
71 #endif