Mercurial > lcfOS
comparison cos/kernel/mm.c @ 37:5c20bd53cccd
Cleanup
author | windel |
---|---|
date | Mon, 16 Jan 2012 21:38:55 +0100 |
parents | 8012221dd740 |
children | 24ce177e01e8 |
comparison
equal
deleted
inserted
replaced
36:91f91ff07ea8 | 37:5c20bd53cccd |
---|---|
4 * | 4 * |
5 * */ | 5 * */ |
6 | 6 |
7 #include "kernel.h" | 7 #include "kernel.h" |
8 | 8 |
9 // Bitmap that keeps track of all the 4 kB memory pages in the system: | |
9 static uint64_t *frames = 0; | 10 static uint64_t *frames = 0; |
10 static uint64_t nframes = 0; | 11 static uint64_t nframes = 0; |
11 | 12 |
12 memmap_t* kernel_map = 0; // kernel memory mapping | 13 memmap_t* kernel_map = 0; // kernel memory mapping |
13 memmap_t* current_map = 0; // The currently active memory mapping | 14 memmap_t* current_map = 0; // The currently active memory mapping |
53 | 54 |
54 // No frame found: | 55 // No frame found: |
55 return (uint64_t) -1; | 56 return (uint64_t) -1; |
56 } | 57 } |
57 | 58 |
58 // Memory manager functions: | 59 /* |
60 * Initializes the memory manager, allocating a bitmap once. | |
61 */ | |
59 void init_memory(uint64_t total_mem_size) | 62 void init_memory(uint64_t total_mem_size) |
60 { | 63 { |
64 printf("Running with %d MB ram\n", total_mem_size / 1000000); | |
65 | |
61 // Only here placement malloc is used! | 66 // Only here placement malloc is used! |
62 // | 67 // |
63 // Allocate and clear bits to remember which 4kb-frames are in use: | 68 // Allocate and clear bits to remember which 4KiB-frames are in use: |
64 nframes = (total_mem_size / 0x1000); | 69 nframes = (total_mem_size / 0x1000); // Calculate number of frames |
65 frames = (uint64_t*)kmalloc_int( (nframes / 64) * sizeof(uint64_t) ); | 70 frames = (uint64_t*)kmalloc_int( (nframes / 64) * sizeof(uint64_t) ); |
66 memset(frames, 0, (nframes / 64) * sizeof(uint64_t)); | 71 memset(frames, 0, (nframes / 64) * sizeof(uint64_t)); |
67 | 72 |
68 // Create kernel map: | 73 // Create kernel map: |
69 kernel_map = (memmap_t*)kmalloc_aligned_int(sizeof(memmap_t)); | 74 kernel_map = (memmap_t*)kmalloc_aligned_int(sizeof(memmap_t)); |