1433d6423SLionel Sambuc 2433d6423SLionel Sambuc #ifndef _REGION_H 3433d6423SLionel Sambuc #define _REGION_H 1 4433d6423SLionel Sambuc 5433d6423SLionel Sambuc #include <minix/callnr.h> 6433d6423SLionel Sambuc #include <minix/com.h> 7433d6423SLionel Sambuc #include <minix/config.h> 8433d6423SLionel Sambuc #include <minix/const.h> 9433d6423SLionel Sambuc #include <minix/ds.h> 10433d6423SLionel Sambuc #include <minix/endpoint.h> 11433d6423SLionel Sambuc #include <minix/minlib.h> 12433d6423SLionel Sambuc #include <minix/type.h> 13433d6423SLionel Sambuc #include <minix/ipc.h> 14433d6423SLionel Sambuc #include <minix/sysutil.h> 15433d6423SLionel Sambuc #include <minix/syslib.h> 16433d6423SLionel Sambuc #include <minix/const.h> 17433d6423SLionel Sambuc 18433d6423SLionel Sambuc #include "phys_region.h" 19433d6423SLionel Sambuc #include "memtype.h" 20433d6423SLionel Sambuc #include "vm.h" 21433d6423SLionel Sambuc #include "fdref.h" 22433d6423SLionel Sambuc 23433d6423SLionel Sambuc struct phys_block { 24433d6423SLionel Sambuc #if SANITYCHECKS 25433d6423SLionel Sambuc u32_t seencount; 26433d6423SLionel Sambuc #endif 27433d6423SLionel Sambuc phys_bytes phys; /* physical memory */ 28433d6423SLionel Sambuc 29433d6423SLionel Sambuc /* first in list of phys_regions that reference this block */ 30433d6423SLionel Sambuc struct phys_region *firstregion; 31433d6423SLionel Sambuc u8_t refcount; /* Refcount of these pages */ 32433d6423SLionel Sambuc u8_t flags; 33433d6423SLionel Sambuc }; 34433d6423SLionel Sambuc 35433d6423SLionel Sambuc #define PBF_INCACHE 0x01 36433d6423SLionel Sambuc 37433d6423SLionel Sambuc typedef struct vir_region { 38433d6423SLionel Sambuc vir_bytes vaddr; /* virtual address, offset from pagetable */ 39433d6423SLionel Sambuc vir_bytes length; /* length in bytes */ 40433d6423SLionel Sambuc struct phys_region **physblocks; 41433d6423SLionel Sambuc u16_t flags; 42433d6423SLionel Sambuc struct vmproc *parent; /* Process that owns this vir_region. */ 43433d6423SLionel Sambuc mem_type_t *def_memtype; /* Default instantiated memory type. */ 44433d6423SLionel Sambuc int remaps; 45433d6423SLionel Sambuc int id; /* unique id */ 46433d6423SLionel Sambuc 47433d6423SLionel Sambuc union { 48433d6423SLionel Sambuc phys_bytes phys; /* VR_DIRECT */ 49433d6423SLionel Sambuc struct { 50433d6423SLionel Sambuc endpoint_t ep; 51433d6423SLionel Sambuc vir_bytes vaddr; 52433d6423SLionel Sambuc int id; 53433d6423SLionel Sambuc } shared; 54433d6423SLionel Sambuc struct phys_block *pb_cache; 55433d6423SLionel Sambuc struct { 56433d6423SLionel Sambuc int inited; 57433d6423SLionel Sambuc struct fdref *fdref; 58433d6423SLionel Sambuc u64_t offset; 59433d6423SLionel Sambuc u16_t clearend; 60433d6423SLionel Sambuc } file; 61433d6423SLionel Sambuc } param; 62433d6423SLionel Sambuc 63433d6423SLionel Sambuc /* AVL fields */ 64433d6423SLionel Sambuc struct vir_region *lower, *higher; 65433d6423SLionel Sambuc int factor; 66433d6423SLionel Sambuc } region_t; 67433d6423SLionel Sambuc 68433d6423SLionel Sambuc /* Mapping flags: */ 69433d6423SLionel Sambuc #define VR_WRITABLE 0x001 /* Process may write here. */ 70433d6423SLionel Sambuc #define VR_PHYS64K 0x004 /* Physical memory must be 64k aligned. */ 71433d6423SLionel Sambuc #define VR_LOWER16MB 0x008 72433d6423SLionel Sambuc #define VR_LOWER1MB 0x010 73433d6423SLionel Sambuc #define VR_SHARED 0x040 74433d6423SLionel Sambuc #define VR_UNINITIALIZED 0x080 /* Do not clear after allocation */ 75433d6423SLionel Sambuc 76433d6423SLionel Sambuc /* Mapping type: */ 77433d6423SLionel Sambuc #define VR_ANON 0x100 /* Memory to be cleared and allocated */ 78433d6423SLionel Sambuc #define VR_DIRECT 0x200 /* Mapped, but not managed by VM */ 79*63483e02SCristiano Giuffrida #define VR_PREALLOC_MAP 0x400 /* Preallocated map. */ 80433d6423SLionel Sambuc 81*63483e02SCristiano Giuffrida /* map_page_region_flags */ 82433d6423SLionel Sambuc #define MF_PREALLOC 0x01 83433d6423SLionel Sambuc 84433d6423SLionel Sambuc #endif 85433d6423SLionel Sambuc 86