add: kpanic

This commit is contained in:
2024-09-22 09:54:56 +02:00
parent 283f073124
commit 2728346711
11 changed files with 58 additions and 50 deletions

View File

@ -1,37 +0,0 @@
#include "sys/io.h"
#include <stdint.h>
#define KBD_INTERFACE 0x64
/* keyboard interface bits */
#define KBD_BIT_KDATA 0 /* keyboard data */
#define KBD_BIT_UDATA 1 /* user data */
#define KBD_IO 0x60 /* keyboard IO port */
#define KBD_RESET 0xFE /* reset CPU command */
#define bit(n) (1 << (n)) /* Set bit n to 1 */
/* Check if bit n in flags is set */
#define check_flag(flags, n) ((flags) & bit(n))
void reboot(void)
{
uint8_t tmp;
asm volatile("cli"); /* disable all interrupts */
do {
tmp = inb(KBD_INTERFACE); /* empty user data */
if (check_flag(tmp, KBD_BIT_KDATA))
inb(KBD_IO); /* empty keyboard data */
} while (check_flag(tmp, KBD_BIT_UDATA));
outb(KBD_INTERFACE, KBD_RESET); /* pulse CPU reset line */
loop:
asm volatile("hlt");
goto loop;
}
void halt(void)
{
asm volatile("hlt");
}