47 lines
1.2 KiB
C
47 lines
1.2 KiB
C
// vmm.h
|
|
// Author: Josh Holtrop
|
|
// Date: 09/30/03
|
|
// Rewritten from scratch: 12/23/03, 07/13/04
|
|
// Modified: 07/15/04
|
|
|
|
#ifndef __HOS_VMM__
|
|
#define __HOS_VMM__ __HOS_VMM__
|
|
|
|
#include "hos_defines.h"
|
|
#include "multiboot.h"
|
|
|
|
#define VMM_HE_TYPES 4 //4 types of heap entries
|
|
#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/wilderness) section of virtual memory
|
|
|
|
#define VMM_MALLOC_GRANULARITY 4 //a power of 2, granularity for all memory requests
|
|
#define VMM_MALLOC_GRAN_MASK VMM_MALLOC_GRANULARITY-1 //mask for determining how much of a request is past granularity
|
|
|
|
|
|
typedef struct {
|
|
void *base; //virtual base address
|
|
u32_t length; //size in bytes
|
|
void *next; //link to next HeapEntry
|
|
void *prev; //link to previous HeapEntry
|
|
} __attribute__((packed)) HeapEntry_t;
|
|
|
|
typedef struct {
|
|
HeapEntry_t entry[256]; //256 HeapEntry objects = 4kb (1 page)
|
|
} __attribute__((packed)) HeapEntryBlock_t;
|
|
|
|
typedef struct {
|
|
int count;
|
|
HeapEntry_t *start;
|
|
} HeapEntryQueue_t;
|
|
|
|
|
|
void vmm_init();
|
|
void *kmalloc(u32_t size);
|
|
void *vmm_palloc();
|
|
|
|
#endif
|
|
|
|
|