Skip to content

Commit

Permalink
protocols/hw: Remove the old PmResetRequest
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Bonke <[email protected]>
  • Loading branch information
Dennisbonke committed Oct 8, 2024
1 parent 19d52e3 commit 2212032
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
35 changes: 8 additions & 27 deletions kernel/thor/system/acpi/pm-interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,53 +56,35 @@ struct PmInterfaceBusObject : private KernelBusObject {
if (preamble.error())
co_return Error::protocolViolation;

if(preamble.id() == bragi::message_id<managarm::hw::PmResetRequest>) {
auto req = bragi::parse_head_only<managarm::hw::PmResetRequest>(reqBuffer, *kernelAlloc);

if (!req) {
infoLogger() << "thor: Closing lane due to illegal HW request." << frg::endlog;
co_return Error::protocolViolation;
}

auto ret = uacpi_reboot();
if(uacpi_unlikely_error(ret))
infoLogger() << "thor: ACPI reset failed: " << uacpi_status_to_string(ret) << frg::endlog;

#ifdef __x86_64__
issuePs2Reset();
infoLogger() << "thor: Reset using PS/2 controller failed" << frg::endlog;
#endif
panicLogger() << "thor: We do not know how to reset" << frg::endlog;
} else if(preamble.id() == bragi::message_id<managarm::hw::RebootRequest>) {
if(preamble.id() == bragi::message_id<managarm::hw::RebootRequest>) {
auto req = bragi::parse_head_only<managarm::hw::RebootRequest>(reqBuffer, *kernelAlloc);

if(!req) {
infoLogger() << "thor: Closing lane due to illegal HW request." << frg::endlog;
co_return Error::protocolViolation;
}

uacpi_sleep_state state = UACPI_SLEEP_STATE_S0;
switch(req->cmd()) {
case RB_POWER_OFF: {
state = UACPI_SLEEP_STATE_S5;
auto ret = uacpi_prepare_for_sleep_state(state);
#ifdef __x86_64__
auto ret = uacpi_prepare_for_sleep_state(UACPI_SLEEP_STATE_S5);
if(uacpi_unlikely_error(ret))
infoLogger() << "thor: Preparing to enter sleep state S5 failed: " << uacpi_status_to_string(ret) << frg::endlog;

// uACPI Documentation states that you must call uacpi_enter_sleep_state with interrupts disabled.
disableInts();

ret = uacpi_enter_sleep_state(state);
ret = uacpi_enter_sleep_state(UACPI_SLEEP_STATE_S5);
if(uacpi_unlikely_error(ret))
infoLogger() << "thor: Entering sleep state S" << (int)state << " failed: " << uacpi_status_to_string(ret) << frg::endlog;

infoLogger() << "thor: Entering sleep state S5 failed: " << uacpi_status_to_string(ret) << frg::endlog;
#endif
// Poweroff failed, panic
panicLogger() << "thor: Poweroff failed" << frg::endlog;
break;
}
case RB_AUTOBOOT: {
state = UACPI_SLEEP_STATE_S5;
auto ret = uacpi_prepare_for_sleep_state(state);
#ifdef __x86_64__
auto ret = uacpi_prepare_for_sleep_state(UACPI_SLEEP_STATE_S5);
if(uacpi_unlikely_error(ret))
infoLogger() << "thor: Preparing for reboot failed: " << uacpi_status_to_string(ret) << frg::endlog;

Expand All @@ -112,7 +94,6 @@ struct PmInterfaceBusObject : private KernelBusObject {
if(uacpi_unlikely_error(ret))
infoLogger() << "thor: ACPI reset failed: " << uacpi_status_to_string(ret) << frg::endlog;

#ifdef __x86_64__
issuePs2Reset();
infoLogger() << "thor: Reset using PS/2 controller failed" << frg::endlog;
#endif
Expand Down
7 changes: 1 addition & 6 deletions protocols/hw/hw.bragi
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ message AccessFbMemoryRequest 11 {
head(128):
}

message PmResetRequest 12 {
message RebootRequest 12 {
head(128):
int64 cmd;
}
Expand All @@ -122,8 +122,3 @@ tail:
tag(8) uint32 fb_type;
}
}

message RebootRequest 17 {
head(128):
int64 cmd;
}

0 comments on commit 2212032

Please sign in to comment.