mirror of
https://github.com/tailix/libkernaux.git
synced 2025-03-17 17:14:00 -04:00
Improve shutdown driver (#120)
This commit is contained in:
parent
0df3f9cbba
commit
fb5ff7f964
2 changed files with 2 additions and 22 deletions
|
@ -5,14 +5,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
// TODO: make this cross-platform
|
||||
#define KERNAUX_DRIVERS_SHUTDOWN_INT 3
|
||||
#define KERNAUX_DRIVERS_SHUTDOWN_ASM "int $3"
|
||||
|
||||
bool kernaux_drivers_shutdown_is_doing();
|
||||
|
||||
__attribute__((noreturn))
|
||||
void kernaux_drivers_shutdown_halt();
|
||||
void kernaux_drivers_shutdown_poweroff();
|
||||
|
|
|
@ -5,21 +5,11 @@
|
|||
#include <kernaux/drivers/shutdown.h>
|
||||
#include <kernaux/drivers/qemu.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
static bool is_doing = false;
|
||||
|
||||
bool kernaux_drivers_shutdown_is_doing()
|
||||
{
|
||||
return is_doing;
|
||||
}
|
||||
|
||||
void kernaux_drivers_shutdown_halt()
|
||||
{
|
||||
is_doing = true;
|
||||
|
||||
#ifdef ASM_X86
|
||||
for (;;) __asm__ __volatile__(KERNAUX_DRIVERS_SHUTDOWN_ASM);
|
||||
// Disable interrupts
|
||||
__asm__ __volatile__("cli");
|
||||
#endif
|
||||
|
||||
volatile int x = 0;
|
||||
|
@ -28,8 +18,6 @@ void kernaux_drivers_shutdown_halt()
|
|||
|
||||
void kernaux_drivers_shutdown_poweroff()
|
||||
{
|
||||
is_doing = true;
|
||||
|
||||
kernaux_drivers_qemu_poweroff();
|
||||
|
||||
// If we can't poweroff then we halt
|
||||
|
|
Loading…
Add table
Reference in a new issue