aspace.h (2341B)
1 /* Copyright 1998-1999, Brian J. Swetland. All rights reserved. 2 ** Distributed under the terms of the OpenBLT License 3 */ 4 5 #ifndef _ASPACE_H_ 6 #define _ASPACE_H_ 7 8 #include "resource.h" 9 #include "list.h" 10 11 #define SEL_KCODE (1*8) 12 #define SEL_KDATA (2*8) 13 #define SEL_KDATA2 (3*8) 14 #define SEL_UCODE (4*8) 15 #define SEL_UDATA (5*8) 16 #define SEL_KTSS (6*8) 17 #define SEL_UTSS (7*8) 18 19 typedef struct __phys_page_t { 20 struct __phys_page_t *next; 21 uint32 refcount; 22 uint32 addr[6]; 23 } phys_page_t; /* 32 bytes */ 24 25 typedef struct __pagegroup_t { 26 uint32 size; /* number of pages */ 27 uint32 refcount; /* number of areamaps */ 28 uint32 flags; /* page info */ 29 list_t areas; /* areas sharing this pagegroup */ 30 phys_page_t *pages; /* physical pages that compose this pagegroup */ 31 } pagegroup_t; 32 33 struct __area_t { 34 resource_t rsrc; 35 pagegroup_t *pgroup; 36 uint32 virt_addr; /* virtual PAGE address */ 37 uint32 length; /* length in pages */ 38 uint32 maxlength; /* maxlength in pages */ 39 }; 40 41 struct __aspace_t { 42 resource_t rsrc; 43 list_t areas; /* list of mapped areas */ 44 uint32 maxvirt; /* highest virt addr pagetabs maps */ 45 /* platform specific */ 46 uint32 *pdir; /* page directory -- 4k */ 47 uint32 *ptab; /* page table -- 4k */ 48 uint32 *high; /* high page table -- 4k (0x8000000 -> ) */ 49 uint32 pdirphys; /* physical address of page directory */ 50 }; 51 52 53 aspace_t *aspace_create(void); 54 void aspace_destroy(aspace_t *a); 55 void aspace_map(aspace_t *a, uint32 phys, uint32 virt, 56 uint32 len, uint32 flags); 57 void aspace_maphi(aspace_t *a, uint32 phys, uint32 virt, 58 uint32 len, uint32 flags); 59 void aspace_clr(aspace_t *a, uint32 virt, uint32 len); 60 void aspace_print(aspace_t *a); 61 void aspace_protect(aspace_t *a, uint32 virt, uint32 flags); 62 63 /* userland stuff */ 64 int area_create(aspace_t *aspace, off_t size, off_t virt, void **addr, uint32 flags); 65 int area_create_uber(off_t size, void *addr); 66 int area_destroy(aspace_t *aspace, int area_id); 67 int area_clone(aspace_t *aspace, int area_id, off_t virt, void **addr, uint32 flags); 68 int area_destroy(aspace_t *aspace, int area_id); 69 int area_resize(aspace_t *aspace, int area_id, off_t size); 70 71 72 #endif