Use poweroff driver from libkernaux

This commit is contained in:
Alex Kotov 2022-11-28 19:06:56 +04:00
parent 65a1acb58d
commit b62433e227
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
5 changed files with 9 additions and 33 deletions

View File

@ -25,7 +25,6 @@ CPPFLAGS = \
# Architecture-dependent
OBJS = start.s.o
OBJS += main.c.o
OBJS += poweroff.c.o
OBJS += panic.c.o
OBJS += paging.c.o

View File

@ -1,8 +1,8 @@
#include "main.h"
#include "../panic.h"
#include "../poweroff.h"
#include <kernaux/drivers/console.h>
#include <kernaux/drivers/shutdown.h>
static const char *const messages[] = {
"0 #DE - Divide Error Exception",
@ -42,7 +42,11 @@ static const char *const messages[] = {
void exception_handler(struct IsrRegisters regs)
{
if (regs.int_no > INT_EXCEPTION_LAST) return;
if (regs.int_no == POWEROFF_INT && poweroff_doing) return;
if (regs.int_no == KERNAUX_DRIVERS_SHUTDOWN_INT &&
kernaux_drivers_shutdown_is_doing())
{
return;
}
kernaux_drivers_console_printf(
"[FAIL] exception: Unhandled protected-mode exception: %s\n",

View File

@ -1,14 +1,14 @@
#include "panic.h"
#include "poweroff.h"
#include <kernaux/asm/i386.h>
#include <kernaux/drivers/console.h>
#include <kernaux/drivers/shutdown.h>
#include <kernaux/drivers/qemu.h>
void panic(const char *const s)
{
kernaux_drivers_console_printf("[FAIL] panic: %s\n", s);
poweroff();
kernaux_drivers_shutdown_poweroff();
}
void halt()
@ -23,5 +23,5 @@ void kernaux_assert_fn(
) {
kernaux_drivers_console_printf("[FAIL] assertion failed: %s:%u: \"%s\"\n",
file, line, str);
poweroff();
kernaux_drivers_shutdown_poweroff();
}

View File

@ -1,14 +0,0 @@
#include "poweroff.h"
#include <stdbool.h>
#include <kernaux/drivers/qemu.h>
bool poweroff_doing = false;
void poweroff()
{
poweroff_doing = true;
kernaux_drivers_qemu_poweroff();
for (;;) asm volatile(POWEROFF_ASM);
}

View File

@ -1,13 +0,0 @@
#ifndef KERNEL_INCLUDED_POWEROFF
#define KERNEL_INCLUDED_POWEROFF 1
#include <stdbool.h>
#define POWEROFF_INT 3
#define POWEROFF_ASM "int $3"
extern bool poweroff_doing;
void poweroff();
#endif