-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ry <ry.diffusion@proton.me>
- Loading branch information
1 parent
e1f8757
commit 7b32228
Showing
9 changed files
with
72 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#ifndef GIT_VERSION | ||
#define GIT_VERSION "UNKNOWN" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
#pragma once | ||
|
||
void panic(char *message); | ||
/** | ||
@brief Panics the kernel | ||
@param message The message to put in kernel panic, must be non null. | ||
*/ | ||
__attribute__((noreturn)) void panic(char message[static 1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
#define DUMP_STACK_ENTRIES_MAX 20 | ||
|
||
/** | ||
@brief Dumps the stack into console | ||
*/ | ||
void dumpStack(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <Kernel/Stack.h> | ||
#include <LibK/stdio.h> | ||
#include <stdint.h> | ||
|
||
#if defined(__x86_64__) | ||
void dumpStack(void) { | ||
kprintf("Stacktrace:\n"); | ||
uint64_t rbp = 0; | ||
|
||
__asm__ volatile("mov %%rbp, %0" : "=r"(rbp)); | ||
|
||
for (uint64_t frame = 0; rbp && frame < DUMP_STACK_ENTRIES_MAX; ++frame) { | ||
kprintf(" [%p]\n", rbp); | ||
rbp += sizeof(void *); | ||
} | ||
} | ||
|
||
#elif defined(__i386__) | ||
/* NOTE: NOT TESTED. */ | ||
|
||
struct stackframe { | ||
struct stackframe *ebp; | ||
uint64_t rip; | ||
}; | ||
|
||
void dumpStack(void) { | ||
kprintf("Stacktrace:\n"); | ||
struct stackframe *stackFrame; | ||
asm("movl %%ebp,%0" : "=r"(stackFrame)::); | ||
for (uint64_t frame = 0; stackFrame && frame < PANIC_STACK_ENTRIES_MAX; | ||
++frame) { | ||
|
||
kprintf(" [%p]\n", stackFrame->rip); | ||
stackFrame = stackFrame->ebp; | ||
} | ||
} | ||
#else | ||
void dumpStack(void) { kprintf("Stacktrace unavaliable.\n"); } | ||
#endif |