Changeset 32
- Timestamp:
- 10/12/08 23:43:39
- Files:
-
- trunk/bin/MouthOS.bin (modified) (previous)
- trunk/build.sh (modified) (1 diff)
- trunk/images/MouthOS.img (modified) (previous)
- trunk/src/arch/intel/as.c (modified) (1 diff)
- trunk/src/include/sys/pageing.h (modified) (5 diffs)
- trunk/src/kernel.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build.sh
r28 r32 268 268 $RUN 269 269 270 INPUT_FILE="\.\/src\/arch\/intel\/as\.c" 271 OUTPUT_FILE="\.\/bin\/kernel\/as\.o" 272 RUN=`echo $COMPILER | sed "s/input/$INPUT_FILE/g"` 273 RUN=`echo $RUN | sed "s/output/$OUTPUT_FILE/g"` 274 RUN=`echo $RUN | sed "s/flags/$FLAGS/g"` 275 $RUN 276 270 277 # Link all the files together... 271 278 trunk/src/arch/intel/as.c
r31 r32 8 8 9 9 as_t * 10 create_as()10 init_as() 11 11 { 12 12 13 as_t *as = kmem_alloc(sizeof(as_t) * (4096 / (PAGE_SIZE * 1024))); 13 as_t *tmp; 14 int i, j; 15 16 #ifdef DEBUG 17 kprintf("init_as(): setting up kernel address space...\n"); 18 #endif 19 20 tmp = kmem_alloc(sizeof(as_t)); 21 for ( i = 0 ; i < 1024 ; i++ ) { 22 23 /* Mark the page as present, kernel level, 24 * read/write and disable caching. 25 */ 26 tmp->pd[i].data = 0; 27 tmp->pd[i].data |= PAGE_PRESENT; 28 tmp->pd[i].data |= PAGE_RW; 29 tmp->pd[i].data |= PAGE_CACHEDISABLED; 30 31 /* Apply our PAGE_MASK to all addresses so 32 * that we only get the first 20 bytes of the 33 * full 32bit address of the page table. 34 */ 35 tmp->pd[i].data |= (PAGE_MASK & tmp->pt[i].pte[i].data); 36 37 for ( j = 0 ; j < 1024 ; j++ ) { 38 39 /* Again mark the pages as present, kernel level, 40 * read/write and disable caching. 41 */ 42 tmp->pt[i].pte[j].data = 0; 43 tmp->pt[i].pte[j].data |= PAGE_PRESENT; 44 tmp->pt[i].pte[j].data |= PAGE_RW; 45 tmp->pt[i].pte[j].data |= PAGE_CACHEDISABLED; 46 47 /* Apply the PAGE_MASK to all addresses so 48 * that we only get the first 20 bytes of the 49 * full 32bit address of the page base. 50 * 51 * The last 10 bits are included in the offset. 52 */ 53 tmp->pt[i].pte[j].data |= (PAGE_MASK & (PAGE_SIZE * 1024 * j)); 54 55 } 56 57 } 58 59 60 #ifdef DEBUG 61 kprintf("init_as(): kernel address space completed..\n"); 62 kprintf("init_as(): enabling pageing...\n"); 63 #endif 64 65 // TODO: Now enable paging. We must do this with asm by 66 // setting BIT32 of CR0 to 1 and then pushing 67 // the address of pde_t into CR3. 68 69 return tmp; 14 70 15 71 } 16 trunk/src/include/sys/pageing.h
r31 r32 1 1 /* MouthOS (wombat) Kernel 2 * 3 * #define PAGE_MASK 0xFFFFF000 2 4 * (C) Copyright 2008. Michael F Clarke. All Rights Reserved. 3 5 */ … … 80 82 */ 81 83 typedef struct pt { 82 pte_t [1024] pte;84 pte_t pte[1024]; 83 85 } pt_t; 84 86 … … 119 121 typedef struct as { 120 122 121 pde_t [1024] pd;122 pt_t [1024] pt;123 pde_t pd[1024]; 124 pt_t pt[1024]; 123 125 124 126 } as_t; … … 185 187 #define PAGE_NOT_FREE 4 186 188 189 #define PAGE_PRESENT 0x1 190 #define PAGE_RW 0x2 191 #define PAGE_USER 0x4 192 #define PAGE_WRITETHROUGH 0x8 193 #define PAGE_CACHEDISABLED 0x10 194 #define PAGE_ACCESSED 0x20 195 #define PAGE_DIRTY 0x40 196 #define PAGE_LARGEPAGES 0x80 197 #define PAGE_GLOBAL 0x100 198 199 #define PAGE_MASK 0xFFFFF000 200 187 201 void init_memory(kinfo_t *kernel_info); 188 202 void *kmem_alloc(int size); … … 190 204 void kmem_free(void *start_addr); 191 205 206 as_t *init_as(); trunk/src/kernel.c
r28 r32 39 39 void *tmp; 40 40 41 as_t *kas; 42 41 43 /* 42 44 * Populate the kernel_info structure with as much information as … … 53 55 init_memory(&kernel_info); 54 56 init_sched(); 57 kas = init_as(); 55 58 56 59 /* … … 58 61 */ 59 62 kprintf("Loading MouthOS Kernel...\n"); 63 kas = kmem_alloc(sizeof(as_t)); 60 64 kprintf("Kernel loaded at: 0x%x, Kernel size: %dK\n", 61 65 kernel_info.entry_addr, kernel_info.size/1024);
