BarinkOS/source/kernel/Memory/PhysicalMemoryManager.h
Nigel 0f0fc9f252 Adding a skeleton for the memory management code
Moved the PMM away from being object orientated as it is just plain annoying
renamed src folder to source
Set timeout to 5 seconds in the grub config
2022-08-21 21:18:53 +02:00

31 lines
726 B
C

#pragma once
#include <stddef.h>
#include "memoryinfo.h"
#include "../Terminal/kterm.h"
#include "../Lib/mem.h"
#include "../bitmap.h"
// Asumming 32 bit x86 for now!
#define BLOCK_SIZE 4092
#define WORD_SIZE 2
#define BLOCKS_PER_WORD 32
#define KB_TO_BLOCKS(x) (x / BLOCK_SIZE)
#define IS_ALIGNED(addr, align) !((addr) & ~((align) - 1))
#define ALIGN(addr, align) (((addr) & ~((align) - 1 )) + (align))
struct PhysicalMemoryManagerInfoBlock
{
uint32_t* memoryBitMap;
size_t pmmap_size;
size_t max_blocks;
int used_blocks;
};
void initPMM(MemoryInfo* memory);
void free_block(void* ptr);
void* allocate_block();
void allocate_region(uint32_t, uint32_t);
void deallocate_region(uint32_t , uint32_t );