summaryrefslogtreecommitdiff
path: root/kernel/mem.h
blob: 6223f0ae52c650cb5cf86879d3be8dcb9688abf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
 * @file
 *
 * Physical Memory Manager
 * =======================
 *  
 * Allocating and Deallocating memory pagewise. Run mem_init() first.
 *
 *
 * Memory Map
 * ----------
 * This will allow to mark a bit on/off for each page to indicte if it is
 * currently used or not.
 *
 * Remember that we have 4096 bytes per page so we need 1048576 bits to 
 * cover the whole 32bit addressable memory 2^32 byte (4GB).
 *
 * This results in a 128KiB map we which allocate statically.
 */

#include "multiboot.h"
#include "ringbuffer.h"

/** 
 *  Init the physical memory manager. Please provide the multiboot_information 
 *  strucutre filled by your bootloader (as grub).
 *  This is required for memory map et al.
 */
uint32_t mem_init(multiboot_information *info);

void*    mem_alloc_block ();
void     mem_free_block(void* p);

uint32_t mem_get_free_blocks_count();

void     mem_sysfs(ringbuffer *r, void (*f)(ringbuffer *r, char *fmt, ...));
void     mem_sysfs_set(uint32_t in);