53 lines
1.5 KiB
C
53 lines
1.5 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
|
|
u32_t padding;
|
|
} __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();
|
|
u32_t vmm_map(void *virt);
|
|
void vmm_map1(unsigned int virt, unsigned int physical);
|
|
void vmm_mapn(unsigned int virt, unsigned int physical, unsigned int n);
|
|
void vmm_unmap1(unsigned int virt);
|
|
void vmm_unmapn(unsigned int virt, unsigned int n);
|
|
int vmm_map_range(void *virt_start, void *virt_end, u32_t phys_start);
|
|
void vmm_heb_init(HeapEntryBlock_t *heb);
|
|
//void *calloc(unsigned int number, unsigned int size);
|
|
|
|
#endif
|
|
|
|
|