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