26 lines
755 B
C
26 lines
755 B
C
#ifndef HEAP_H
|
|
#define HEAP_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
// Начальный виртуальный адрес кучи ядра (3 МБ)
|
|
#define HEAP_START 0x00300000
|
|
|
|
// Структура заголовка блока памяти
|
|
typedef struct heap_chunk {
|
|
size_t size; // Размер полезных данных в байтах
|
|
uint8_t is_free; // Флаг: 1 - свободен, 0 - занят
|
|
struct heap_chunk* next; // Указатель на следующий блок
|
|
} heap_chunk_t;
|
|
|
|
// Инициализация кучи
|
|
void kheap_init(void);
|
|
|
|
// Выделение памяти
|
|
void* kmalloc(size_t size);
|
|
|
|
// Освобождение памяти
|
|
void kfree(void* ptr);
|
|
|
|
#endif
|