mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-19 00:42:06 +00:00
boot: save 12KB
This commit is contained in:
parent
afccc35e79
commit
888b35833e
7 changed files with 125 additions and 31 deletions
|
@ -26,18 +26,42 @@ namespace ams::gpio::driver::impl {
|
|||
alignas(os::MemoryPageSize) u8 g_interrupt_thread_stack[InterruptThreadStackSize];
|
||||
|
||||
gpio::driver::IGpioDriver::List &GetGpioDriverList() {
|
||||
static gpio::driver::IGpioDriver::List s_gpio_driver_list;
|
||||
static constinit gpio::driver::IGpioDriver::List s_gpio_driver_list;
|
||||
return s_gpio_driver_list;
|
||||
}
|
||||
|
||||
ddsf::EventHandlerManager &GetInterruptHandlerManager() {
|
||||
static ddsf::EventHandlerManager s_interrupt_handler_manager;
|
||||
return s_interrupt_handler_manager;
|
||||
static constinit util::TypedStorage<ddsf::EventHandlerManager> s_interrupt_handler_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
std::scoped_lock lk(s_mutex);
|
||||
|
||||
if (AMS_LIKELY(!s_initialized)) {
|
||||
util::ConstructAt(s_interrupt_handler_manager);
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
return util::GetReference(s_interrupt_handler_manager);
|
||||
}
|
||||
|
||||
ddsf::DeviceCodeEntryManager &GetDeviceCodeEntryManager() {
|
||||
static ddsf::DeviceCodeEntryManager s_device_code_entry_manager(ddsf::GetDeviceCodeEntryHolderMemoryResource());
|
||||
return s_device_code_entry_manager;
|
||||
static constinit util::TypedStorage<ddsf::DeviceCodeEntryManager> s_device_code_entry_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
std::scoped_lock lk(s_mutex);
|
||||
|
||||
if (AMS_LIKELY(!s_initialized)) {
|
||||
util::ConstructAt(s_device_code_entry_manager, ddsf::GetDeviceCodeEntryHolderMemoryResource());
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
return util::GetReference(s_device_code_entry_manager);
|
||||
}
|
||||
|
||||
void InterruptThreadFunction(void *arg) {
|
||||
|
|
|
@ -98,11 +98,13 @@ namespace ams::i2c::driver::board::nintendo::nx {
|
|||
}
|
||||
|
||||
void Initialize() {
|
||||
/* TODO: Should these be moved into getters? They're only used here, and they never destruct. */
|
||||
static impl::I2cBusAccessorManager s_bus_accessor_manager(ddsf::GetMemoryResource());
|
||||
static impl::I2cDevicePropertyManager s_device_manager(ddsf::GetMemoryResource());
|
||||
static constinit util::TypedStorage<impl::I2cBusAccessorManager> s_bus_accessor_manager;
|
||||
static constinit util::TypedStorage<impl::I2cDevicePropertyManager> s_device_manager;
|
||||
|
||||
return Initialize(s_bus_accessor_manager, s_device_manager);
|
||||
util::ConstructAt(s_bus_accessor_manager, ddsf::GetMemoryResource());
|
||||
util::ConstructAt(s_device_manager, ddsf::GetMemoryResource());
|
||||
|
||||
return Initialize(util::GetReference(s_bus_accessor_manager), util::GetReference(s_device_manager));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,13 +24,25 @@ namespace ams::i2c::driver::impl {
|
|||
constinit int g_init_count = 0;
|
||||
|
||||
i2c::driver::II2cDriver::List &GetI2cDriverList() {
|
||||
static i2c::driver::II2cDriver::List s_driver_list;
|
||||
static constinit i2c::driver::II2cDriver::List s_driver_list;
|
||||
return s_driver_list;
|
||||
}
|
||||
|
||||
ddsf::DeviceCodeEntryManager &GetDeviceCodeEntryManager() {
|
||||
static ddsf::DeviceCodeEntryManager s_device_code_entry_manager(ddsf::GetDeviceCodeEntryHolderMemoryResource());
|
||||
return s_device_code_entry_manager;
|
||||
static constinit util::TypedStorage<ddsf::DeviceCodeEntryManager> s_device_code_entry_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
std::scoped_lock lk(s_mutex);
|
||||
|
||||
if (AMS_LIKELY(!s_initialized)) {
|
||||
util::ConstructAt(s_device_code_entry_manager, ddsf::GetDeviceCodeEntryHolderMemoryResource());
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
return util::GetReference(s_device_code_entry_manager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,17 +30,36 @@ namespace ams::powctl::impl {
|
|||
constinit sf::UnitHeapMemoryResource g_unit_heap_memory_resource;
|
||||
|
||||
IPowerControlDriver::List &GetDriverList() {
|
||||
static IPowerControlDriver::List s_driver_list;
|
||||
static constinit IPowerControlDriver::List s_driver_list;
|
||||
return s_driver_list;
|
||||
}
|
||||
|
||||
ddsf::EventHandlerManager &GetInterruptHandlerManager() {
|
||||
static ddsf::EventHandlerManager s_interrupt_handler_manager;
|
||||
return s_interrupt_handler_manager;
|
||||
static constinit util::TypedStorage<ddsf::EventHandlerManager> s_interrupt_handler_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
std::scoped_lock lk(s_mutex);
|
||||
|
||||
if (AMS_LIKELY(!s_initialized)) {
|
||||
util::ConstructAt(s_interrupt_handler_manager);
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
return util::GetReference(s_interrupt_handler_manager);
|
||||
}
|
||||
|
||||
ddsf::DeviceCodeEntryManager &GetDeviceCodeEntryManager() {
|
||||
static ddsf::DeviceCodeEntryManager s_device_code_entry_manager = [] {
|
||||
static constinit util::TypedStorage<ddsf::DeviceCodeEntryManager> s_device_code_entry_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
std::scoped_lock lk(s_mutex);
|
||||
|
||||
if (AMS_LIKELY(!s_initialized)) {
|
||||
/* Initialize the entry code heap. */
|
||||
g_unit_heap_handle = lmem::CreateUnitHeap(g_unit_heap_memory, sizeof(g_unit_heap_memory), sizeof(ddsf::DeviceCodeEntryHolder), lmem::CreateOption_ThreadSafe);
|
||||
|
||||
|
@ -48,10 +67,13 @@ namespace ams::powctl::impl {
|
|||
g_unit_heap_memory_resource.Attach(g_unit_heap_handle);
|
||||
|
||||
/* Make the entry manager using the newly initialized memory resource. */
|
||||
return ddsf::DeviceCodeEntryManager(std::addressof(g_unit_heap_memory_resource));
|
||||
}();
|
||||
util::ConstructAt(s_device_code_entry_manager, std::addressof(g_unit_heap_memory_resource));
|
||||
|
||||
return s_device_code_entry_manager;
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
return util::GetReference(s_device_code_entry_manager);
|
||||
}
|
||||
|
||||
void InterruptThreadFunction(void *arg) {
|
||||
|
|
|
@ -24,13 +24,25 @@ namespace ams::pwm::driver::impl {
|
|||
constinit int g_init_count = 0;
|
||||
|
||||
pwm::driver::IPwmDriver::List &GetPwmDriverList() {
|
||||
static pwm::driver::IPwmDriver::List s_driver_list;
|
||||
static constinit pwm::driver::IPwmDriver::List s_driver_list;
|
||||
return s_driver_list;
|
||||
}
|
||||
|
||||
ddsf::DeviceCodeEntryManager &GetDeviceCodeEntryManager() {
|
||||
static ddsf::DeviceCodeEntryManager s_device_code_entry_manager(ddsf::GetDeviceCodeEntryHolderMemoryResource());
|
||||
return s_device_code_entry_manager;
|
||||
static constinit util::TypedStorage<ddsf::DeviceCodeEntryManager> s_device_code_entry_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
std::scoped_lock lk(s_mutex);
|
||||
|
||||
if (AMS_LIKELY(!s_initialized)) {
|
||||
util::ConstructAt(s_device_code_entry_manager, ddsf::GetDeviceCodeEntryHolderMemoryResource());
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
return util::GetReference(s_device_code_entry_manager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue