SHOW:
|
|
- or go back to the newest paste.
| 1 | - | #include <pmm.h> |
| 1 | + | |
| 2 | - | #include <debug.h> |
| 2 | + | |
| 3 | - | #include <string.h> |
| 3 | + | |
| 4 | - | #include <heap.h> |
| 4 | + | |
| 5 | return addr / 32; | |
| 6 | - | #define BITMAP_SIZE 32768 |
| 6 | + | |
| 7 | - | static uint32_t bitmap[BITMAP_SIZE]; |
| 7 | + | |
| 8 | void pfree(void* addr) | |
| 9 | - | uint32_t total_memory = 0; |
| 9 | + | |
| 10 | - | uint32_t free_memory; |
| 10 | + | |
| 11 | uint32_t index = get_index((uint32_t) addr, &offset); | |
| 12 | - | extern void* kernel_start; // Anfang des Kernels |
| 12 | + | |
| 13 | - | extern void* kernel_end; // Ende des Kernels |
| 13 | + | |
| 14 | } | |
| 15 | ||
| 16 | static void use(void* addr) | |
| 17 | {
| |
| 18 | uint32_t offset; | |
| 19 | uint32_t index = get_index((uint32_t) addr, &offset); | |
| 20 | bitmap[index] |= (1 << offset); | |
| 21 | free_memory -= 0x1000; | |
| 22 | } | |
| 23 | ||
| 24 | static uint32_t is_free(void* addr) | |
| 25 | {
| |
| 26 | uint32_t offset; | |
| 27 | uint32_t index = get_index((uint32_t) addr, &offset); | |
| 28 | return (bitmap[index] & (1 << offset)); | |
| 29 | } |