45 lines
1.0 KiB
C
45 lines
1.0 KiB
C
// vmm.h
|
|
// Author: Josh Holtrop
|
|
// Date: 09/30/03
|
|
// Rewritten from scratch: 12/23/03
|
|
// Modified: 12/29/03
|
|
|
|
|
|
#define VMM_HE_UNUSED 0 //available entry
|
|
#define VMM_HE_FREE 1 //free section of memory
|
|
#define VMM_HE_USED 2 //used section of memory
|
|
#define VMM_HE_HOLE 3 //a "hole" (unmapped) section of virtual memory
|
|
#define VMM_HE_HEB 4 //HeapEntryBlock
|
|
|
|
|
|
typedef struct {
|
|
dword base; //virtual base address
|
|
dword size; //size in bytes
|
|
dword attributes; //free/used/hole
|
|
dword link; //link to next HeapEntry
|
|
} __attribute__((packed)) HeapEntry;
|
|
|
|
|
|
typedef struct {
|
|
HeapEntry entry[256]; //256 HeapEntry objects = 4kb (1 page)
|
|
} __attribute__((packed)) HeapEntryBlock;
|
|
|
|
|
|
void vmm_init();
|
|
void *malloc(dword bytes);
|
|
int free(void *ptr);
|
|
void vmm_map1(dword virt, dword physical);
|
|
void vmm_mapn(dword virt, dword physical, dword n);
|
|
void vmm_unmap1(dword virt);
|
|
void vmm_unmapn(dword virt, dword n);
|
|
void vmm_heb_init(HeapEntryBlock *heb);
|
|
|
|
|
|
HeapEntry *firstHeapEntry = (HeapEntry *)0xD0000000;
|
|
|
|
|
|
|
|
|
|
|
|
|