boot/powctl/i2c: more miscellaneous fixes

This commit is contained in:
Michael Scire 2020-11-10 05:50:13 -08:00
parent 62ff502979
commit c5656d39d2
6 changed files with 89 additions and 57 deletions

View file

@ -30,8 +30,16 @@ namespace ams::i2c::driver::board::nintendo_nx::impl {
IAllocator(ams::MemoryResource *mr) : memory_resource(mr), list(), list_lock() { /* ... */ }
~IAllocator() {
/* TODO: Remove all entries, etc */
AMS_ABORT("BusAccessorManager not destructible");
std::scoped_lock lk(this->list_lock);
/* Remove all entries. */
auto it = this->list.begin();
while (it != this->list.end()) {
T *obj = std::addressof(*it);
it = this->list.erase(it);
this->memory_resource->Deallocate(obj, sizeof(T));
}
}
template<typename ...Args>

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) {

View file

@ -35,7 +35,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -49,7 +49,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -63,7 +63,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -77,7 +77,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -91,7 +91,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -105,7 +105,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -119,7 +119,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -133,7 +133,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -147,7 +147,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -161,7 +161,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -175,7 +175,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -189,7 +189,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -203,7 +203,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -217,7 +217,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -231,7 +231,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -245,7 +245,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -259,7 +259,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -273,7 +273,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -287,7 +287,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -301,7 +301,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -315,7 +315,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -329,7 +329,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -343,7 +343,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -357,7 +357,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -371,7 +371,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -385,7 +385,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -399,7 +399,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -413,7 +413,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -427,7 +427,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();

View file

@ -35,7 +35,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -49,7 +49,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -63,7 +63,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -77,7 +77,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -91,7 +91,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -105,7 +105,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -119,7 +119,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -133,7 +133,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -147,7 +147,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -161,7 +161,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -175,7 +175,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -189,7 +189,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -203,7 +203,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -217,7 +217,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -231,7 +231,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -245,7 +245,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -259,7 +259,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -275,7 +275,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -289,7 +289,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -303,7 +303,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Read));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Read), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();
@ -317,7 +317,7 @@ namespace ams::powctl {
auto &impl = GetOpenSessionImpl(session);
/* Check the access mode. */
R_TRY(impl.CheckAccess(ddsf::AccessMode_Write));
R_UNLESS(impl.CheckAccess(ddsf::AccessMode_Write), ddsf::ResultPermissionDenied());
/* Get the device. */
auto &device = impl.GetDevice().SafeCastTo<impl::IDevice>();

View file

@ -530,7 +530,7 @@ namespace ams::boot {
if (g_lcd_vendor == 0x2050) {
EnableBacklightForVendor2050ForHardwareTypeFive(0);
} else {
pwm::driver::SetEnabled(g_lcd_backlight_session, true);
pwm::driver::SetEnabled(g_lcd_backlight_session, false);
pwm::driver::CloseSession(g_lcd_backlight_session);
}