Files
PluralTechnology/service/ptos/head/mm/pm.h
T
2026-07-10 19:07:11 -04:00

50 lines
885 B
C

/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Physical memory management
* Author: Chloe M.
*/
#ifndef _MM_PM_H_
#define _MM_PM_H_ 1
#include <ptdef.h>
#include <hal/page.h>
/* Used when out of memory */
#define PFN_ERROR 0
/* Page frame number type */
typedef USIZE MM_PFN;
/*
* These macros allow the conversion of page frame numbers
* to physical addresses and vice versa.
*/
#define PFN_TO_ADDRESS(PFN) \
((PFN) << LOG2_PAGESIZE)
#define ADDRESS_TO_PFN(ADDR) \
((ADDR) >> LOG2_PAGESIZE)
/*
* Initialize the physical memory management
*/
VOID MmPmInit(VOID);
/*
* Request a single frame of memory
*
* Returns PFN_ERROR on failure
*/
MM_PFN MmRequestFrame(VOID);
/*
* Reclaim a single frame of memory
*
* @Pfn: Page frame number to reclaim
*/
VOID MmReclaimFrame(MM_PFN Pfn);
#endif /* !_MM_PM_H_ */