-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanic.c
More file actions
34 lines (29 loc) · 687 Bytes
/
panic.c
File metadata and controls
34 lines (29 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#if CHAPTER >= 6
//
// panic.c -- Defines the interface for bringing the system to an abnormal halt.
// Written for JamesM's kernel development tutorials.
//
#include "panic.h"
#include "common.h"
#include "elf.h"
static void print_stack_trace ();
extern elf_t kernel_elf;
void panic (const char *msg)
{
printk ("*** System panic: %s\n", msg);
print_stack_trace ();
printk ("***\n");
for (;;) ;
}
void print_stack_trace ()
{
uint32_t *ebp, *eip;
asm volatile ("mov %%ebp, %0" : "=r" (ebp));
while (ebp)
{
eip = ebp+1;
printk (" [0x%x] %s\n", *eip, elf_lookup_symbol (*eip, &kernel_elf));
ebp = (uint32_t*) *ebp;
}
}
#endif // CHAPTER >= 6