2021-09-14 15:34:14 +00:00
|
|
|
#ifndef _MMNGR_PHYS_H
|
|
|
|
#define _MMNGR_PHYS_H
|
|
|
|
|
|
|
|
#define pmmngr_load_PDBR(addr) write_cr3(addr)
|
|
|
|
#define pmmngr_get_PDBR() read_cr3()
|
|
|
|
|
|
|
|
// physical address
|
|
|
|
typedef unsigned physical_addr;
|
|
|
|
|
2021-09-14 15:35:13 +00:00
|
|
|
struct memory_stack_entry{
|
|
|
|
unsigned short low;
|
|
|
|
unsigned char high;
|
|
|
|
} __attribute__ ((__packed__));
|
|
|
|
typedef struct memory_stack_entry mstack;
|
|
|
|
|
|
|
|
// CR registers r/w operations
|
|
|
|
extern unsigned read_cr0();
|
|
|
|
extern unsigned read_cr3();
|
|
|
|
extern void write_cr0(unsigned data);
|
|
|
|
extern void write_cr3(unsigned data);
|
|
|
|
|
|
|
|
// Free/Alloc memory block(s)
|
|
|
|
extern void pmmngr_free_block(void* address);
|
|
|
|
extern void pmmngr_free_blocks(unsigned base, unsigned size);
|
|
|
|
extern void* pmmngr_alloc_block ();
|
|
|
|
extern void* pmmngr_alloc_blocks (unsigned blocks);
|
|
|
|
|
|
|
|
// De/Initialisation routines
|
|
|
|
extern void pmmngr_init (unsigned memSize, unsigned stack);
|
|
|
|
extern void pmmngr_init_region (unsigned base, unsigned size);
|
|
|
|
extern void pmmngr_deinit_region (unsigned base, unsigned size);
|
|
|
|
|
|
|
|
// Useful information
|
|
|
|
extern unsigned pmmngr_get_memory_size (); // returns amount of physical memory the manager is set to use
|
|
|
|
extern unsigned pmmngr_get_use_block_count (); // returns number of blocks currently in use
|
|
|
|
extern unsigned pmmngr_get_free_block_count (); // returns number of blocks not in use
|
|
|
|
extern unsigned pmmngr_get_block_count (); // returns number of memory blocks
|
|
|
|
extern unsigned pmmngr_get_block_size (); // returns default memory block size in unsigned chars
|
|
|
|
extern unsigned char pmmngr_test_block (unsigned block);
|
|
|
|
|
|
|
|
// Paging
|
|
|
|
extern void pmmngr_paging_enable (unsigned char b); // enable or disable paging
|
|
|
|
extern unsigned char pmmngr_is_paging (); // test if paging is enabled
|
|
|
|
|
|
|
|
extern void print_stack();
|
|
|
|
|
2021-09-14 15:34:14 +00:00
|
|
|
#endif
|