Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 688 → Rev 689

/kernel/trunk/generic/include/mm/frame.h
38,9 → 38,14
 
#define ONE_FRAME 0
 
#define FRAME_KA 1 /* skip frames conflicting with user address space */
#define FRAME_PANIC 2 /* panic on failure */
#define FRAME_KA 1 /* skip frames conflicting with user address space */
#define FRAME_PANIC 2 /* panic on failure */
#define FRAME_NON_BLOCKING 4 /* do not panic and do not sleep on failure */
 
#define FRAME_OK 0 /* frame_alloc return status */
#define FRAME_NO_MEMORY 1 /* frame_alloc return status */
#define FRAME_ERROR 2 /* frame_alloc return status */
 
#define FRAME2ADDR(zone, frame) ((zone)->base + ((frame) - (zone)->frames) * FRAME_SIZE)
#define ADDR2FRAME(zone, addr) (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
#define FRAME_INDEX(zone, frame) ((index_t)((frame) - (zone)->frames))
88,8 → 93,10
 
extern void frame_init(void);
extern void frame_initialize(frame_t *frame, zone_t *zone);
__address frame_alloc(int flags, __u8 order);
 
__address frame_alloc(int flags, __u8 order, int * status);
extern void frame_free(__address addr);
 
zone_t * get_zone_by_frame(frame_t * frame);
 
/*
/kernel/trunk/generic/src/proc/thread.c
173,9 → 173,9
spinlock_initialize(&t->lock, "thread_t_lock");
frame_ks = frame_alloc(FRAME_KA, ONE_FRAME);
frame_ks = frame_alloc(FRAME_KA, ONE_FRAME, NULL);
if (THREAD_USER_STACK & flags) {
frame_us = frame_alloc(FRAME_KA, ONE_FRAME);
frame_us = frame_alloc(FRAME_KA, ONE_FRAME, NULL);
}
 
ipl = interrupts_disable();
/kernel/trunk/generic/src/cpu/cpu.c
61,7 → 61,7
memsetb((__address) cpus, sizeof(cpu_t) * config.cpu_count, 0);
 
for (i=0; i < config.cpu_count; i++) {
cpus[i].stack = (__u8 *) frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME);
cpus[i].stack = (__u8 *) frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL);
cpus[i].id = i;
/kernel/trunk/generic/src/mm/vm.c
70,7 → 70,7
pte_t *src_ptl0, *dst_ptl0;
src_ptl0 = (pte_t *) PA2KA((__address) GET_PTL0_ADDRESS());
dst_ptl0 = (pte_t *) frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME);
dst_ptl0 = (pte_t *) frame_alloc(FRAME_KA | FRAME_PANIC, ONE_FRAME, NULL);
 
// memsetb((__address) dst_ptl0, PAGE_SIZE, 0);
// memcpy((void *) &dst_ptl0[KAS_START_INDEX], (void *) &src_ptl0[KAS_START_INDEX], KAS_INDICES);
116,7 → 116,7
}
for (i=0; i<size; i++)
a->mapping[i] = frame_alloc(0, ONE_FRAME);
a->mapping[i] = frame_alloc(0, ONE_FRAME, NULL);
spinlock_initialize(&a->lock, "vm_area_lock");
/kernel/trunk/generic/src/mm/frame.c
83,7 → 83,7
*
* @return Allocated frame.
*/
__address frame_alloc(int flags, __u8 order)
__address frame_alloc(int flags, __u8 order, int * status)
{
ipl_t ipl;
link_t *cur, *tmp;
117,6 → 117,8
if (flags & FRAME_PANIC)
panic("Can't allocate frame.\n");
/*
* TODO: Sleep until frames are available again.
*/
123,6 → 125,12
spinlock_unlock(&zone_head_lock);
interrupts_restore(ipl);
 
if (flags & FRAME_NON_BLOCKING) {
ASSERT(status != NULL);
*status = FRAME_NO_MEMORY;
return NULL;
}
panic("Sleep not implemented.\n");
goto loop;
}
151,6 → 159,11
if (flags & FRAME_KA)
v = PA2KA(v);
if (flags & FRAME_NON_BLOCKING) {
ASSERT(status != NULL);
*status = FRAME_OK;
}
return v;
}