boot/powctl/i2c: more miscellaneous fixes

This commit is contained in:
Michael Scire
2020-11-10 05:50:13 -08:00
committed by SciresM
parent affdea9244
commit b62aa044e4
6 changed files with 89 additions and 57 deletions

View File

@@ -42,6 +42,22 @@ namespace ams::powctl::impl::board::nintendo_nx {
powctl::impl::RegisterDriver(std::addressof(*g_battery_driver));
}
void FinalizeChargerDriver() {
/* Unregister the driver. */
powctl::impl::UnregisterDriver(std::addressof(*g_charger_driver));
/* Destroy the battery driver. */
g_charger_driver = std::nullopt;
}
void FinalizeBatteryDriver() {
/* Unregister the driver. */
powctl::impl::UnregisterDriver(std::addressof(*g_battery_driver));
/* Destroy the battery driver. */
g_battery_driver = std::nullopt;
}
}
void Initialize(bool use_event_handlers) {
@@ -50,8 +66,8 @@ namespace ams::powctl::impl::board::nintendo_nx {
}
void Finalize() {
/* TODO */
AMS_ABORT();
FinalizeBatteryDriver();
FinalizeChargerDriver();
}
}

View File

@@ -85,8 +85,16 @@ namespace ams::powctl::impl {
os::WaitThread(std::addressof(g_interrupt_thread));
os::DestroyThread(std::addressof(g_interrupt_thread));
/* TODO: What else? */
AMS_ABORT();
/* Reset all device code entries. */
GetDeviceCodeEntryManager().Reset();
/* Finalize all registered drivers. */
for (auto &driver : GetDriverList()) {
driver.SafeCastTo<IPowerControlDriver>().FinalizeDriver();
}
/* Finalize the interrupt handler manager. */
GetInterruptHandlerManager().Finalize();
}
void RegisterDriver(IPowerControlDriver *driver) {