33 lines
740 B
C
33 lines
740 B
C
/*
|
|
* @author xamidev <xamidev@riseup.net>
|
|
* @brief Kernel heap
|
|
* @license GPL-3.0-only
|
|
*/
|
|
|
|
#ifndef KHEAP_H
|
|
#define KHEAP_H
|
|
|
|
// We need some kind of simple kernel heap to make our linked list
|
|
// for the VMM, as we need "malloc" and "free" for that data structure.
|
|
// When the kernel heap is ready, we can alloc our VM object linked list
|
|
// and then continue working on the VMM.
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
struct heap_block_t
|
|
{
|
|
size_t size;
|
|
bool free; // 1byte
|
|
uint8_t reserved[7]; // (7+1 = 8 bytes)
|
|
struct heap_block_t* next;
|
|
} __attribute__((aligned(16)));
|
|
|
|
void kheap_init();
|
|
void* kmalloc(size_t size);
|
|
void kfree(void* ptr);
|
|
void* kalloc_stack();
|
|
void kheap_map_page();
|
|
|
|
#endif |