1 /* 2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 3 ** Distributed under the terms of the NewOS License. 4 */ 5 #ifndef KERNEL_ARCH_VM_TRANSLATION_MAP_H 6 #define KERNEL_ARCH_VM_TRANSLATION_MAP_H 7 8 9 #include <kernel.h> 10 #include <lock.h> 11 12 13 struct kernel_args; 14 15 16 typedef struct vm_translation_map_struct { 17 struct vm_translation_map_struct *next; 18 struct vm_translation_map_ops_struct *ops; 19 recursive_lock lock; 20 int map_count; 21 struct vm_translation_map_arch_info_struct *arch_data; 22 } vm_translation_map; 23 24 25 // table of operations the vm may want to do to this mapping 26 typedef struct vm_translation_map_ops_struct { 27 void (*destroy)(vm_translation_map *); 28 int (*lock)(vm_translation_map*); 29 int (*unlock)(vm_translation_map*); 30 int (*map)(vm_translation_map *map, addr va, addr pa, unsigned int attributes); 31 int (*unmap)(vm_translation_map *map, addr start, addr end); 32 int (*query)(vm_translation_map *map, addr va, addr *out_physical, unsigned int *out_flags); 33 addr (*get_mapped_size)(vm_translation_map*); 34 int (*protect)(vm_translation_map *map, addr base, addr top, unsigned int attributes); 35 int (*clear_flags)(vm_translation_map *map, addr va, unsigned int flags); 36 void (*flush)(vm_translation_map *map); 37 int (*get_physical_page)(addr physical_address, addr *out_virtual_address, int flags); 38 int (*put_physical_page)(addr virtual_address); 39 } vm_translation_map_ops; 40 41 int vm_translation_map_create(vm_translation_map *new_map, bool kernel); 42 int vm_translation_map_module_init(struct kernel_args *ka); 43 int vm_translation_map_module_init2(struct kernel_args *ka); 44 void vm_translation_map_module_init_post_sem(struct kernel_args *ka); 45 // quick function to map a page in regardless of map context. Used in VM initialization, 46 // before most vm data structures exist 47 int vm_translation_map_quick_map(struct kernel_args *ka, addr va, addr pa, 48 unsigned int attributes, addr (*get_free_page)(kernel_args *)); 49 50 #include <arch_vm_translation_map.h> 51 52 #endif /* KERNEL_VM_TRANSLATION_MAP_H */ 53 54