From 1ebb5df920fee910d18dd3934cd1a3e5ef98c8c4 Mon Sep 17 00:00:00 2001 From: deadwood Date: Sun, 16 Jan 2022 10:28:06 +0100 Subject: [PATCH] Introduce EMERGENCY flag for ShutdownA This flag indicates that something has already gone wrong and least amount of code should be used to do reboot or shutdown. This means not running non-critical reset handlers. Note that the handler itself needs to decide whethere it is critical or not. --- arch/all-mingw32/exec/shutdowna.c | 2 +- arch/all-pc/exec/powerstate_handlers.c | 4 ++-- arch/all-unix/exec/shutdowna.c | 2 +- arch/m68k-amiga/exec/shutdowna.c | 2 +- arch/ppc-chrp/exec/shutdowna.c | 4 ++-- compiler/include/exec/tasks.h | 3 +++ rom/efi/efi_init.c | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/all-mingw32/exec/shutdowna.c b/arch/all-mingw32/exec/shutdowna.c index 1d089bfac0..4796d378be 100644 --- a/arch/all-mingw32/exec/shutdowna.c +++ b/arch/all-mingw32/exec/shutdowna.c @@ -18,7 +18,7 @@ AROS_LH1(ULONG, ShutdownA, while it's running. There's no sense in this beyond this point, so we simply Disable() */ Disable(); - switch(action) + switch(action & SD_ACTION_MASK) { case SD_ACTION_POWEROFF: PD(SysBase).ExitProcess(0); diff --git a/arch/all-pc/exec/powerstate_handlers.c b/arch/all-pc/exec/powerstate_handlers.c index 3d8b498121..e853423908 100644 --- a/arch/all-pc/exec/powerstate_handlers.c +++ b/arch/all-pc/exec/powerstate_handlers.c @@ -18,7 +18,7 @@ AROS_INTH1(Exec_X86ColdResetHandler, struct Interrupt *, handler) { AROS_INTFUNC_INIT - UBYTE action = handler->is_Node.ln_Type; + UBYTE action = handler->is_Node.ln_Type & SD_ACTION_MASK; if (action == SD_ACTION_COLDREBOOT) { @@ -35,7 +35,7 @@ AROS_INTH1(Exec_X86WarmResetHandler, struct Interrupt *, handler) { AROS_INTFUNC_INIT - UBYTE action = handler->is_Node.ln_Type; + UBYTE action = handler->is_Node.ln_Type & SD_ACTION_MASK; if (action == SD_ACTION_WARMREBOOT) { diff --git a/arch/all-unix/exec/shutdowna.c b/arch/all-unix/exec/shutdowna.c index 2768da416d..e4488b0b30 100644 --- a/arch/all-unix/exec/shutdowna.c +++ b/arch/all-unix/exec/shutdowna.c @@ -23,7 +23,7 @@ AROS_LH1(ULONG, ShutdownA, int exitcode; - switch(action) + switch(action & SD_ACTION_MASK) { case SD_ACTION_POWEROFF: exitcode = 0; diff --git a/arch/m68k-amiga/exec/shutdowna.c b/arch/m68k-amiga/exec/shutdowna.c index 5fe50c16b3..dd00cbd2bd 100644 --- a/arch/m68k-amiga/exec/shutdowna.c +++ b/arch/m68k-amiga/exec/shutdowna.c @@ -17,7 +17,7 @@ AROS_LH1(ULONG, ShutdownA, { AROS_LIBFUNC_INIT - switch (action) { + switch (action & SD_ACTION_MASK) { case SD_ACTION_POWEROFF: { /* No stock Amiga hardware is known to support this. diff --git a/arch/ppc-chrp/exec/shutdowna.c b/arch/ppc-chrp/exec/shutdowna.c index 16e74e392b..43d493e8da 100644 --- a/arch/ppc-chrp/exec/shutdowna.c +++ b/arch/ppc-chrp/exec/shutdowna.c @@ -34,9 +34,9 @@ AROS_LH1(ULONG, ShutdownA, if (RTASBase) { - if (action == SD_ACTION_COLDREBOOT) + if ((action & SD_ACTION_MASK) == SD_ACTION_COLDREBOOT) rtas_call(SysBase, "system-reboot", 0, 1, NULL); - else if (action ==SD_ACTION_POWEROFF) + else if ((action & SD_ACTION_MASK) ==SD_ACTION_POWEROFF) rtas_call(SysBase, "power-off", 2, 1, NULL, -1, -1); } diff --git a/compiler/include/exec/tasks.h b/compiler/include/exec/tasks.h index 2d9107a2a5..2ee08df60c 100644 --- a/compiler/include/exec/tasks.h +++ b/compiler/include/exec/tasks.h @@ -234,4 +234,7 @@ struct ETask #define SD_ACTION_COLDREBOOT 1 #define SD_ACTION_WARMREBOOT 2 +#define SD_ACTION_MASK 0x00000007 +#define SD_FLAG_EMERGENCY 0x00000008 /* Only the most basic/essential code should be executed */ + #endif /* EXEC_TASKS_H */ diff --git a/rom/efi/efi_init.c b/rom/efi/efi_init.c index b3d8cf4f93..d6e3276b6e 100644 --- a/rom/efi/efi_init.c +++ b/rom/efi/efi_init.c @@ -26,7 +26,7 @@ AROS_INTH1(static ResetHandler, struct EFIBase *, EFIBase) { AROS_INTFUNC_INIT - UBYTE action = EFIBase->reset_handler.is_Node.ln_Type; + UBYTE action = EFIBase->reset_handler.is_Node.ln_Type & SD_ACTION_MASK; IPTR efiAction; switch (action)