Changeset 8cbf1c3 in mainline
- Timestamp:
- 2013-09-09T23:13:10Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e2a0d76
- Parents:
- c67dbd6
- Location:
- kernel
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/mm/page.c
rc67dbd6 r8cbf1c3 69 69 #ifdef HIGH_EXCEPTION_VECTORS 70 70 /* Create mapping for exception table at high offset */ 71 uintptr_t ev_frame = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_NONE);71 uintptr_t ev_frame = frame_alloc(ONE_FRAME, FRAME_NONE, 0); 72 72 page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, ev_frame, flags); 73 73 #else -
kernel/arch/arm32/src/ras.c
rc67dbd6 r8cbf1c3 53 53 uintptr_t frame; 54 54 55 frame = (uintptr_t)frame_alloc(ONE_FRAME,56 FRAME_ATOMIC | FRAME_HIGHMEM );55 frame = frame_alloc(ONE_FRAME, 56 FRAME_ATOMIC | FRAME_HIGHMEM, 0); 57 57 if (!frame) 58 frame = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_LOWMEM);58 frame = frame_alloc(ONE_FRAME, FRAME_LOWMEM, 0); 59 59 ras_page = (uintptr_t *) km_map(frame, 60 60 PAGE_SIZE, PAGE_READ | PAGE_WRITE | PAGE_USER | PAGE_CACHEABLE); -
kernel/arch/ia64/src/mm/vhpt.c
rc67dbd6 r8cbf1c3 42 42 uintptr_t vhpt_set_up(void) 43 43 { 44 vhpt_base = frame_alloc(VHPT_WIDTH - FRAME_WIDTH,45 FRAME_ KA | FRAME_ATOMIC);44 vhpt_base = (vhpt_entry_t *) PA2KA(frame_alloc(VHPT_WIDTH - FRAME_WIDTH, 45 FRAME_ATOMIC, 0)); 46 46 if (!vhpt_base) 47 47 panic("Kernel configured with VHPT but no memory for table."); -
kernel/arch/sparc64/src/mm/sun4u/as.c
rc67dbd6 r8cbf1c3 71 71 sizeof(tsb_entry_t)) >> FRAME_WIDTH); 72 72 73 uintptr_t tsb = (uintptr_t) frame_alloc(order, flags | FRAME_KA);73 uintptr_t tsb = PA2KA(frame_alloc(order, flags, 0)); 74 74 75 75 if (!tsb) -
kernel/arch/sparc64/src/mm/sun4v/as.c
rc67dbd6 r8cbf1c3 69 69 (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH); 70 70 71 uintptr_t tsb = (uintptr_t) frame_alloc(order, flags);71 uintptr_t tsb = frame_alloc(order, flags, 0); 72 72 73 73 if (!tsb) -
kernel/genarch/src/mm/as_pt.c
rc67dbd6 r8cbf1c3 73 73 pte_t *ptl0_create(unsigned int flags) 74 74 { 75 pte_t *dst_ptl0 = (pte_t *) frame_alloc(PTL0_SIZE,76 FRAME_LOWMEM | FRAME_KA);75 pte_t *dst_ptl0 = (pte_t *) PA2KA(frame_alloc(PTL0_SIZE, 76 FRAME_LOWMEM, 0)); 77 77 size_t table_size = FRAME_SIZE << PTL0_SIZE; 78 78 -
kernel/genarch/src/mm/page_pt.c
rc67dbd6 r8cbf1c3 82 82 83 83 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { 84 pte_t *newpt = (pte_t *) frame_alloc(PTL1_SIZE,85 FRAME_LOWMEM | FRAME_KA);84 pte_t *newpt = (pte_t *) PA2KA(frame_alloc(PTL1_SIZE, 85 FRAME_LOWMEM, 0)); 86 86 memsetb(newpt, FRAME_SIZE << PTL1_SIZE, 0); 87 87 SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt)); … … 101 101 102 102 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { 103 pte_t *newpt = (pte_t *) frame_alloc(PTL2_SIZE,104 FRAME_LOWMEM | FRAME_KA);103 pte_t *newpt = (pte_t *) PA2KA(frame_alloc(PTL2_SIZE, 104 FRAME_LOWMEM, 0)); 105 105 memsetb(newpt, FRAME_SIZE << PTL2_SIZE, 0); 106 106 SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt)); … … 118 118 119 119 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { 120 pte_t *newpt = (pte_t *) frame_alloc(PTL3_SIZE,121 FRAME_LOWMEM | FRAME_KA);120 pte_t *newpt = (pte_t *) PA2KA(frame_alloc(PTL3_SIZE, 121 FRAME_LOWMEM, 0)); 122 122 memsetb(newpt, FRAME_SIZE << PTL3_SIZE, 0); 123 123 SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt)); … … 385 385 uintptr_t l1; 386 386 387 l1 = (uintptr_t) frame_alloc(order, FRAME_KA | FRAME_LOWMEM);387 l1 = PA2KA(frame_alloc(order, FRAME_LOWMEM, 0)); 388 388 memsetb((void *) l1, FRAME_SIZE << order, 0); 389 389 SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(addr), KA2PA(l1)); -
kernel/generic/include/mm/frame.h
rc67dbd6 r8cbf1c3 50 50 typedef uint8_t frame_flags_t; 51 51 52 #define FRAME_NONE 0x0 53 /** Convert the frame address to kernel VA. */ 54 #define FRAME_KA 0x1 52 #define FRAME_NONE 0x00 55 53 /** Do not panic and do not sleep on failure. */ 56 #define FRAME_ATOMIC 0x 254 #define FRAME_ATOMIC 0x01 57 55 /** Do not start reclaiming when no free memory. */ 58 #define FRAME_NO_RECLAIM 0x 456 #define FRAME_NO_RECLAIM 0x02 59 57 /** Do not reserve / unreserve memory. */ 60 #define FRAME_NO_RESERVE 0x 858 #define FRAME_NO_RESERVE 0x04 61 59 /** Allocate a frame which can be identity-mapped. */ 62 #define FRAME_LOWMEM 0x1060 #define FRAME_LOWMEM 0x08 63 61 /** Allocate a frame which cannot be identity-mapped. */ 64 #define FRAME_HIGHMEM 0x2062 #define FRAME_HIGHMEM 0x10 65 63 66 64 typedef uint8_t zone_flags_t; 67 65 68 #define ZONE_NONE 0x066 #define ZONE_NONE 0x00 69 67 /** Available zone (free for allocation) */ 70 #define ZONE_AVAILABLE 0x 168 #define ZONE_AVAILABLE 0x01 71 69 /** Zone is reserved (not available for allocation) */ 72 #define ZONE_RESERVED 0x 270 #define ZONE_RESERVED 0x02 73 71 /** Zone is used by firmware (not available for allocation) */ 74 #define ZONE_FIRMWARE 0x 472 #define ZONE_FIRMWARE 0x04 75 73 /** Zone contains memory that can be identity-mapped */ 76 #define ZONE_LOWMEM 0x874 #define ZONE_LOWMEM 0x08 77 75 /** Zone contains memory that cannot be identity-mapped */ 78 #define ZONE_HIGHMEM 76 #define ZONE_HIGHMEM 0x10 79 77 80 78 /** Mask of zone bits that must be matched exactly. */ 81 #define ZONE_EF_MASK 0x779 #define ZONE_EF_MASK 0x07 82 80 83 81 #define FRAME_TO_ZONE_FLAGS(ff) \ … … 138 136 NO_TRACE static inline size_t SIZE2FRAMES(size_t size) 139 137 { 140 if ( !size)138 if (size == 0) 141 139 return 0; 140 142 141 return (size_t) ((size - 1) >> FRAME_WIDTH) + 1; 143 142 } … … 161 160 extern void frame_init(void); 162 161 extern bool frame_adjust_zone_bounds(bool, uintptr_t *, size_t *); 163 extern void *frame_alloc_generic(uint8_t, frame_flags_t, size_t *);164 extern void *frame_alloc(uint8_t, frame_flags_t);165 extern void *frame_alloc_noreserve(uint8_t, frame_flags_t);162 extern uintptr_t frame_alloc_generic(uint8_t, frame_flags_t, uintptr_t, size_t *); 163 extern uintptr_t frame_alloc(uint8_t, frame_flags_t, uintptr_t); 164 extern uintptr_t frame_alloc_noreserve(uint8_t, frame_flags_t, uintptr_t); 166 165 extern void frame_free_generic(uintptr_t, frame_flags_t); 167 166 extern void frame_free(uintptr_t); -
kernel/generic/include/mm/page.h
rc67dbd6 r8cbf1c3 65 65 extern void page_table_destroy(pte_t *); 66 66 67 extern int page_find_mapping(uintptr_t, void **);68 extern sysarg_t sys_page_find_mapping(uintptr_t, void*);67 extern int page_find_mapping(uintptr_t, uintptr_t *); 68 extern sysarg_t sys_page_find_mapping(uintptr_t, uintptr_t *); 69 69 70 70 #endif -
kernel/generic/src/cpu/cpu.c
rc67dbd6 r8cbf1c3 73 73 size_t i; 74 74 for (i = 0; i < config.cpu_count; i++) { 75 cpus[i].stack = (uint8_t *) frame_alloc(STACK_FRAMES,76 FRAME_LOWMEM | FRAME_ KA | FRAME_ATOMIC);75 cpus[i].stack = (uint8_t *) PA2KA(frame_alloc(STACK_FRAMES, 76 FRAME_LOWMEM | FRAME_ATOMIC, 0)); 77 77 cpus[i].id = i; 78 78 -
kernel/generic/src/ddi/ddi.c
rc67dbd6 r8cbf1c3 314 314 315 315 NO_TRACE static int dmamem_map(uintptr_t virt, size_t size, unsigned int map_flags, 316 unsigned int flags, void **phys)316 unsigned int flags, uintptr_t *phys) 317 317 { 318 318 ASSERT(TASK); … … 323 323 324 324 NO_TRACE static int dmamem_map_anonymous(size_t size, unsigned int map_flags, 325 unsigned int flags, void **phys, uintptr_t *virt, uintptr_t bound)325 unsigned int flags, uintptr_t *phys, uintptr_t *virt, uintptr_t bound) 326 326 { 327 327 ASSERT(TASK); … … 336 336 order = fnzb(pages - 1) + 1; 337 337 338 *phys = frame_alloc_noreserve(order, 0 );339 if (*phys == NULL)338 *phys = frame_alloc_noreserve(order, 0, 0); 339 if (*phys == 0) 340 340 return ENOMEM; 341 341 342 342 mem_backend_data_t backend_data; 343 backend_data.base = (uintptr_t)*phys;343 backend_data.base = *phys; 344 344 backend_data.frames = pages; 345 345 346 346 if (!as_area_create(TASK->as, map_flags, size, 347 347 AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) { 348 frame_free_noreserve( (uintptr_t)*phys);348 frame_free_noreserve(*phys); 349 349 return ENOMEM; 350 350 } … … 387 387 */ 388 388 389 void *phys;389 uintptr_t phys; 390 390 int rc = dmamem_map((uintptr_t) virt_ptr, size, map_flags, 391 391 flags, &phys); … … 404 404 */ 405 405 406 void *phys;406 uintptr_t phys; 407 407 uintptr_t virt = (uintptr_t) -1; 408 408 int rc = dmamem_map_anonymous(size, map_flags, flags, -
kernel/generic/src/mm/frame.c
rc67dbd6 r8cbf1c3 873 873 874 874 return ADDR2PFN((uintptr_t) frame_alloc(order - FRAME_WIDTH, 875 FRAME_LOWMEM | FRAME_ATOMIC ));875 FRAME_LOWMEM | FRAME_ATOMIC, 0)); 876 876 } 877 877 … … 1024 1024 * 1025 1025 */ 1026 void *frame_alloc_generic(uint8_t order, frame_flags_t flags, size_t *pzone) 1026 uintptr_t frame_alloc_generic(uint8_t order, frame_flags_t flags, 1027 uintptr_t constraint, size_t *pzone) 1027 1028 { 1028 1029 size_t size = ((size_t) 1) << order; … … 1071 1072 if (!(flags & FRAME_NO_RESERVE)) 1072 1073 reserve_free(size); 1073 return NULL;1074 return 0; 1074 1075 } 1075 1076 … … 1126 1127 *pzone = znum; 1127 1128 1128 if (flags & FRAME_KA) 1129 return (void *) PA2KA(PFN2ADDR(pfn)); 1130 1131 return (void *) PFN2ADDR(pfn); 1132 } 1133 1134 void *frame_alloc(uint8_t order, frame_flags_t flags) 1135 { 1136 return frame_alloc_generic(order, flags, NULL); 1137 } 1138 1139 void *frame_alloc_noreserve(uint8_t order, frame_flags_t flags) 1140 { 1141 return frame_alloc_generic(order, flags | FRAME_NO_RESERVE, NULL); 1129 return PFN2ADDR(pfn); 1130 } 1131 1132 uintptr_t frame_alloc(uint8_t order, frame_flags_t flags, uintptr_t constraint) 1133 { 1134 return frame_alloc_generic(order, flags, constraint, NULL); 1135 } 1136 1137 uintptr_t frame_alloc_noreserve(uint8_t order, frame_flags_t flags, 1138 uintptr_t constraint) 1139 { 1140 return frame_alloc_generic(order, flags | FRAME_NO_RESERVE, constraint, 1141 NULL); 1142 1142 } 1143 1143 -
kernel/generic/src/mm/km.c
rc67dbd6 r8cbf1c3 249 249 * Allocate a frame, preferably from high memory. 250 250 */ 251 frame = (uintptr_t)frame_alloc(ONE_FRAME,252 FRAME_HIGHMEM | FRAME_ATOMIC | flags );251 frame = frame_alloc(ONE_FRAME, 252 FRAME_HIGHMEM | FRAME_ATOMIC | flags, 0); 253 253 if (frame) { 254 254 page = km_map(frame, PAGE_SIZE, … … 256 256 ASSERT(page); // FIXME 257 257 } else { 258 frame = (uintptr_t) frame_alloc(ONE_FRAME, 259 FRAME_LOWMEM | flags); 258 frame = frame_alloc(ONE_FRAME, FRAME_LOWMEM | flags, 0); 260 259 if (!frame) 261 260 return (uintptr_t) NULL; -
kernel/generic/src/mm/page.c
rc67dbd6 r8cbf1c3 169 169 } 170 170 171 int page_find_mapping(uintptr_t virt, void **phys)171 int page_find_mapping(uintptr_t virt, uintptr_t *phys) 172 172 { 173 173 page_table_lock(AS, true); … … 179 179 } 180 180 181 *phys = (void *)PTE_GET_FRAME(pte) +181 *phys = PTE_GET_FRAME(pte) + 182 182 (virt - ALIGN_DOWN(virt, PAGE_SIZE)); 183 183 … … 193 193 * 194 194 */ 195 sysarg_t sys_page_find_mapping(uintptr_t virt, void*phys_ptr)196 { 197 void *phys;195 sysarg_t sys_page_find_mapping(uintptr_t virt, uintptr_t *phys_ptr) 196 { 197 uintptr_t phys; 198 198 int rc = page_find_mapping(virt, &phys); 199 199 if (rc != EOK) -
kernel/generic/src/mm/slab.c
rc67dbd6 r8cbf1c3 182 182 size_t zone = 0; 183 183 184 void *data = frame_alloc_generic(cache->order, FRAME_KA | flags, &zone); 184 void *data = (void *) 185 PA2KA(frame_alloc_generic(cache->order, flags, 0, &zone)); 185 186 if (!data) { 186 187 return NULL; -
kernel/generic/src/proc/thread.c
rc67dbd6 r8cbf1c3 192 192 kmflags &= ~FRAME_HIGHMEM; 193 193 194 thread->kstack = (uint8_t *) frame_alloc(STACK_FRAMES, FRAME_KA | kmflags); 194 thread->kstack = (uint8_t *) 195 PA2KA(frame_alloc(STACK_FRAMES, kmflags, 0)); 195 196 if (!thread->kstack) { 196 197 #ifdef CONFIG_FPU -
kernel/generic/src/time/clock.c
rc67dbd6 r8cbf1c3 81 81 void clock_counter_init(void) 82 82 { 83 void *faddr = frame_alloc(ONE_FRAME, FRAME_ATOMIC);84 if ( !faddr)83 uintptr_t faddr = frame_alloc(ONE_FRAME, FRAME_ATOMIC, 0); 84 if (faddr == 0) 85 85 panic("Cannot allocate page for clock."); 86 86 … … 91 91 uptime->useconds = 0; 92 92 93 clock_parea.pbase = (uintptr_t)faddr;93 clock_parea.pbase = faddr; 94 94 clock_parea.frames = 1; 95 95 clock_parea.unpriv = true; -
kernel/test/mm/falloc1.c
rc67dbd6 r8cbf1c3 58 58 unsigned int allocated = 0; 59 59 for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) { 60 frames[allocated] = (uintptr_t)61 frame_alloc(order, FRAME_ATOMIC | FRAME_KA);60 frames[allocated] = 61 PA2KA(frame_alloc(order, FRAME_ATOMIC, 0)); 62 62 63 63 if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != -
kernel/test/mm/falloc2.c
rc67dbd6 r8cbf1c3 53 53 uint8_t val = THREAD->tid % THREADS; 54 54 55 void **frames = (void **)56 malloc(MAX_FRAMES * sizeof( void *), FRAME_ATOMIC);55 uintptr_t *frames = (uintptr_t *) 56 malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC); 57 57 if (frames == NULL) { 58 58 TPRINTF("Thread #%" PRIu64 " (cpu%u): " … … 74 74 for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) { 75 75 frames[allocated] = 76 frame_alloc(order, FRAME_ATOMIC | FRAME_KA);76 PA2KA(frame_alloc(order, FRAME_ATOMIC, 0)); 77 77 if (frames[allocated]) { 78 memsetb( frames[allocated], FRAME_SIZE << order, val);78 memsetb((void *) frames[allocated], FRAME_SIZE << order, val); 79 79 allocated++; 80 80 } else … … 93 93 if (((uint8_t *) frames[i])[k] != val) { 94 94 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 95 "Unexpected data (%c) in block % poffset %zu\n",95 "Unexpected data (%c) in block %zu offset %zu\n", 96 96 THREAD->tid, CPU->id, ((char *) frames[i])[k], 97 97 frames[i], k); -
kernel/test/mm/mapping1.c
rc67dbd6 r8cbf1c3 42 42 { 43 43 uintptr_t page0, page1; 44 uintptr_t frame;45 44 uint32_t v; 46 45 int i; 47 46 48 frame = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_NONE);49 47 uintptr_t frame = frame_alloc(ONE_FRAME, FRAME_NONE, 0); 48 50 49 page0 = km_map(frame, FRAME_SIZE, 51 50 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
Note:
See TracChangeset
for help on using the changeset viewer.