Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 67 → Rev 68

/SPARTAN/trunk/include/panic.h
29,8 → 29,12
#ifndef __PANIC_H__
#define __PANIC_H__
 
#define PANIC "KERNEL PANIC: "
#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
 
extern void panic(char *fmt, ...);
extern void panic_printf(char *fmt, ...);
 
#endif
/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 int base);
static void print_number(const __native num, const unsigned int base);
 
extern void putchar(const char c);
extern void printf(const char *fmt, ...);
/SPARTAN/trunk/include/list.h
68,7 → 68,7
link_initialize(link); \
}
 
#define list_empty(head) (((head)->next == (head))?1:0)
#define list_empty(head) (((head)->next == (head))?true:false)
 
#define list_get_instance(link,type,member) (type *)(((__u8*)(link))-((__u8*)&(((type *)NULL)->member)))
 
/SPARTAN/trunk/include/typedefs.h
34,6 → 34,8
 
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/src/synch/rwlock.c
184,10 → 184,10
cpu_priority_restore(pri);
break;
case ESYNCH_OK_ATOMIC:
panic(PANIC "_mutex_lock_timeout()==ESYNCH_OK_ATOMIC");
panic("_mutex_lock_timeout()==ESYNCH_OK_ATOMIC");
break;
dafault:
panic(PANIC "invalid ESYNCH");
panic("invalid ESYNCH");
break;
}
return rc;
/SPARTAN/trunk/src/main/kinit.c
119,17 → 119,17
* Create the first user task.
*/
m = vm_create();
if (!m) panic(PANIC "vm_create");
if (!m) panic("vm_create");
u = task_create(m);
if (!u) panic(PANIC "task_create");
if (!u) panic("task_create");
t = thread_create(uinit, NULL, u, THREAD_USER_STACK);
if (!t) panic(PANIC "thread_create");
if (!t) 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(PANIC "vm_area_create: vm_text");
if (!a) 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(PANIC "vm_area_create: vm_stack");
if (!a) panic("vm_area_create: vm_stack");
thread_ready(t);
#endif /* __USERSPACE__ */
/SPARTAN/trunk/src/main/main.c
29,6 → 29,7
#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/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 int base)
void print_number(const __native num, const unsigned 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/time/timeout.c
30,6 → 30,7
#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/src/proc/scheduler.c
37,6 → 37,7
#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/mm/vm.c
62,7 → 62,7
vm_area_t *a;
if (addr % PAGE_SIZE)
panic(PANIC "addr not aligned to a page boundary");
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(PANIC "unexpected vm_type_t %d", a->type);
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(PANIC "malloc/frame_bitmap\n");
panic("malloc/frame_bitmap\n");
 
/*
* Mark all frames free.
144,16 → 144,16
return i*FRAME_SIZE;
}
}
panic(PANIC "frames_free inconsistent (%d)\n", frames_free);
panic("frames_free inconsistent (%d)\n", frames_free);
}
spinlock_unlock(&framelock);
cpu_priority_restore(pri);
 
if (flags & FRAME_PANIC)
panic(PANIC "unable to allocate frame\n");
panic("unable to allocate frame\n");
/* TODO: implement sleeping logic here */
panic(PANIC "sleep not supported\n");
panic("sleep not supported\n");
goto loop;
}
195,9 → 195,9
frames_free++;
}
}
else panic(PANIC "frame_free: frame already free\n");
else panic("frame_free: frame already free\n");
}
else panic(PANIC "frame_free: frame number too big\n");
else panic("frame_free: frame number too big\n");
spinlock_unlock(&framelock);
cpu_priority_restore(pri);
/SPARTAN/trunk/src/mm/heap.c
30,6 → 30,7
#include <synch/spinlock.h>
#include <func.h>
#include <memstr.h>
#include <panic.h>
#include <arch/types.h>
 
/*
/SPARTAN/trunk/arch/ia64/src/fake.s
47,7 → 47,7
.global frame_arch_init
.global map_page_to_frame
.global memsetb
.global panic
.global panic_printf
 
before_thread_runs_arch:
userspace:
68,6 → 68,6
frame_arch_init:
map_page_to_frame:
memsetb:
panic:
panic_printf:
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(PANIC "unhandled exception %d\n", excno); break;
default: panic("unhandled exception %d\n", excno); break;
}
if (THREAD) {
/SPARTAN/trunk/arch/mips/src/cache.c
31,5 → 31,5
 
void cache_error(void)
{
panic(PANIC "cache_error exception\n");
panic("cache_error exception\n");
}
/SPARTAN/trunk/arch/mips/src/mm/tlb.c
41,12 → 41,12
main_bsp();
}
panic(PANIC "tlb_refill exception\n");
panic("tlb_refill exception\n");
}
 
void tlb_invalid(void)
{
panic(PANIC "%X: TLB exception at %X", cp0_badvaddr_read(), THREAD ? THREAD->saved_epc : 0);
panic("%X: TLB exception at %X", cp0_badvaddr_read(), THREAD ? THREAD->saved_epc : 0);
}
 
void tlb_invalidate(int asid)
/SPARTAN/trunk/arch/mips/src/panic.s
32,9 → 32,9
.set noreorder
.set nomacro
 
.global panic
.global panic_printf
panic:
panic_printf:
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(PANIC "unhandled interrupt %d\n", i); break;
case 0x6: panic("unhandled interrupt %d\n", i); break;
case 0x7:
/* clear timer interrupt */
cp0_compare_write(cp0_compare_value);
/SPARTAN/trunk/arch/ia32/src/debug/panic.s
27,8 → 27,8
#
 
.text
.global panic
.global panic_printf
 
panic:
panic_printf:
movl $halt,(%esp) # fake stack to make printf return to halt
jmp printf
/SPARTAN/trunk/arch/ia32/src/pm.c
143,7 → 143,7
else {
tss_p = (struct tss *) malloc(sizeof(struct tss));
if (!tss_p)
panic(PANIC "could not allocate TSS\n");
panic("could not allocate TSS\n");
}
 
tss_initialize(tss_p);
/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(PANIC "couldn't allocate memory for GDT\n");
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,6 → 28,7
 
#include <arch/interrupt.h>
#include <print.h>
#include <debug.h>
#include <panic.h>
#include <arch/i8259.h>
#include <func.h>
48,12 → 49,14
 
iroutine trap_register(__u8 n, iroutine f)
{
ASSERT(n < IVT_ITEMS);
iroutine old;
old = ivt[n];
ivt[n] = f;
return old;
return old;
}
 
/*
62,7 → 65,9
*/
void trap_dispatcher(__u8 n, __u32 stack[])
{
ivt[n](n,stack);
ASSERT(n < IVT_ITEMS);
ivt[n](n, stack);
}
 
void null_interrupt(__u8 n, __u32 stack[])
112,7 → 117,7
if (enable_irqs_function)
enable_irqs_function(irqmask);
else
panic(PANIC "no enable_irqs_function\n");
panic("no enable_irqs_function\n");
}
 
void trap_virtual_disable_irqs(__u16 irqmask)
120,7 → 125,7
if (disable_irqs_function)
disable_irqs_function(irqmask);
else
panic(PANIC "no disable_irqs_function\n");
panic("no disable_irqs_function\n");
}
 
void trap_virtual_eoi(void)
128,6 → 133,6
if (eoi_function)
eoi_function();
else
panic(PANIC "no eoi_function\n");
panic("no eoi_function\n");
 
}