Added address space defn to C header

This commit is contained in:
secXsQuared1995 2017-02-05 20:32:28 -08:00
parent 1c1f73f7a8
commit cdd705ce32
2 changed files with 30 additions and 10 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
#################
x64/target
x64/*.ini
x64/cmake-build-debug/*
#################
## Eclipse

View File

@ -8,12 +8,31 @@
typedef uint64_t virtual_addr_t;
typedef physical_addr_t address_space_t;
#define K_BASE_VADDR 0xFFFF800000000000
#define K_END_VADDR 0xFFFFFFFFFFFFFFFF
#define KERNEL_PAGE_SIZE (0x1000ull)
//U_BASE = 1MB
#define U_BASE_VADDR 0x0000000000100000
#define U_END_BADDR 0x7FFFFFFFFFFFFFFF
#define KERNEL_AREA_START_VADDR (0xFFFF800000000000ull)
#define KERNEL_AREA_SIZE (0xFFFFFFFFFFFFFFFF - KERNEL_AREA_START_VADDR + 1)
#define KERNEL_PAGE_TABLE_VADDR (0xFFFFFF0000000000ull)
#define KERNEL_PAGE_TABLE_SIZE (0x8000000000ull)
// 510 GB
#define KERNEL_DYN_VADDR (KERNEL_PAGE_TABLE_VADDR + KERNEL_PAGE_TABLE_SIZE)
#define KERNEL_DYN_SIZE (0x7F80000000ull)
#define KERNEL_HEAP_VADDR KERNEL_DYN_VADDR
#define KERNEL_INITIAL_HEAP_SIZE (0x1000ull)
#define KERNEL_INITIAL_STACK_SIZE (0x1000ull)
#define KERNEL_STACK_VADDR (KERNEL_DYN_VADDR + KERNEL_DYN_SIZE - KERNEL_INITIAL_STACK_SIZE)
// address space that is reserved for HAL to map its own stuff
#define KERNEL_HAL_VADDR (KERNEL_DYN_VADDR + KERNEL_DYN_SIZE)
// 16MB Virtual Address Space
#define KERNEL_HAL_VADDR_LIMIT (0x1000000ull)
#define KERNEL_LOAD_VADDR (KERNEL_HAL_VADDR + KERNEL_HAL_VADDR_LIMIT)
#define KERNEL_LOAD_SIZE (0xFFFFFFFFFFFFFFFF - KERNEL_LOAD_VADDR + 1)
//
// all the address spaces passed by the kernel would be initialized by k_create_address_space
@ -30,7 +49,7 @@ typedef void (KABI *page_free_func_t)(physical_addr_t page);
#define K_PAGE_ATTR_WRITABLE (1 << 1)
// this function should map the v_addr to p_addr for the target address space
extern void KABI ke_map_virtual_addr(physical_addr_t addr_space,
extern void KABI mm_map_virtual_addr(physical_addr_t addr_space,
virtual_addr_t v_addr,
physical_addr_t p_addr,
uint64_t attribute,
@ -53,16 +72,16 @@ typedef struct
// so that these pages are global (modifying the mapping in this area affects everyone)
// the K_BASE_VADDR to K_END_VADDR includes the reserved virtual addr space by the HAL
// if HAL's reserved virtual addr will be mapped to different physical pages, the HAL should make the change
address_space_t KABI ke_create_address_space(address_space_t address_space,
page_alloc_func_t alloc);
address_space_t KABI mm_create_address_space(address_space_t address_space,
page_alloc_func_t alloc);
// this function destroys the target address space without destroying the K_BASE_VADDR to K_END_VADDR
// target_addr_space is guaranteed to be not the same as the current address space
// when the function returns, the current address space must stay unchanged
void KABI ke_destroy_address_space(address_space_t address_space,
void KABI mm_destroy_address_space(address_space_t address_space,
page_free_func_t free);
// as the name implies
void KABI ke_switch_address_space(address_space_t target_addr_space);
void KABI mm_switch_address_space(address_space_t target_addr_space);
#endif