/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); |
} |
} |