implement kernel panic

This commit is contained in:
2025-07-18 12:36:18 +03:00
parent 550a36ba88
commit 8fae948c32
3 changed files with 19 additions and 6 deletions

View File

@@ -84,7 +84,9 @@ char *strcpy(char *dst, const char *src) {
*d++ = *src++;
*d = '\0';
return dst;
}
} // The strcpy function continues copying even if
// src is longer than the memory area of dst.
// This can easily lead to bugs and vulnerabilities
int strcmp(const char *s1, const char *s2) {
while (*s1 && *s2) {

View File

@@ -27,12 +27,17 @@ void putchar(char ch) {
}
void kernel_main(void) {
printf("\n\nHello %s\n", "RETARD!");
printf("60 + 9 = %d, %x\n", 60 + 9, 0x1234abcd);
// printf("\n\nHello %s\n", "friend :3");
// printf("60 + 9 = %d, %x\n", 60 + 9, 0x1234abcd);
//
// for (;;) {
// __asm__ __volatile__("wfi");
// }
memset(__bss, 0, (size_t) __bss_end - (size_t) __bss);
for (;;) {
__asm__ __volatile__("wfi");
}
PANIC("BOOOO!!! GET INFECTED WITH BOOTKID YOU SKID! 0x1337h@x0r");
printf("you lucky bitch got away\n");
}
__attribute__((section(".text.boot")))

View File

@@ -4,3 +4,9 @@ struct sbiret {
long error;
long value;
};
#define PANIC(fmt, ...) \
do { \
printf("YOU GOT A PANIC ERROR: %s:%d: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \
while (1) {} \
} while (0)