matos/core/mem.h
2024-01-29 23:27:10 +01:00

30 lines
702 B
C

#pragma once
#include "stdint.h"
#include "types.h"
/** Physical Page related function
*/
#define PAGE_SHIFT 12U
#define PAGE_SIZE (1U << PAGE_SHIFT)
#define PAGE_MASK (PAGE_SIZE - 1)
// Defined in linker.ld script
extern char __ld_kernel_begin;
extern char __ld_kernel_end;
struct phyMemDesc {
paddr_t phy_addr;
unsigned long ref;
struct phyMemDesc *next, *prev;
};
int memSetup(paddr_t upperMem, paddr_t * firstUsed, 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);