Changeset d3e7ff4 in mainline
- Timestamp:
- 2006-03-14T14:10:25Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5581c45e
- Parents:
- 5be1923
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/include/mm/page.h
r5be1923 rd3e7ff4 82 82 83 83 #define PTE_VALID_ARCH(p) (*((__u64 *) (p)) != 0) 84 #define PTE_PRESENT_ARCH(p) ((p)->present != 0) 85 #define PTE_GET_FRAME_ARCH(p) ((((__address)(p)->addr_12_31)<<12) | ((__address)(p)->addr_32_51<<32)) 84 86 85 87 #ifndef __ASM__ -
arch/ia32/include/mm/page.h
r5be1923 rd3e7ff4 81 81 82 82 #define PTE_VALID_ARCH(p) (*((__u32 *) (p)) != 0) 83 #define PTE_PRESENT_ARCH(p) ((p)->present != 0) 84 #define PTE_GET_FRAME_ARCH(p) ((p)->frame_address<<FRAME_WIDTH) 83 85 84 86 #ifndef __ASM__ -
arch/mips32/include/mm/page.h
r5be1923 rd3e7ff4 95 95 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x)) 96 96 97 #define PTE_VALID_ARCH(p) (*((__u32 *) (p)) != 0) 97 #define PTE_VALID_ARCH(pte) (*((__u32 *) (pte)) != 0) 98 #define PTE_PRESENT_ARCH(pte) ((pte)->p != 0) 99 #define PTE_GET_FRAME_ARCH(pte) ((pte)->pfn<<FRAME_WIDTH) 98 100 99 101 #ifndef __ASM__ -
arch/ppc32/include/mm/page.h
r5be1923 rd3e7ff4 78 78 79 79 #define PTE_VALID_ARCH(p) 1 80 #define PTE_PRESENT_ARCH(p) 1 81 #define PTE_GET_FRAME_ARCH(p) 0 80 82 81 83 #ifndef __ASM__ -
arch/ppc32/src/dummy.s
r5be1923 rd3e7ff4 37 37 .global fpu_enable 38 38 .global fpu_disable 39 .global tlb_invalidate_all 40 .global tlb_invalidate_asid 41 .global tlb_invalidate_pages 39 42 40 43 before_thread_runs_arch: … … 45 48 fpu_enable: 46 49 fpu_disable: 50 tlb_invalidate_all: 51 tlb_invalidate_asid: 52 tlb_invalidate_pages: 53 47 54 48 55 dummy: -
arch/sparc64/include/mm/page.h
r5be1923 rd3e7ff4 39 39 #include <mm/page.h> 40 40 #include <arch/types.h> 41 #include <genarch/mm/page_ht.h> 41 42 42 43 #define KA2PA(x) ((__address) (x)) -
arch/sparc64/include/types.h
r5be1923 rd3e7ff4 48 48 49 49 typedef __u64 __native; 50 typedef __s64 __ native;50 typedef __s64 __snative; 51 51 52 52 typedef struct pte pte_t; -
genarch/include/mm/page_ht.h
r5be1923 rd3e7ff4 47 47 #define PAGE_HT_ENTRIES (1<<PAGE_HT_ENTRIES_BITS) 48 48 49 #define PTE_VALID_ARCH(pte) ((pte) != NULL) 50 #define PTE_PRESENT_ARCH(pte) ((pte)->p != 0) 51 #define PTE_GET_FRAME_ARCH(pte) ((pte)->frame) 52 49 53 struct pte { 50 54 link_t link; /**< Page hash table link. */ -
genarch/include/mm/page_pt.h
r5be1923 rd3e7ff4 93 93 #define SET_FRAME_FLAGS(ptl3, i, x) SET_FRAME_FLAGS_ARCH(ptl3, i, x) 94 94 95 /* 96 * Determine whether the mapping is valid. 97 */ 98 #define PTE_VALID(p) PTE_VALID_ARCH((p)) 95 #define PTE_VALID(p) PTE_VALID_ARCH((p)) 96 #define PTE_PRESENT(p) PTE_PRESENT_ARCH((p)) 97 #define PTE_GET_FRAME(p) PTE_GET_FRAME_ARCH((p)) 99 98 100 99 extern page_mapping_operations_t pt_mapping_operations; -
generic/include/mm/as.h
r5be1923 rd3e7ff4 105 105 extern as_t *as_create(int flags); 106 106 extern as_area_t *as_area_create(as_t *as, as_area_type_t type, size_t size, __address base); 107 extern __address as_remap(as_t *as, __address address, size_t size, int flags); 107 108 extern void as_set_mapping(as_t *as, __address page, __address frame); 108 109 extern int as_page_fault(__address page); -
generic/include/mm/page.h
r5be1923 rd3e7ff4 61 61 #define PAGE_GLOBAL (1<<PAGE_GLOBAL_SHIFT) 62 62 63 64 63 /* TODO - check that userspace is OK, platform specific functions etc */ 65 64 static inline void copy_to_uspace(void *dst, void *src, count_t cnt) -
generic/include/syscall/syscall.h
r5be1923 rd3e7ff4 33 33 SYS_CTL = 0, 34 34 SYS_IO, 35 SYS_MREMAP, 35 36 SYS_IPC_CALL_SYNC, 36 37 SYS_IPC_CALL_SYNC_MEDIUM, -
generic/src/mm/as.c
r5be1923 rd3e7ff4 70 70 71 71 static int get_area_flags(as_area_t *a); 72 static as_area_t *find_area_and_lock(as_t *as, __address va); 72 73 73 74 /** Initialize address space subsystem. */ … … 169 170 void as_set_mapping(as_t *as, __address page, __address frame) 170 171 { 171 as_area_t *a, *area = NULL; 172 link_t *cur; 172 as_area_t *area; 173 173 ipl_t ipl; 174 174 … … 176 176 spinlock_lock(&as->lock); 177 177 178 /* 179 * First, try locate an area. 180 */ 181 for (cur = as->as_area_head.next; cur != &as->as_area_head; cur = cur->next) { 182 a = list_get_instance(cur, as_area_t, link); 183 spinlock_lock(&a->lock); 184 185 if ((page >= a->base) && (page < a->base + a->size * PAGE_SIZE)) { 186 area = a; 187 break; 188 } 189 190 spinlock_unlock(&a->lock); 191 } 192 178 area = find_area_and_lock(as, page); 193 179 if (!area) { 194 180 panic("page not part of any as_area\n"); 195 181 } 196 182 197 /*198 * Note: area->lock is held.199 */200 201 183 page_mapping_insert(as, page, frame, get_area_flags(area)); 202 184 … … 217 199 int as_page_fault(__address page) 218 200 { 219 link_t *cur; 220 as_area_t *a, *area = NULL; 201 as_area_t *area; 221 202 __address frame; 222 203 … … 224 205 spinlock_lock(&AS->lock); 225 206 226 /* 227 * Search this areas of this address space for presence of 'page'. 228 */ 229 for (cur = AS->as_area_head.next; cur != &AS->as_area_head; cur = cur->next) { 230 a = list_get_instance(cur, as_area_t, link); 231 spinlock_lock(&a->lock); 232 233 if ((page >= a->base) && (page < a->base + a->size * PAGE_SIZE)) { 234 235 /* 236 * We found the area containing 'page'. 237 * TODO: access checking 238 */ 239 area = a; 240 break; 241 } 242 243 spinlock_unlock(&a->lock); 244 } 245 207 area = find_area_and_lock(AS, page); 246 208 if (!area) { 247 209 /* … … 253 215 } 254 216 255 /*256 * Note: area->lock is held.257 */258 259 217 /* 260 218 * In general, there can be several reasons that … … 400 358 return as_operations->page_table_create(flags); 401 359 } 360 361 /** Find address space area and change it. 362 * 363 * @param as Address space. 364 * @param address Virtual address belonging to the area to be changed. Must be page-aligned. 365 * @param size New size of the virtual memory block starting at address. 366 * @param flags Flags influencing the remap operation. Currently unused. 367 * 368 * @return address on success, (__address) -1 otherwise. 369 */ 370 __address as_remap(as_t *as, __address address, size_t size, int flags) 371 { 372 as_area_t *area = NULL; 373 ipl_t ipl; 374 size_t pages; 375 376 ipl = interrupts_disable(); 377 spinlock_lock(&as->lock); 378 379 /* 380 * Locate the area. 381 */ 382 area = find_area_and_lock(as, address); 383 if (!area) { 384 spinlock_unlock(&as->lock); 385 return (__address) -1; 386 } 387 388 pages = SIZE2FRAMES((address - area->base) + size); 389 if (pages < area->size) { 390 int i; 391 392 /* 393 * Shrinking the area. 394 */ 395 for (i = pages; i < area->size; i++) { 396 pte_t *pte; 397 398 /* 399 * Releasing physical memory. 400 * This depends on the fact that the memory was allocated using frame_alloc(). 401 */ 402 pte = page_mapping_find(as, area->base + i*PAGE_SIZE); 403 if (pte) { 404 ASSERT(PTE_PRESENT(pte)); 405 frame_free(ADDR2PFN(PTE_GET_FRAME(pte))); 406 } 407 page_mapping_remove(as, area->base + i*PAGE_SIZE); 408 } 409 /* 410 * Invalidate TLB's. 411 */ 412 tlb_shootdown_start(TLB_INVL_PAGES, AS->asid, area->base + pages*PAGE_SIZE, area->size - pages); 413 tlb_invalidate_pages(AS->asid, area->base + pages*PAGE_SIZE, area->size - pages); 414 tlb_shootdown_finalize(); 415 } else { 416 /* 417 * Growing the area. 418 */ 419 area->size = size; 420 } 421 422 spinlock_unlock(&area->lock); 423 spinlock_unlock(&as->lock); 424 interrupts_restore(ipl); 425 426 return address; 427 } 428 429 /** Find address space area and lock it. 430 * 431 * The address space must be locked and interrupts must be disabled. 432 * 433 * @param as Address space. 434 * @param va Virtual address. 435 * 436 * @return Locked address space area containing va on success or NULL on failure. 437 */ 438 as_area_t *find_area_and_lock(as_t *as, __address va) 439 { 440 link_t *cur; 441 as_area_t *a; 442 443 for (cur = as->as_area_head.next; cur != &as->as_area_head; cur = cur->next) { 444 a = list_get_instance(cur, as_area_t, link); 445 spinlock_lock(&a->lock); 446 447 if ((va >= a->base) && (va < a->base + a->size * PAGE_SIZE)) 448 return a; 449 450 spinlock_unlock(&a->lock); 451 } 452 453 return NULL; 454 } -
generic/src/syscall/syscall.c
r5be1923 rd3e7ff4 29 29 #include <syscall/syscall.h> 30 30 #include <proc/thread.h> 31 #include <mm/as.h> 31 32 #include <print.h> 32 33 #include <putchar.h> … … 182 183 } 183 184 185 static __native sys_mremap(void *address, size_t size, unsigned long flags) 186 { 187 return as_remap(AS, (__address) address, size, 0); 188 } 184 189 185 190 syshandler_t syscall_table[SYSCALL_END] = { 186 191 sys_ctl, 187 192 sys_io, 193 sys_mremap, 188 194 sys_ipc_call_sync, 189 195 sys_ipc_call_sync_medium,
Note:
See TracChangeset
for help on using the changeset viewer.