Changes in kernel/generic/include/mm/as.h [0321109:c15b374] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/mm/as.h
r0321109 rc15b374 43 43 44 44 /** Address space area flags. */ 45 #define AS_AREA_READ 46 #define AS_AREA_WRITE 47 #define AS_AREA_EXEC 48 #define AS_AREA_CACHEABLE 45 #define AS_AREA_READ 1 46 #define AS_AREA_WRITE 2 47 #define AS_AREA_EXEC 4 48 #define AS_AREA_CACHEABLE 8 49 49 50 50 /** Address space area info exported to userspace. */ … … 52 52 /** Starting address */ 53 53 uintptr_t start_addr; 54 54 55 55 /** Area size */ 56 56 size_t size; 57 57 58 58 /** Area flags */ 59 int flags;59 unsigned int flags; 60 60 } as_area_info_t; 61 61 … … 75 75 * Defined to be true if user address space and kernel address space shadow each 76 76 * other. 77 */ 78 #define KERNEL_ADDRESS_SPACE_SHADOWED KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 79 80 #define KERNEL_ADDRESS_SPACE_START KERNEL_ADDRESS_SPACE_START_ARCH 81 #define KERNEL_ADDRESS_SPACE_END KERNEL_ADDRESS_SPACE_END_ARCH 82 #define USER_ADDRESS_SPACE_START USER_ADDRESS_SPACE_START_ARCH 83 #define USER_ADDRESS_SPACE_END USER_ADDRESS_SPACE_END_ARCH 84 85 #define USTACK_ADDRESS USTACK_ADDRESS_ARCH 77 * 78 */ 79 #define KERNEL_ADDRESS_SPACE_SHADOWED KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 80 81 #define KERNEL_ADDRESS_SPACE_START KERNEL_ADDRESS_SPACE_START_ARCH 82 #define KERNEL_ADDRESS_SPACE_END KERNEL_ADDRESS_SPACE_END_ARCH 83 #define USER_ADDRESS_SPACE_START USER_ADDRESS_SPACE_START_ARCH 84 #define USER_ADDRESS_SPACE_END USER_ADDRESS_SPACE_END_ARCH 85 86 #define USTACK_ADDRESS USTACK_ADDRESS_ARCH 86 87 87 88 /** Kernel address space. */ 88 #define FLAG_AS_KERNEL (1 << 0)89 #define FLAG_AS_KERNEL (1 << 0) 89 90 90 91 /* Address space area attributes. */ 91 #define AS_AREA_ATTR_NONE 92 #define AS_AREA_ATTR_PARTIAL 1/**< Not fully initialized area. */92 #define AS_AREA_ATTR_NONE 0 93 #define AS_AREA_ATTR_PARTIAL 1 /**< Not fully initialized area. */ 93 94 94 95 /** The page fault was not resolved by as_page_fault(). */ 95 #define AS_PF_FAULT 0 96 #define AS_PF_FAULT 0 97 96 98 /** The page fault was resolved by as_page_fault(). */ 97 #define AS_PF_OK 1 99 #define AS_PF_OK 1 100 98 101 /** The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */ 99 #define AS_PF_DEFER 102 #define AS_PF_DEFER 2 100 103 101 104 /** Address space structure. … … 105 108 * supposed to figure in the list as they are shared by all tasks and 106 109 * set up during system initialization. 110 * 107 111 */ 108 112 typedef struct as { 109 113 /** Protected by asidlock. */ 110 114 link_t inactive_as_with_asid_link; 115 111 116 /** 112 117 * Number of processors on wich is this address space active. … … 114 119 */ 115 120 size_t cpu_refcount; 121 116 122 /** 117 123 * Address space identifier. … … 120 126 */ 121 127 asid_t asid; 122 128 123 129 /** Number of references (i.e tasks that reference this as). */ 124 130 atomic_t refcount; 125 131 126 132 mutex_t lock; 127 133 128 134 /** B+tree of address space areas. */ 129 135 btree_t as_area_btree; … … 131 137 /** Non-generic content. */ 132 138 as_genarch_t genarch; 133 139 134 140 /** Architecture specific content. */ 135 141 as_arch_t arch; … … 137 143 138 144 typedef struct { 139 pte_t *(* page_table_create)(int flags); 140 void (* page_table_destroy)(pte_t *page_table); 141 void (* page_table_lock)(as_t *as, bool lock); 142 void (* page_table_unlock)(as_t *as, bool unlock); 145 pte_t *(* page_table_create)(unsigned int); 146 void (* page_table_destroy)(pte_t *); 147 void (* page_table_lock)(as_t *, bool); 148 void (* page_table_unlock)(as_t *, bool); 149 bool (* page_table_locked)(as_t *); 143 150 } as_operations_t; 144 151 … … 146 153 * This structure contains information associated with the shared address space 147 154 * area. 155 * 148 156 */ 149 157 typedef struct { 150 158 /** This lock must be acquired only when the as_area lock is held. */ 151 mutex_t lock; 159 mutex_t lock; 152 160 /** This structure can be deallocated if refcount drops to 0. */ 153 161 size_t refcount; 162 154 163 /** 155 164 * B+tree containing complete map of anonymous pages of the shared area. … … 162 171 PF_ACCESS_READ, 163 172 PF_ACCESS_WRITE, 164 PF_ACCESS_EXEC 173 PF_ACCESS_EXEC, 174 PF_ACCESS_UNKNOWN 165 175 } pf_access_t; 166 176 … … 169 179 /** Backend data stored in address space area. */ 170 180 typedef union mem_backend_data { 171 struct { /**< elf_backend members */ 181 /** elf_backend members */ 182 struct { 172 183 elf_header_t *elf; 173 184 elf_segment_header_t *segment; 174 185 }; 175 struct { /**< phys_backend members */ 186 187 /** phys_backend members */ 188 struct { 176 189 uintptr_t base; 177 190 size_t frames; … … 182 195 * 183 196 * Each as_area_t structure describes one contiguous area of virtual memory. 197 * 184 198 */ 185 199 typedef struct { 186 200 mutex_t lock; 187 201 /** Containing address space. */ 188 as_t *as; 202 as_t *as; 203 189 204 /** 190 205 * Flags related to the memory represented by the address space area. 191 206 */ 192 int flags; 207 unsigned int flags; 208 193 209 /** Attributes related to the address space area itself. */ 194 int attributes;210 unsigned int attributes; 195 211 /** Size of this area in multiples of PAGE_SIZE. */ 196 212 size_t pages; … … 199 215 /** Map of used space. */ 200 216 btree_t used_space; 201 217 202 218 /** 203 219 * If the address space area has been shared, this pointer will … … 205 221 */ 206 222 share_info_t *sh_info; 207 223 208 224 /** Memory backend backing this address space area. */ 209 225 struct mem_backend *backend; 210 226 211 227 /** Data to be used by the backend. */ 212 228 mem_backend_data_t backend_data; … … 215 231 /** Address space area backend structure. */ 216 232 typedef struct mem_backend { 217 int (* page_fault)(as_area_t * area, uintptr_t addr, pf_access_t access);218 void (* frame_free)(as_area_t * area, uintptr_t page, uintptr_t frame);219 void (* share)(as_area_t * area);233 int (* page_fault)(as_area_t *, uintptr_t, pf_access_t); 234 void (* frame_free)(as_area_t *, uintptr_t, uintptr_t); 235 void (* share)(as_area_t *); 220 236 } mem_backend_t; 221 237 … … 227 243 extern void as_init(void); 228 244 229 extern as_t *as_create( int);245 extern as_t *as_create(unsigned int); 230 246 extern void as_destroy(as_t *); 231 247 extern void as_hold(as_t *); … … 234 250 extern int as_page_fault(uintptr_t, pf_access_t, istate_t *); 235 251 236 extern as_area_t *as_area_create(as_t *, int, size_t, uintptr_t, int,237 mem_backend_t *, mem_backend_data_t *);252 extern as_area_t *as_area_create(as_t *, unsigned int, size_t, uintptr_t, 253 unsigned int, mem_backend_t *, mem_backend_data_t *); 238 254 extern int as_area_destroy(as_t *, uintptr_t); 239 extern int as_area_resize(as_t *, uintptr_t, size_t, int); 240 extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t, int); 241 extern int as_area_change_flags(as_t *, int, uintptr_t); 242 243 extern int as_area_get_flags(as_area_t *); 255 extern int as_area_resize(as_t *, uintptr_t, size_t, unsigned int); 256 extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t, 257 unsigned int); 258 extern int as_area_change_flags(as_t *, unsigned int, uintptr_t); 259 260 extern unsigned int as_area_get_flags(as_area_t *); 244 261 extern bool as_area_check_access(as_area_t *, pf_access_t); 245 262 extern size_t as_area_get_size(uintptr_t); … … 249 266 250 267 /* Interface to be implemented by architectures. */ 268 251 269 #ifndef as_constructor_arch 252 extern int as_constructor_arch(as_t *, int);270 extern int as_constructor_arch(as_t *, unsigned int); 253 271 #endif /* !def as_constructor_arch */ 272 254 273 #ifndef as_destructor_arch 255 274 extern int as_destructor_arch(as_t *); 256 275 #endif /* !def as_destructor_arch */ 276 257 277 #ifndef as_create_arch 258 extern int as_create_arch(as_t *, int);278 extern int as_create_arch(as_t *, unsigned int); 259 279 #endif /* !def as_create_arch */ 280 260 281 #ifndef as_install_arch 261 282 extern void as_install_arch(as_t *); 262 283 #endif /* !def as_install_arch */ 284 263 285 #ifndef as_deinstall_arch 264 286 extern void as_deinstall_arch(as_t *); … … 270 292 extern mem_backend_t phys_backend; 271 293 272 /** 294 /** 273 295 * This flags is passed when running the loader, otherwise elf_load() 274 296 * would return with a EE_LOADER error code. 275 */ 276 #define ELD_F_NONE 0 277 #define ELD_F_LOADER 1 278 279 extern unsigned int elf_load(elf_header_t *, as_t *, int); 297 * 298 */ 299 #define ELD_F_NONE 0 300 #define ELD_F_LOADER 1 301 302 extern unsigned int elf_load(elf_header_t *, as_t *, unsigned int); 280 303 281 304 /* Address space area related syscalls. */ 282 extern unative_t sys_as_area_create(uintptr_t, size_t, int);283 extern unative_t sys_as_area_resize(uintptr_t, size_t, int);284 extern unative_t sys_as_area_change_flags(uintptr_t, int);305 extern unative_t sys_as_area_create(uintptr_t, size_t, unsigned int); 306 extern unative_t sys_as_area_resize(uintptr_t, size_t, unsigned int); 307 extern unative_t sys_as_area_change_flags(uintptr_t, unsigned int); 285 308 extern unative_t sys_as_area_destroy(uintptr_t); 286 309
Note:
See TracChangeset
for help on using the changeset viewer.