matos/core/mem.h
2021-02-10 21:15:35 +01:00

25 lines
605 B
C

#pragma once
#include "stdarg.h"
#include "types.h"
#define PAGE_SHIFT 12U
#define PAGE_SIZE (1U << PAGE_SHIFT)
// Defined in linker.ld script
extern uint32_t __ld_kernel_begin;
extern uint32_t __ld_kernel_end;
struct memDesc {
paddr_t phy_addr;
unsigned long ref;
struct memDesc *next, *prev;
};
int memSetup(paddr_t upperMem, paddr_t *lastUsed);
int memAddBank(paddr_t bottomMem, paddr_t topMem, int isFree);
paddr_t allocPhyPage(uint nbPage);
int unrefPhyPage(paddr_t addr);
int refPhyPage(paddr_t addr);
unsigned long getNbAllocatedPage(void);
void memGetStat(uint *free, uint *used);