diff --git a/apps/installer.cpp b/apps/installer.cpp index 50465e6..1caf154 100644 --- a/apps/installer.cpp +++ b/apps/installer.cpp @@ -948,11 +948,11 @@ void ButtonInstallOptions(EsInstance *, EsElement *, EsCommand *) { } void ButtonShutdown(EsInstance *, EsElement *, EsCommand *) { - EsSyscall(ES_SYSCALL_SHUTDOWN, SHUTDOWN_ACTION_POWER_OFF, 0, 0, 0); + EsSyscall(ES_SYSCALL_SHUTDOWN, ES_SHUTDOWN_ACTION_POWER_OFF, 0, 0, 0); } void ButtonRestart(EsInstance *, EsElement *, EsCommand *) { - EsSyscall(ES_SYSCALL_SHUTDOWN, SHUTDOWN_ACTION_RESTART, 0, 0, 0); + EsSyscall(ES_SYSCALL_SHUTDOWN, ES_SHUTDOWN_ACTION_RESTART, 0, 0, 0); } void ButtonInstall(EsInstance *, EsElement *, EsCommand *) { diff --git a/desktop/api.cpp b/desktop/api.cpp index 3ca20a6..c2aa850 100644 --- a/desktop/api.cpp +++ b/desktop/api.cpp @@ -553,6 +553,10 @@ void EsSystemShowShutdownDialog() { MessageDesktop(&message, 1); } +void EsSystemShutdown(uint32_t action) { + EsSyscall(ES_SYSCALL_SHUTDOWN, action, 0, 0, 0); +} + void EsSystemConfigurationReadFileTypes(EsBuffer *buffer) { uint8_t m = DESKTOP_MSG_FILE_TYPES_GET; MessageDesktop(&m, 1, ES_INVALID_HANDLE, buffer); diff --git a/desktop/api_tests.cpp b/desktop/api_tests.cpp index 43cad91..5c3aaff 100644 --- a/desktop/api_tests.cpp +++ b/desktop/api_tests.cpp @@ -1229,7 +1229,7 @@ bool RestartTest() { index++; if (ES_SUCCESS != EsFileWriteAll(EsLiteral("|Settings:/restart_test.txt"), &index, sizeof(uint32_t))) return false; EsPrint("Restart %d...\n", index); - EsSyscall(ES_SYSCALL_SHUTDOWN, SHUTDOWN_ACTION_RESTART, 0, 0, 0); + EsSyscall(ES_SYSCALL_SHUTDOWN, ES_SHUTDOWN_ACTION_RESTART, 0, 0, 0); while (EsMessageReceive()); return false; } @@ -1345,7 +1345,7 @@ void RunTests() { } } - EsSyscall(ES_SYSCALL_SHUTDOWN, SHUTDOWN_ACTION_POWER_OFF, 0, 0, 0); + EsSyscall(ES_SYSCALL_SHUTDOWN, ES_SHUTDOWN_ACTION_POWER_OFF, 0, 0, 0); EsProcessTerminateCurrent(); } diff --git a/desktop/desktop.cpp b/desktop/desktop.cpp index 225021c..53b1055 100644 --- a/desktop/desktop.cpp +++ b/desktop/desktop.cpp @@ -1418,11 +1418,11 @@ void ShutdownModalCreate() { // Setup command callbacks when the buttons are pressed. EsButtonOnCommand(shutdownButton, [] (EsInstance *, EsElement *, EsCommand *) { - Shutdown(SHUTDOWN_ACTION_POWER_OFF); + Shutdown(ES_SHUTDOWN_ACTION_POWER_OFF); }); EsButtonOnCommand(restartButton, [] (EsInstance *, EsElement *, EsCommand *) { - Shutdown(SHUTDOWN_ACTION_RESTART); + Shutdown(ES_SHUTDOWN_ACTION_RESTART); }); EsButtonOnCommand(cancelButton, [] (EsInstance *, EsElement *element, EsCommand *) { diff --git a/desktop/os.header b/desktop/os.header index ea2d0af..cffa83a 100644 --- a/desktop/os.header +++ b/desktop/os.header @@ -779,6 +779,9 @@ define ES_LIST_VIEW_CHOOSE_ITEM_ENTER (2) define ES_LIST_VIEW_CHOOSE_ITEM_DOUBLE_CLICK (3) define ES_LIST_VIEW_CHOOSE_ITEM_MIDDLE_CLICK (4) +define ES_SHUTDOWN_ACTION_POWER_OFF (1) +define ES_SHUTDOWN_ACTION_RESTART (2) + include desktop/icons.header enum EsFatalError { @@ -1984,6 +1987,7 @@ function EsHandle EsTakeSystemSnapshot(int type, size_t *bufferSize); function EsInstance *_EsInstanceCreate(size_t bytes, EsMessage *message, STRING name = BLANK_STRING); function EsError EsHandleClose(EsHandle handle); function void EsSystemShowShutdownDialog(); +function void EsSystemShutdown(uint32_t action); function void EsPOSIXInitialise(int *argc, char ***argv); function long EsPOSIXSystemCall(long n, long a1, long a2, long a3, long a4, long a5, long a6); diff --git a/desktop/prefix.h b/desktop/prefix.h index c62c28d..bc6e4fd 100644 --- a/desktop/prefix.h +++ b/desktop/prefix.h @@ -378,9 +378,6 @@ struct SystemStartupDataHeader { #define CURSOR_SPEED(x) ((x) >> 16) #define CURSOR_TRAILS(x) (((x) >> 13) & 7) -#define SHUTDOWN_ACTION_POWER_OFF (1) -#define SHUTDOWN_ACTION_RESTART (2) - #ifdef __cplusplus extern "C" const void *EsBufferRead(struct EsBuffer *buffer, size_t readBytes); extern "C" const void *EsBufferReadMany(struct EsBuffer *buffer, size_t a, size_t b); diff --git a/drivers/acpi.cpp b/drivers/acpi.cpp index 1c86071..69e1ea6 100644 --- a/drivers/acpi.cpp +++ b/drivers/acpi.cpp @@ -329,7 +329,7 @@ CPULocalStorage *KGetCPULocal(uintptr_t index) { #include "acpica.cpp" #else void ArchShutdown() { - if (shutdownAction == SHUTDOWN_ACTION_RESTART) ProcessorReset(); + if (shutdownAction == ES_SHUTDOWN_ACTION_RESTART) ProcessorReset(); StartDebugOutput(); EsPrint("\nIt's now safe to turn off your computer.\n"); ProcessorDisableInterrupts(); diff --git a/drivers/acpica.cpp b/drivers/acpica.cpp index 24dea2a..00dd538 100644 --- a/drivers/acpica.cpp +++ b/drivers/acpica.cpp @@ -595,7 +595,7 @@ ACPI_STATUS ACPIWalkNamespaceCallback(ACPI_HANDLE object, uint32_t depth, void * } void ArchShutdown() { - if (shutdownAction == SHUTDOWN_ACTION_RESTART) ProcessorReset(); + if (shutdownAction == ES_SHUTDOWN_ACTION_RESTART) ProcessorReset(); AcpiEnterSleepStatePrep(5); ProcessorDisableInterrupts(); AcpiEnterSleepState(5); diff --git a/util/api_table.ini b/util/api_table.ini index 0da9008..ec83299 100644 --- a/util/api_table.ini +++ b/util/api_table.ini @@ -340,6 +340,7 @@ EsClipboardReadText=338 EsClipboardOpen=339 EsSpacerCreate=340 EsTextPlanCreate=341 +EsSystemShutdown=342 EsListDisplayCreate=343 EsCRTfabsf=344 EsCRTisnanf=345