/SPARTAN/trunk/include/list.h |
---|
68,7 → 68,7 |
link_initialize(link); \ |
} |
#define list_empty(head) (((head)->next == (head))?true:false) |
#define list_empty(head) (((head)->next == (head))?1:0) |
#define list_get_instance(link,type,member) (type *)(((__u8*)(link))-((__u8*)&(((type *)NULL)->member))) |
/SPARTAN/trunk/include/typedefs.h |
---|
34,8 → 34,6 |
typedef short bool; |
typedef unsigned int size_t; |
typedef struct config config_t; |
typedef struct cpu_private_data cpu_private_data_t; |
typedef struct cpu_info cpu_info_t; |
/SPARTAN/trunk/include/print.h |
---|
37,7 → 37,7 |
static void print_str(const char *str); |
static void print_fixed_hex(const __native num, const int width); |
static void print_number(const __native num, const unsigned int base); |
static void print_number(const __native num, const int base); |
extern void putchar(const char c); |
extern void printf(const char *fmt, ...); |
/SPARTAN/trunk/include/panic.h |
---|
29,12 → 29,8 |
#ifndef __PANIC_H__ |
#define __PANIC_H__ |
#ifndef NDEBUG |
# define panic(format, ...) panic_printf("Kernel panic in %s() at %s on line %d: " format, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); |
#else |
# define panic(format, ...) panic_printf("Kernel panic: " format, ##__VA_ARGS__); |
#endif |
#define PANIC "KERNEL PANIC: " |
extern void panic_printf(char *fmt, ...); |
extern void panic(char *fmt, ...); |
#endif |
/SPARTAN/trunk/src/debug/print.c |
---|
46,11 → 46,11 |
*/ |
void print_str(const char *str) |
{ |
int i = 0; |
int i = 0; |
char c; |
while (c = str[i++]) |
putchar(c); |
putchar(c); |
} |
84,12 → 84,12 |
* be in range 2 .. 16). |
* |
*/ |
void print_number(const __native num, const unsigned int base) |
void print_number(const __native num, const int base) |
{ |
int val = num; |
char d[sizeof(__native)*8+1]; /* this is good enough even for base == 2 */ |
int i = sizeof(__native)*8-1; |
int i = sizeof(__native)*8-1; |
do { |
d[i--] = digits[val % base]; |
} while (val /= base); |
/SPARTAN/trunk/src/proc/scheduler.c |
---|
37,7 → 37,6 |
#include <arch.h> |
#include <arch/asm.h> |
#include <list.h> |
#include <panic.h> |
#include <typedefs.h> |
#include <mm/page.h> |
#include <synch/spinlock.h> |
/SPARTAN/trunk/src/main/main.c |
---|
29,7 → 29,6 |
#include <arch/asm.h> |
#include <arch/context.h> |
#include <print.h> |
#include <panic.h> |
#include <config.h> |
#include <time/clock.h> |
#include <proc/scheduler.h> |
/SPARTAN/trunk/src/main/kinit.c |
---|
119,17 → 119,17 |
* Create the first user task. |
*/ |
m = vm_create(); |
if (!m) panic("vm_create"); |
if (!m) panic(PANIC "vm_create"); |
u = task_create(m); |
if (!u) panic("task_create"); |
if (!u) panic(PANIC "task_create"); |
t = thread_create(uinit, NULL, u, THREAD_USER_STACK); |
if (!t) panic("thread_create"); |
if (!t) panic(PANIC "thread_create"); |
/* |
* Create the text vm_area and copy the userspace code there. |
*/ |
a = vm_area_create(m, VMA_TEXT, 1, UTEXT_ADDRESS); |
if (!a) panic("vm_area_create: vm_text"); |
if (!a) panic(PANIC "vm_area_create: vm_text"); |
memcopy((__address) utext, PA2KA(a->mapping[0]), utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE); |
/* |
136,7 → 136,7 |
* Create the data vm_area. |
*/ |
a = vm_area_create(m, VMA_STACK, 1, USTACK_ADDRESS); |
if (!a) panic("vm_area_create: vm_stack"); |
if (!a) panic(PANIC "vm_area_create: vm_stack"); |
thread_ready(t); |
#endif /* __USERSPACE__ */ |
/SPARTAN/trunk/src/mm/vm.c |
---|
62,7 → 62,7 |
vm_area_t *a; |
if (addr % PAGE_SIZE) |
panic("addr not aligned to a page boundary"); |
panic(PANIC "addr not aligned to a page boundary"); |
pri = cpu_priority_high(); |
spinlock_lock(&m->lock); |
124,7 → 124,7 |
flags = PAGE_READ | PAGE_WRITE | PAGE_USER | PAGE_PRESENT | PAGE_CACHEABLE; |
break; |
default: |
panic("unexpected vm_type_t %d", a->type); |
panic(PANIC "unexpected vm_type_t %d", a->type); |
} |
for (i=0; i<a->size; i++) |
/SPARTAN/trunk/src/mm/frame.c |
---|
71,7 → 71,7 |
frame_bitmap = (__u8 *) malloc(frame_bitmap_octets); |
if (!frame_bitmap) |
panic("malloc/frame_bitmap\n"); |
panic(PANIC "malloc/frame_bitmap\n"); |
/* |
* Mark all frames free. |
144,16 → 144,16 |
return i*FRAME_SIZE; |
} |
} |
panic("frames_free inconsistent (%d)\n", frames_free); |
panic(PANIC "frames_free inconsistent (%d)\n", frames_free); |
} |
spinlock_unlock(&framelock); |
cpu_priority_restore(pri); |
if (flags & FRAME_PANIC) |
panic("unable to allocate frame\n"); |
panic(PANIC "unable to allocate frame\n"); |
/* TODO: implement sleeping logic here */ |
panic("sleep not supported\n"); |
panic(PANIC "sleep not supported\n"); |
goto loop; |
} |
195,9 → 195,9 |
frames_free++; |
} |
} |
else panic("frame_free: frame already free\n"); |
else panic(PANIC "frame_free: frame already free\n"); |
} |
else panic("frame_free: frame number too big\n"); |
else panic(PANIC "frame_free: frame number too big\n"); |
spinlock_unlock(&framelock); |
cpu_priority_restore(pri); |
/SPARTAN/trunk/src/mm/heap.c |
---|
30,7 → 30,6 |
#include <synch/spinlock.h> |
#include <func.h> |
#include <memstr.h> |
#include <panic.h> |
#include <arch/types.h> |
/* |
/SPARTAN/trunk/src/synch/rwlock.c |
---|
184,10 → 184,10 |
cpu_priority_restore(pri); |
break; |
case ESYNCH_OK_ATOMIC: |
panic("_mutex_lock_timeout()==ESYNCH_OK_ATOMIC"); |
panic(PANIC "_mutex_lock_timeout()==ESYNCH_OK_ATOMIC"); |
break; |
dafault: |
panic("invalid ESYNCH"); |
panic(PANIC "invalid ESYNCH"); |
break; |
} |
return rc; |
/SPARTAN/trunk/src/time/timeout.c |
---|
30,7 → 30,6 |
#include <typedefs.h> |
#include <arch/types.h> |
#include <config.h> |
#include <panic.h> |
#include <synch/spinlock.h> |
#include <func.h> |
#include <cpu.h> |
/SPARTAN/trunk/arch/ia32/src/smp/mps.c |
---|
469,7 → 469,7 |
* Prepare new GDT for CPU in question. |
*/ |
if (!(gdt_new = (struct descriptor *) malloc(GDT_ITEMS*sizeof(struct descriptor)))) |
panic("couldn't allocate memory for GDT\n"); |
panic(PANIC "couldn't allocate memory for GDT\n"); |
memcopy(gdt, gdt_new, GDT_ITEMS*sizeof(struct descriptor)); |
gdtr.base = (__address) gdt_new; |
/SPARTAN/trunk/arch/ia32/src/interrupt.c |
---|
28,7 → 28,6 |
#include <arch/interrupt.h> |
#include <print.h> |
#include <debug.h> |
#include <panic.h> |
#include <arch/i8259.h> |
#include <func.h> |
49,14 → 48,12 |
iroutine trap_register(__u8 n, iroutine f) |
{ |
ASSERT(n < IVT_ITEMS); |
iroutine old; |
old = ivt[n]; |
ivt[n] = f; |
return old; |
return old; |
} |
/* |
65,9 → 62,7 |
*/ |
void trap_dispatcher(__u8 n, __u32 stack[]) |
{ |
ASSERT(n < IVT_ITEMS); |
ivt[n](n, stack); |
ivt[n](n,stack); |
} |
void null_interrupt(__u8 n, __u32 stack[]) |
117,7 → 112,7 |
if (enable_irqs_function) |
enable_irqs_function(irqmask); |
else |
panic("no enable_irqs_function\n"); |
panic(PANIC "no enable_irqs_function\n"); |
} |
void trap_virtual_disable_irqs(__u16 irqmask) |
125,7 → 120,7 |
if (disable_irqs_function) |
disable_irqs_function(irqmask); |
else |
panic("no disable_irqs_function\n"); |
panic(PANIC "no disable_irqs_function\n"); |
} |
void trap_virtual_eoi(void) |
133,6 → 128,6 |
if (eoi_function) |
eoi_function(); |
else |
panic("no eoi_function\n"); |
panic(PANIC "no eoi_function\n"); |
} |
/SPARTAN/trunk/arch/ia32/src/pm.c |
---|
143,7 → 143,7 |
else { |
tss_p = (struct tss *) malloc(sizeof(struct tss)); |
if (!tss_p) |
panic("could not allocate TSS\n"); |
panic(PANIC "could not allocate TSS\n"); |
} |
tss_initialize(tss_p); |
/SPARTAN/trunk/arch/ia32/src/debug/panic.s |
---|
27,8 → 27,8 |
# |
.text |
.global panic_printf |
.global panic |
panic_printf: |
panic: |
movl $halt,(%esp) # fake stack to make printf return to halt |
jmp printf |
/SPARTAN/trunk/arch/ia64/src/fake.s |
---|
47,7 → 47,7 |
.global frame_arch_init |
.global map_page_to_frame |
.global memsetb |
.global panic_printf |
.global panic |
before_thread_runs_arch: |
userspace: |
68,6 → 68,6 |
frame_arch_init: |
map_page_to_frame: |
memsetb: |
panic_printf: |
panic: |
br.ret.sptk.many b0 |
/SPARTAN/trunk/arch/mips/src/exception.c |
---|
51,7 → 51,7 |
case EXC_Int: interrupt(); break; |
case EXC_TLBL: |
case EXC_TLBS: tlb_invalid(); break; |
default: panic("unhandled exception %d\n", excno); break; |
default: panic(PANIC "unhandled exception %d\n", excno); break; |
} |
if (THREAD) { |
/SPARTAN/trunk/arch/mips/src/mm/tlb.c |
---|
41,12 → 41,12 |
main_bsp(); |
} |
panic("tlb_refill exception\n"); |
panic(PANIC "tlb_refill exception\n"); |
} |
void tlb_invalid(void) |
{ |
panic("%X: TLB exception at %X", cp0_badvaddr_read(), THREAD ? THREAD->saved_epc : 0); |
panic(PANIC "%X: TLB exception at %X", cp0_badvaddr_read(), THREAD ? THREAD->saved_epc : 0); |
} |
void tlb_invalidate(int asid) |
/SPARTAN/trunk/arch/mips/src/cache.c |
---|
31,5 → 31,5 |
void cache_error(void) |
{ |
panic("cache_error exception\n"); |
panic(PANIC "cache_error exception\n"); |
} |
/SPARTAN/trunk/arch/mips/src/panic.s |
---|
32,9 → 32,9 |
.set noreorder |
.set nomacro |
.global panic_printf |
.global panic |
panic_printf: |
panic: |
jal printf |
nop |
j cpu_halt |
/SPARTAN/trunk/arch/mips/src/interrupt.c |
---|
75,7 → 75,7 |
case 0x3: |
case 0x4: |
case 0x5: |
case 0x6: panic("unhandled interrupt %d\n", i); break; |
case 0x6: panic(PANIC "unhandled interrupt %d\n", i); break; |
case 0x7: |
/* clear timer interrupt */ |
cp0_compare_write(cp0_compare_value); |