/kernel/trunk/test/mm/falloc1/test.c |
---|
55,7 → 55,7 |
printf("Allocating %d frames blocks ... ", 1 << order); |
allocated = 0; |
for (i = 0; i < MAX_FRAMES >> order; i++) { |
frames[allocated] = PA2KA(PFN2ADDR(frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status))); |
frames[allocated] = frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status); |
if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) { |
panic("Test failed. Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10); |
80,7 → 80,7 |
printf("Deallocating ... "); |
for (i = 0; i < allocated; i++) { |
frame_free(ADDR2PFN(KA2PA(frames[i]))); |
frame_free(KA2PA(frames[i])); |
} |
printf("done.\n"); |
} |
/kernel/trunk/test/mm/falloc2/test.c |
---|
65,7 → 65,7 |
printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order); |
allocated = 0; |
for (i = 0; i < (MAX_FRAMES >> order); i++) { |
frames[allocated] = PA2KA(PFN2ADDR(frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status))); |
frames[allocated] = frame_alloc_rc(order, FRAME_ATOMIC | FRAME_KA, &status); |
if (status == 0) { |
memsetb(frames[allocated], FRAME_SIZE << order, val); |
allocated++; |
83,7 → 83,7 |
failed(); |
} |
} |
frame_free(ADDR2PFN(KA2PA(frames[i]))); |
frame_free(KA2PA(frames[i])); |
} |
printf("Thread #%d (cpu%d): Finished run.\n", THREAD->tid, CPU->id); |
} |
/kernel/trunk/test/mm/mapping1/test.c |
---|
47,8 → 47,8 |
printf("Memory management test mapping #1\n"); |
frame0 = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
frame1 = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
frame0 = frame_alloc(ONE_FRAME, FRAME_KA); |
frame1 = frame_alloc(ONE_FRAME, FRAME_KA); |
printf("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0)); |
*((__u32 *) frame0) = VALUE0; |
/kernel/trunk/genarch/src/fb/fb.c |
---|
394,10 → 394,8 |
else |
order = fnzb(pages-1)+1; |
pfn_t frame = frame_alloc_rc(order,FRAME_ATOMIC,&rc); |
if (!rc) |
dbbuffer = (void *)PA2KA(PFN2ADDR(frame)); |
else |
dbbuffer = frame_alloc_rc(order,FRAME_ATOMIC | FRAME_KA, &rc); |
if (!dbbuffer) |
printf("Failed to allocate scroll buffer.\n"); |
dboffset = 0; |
/kernel/trunk/genarch/src/mm/page_pt.c |
---|
71,13 → 71,13 |
void pt_mapping_insert(as_t *as, __address page, __address frame, int flags) |
{ |
pte_t *ptl0, *ptl1, *ptl2, *ptl3; |
__address newpt; |
pte_t *newpt; |
ptl0 = (pte_t *) PA2KA((__address) as->page_table); |
if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { |
newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
memsetb(newpt, PAGE_SIZE, 0); |
newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA); |
memsetb((__address)newpt, PAGE_SIZE, 0); |
SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt)); |
SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); |
} |
85,8 → 85,8 |
ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page))); |
if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { |
newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
memsetb(newpt, PAGE_SIZE, 0); |
newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA); |
memsetb((__address)newpt, PAGE_SIZE, 0); |
SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt)); |
SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); |
} |
94,8 → 94,8 |
ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page))); |
if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { |
newpt = PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA))); |
memsetb(newpt, PAGE_SIZE, 0); |
newpt = (pte_t *)frame_alloc(ONE_FRAME, FRAME_KA); |
memsetb((__address)newpt, PAGE_SIZE, 0); |
SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt)); |
SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), PAGE_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | PAGE_WRITE); |
} |
165,7 → 165,7 |
* PTL3 is empty. |
* Release the frame and remove PTL3 pointer from preceding table. |
*/ |
frame_free(ADDR2PFN(KA2PA((__address) ptl3))); |
frame_free(KA2PA((__address) ptl3)); |
if (PTL2_ENTRIES) |
memsetb((__address) &ptl2[PTL2_INDEX(page)], sizeof(pte_t), 0); |
else if (PTL1_ENTRIES) |
194,7 → 194,7 |
* PTL2 is empty. |
* Release the frame and remove PTL2 pointer from preceding table. |
*/ |
frame_free(ADDR2PFN(KA2PA((__address) ptl2))); |
frame_free(KA2PA((__address) ptl2)); |
if (PTL1_ENTRIES) |
memsetb((__address) &ptl1[PTL1_INDEX(page)], sizeof(pte_t), 0); |
else |
223,7 → 223,7 |
* PTL1 is empty. |
* Release the frame and remove PTL1 pointer from preceding table. |
*/ |
frame_free(ADDR2PFN(KA2PA((__address) ptl1))); |
frame_free(KA2PA((__address) ptl1)); |
memsetb((__address) &ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); |
} |
} |
/kernel/trunk/genarch/src/mm/as_pt.c |
---|
73,7 → 73,7 |
pte_t *src_ptl0, *dst_ptl0; |
ipl_t ipl; |
dst_ptl0 = (pte_t *) PA2KA(PFN2ADDR(frame_alloc(ONE_FRAME, FRAME_KA | FRAME_PANIC))); |
dst_ptl0 = (pte_t *) frame_alloc(ONE_FRAME, FRAME_KA | FRAME_PANIC); |
if (flags & FLAG_AS_KERNEL) { |
memsetb((__address) dst_ptl0, PAGE_SIZE, 0); |
108,7 → 108,7 |
*/ |
void ptl0_destroy(pte_t *page_table) |
{ |
frame_free(ADDR2PFN((__address) page_table)); |
frame_free((__address)page_table); |
} |
/** Lock page tables. |
/kernel/trunk/generic/include/mm/frame.h |
---|
94,8 → 94,8 |
#define frame_alloc_rc_zone(order, flags, status, zone) frame_alloc_generic(order, flags, status, zone) |
extern void frame_init(void); |
extern pfn_t frame_alloc_generic(__u8 order, int flags, int * status, int *pzone); |
extern void frame_free(pfn_t pfn); |
extern void * frame_alloc_generic(__u8 order, int flags, int * status, int *pzone); |
extern void frame_free(__address frame); |
extern void frame_reference_add(pfn_t pfn); |
extern int zone_create(pfn_t start, count_t count, pfn_t confframe, int flags); |
/kernel/trunk/generic/src/cpu/cpu.c |
---|
71,7 → 71,7 |
memsetb((__address) cpus, sizeof(cpu_t) * config.cpu_count, 0); |
for (i=0; i < config.cpu_count; i++) { |
cpus[i].stack = (__u8 *) PA2KA(PFN2ADDR(frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_PANIC))); |
cpus[i].stack = (__u8 *) frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_PANIC); |
cpus[i].id = i; |
/kernel/trunk/generic/src/time/clock.c |
---|
79,7 → 79,7 |
{ |
void *faddr; |
faddr = (void *)PFN2ADDR(frame_alloc(0, FRAME_ATOMIC)); |
faddr = frame_alloc(0, FRAME_ATOMIC); |
if (!faddr) |
panic("Cannot allocate page for clock"); |
/kernel/trunk/generic/src/console/klog.c |
---|
58,7 → 58,7 |
{ |
void *faddr; |
faddr = (void *)PFN2ADDR(frame_alloc(KLOG_ORDER, FRAME_ATOMIC)); |
faddr = frame_alloc(KLOG_ORDER, FRAME_ATOMIC); |
if (!faddr) |
panic("Cannot allocate page for klog"); |
klog = (char *)PA2KA(faddr); |
/kernel/trunk/generic/src/proc/thread.c |
---|
124,7 → 124,6 |
static int thr_constructor(void *obj, int kmflags) |
{ |
thread_t *t = (thread_t *)obj; |
pfn_t pfn; |
int status; |
spinlock_initialize(&t->lock, "thread_t_lock"); |
142,7 → 141,7 |
# endif |
#endif |
pfn = frame_alloc_rc(STACK_FRAMES, FRAME_KA | kmflags,&status); |
t->kstack = frame_alloc_rc(STACK_FRAMES, FRAME_KA | kmflags,&status); |
if (status) { |
#ifdef ARCH_HAS_FPU |
if (t->saved_fpu_context) |
150,7 → 149,6 |
#endif |
return -1; |
} |
t->kstack = (__u8 *)PA2KA(PFN2ADDR(pfn)); |
return 0; |
} |
160,7 → 158,7 |
{ |
thread_t *t = (thread_t *)obj; |
frame_free(ADDR2PFN(KA2PA(t->kstack))); |
frame_free(KA2PA(t->kstack)); |
#ifdef ARCH_HAS_FPU |
if (t->saved_fpu_context) |
slab_free(fpu_context_slab,t->saved_fpu_context); |
/kernel/trunk/generic/src/mm/slab.c |
---|
162,11 → 162,9 |
size_t fsize; |
int i; |
int status; |
pfn_t pfn; |
int zone=0; |
pfn = frame_alloc_rc_zone(cache->order, FRAME_KA | flags, &status, &zone); |
data = (void *) PA2KA(PFN2ADDR(pfn)); |
data = frame_alloc_rc_zone(cache->order, FRAME_KA | flags, &status, &zone); |
if (status != FRAME_OK) { |
return NULL; |
} |
173,7 → 171,7 |
if (! (cache->flags & SLAB_CACHE_SLINSIDE)) { |
slab = slab_alloc(slab_extern_cache, flags); |
if (!slab) { |
frame_free(ADDR2PFN(KA2PA(data))); |
frame_free(KA2PA(data)); |
return NULL; |
} |
} else { |
183,7 → 181,7 |
/* Fill in slab structures */ |
for (i=0; i < (1 << cache->order); i++) |
frame_set_parent(pfn+i, slab, zone); |
frame_set_parent(ADDR2PFN(KA2PA(data))+i, slab, zone); |
slab->start = data; |
slab->available = cache->objects; |
204,7 → 202,7 |
*/ |
static count_t slab_space_free(slab_cache_t *cache, slab_t *slab) |
{ |
frame_free(ADDR2PFN(KA2PA(slab->start))); |
frame_free(KA2PA(slab->start)); |
if (! (cache->flags & SLAB_CACHE_SLINSIDE)) |
slab_free(slab_extern_cache, slab); |
/kernel/trunk/generic/src/mm/backend_anon.c |
---|
105,7 → 105,7 |
} |
} |
if (allocate) { |
frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
frame = (__address) frame_alloc(ONE_FRAME, 0); |
memsetb(PA2KA(frame), FRAME_SIZE, 0); |
/* |
132,7 → 132,7 |
* do not forget to distinguish between |
* the different causes |
*/ |
frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
frame = (__address)frame_alloc(ONE_FRAME, 0); |
memsetb(PA2KA(frame), FRAME_SIZE, 0); |
} |
158,7 → 158,7 |
*/ |
void anon_frame_free(as_area_t *area, __address page, __address frame) |
{ |
frame_free(ADDR2PFN(frame)); |
frame_free(frame); |
} |
/** Share the anonymous address space area. |
/kernel/trunk/generic/src/mm/as.c |
---|
1496,7 → 1496,7 |
node = list_get_instance(cur, btree_node_t, leaf_link); |
for (i = 0; i < node->keys; i++) |
frame_free(ADDR2PFN((__address) node->value[i])); |
frame_free((__address) node->value[i]); |
} |
} |
/kernel/trunk/generic/src/mm/frame.c |
---|
928,10 → 928,10 |
* @param status Allocation status (FRAME_OK on success), unused if NULL. |
* @param pzone Preferred zone |
* |
* @return Allocated frame. |
* @return Physical address of the allocated frame. |
* |
*/ |
pfn_t frame_alloc_generic(__u8 order, int flags, int *status, int *pzone) |
void * frame_alloc_generic(__u8 order, int flags, int *status, int *pzone) |
{ |
ipl_t ipl; |
int freed; |
971,7 → 971,7 |
ASSERT(status != NULL); |
if (status) |
*status = FRAME_NO_MEMORY; |
return NULL; |
return 0; |
} |
panic("Sleep not implemented.\n"); |
986,7 → 986,10 |
if (status) |
*status = FRAME_OK; |
return v; |
if (flags & FRAME_KA) |
return (void *)PA2KA(PFN2ADDR(v)); |
return (void *)PFN2ADDR(v); |
} |
/** Free a frame. |
995,12 → 998,13 |
* Decrement frame reference count. |
* If it drops to zero, move the frame structure to free list. |
* |
* @param pfn Frame number of the frame to be freed. |
* @param Frame Physical Address of of the frame to be freed. |
*/ |
void frame_free(pfn_t pfn) |
void frame_free(__address frame) |
{ |
ipl_t ipl; |
zone_t *zone; |
pfn_t pfn = ADDR2PFN(frame); |
ipl = interrupts_disable(); |
/kernel/trunk/generic/src/mm/backend_elf.c |
---|
134,7 → 134,7 |
* as COW. |
*/ |
if (entry->p_flags & PF_W) { |
frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
frame = (__address)frame_alloc(ONE_FRAME, 0); |
memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), FRAME_SIZE); |
if (area->sh_info) { |
153,7 → 153,7 |
* To resolve the situation, a frame must be allocated |
* and cleared. |
*/ |
frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
frame = (__address)frame_alloc(ONE_FRAME, 0); |
memsetb(PA2KA(frame), FRAME_SIZE, 0); |
if (area->sh_info) { |
170,7 → 170,7 |
* the upper part is anonymous memory. |
*/ |
size = entry->p_filesz - (i<<PAGE_WIDTH); |
frame = PFN2ADDR(frame_alloc(ONE_FRAME, 0)); |
frame = (__address)frame_alloc(ONE_FRAME, 0); |
memsetb(PA2KA(frame) + size, FRAME_SIZE - size, 0); |
memcpy((void *) PA2KA(frame), (void *) (base + i*FRAME_SIZE), size); |
218,7 → 218,7 |
/* |
* Free the frame with the copy of writable segment data. |
*/ |
frame_free(ADDR2PFN(frame)); |
frame_free(frame); |
} |
} else { |
/* |
226,7 → 226,7 |
* part is backed by the ELF image and the upper is anonymous). |
* In any case, a frame needs to be freed. |
*/ |
frame_free(ADDR2PFN(frame)); |
frame_free(frame); |
} |
} |
/kernel/trunk/arch/sparc64/src/mm/page.c |
---|
73,7 → 73,7 |
else |
order = (fnzb32(size - 1) + 1) - FRAME_WIDTH; |
__address virtaddr = PA2KA(PFN2ADDR(frame_alloc(order, FRAME_KA))); |
__address virtaddr = frame_alloc(order, FRAME_KA); |
for (i = 0; i < sizemap[order].count; i++) |
dtlb_insert_mapping(virtaddr + i*sizemap[order].increment, |
/kernel/trunk/arch/ia64/src/mm/vhpt.c |
---|
42,7 → 42,7 |
__address vhpt_set_up(void) |
{ |
vhpt_base=(vhpt_entry_t*) PA2KA(PFN2ADDR(frame_alloc(VHPT_WIDTH-FRAME_WIDTH,FRAME_KA))); |
vhpt_base=(vhpt_entry_t*) frame_alloc(VHPT_WIDTH-FRAME_WIDTH,FRAME_KA); |
if(!vhpt_base) panic("Kernel configured with VHPT but no memory for table."); |
vhpt_invalidate_all(); |
return (__address) vhpt_base; |
/kernel/trunk/arch/ppc64/src/mm/page.c |
---|
274,8 → 274,7 |
} |
/* Allocate page hash table */ |
phte_t *physical_phte = (phte_t *) PFN2ADDR(frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC)); |
phte = (phte_t *) PA2KA((__address) physical_phte); |
phte_t *physical_phte = (phte_t *) frame_alloc(PHT_ORDER, FRAME_KA | FRAME_PANIC); |
ASSERT((__address) physical_phte % (1 << PHT_BITS) == 0); |
pht_init(); |
/kernel/trunk/arch/ia32/src/smp/smp.c |
---|
73,11 → 73,11 |
ops = &mps_config_operations; |
} |
l_apic_address = PA2KA(PFN2ADDR(frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status))); |
l_apic_address = (__address) frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status); |
if (status != FRAME_OK) |
panic("cannot allocate address for l_apic\n"); |
io_apic_address = PA2KA(PFN2ADDR(frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status))); |
io_apic_address = (__address) frame_alloc_rc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA, &status); |
if (status != FRAME_OK) |
panic("cannot allocate address for io_apic\n"); |