boot: save 12KB

This commit is contained in:
Michael Scire
2021-10-07 19:33:07 -07:00
parent afccc35e79
commit 888b35833e
7 changed files with 125 additions and 31 deletions

View File

@@ -25,9 +25,20 @@ namespace ams::powctl::impl::board::nintendo::nx {
constinit util::optional<BatteryDevice> g_battery_device;
constinit util::TypedStorage<Max17050Driver> g_max17050_driver;
constinit bool g_constructed_max17050_driver;
constinit os::SdkMutex g_max17050_driver_mutex;
Max17050Driver &GetMax17050Driver() {
static Max17050Driver s_max17050_driver;
return s_max17050_driver;
if (AMS_UNLIKELY(!g_constructed_max17050_driver)) {
std::scoped_lock lk(g_max17050_driver_mutex);
if (AMS_LIKELY(!g_constructed_max17050_driver)) {
util::ConstructAt(g_max17050_driver);
}
}
return util::GetReference(g_max17050_driver);
}
constexpr inline const double SenseResistorValue = 0.005;

View File

@@ -25,9 +25,20 @@ namespace ams::powctl::impl::board::nintendo::nx {
constinit util::optional<ChargerDevice> g_charger_device;
constinit util::TypedStorage<Bq24193Driver> g_bq24193_driver;
constinit bool g_constructed_bq24193_driver;
constinit os::SdkMutex g_bq24193_driver_mutex;
Bq24193Driver &GetBq24193Driver() {
static Bq24193Driver s_bq24193_driver;
return s_bq24193_driver;
if (AMS_UNLIKELY(!g_constructed_bq24193_driver)) {
std::scoped_lock lk(g_bq24193_driver_mutex);
if (AMS_LIKELY(!g_constructed_bq24193_driver)) {
util::ConstructAt(g_bq24193_driver);
}
}
return util::GetReference(g_bq24193_driver);
}
}