comparison cos/kernel/kernel.c @ 33:d8185ddb6c7b

Added more interrupt handlers
author windel
date Sun, 15 Jan 2012 13:39:49 +0100
parents 3a6a9b929db0
children 8012221dd740
comparison
equal deleted inserted replaced
32:3a6a9b929db0 33:d8185ddb6c7b
1
2 #include "kernel.h" 1 #include "kernel.h"
3 2
4 static void testMalloc() 3 static void testMalloc()
5 { 4 {
6 char *a, *b; 5 char *a, *b;
25 init_screen(); 24 init_screen();
26 setupIDT(); 25 setupIDT();
27 26
28 uint64_t available_memory = 0; 27 uint64_t available_memory = 0;
29 28
29 printf("Running with %d MB ram\n", available_memory / 1000000);
30
31 printf("Detecting amount of memory\n");
32
33 printf("Grub multiboot header location: %x\n", multiboot_info);
34 // On real hardware, the retrieval of the flags fails into general protection fault??
35
36 printf("Grub lower mem: %d\n", multiboot_info->mem_lower);
37 printf("Grub multiboot header flags: %x\n", multiboot_info->flags);
38
30 /* Display memory information from multiboot header */ 39 /* Display memory information from multiboot header */
31 if ((multiboot_info->flags & (1<<6)) == (1<<6)) 40 if ((multiboot_info->flags & (1<<6)) == (1<<6))
32 { 41 {
42 printf("Found GRUB memory map\n");
33 multiboot_memory_map_t *mmap; 43 multiboot_memory_map_t *mmap;
34 for (mmap = (multiboot_memory_map_t*)(uint64_t)multiboot_info->mmap_addr; 44 for (mmap = (multiboot_memory_map_t*)(uint64_t)multiboot_info->mmap_addr;
35 (uint64_t)mmap < multiboot_info->mmap_addr + multiboot_info->mmap_length; 45 (uint64_t)mmap < multiboot_info->mmap_addr + multiboot_info->mmap_length;
36 mmap = (multiboot_memory_map_t*) ( (uint64_t)mmap + mmap->size + sizeof(mmap->size)) ) 46 mmap = (multiboot_memory_map_t*) ( (uint64_t)mmap + mmap->size + sizeof(mmap->size)) )
37 { 47 {
40 if ( (mmap->type == 1) && (mmap->base == 0x100000) ) 50 if ( (mmap->type == 1) && (mmap->base == 0x100000) )
41 { 51 {
42 available_memory = mmap->length; 52 available_memory = mmap->length;
43 } 53 }
44 } 54 }
55 }
56 else
57 {
58 printf("Found no GRUB map\n");
45 } 59 }
46 60
47 printf("Running with %d MB ram\n", available_memory / 1000000); 61 printf("Running with %d MB ram\n", available_memory / 1000000);
48 62
49 fs_node_t *fs_root = 0; 63 fs_node_t *fs_root = 0;
114 } 128 }
115 if (strncmp(buffer, "b", 1)) 129 if (strncmp(buffer, "b", 1))
116 { 130 {
117 magicBochsBreak(); 131 magicBochsBreak();
118 } 132 }
119 } 133 if (strncmp(buffer, "pf", 2))
134 {
135 /* Test general protection exception */
136 uint64_t *x;
137 x = (uint64_t*)0x4000000; // Address that is not mapped
138 *x = 0x2; // trigger paging exception
139 }
140
141 }
120 } 142 }
121 143
122 144