1 /* See COPYRIGHT for copyright information. */
4 #include <inc/string.h>
5 #include <inc/assert.h>
7 #include <kern/monitor.h>
8 #include <kern/console.h>
10 // Test the stack backtrace function (lab 1 only)
14 cprintf("entering test_backtrace %d\n", x
);
18 mon_backtrace(0, 0, 0);
19 cprintf("leaving test_backtrace %d\n", x
);
25 extern char edata
[], end
[];
26 extern const uintptr_t sctors
[], ectors
[];
27 const uintptr_t *ctorva
;
29 // Initialize the console.
30 // Can't call cprintf until after we do this!
33 // Then call any global constructors (e.g., defined by C++).
34 // This relies on linker script magic to define the 'sctors' and
35 // 'ectors' symbols; see kern/kernel.ld.
36 // Call after cons_init() so we can cprintf() if necessary.
37 for (ctorva
= ectors
; ctorva
> sctors
; )
38 ((void(*)()) *--ctorva
)();
40 cprintf("6828 decimal is %o octal!\n", 6828);
48 // Test the stack backtrace function (lab 1 only)
51 // Drop into the kernel monitor.
58 * Variable panicstr contains argument to first call to panic; used as flag
59 * to indicate that the kernel has already called panic.
61 static const char *panicstr
;
64 * Panic is called on unresolvable fatal errors.
65 * It prints "panic: mesg", and then enters the kernel monitor.
68 _panic(const char *file
, int line
, const char *fmt
, ...)
76 // Be extra sure that the machine is in as reasonable state
77 __asm
__volatile("cli; cld");
80 cprintf("kernel panic at %s:%d: ", file
, line
);
86 /* break into the kernel monitor */
91 /* like panic, but don't */
93 _warn(const char *file
, int line
, const char *fmt
, ...)
98 cprintf("kernel warning at %s:%d: ", file
, line
);