36 lines
884 B
C
36 lines
884 B
C
|
|
|
|
typedef struct {
|
|
qword base;
|
|
qword limit;
|
|
dword attributes;
|
|
} __attribute__((packed)) memmap_entry;
|
|
|
|
|
|
typedef struct {
|
|
dword base;
|
|
dword length; //in pages
|
|
dword pid; //normally PID of process, use NP, AVAIL for special flags
|
|
dword link; //leave dword instead of pointer so i dont have to worry about pointer arithmetic
|
|
} __attribute__ ((packed)) pageblock; //16 byte pageblock entry - 256 entries = 1 page
|
|
|
|
|
|
void mm_init();
|
|
void mm_init_pageblockpage(pageblock *pbp);
|
|
void *mm_palloc(dword numpages, dword proc_pid);
|
|
void mm_coalesce(pageblock *pb);
|
|
int mm_pfree(void *ptr);
|
|
dword mm_freeentries();
|
|
dword mm_freemem();
|
|
pageblock *mm_new_pageblock_page();
|
|
pageblock *mm_lastpageblockentry();
|
|
pageblock *mm_nextpageblockentry();
|
|
|
|
|
|
#define MM_PB_NP 0x00 //00000000
|
|
#define MM_PB_AVAIL 0x01 //00000001
|
|
|
|
|
|
|
|
|