Changeset 2e9eae2 in mainline
- Timestamp:
- 2006-06-23T16:03:53Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 757551a3
- Parents:
- a832dd7
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ia32/src/smp/smp.c
ra832dd7 r2e9eae2 74 74 } 75 75 76 l_apic_address = PA2KA(PFN2ADDR(frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status)));76 l_apic_address = (__address) frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status); 77 77 if (status != FRAME_OK) 78 78 panic("cannot allocate address for l_apic\n"); 79 79 80 io_apic_address = PA2KA(PFN2ADDR(frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status)));80 io_apic_address = (__address) frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status); 81 81 if (status != FRAME_OK) 82 82 panic("cannot allocate address for io_apic\n"); -
arch/ia64/src/mm/vhpt.c
ra832dd7 r2e9eae2 43 43 __address vhpt_set_up(void) 44 44 { 45 vhpt_base=(vhpt_entry_t*) PA2KA(PFN2ADDR(frame_alloc(VHPT_WIDTH-FRAME_WIDTH,FRAME_KA)));45 vhpt_base=(vhpt_entry_t*) frame_alloc(VHPT_WIDTH-FRAME_WIDTH,FRAME_KA); 46 46 if(!vhpt_base) panic("Kernel configured with VHPT but no memory for table."); 47 47 vhpt_invalidate_all(); -
arch/ppc64/src/mm/page.c
ra832dd7 r2e9eae2 275 275 276 276 /* Allocate page hash table */ 277 phte_t *physical_phte = (phte_t *) PFN2ADDR(frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC)); 278 phte = (phte_t *) PA2KA((__address) physical_phte); 277 phte_t *physical_phte = (phte_t *) frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC); 279 278 280 279 ASSERT((__address) physical_phte % (1 << PHT_BITS) == 0); -
arch/sparc64/src/mm/page.c
ra832dd7 r2e9eae2 74 74 order = (fnzb32(size - 1) + 1) - FRAME_WIDTH; 75 75 76 __address virtaddr = PA2KA(PFN2ADDR(frame_alloc(order, FRAME_KA)));76 __address virtaddr = frame_alloc(order, FRAME_KA); 77 77 78 78 for (i = 0; i < sizemap[order].count; i++) -
genarch/src/fb/fb.c
ra832dd7 r2e9eae2 395 395 order = fnzb(pages-1)+1; 396 396 397 pfn_t frame = frame_alloc_rc(order,FRAME_ATOMIC,&rc); 398 if (!rc) 399 dbbuffer = (void *)PA2KA(PFN2ADDR(frame)); 400 else 397 dbbuffer = frame_alloc_rc(order,FRAME_ATOMIC | FRAME_KA, &rc); 398 if (!dbbuffer) 401 399 printf("Failed to allocate scroll buffer.\n"); 402 400 dboffset = 0; -
genarch/src/mm/as_pt.c
ra832dd7 r2e9eae2 74 74 ipl_t ipl; 75 75 76 dst_ptl0 = (pte_t *) PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA | FRAME_PANIC)));76 dst_ptl0 = (pte_t *) frame_alloc(ONE_FRAME, FRAME_KA | FRAME_PANIC); 77 77 78 78 if (flags & FLAG_AS_KERNEL) { … … 109 109 void ptl0_destroy(pte_t *page_table) 110 110 { 111 frame_free( ADDR2PFN((__address) page_table));111 frame_free((__address)page_table); 112 112 } 113 113 -
genarch/src/mm/page_pt.c
ra832dd7 r2e9eae2 72 72 { 73 73 pte_t *ptl0, *ptl1, *ptl2, *ptl3; 74 __addressnewpt;74 pte_t *newpt; 75 75 76 76 ptl0 = (pte_t *) PA2KA((__address) as->page_table); 77 77 78 78 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { 79 newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));80 memsetb( newpt, PAGE_SIZE, 0);79 newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA); 80 memsetb((__address)newpt, PAGE_SIZE, 0); 81 81 SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt)); 82 82 SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); … … 86 86 87 87 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { 88 newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));89 memsetb( newpt, PAGE_SIZE, 0);88 newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA); 89 memsetb((__address)newpt, PAGE_SIZE, 0); 90 90 SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt)); 91 91 SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); … … 95 95 96 96 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { 97 newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));98 memsetb( newpt, PAGE_SIZE, 0);97 newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA); 98 memsetb((__address)newpt, PAGE_SIZE, 0); 99 99 SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt)); 100 100 SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); … … 166 166 * Release the frame and remove PTL3 pointer from preceding table. 167 167 */ 168 frame_free( ADDR2PFN(KA2PA((__address) ptl3)));168 frame_free(KA2PA((__address) ptl3)); 169 169 if (PTL2_ENTRIES) 170 170 memsetb((__address) &ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0); … … 195 195 * Release the frame and remove PTL2 pointer from preceding table. 196 196 */ 197 frame_free( ADDR2PFN(KA2PA((__address) ptl2)));197 frame_free(KA2PA((__address) ptl2)); 198 198 if (PTL1_ENTRIES) 199 199 memsetb((__address) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0); … … 224 224 * Release the frame and remove PTL1 pointer from preceding table. 225 225 */ 226 frame_free( ADDR2PFN(KA2PA((__address) ptl1)));226 frame_free(KA2PA((__address) ptl1)); 227 227 memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); 228 228 } -
generic/include/mm/frame.h
ra832dd7 r2e9eae2 95 95 96 96 extern void frame_init(void); 97 extern pfn_tframe_alloc_generic(__u8 order, int flags, int * status, int *pzone);98 extern void frame_free( pfn_t pfn);97 extern void * frame_alloc_generic(__u8 order, int flags, int * status, int *pzone); 98 extern void frame_free(__address frame); 99 99 extern void frame_reference_add(pfn_t pfn); 100 100 -
generic/src/console/klog.c
ra832dd7 r2e9eae2 59 59 void *faddr; 60 60 61 faddr = (void *)PFN2ADDR(frame_alloc(KLOG_ORDER, FRAME_ATOMIC));61 faddr = frame_alloc(KLOG_ORDER, FRAME_ATOMIC); 62 62 if (!faddr) 63 63 panic("Cannot allocate page for klog"); -
generic/src/cpu/cpu.c
ra832dd7 r2e9eae2 72 72 73 73 for (i=0; i < config.cpu_count; i++) { 74 cpus[i].stack = (__u8 *) PA2KA(PFN2ADDR(frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_PANIC)));74 cpus[i].stack = (__u8 *) frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_PANIC); 75 75 76 76 cpus[i].id = i; -
generic/src/mm/as.c
ra832dd7 r2e9eae2 1497 1497 node = list_get_instance(cur, btree_node_t, leaf_link); 1498 1498 for (i = 0; i < node->keys; i++) 1499 frame_free( ADDR2PFN((__address) node->value[i]));1499 frame_free((__address) node->value[i]); 1500 1500 } 1501 1501 -
generic/src/mm/backend_anon.c
ra832dd7 r2e9eae2 106 106 } 107 107 if (allocate) { 108 frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));108 frame = (__address) frame_alloc(ONE_FRAME, 0); 109 109 memsetb(PA2KA(frame), FRAME_SIZE, 0); 110 110 … … 133 133 * the different causes 134 134 */ 135 frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));135 frame = (__address)frame_alloc(ONE_FRAME, 0); 136 136 memsetb(PA2KA(frame), FRAME_SIZE, 0); 137 137 } … … 159 159 void anon_frame_free(as_area_t *area, __address page, __address frame) 160 160 { 161 frame_free( ADDR2PFN(frame));161 frame_free(frame); 162 162 } 163 163 -
generic/src/mm/backend_elf.c
ra832dd7 r2e9eae2 135 135 */ 136 136 if (entry->p_flags & PF_W) { 137 frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));137 frame = (__address)frame_alloc(ONE_FRAME, 0); 138 138 memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), FRAME_SIZE); 139 139 … … 154 154 * and cleared. 155 155 */ 156 frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));156 frame = (__address)frame_alloc(ONE_FRAME, 0); 157 157 memsetb(PA2KA(frame), FRAME_SIZE, 0); 158 158 … … 171 171 */ 172 172 size = entry->p_filesz - (i<<PAGE_WIDTH); 173 frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0));173 frame = (__address)frame_alloc(ONE_FRAME, 0); 174 174 memsetb(PA2KA(frame) + size, FRAME_SIZE - size, 0); 175 175 memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), size); … … 219 219 * Free the frame with the copy of writable segment data. 220 220 */ 221 frame_free( ADDR2PFN(frame));221 frame_free(frame); 222 222 } 223 223 } else { … … 227 227 * In any case, a frame needs to be freed. 228 228 */ 229 frame_free( ADDR2PFN(frame));229 frame_free(frame); 230 230 } 231 231 } -
generic/src/mm/frame.c
ra832dd7 r2e9eae2 929 929 * @param pzone Preferred zone 930 930 * 931 * @return Allocated frame.932 * 933 */ 934 pfn_tframe_alloc_generic(__u8 order, int flags, int *status, int *pzone)931 * @return Physical address of the allocated frame. 932 * 933 */ 934 void * frame_alloc_generic(__u8 order, int flags, int *status, int *pzone) 935 935 { 936 936 ipl_t ipl; … … 972 972 if (status) 973 973 *status = FRAME_NO_MEMORY; 974 return NULL;974 return 0; 975 975 } 976 976 … … 987 987 if (status) 988 988 *status = FRAME_OK; 989 return v; 989 990 if (flags & FRAME_KA) 991 return (void *)PA2KA(PFN2ADDR(v)); 992 return (void *)PFN2ADDR(v); 990 993 } 991 994 … … 996 999 * If it drops to zero, move the frame structure to free list. 997 1000 * 998 * @param pfn Frame numberof the frame to be freed.999 */ 1000 void frame_free( pfn_t pfn)1001 * @param Frame Physical Address of of the frame to be freed. 1002 */ 1003 void frame_free(__address frame) 1001 1004 { 1002 1005 ipl_t ipl; 1003 1006 zone_t *zone; 1007 pfn_t pfn = ADDR2PFN(frame); 1004 1008 1005 1009 ipl = interrupts_disable(); -
generic/src/mm/slab.c
ra832dd7 r2e9eae2 163 163 int i; 164 164 int status; 165 pfn_t pfn;166 165 int zone=0; 167 166 168 pfn = frame_alloc_rc_zone(cache->order, FRAME_KA | flags, &status, &zone); 169 data = (void *) PA2KA(PFN2ADDR(pfn)); 167 data = frame_alloc_rc_zone(cache->order, FRAME_KA | flags, &status, &zone); 170 168 if (status != FRAME_OK) { 171 169 return NULL; … … 174 172 slab = slab_alloc(slab_extern_cache, flags); 175 173 if (!slab) { 176 frame_free( ADDR2PFN(KA2PA(data)));174 frame_free(KA2PA(data)); 177 175 return NULL; 178 176 } … … 184 182 /* Fill in slab structures */ 185 183 for (i=0; i < (1 << cache->order); i++) 186 frame_set_parent( pfn+i, slab, zone);184 frame_set_parent(ADDR2PFN(KA2PA(data))+i, slab, zone); 187 185 188 186 slab->start = data; … … 205 203 static count_t slab_space_free(slab_cache_t *cache, slab_t *slab) 206 204 { 207 frame_free( ADDR2PFN(KA2PA(slab->start)));205 frame_free(KA2PA(slab->start)); 208 206 if (! (cache->flags & SLAB_CACHE_SLINSIDE)) 209 207 slab_free(slab_extern_cache, slab); -
generic/src/proc/thread.c
ra832dd7 r2e9eae2 125 125 { 126 126 thread_t *t = (thread_t *)obj; 127 pfn_t pfn;128 127 int status; 129 128 … … 143 142 #endif 144 143 145 pfn= frame_alloc_rc(STACK_FRAMES, FRAME_KA | kmflags,&status);144 t->kstack = frame_alloc_rc(STACK_FRAMES, FRAME_KA | kmflags,&status); 146 145 if (status) { 147 146 #ifdef ARCH_HAS_FPU … … 151 150 return -1; 152 151 } 153 t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn));154 152 155 153 return 0; … … 161 159 thread_t *t = (thread_t *)obj; 162 160 163 frame_free( ADDR2PFN(KA2PA(t->kstack)));161 frame_free(KA2PA(t->kstack)); 164 162 #ifdef ARCH_HAS_FPU 165 163 if (t->saved_fpu_context) -
generic/src/time/clock.c
ra832dd7 r2e9eae2 80 80 void *faddr; 81 81 82 faddr = (void *)PFN2ADDR(frame_alloc(0, FRAME_ATOMIC));82 faddr = frame_alloc(0, FRAME_ATOMIC); 83 83 if (!faddr) 84 84 panic("Cannot allocate page for clock"); -
test/mm/falloc1/test.c
ra832dd7 r2e9eae2 56 56 allocated = 0; 57 57 for (i = 0; i < MAX_FRAMES >> order; i++) { 58 frames[allocated] = PA2KA(PFN2ADDR(frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status)));58 frames[allocated] = frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status); 59 59 60 60 if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) { … … 81 81 printf("Deallocating ... "); 82 82 for (i = 0; i < allocated; i++) { 83 frame_free( ADDR2PFN(KA2PA(frames[i])));83 frame_free(KA2PA(frames[i])); 84 84 } 85 85 printf("done.\n"); -
test/mm/falloc2/test.c
ra832dd7 r2e9eae2 66 66 allocated = 0; 67 67 for (i = 0; i < (MAX_FRAMES >> order); i++) { 68 frames[allocated] = PA2KA(PFN2ADDR(frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status)));68 frames[allocated] = frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status); 69 69 if (status == 0) { 70 70 memsetb(frames[allocated], FRAME_SIZE << order, val); … … 84 84 } 85 85 } 86 frame_free( ADDR2PFN(KA2PA(frames[i])));86 frame_free(KA2PA(frames[i])); 87 87 } 88 88 printf("Thread #%d (cpu%d): Finished run.\n", THREAD->tid, CPU->id); -
test/mm/mapping1/test.c
ra832dd7 r2e9eae2 48 48 printf("Memory management test mapping #1\n"); 49 49 50 frame0 = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));51 frame1 = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA)));50 frame0 = frame_alloc(ONE_FRAME, FRAME_KA); 51 frame1 = frame_alloc(ONE_FRAME, FRAME_KA); 52 52 53 53 printf("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0));
Note:
See TracChangeset
for help on using the changeset viewer.