Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
173d5c2d3a | ||
|
|
52c1cef064 | ||
|
|
4efa5d7dd0 | ||
|
|
275da52305 | ||
|
|
30fac905af | ||
|
|
78f7218c4f | ||
|
|
09c6aa29dd |
@@ -1,4 +1,10 @@
|
||||
# Changelog
|
||||
## 1.2.6
|
||||
+ Support was added for 13.2.1.
|
||||
+ A number of minor issues were fixed and improvements were made, including:
|
||||
+ A minor performance improvement was implemented in service table dispatch by sorting and binary-searching the service command table instead of using linear search.
|
||||
+ Static initialization logic in Atmosphere was made much more regular.
|
||||
+ General system stability improvements to enhance the user's experience.
|
||||
## 1.2.5
|
||||
+ Support was added for 13.2.0.
|
||||
+ A number of minor issues were fixed and improvements were made, including:
|
||||
|
||||
@@ -249,6 +249,8 @@ namespace ams::nxboot {
|
||||
return ams::TargetFirmware_12_1_0;
|
||||
} else if (std::memcmp(package1 + 0x10, "20210805", 8) == 0) {
|
||||
return ams::TargetFirmware_13_0_0;
|
||||
} else if (std::memcmp(package1 + 0x10, "20220105", 8) == 0) {
|
||||
return ams::TargetFirmware_13_2_1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[subrepo]
|
||||
remote = https://github.com/Atmosphere-NX/Atmosphere-libs
|
||||
branch = master
|
||||
commit = c4d0335b79da7207b49abf1988f45b0168b692f0
|
||||
parent = 96631d8225611b2b490ec1e8b5a84c1b0e53157a
|
||||
commit = 0d161b8588aa6482b84f3c44dd001055b01a047f
|
||||
parent = 4efa5d7dd0bfbdf89a6261af0aef3878ca784b05
|
||||
method = merge
|
||||
cmdver = 0.4.1
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace ams::pkg2 {
|
||||
|
||||
constexpr inline int PayloadCount = 3;
|
||||
|
||||
constexpr inline int MinimumValidDataVersion = 0; /* We allow older package2 to load; this value is currently 0x13 in Nintendo's code. */
|
||||
constexpr inline int CurrentBootloaderVersion = 0xF;
|
||||
constexpr inline int MinimumValidDataVersion = 0; /* We allow older package2 to load; this value is currently 0x14 in Nintendo's code. */
|
||||
constexpr inline int CurrentBootloaderVersion = 0x10;
|
||||
|
||||
struct Package2Meta {
|
||||
using Magic = util::FourCC<'P','K','2','1'>;
|
||||
|
||||
@@ -167,6 +167,7 @@ namespace ams::fuse {
|
||||
}
|
||||
|
||||
constexpr const TargetFirmware FuseVersionIncrementFirmwares[] = {
|
||||
TargetFirmware_13_2_1,
|
||||
TargetFirmware_12_0_2,
|
||||
TargetFirmware_11_0_0,
|
||||
TargetFirmware_10_0_0,
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace ams::kern::arch::arm {
|
||||
PriorityLevel_Scheduler = 2,
|
||||
};
|
||||
private:
|
||||
static inline u32 s_mask[cpu::NumCores];
|
||||
static constinit inline u32 s_mask[cpu::NumCores];
|
||||
private:
|
||||
volatile GicDistributor *m_gicd;
|
||||
volatile GicCpuInterface *m_gicc;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace ams::kern::arch::arm64::cpu {
|
||||
|
||||
class KPerformanceCounterInterruptHandler : public KInterruptHandler {
|
||||
private:
|
||||
static inline KLightLock s_lock;
|
||||
static constinit inline KLightLock s_lock;
|
||||
private:
|
||||
u64 m_counter;
|
||||
s32 m_which;
|
||||
|
||||
@@ -114,6 +114,7 @@ namespace ams::kern::board::nintendo::nx {
|
||||
ams::svc::DeviceName_Hda,
|
||||
ams::svc::DeviceName_Isp2,
|
||||
ams::svc::DeviceName_Sata,
|
||||
ams::svc::DeviceName_Vi,
|
||||
ams::svc::DeviceName_XusbHost,
|
||||
ams::svc::DeviceName_XusbDev,
|
||||
ams::svc::DeviceName_Tsec,
|
||||
|
||||
@@ -277,6 +277,9 @@ namespace ams::kern::svc {
|
||||
}
|
||||
|
||||
Result WriteDebugProcessMemory(ams::svc::Handle debug_handle, uintptr_t buffer, uintptr_t address, size_t size) {
|
||||
/* Only allow invoking the svc on development hardware. */
|
||||
R_UNLESS(KTargetSystem::IsDebugMode(), svc::ResultNotImplemented());
|
||||
|
||||
/* Validate address / size. */
|
||||
R_UNLESS(size > 0, svc::ResultInvalidSize());
|
||||
R_UNLESS((address < address + size), svc::ResultInvalidCurrentMemory());
|
||||
|
||||
@@ -68,6 +68,7 @@ namespace ams::hos {
|
||||
Version_13_0_0 = ::ams::TargetFirmware_13_0_0,
|
||||
Version_13_1_0 = ::ams::TargetFirmware_13_1_0,
|
||||
Version_13_2_0 = ::ams::TargetFirmware_13_2_0,
|
||||
Version_13_2_1 = ::ams::TargetFirmware_13_2_1,
|
||||
|
||||
Version_Current = ::ams::TargetFirmware_Current,
|
||||
|
||||
|
||||
@@ -53,16 +53,32 @@ namespace ams::sf::cmif {
|
||||
u32 cmd_id;
|
||||
Result (*handler)(CmifOutHeader **out_header_ptr, ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data);
|
||||
|
||||
constexpr inline bool Matches(u32 cmd_id, hos::Version hosver) const {
|
||||
constexpr inline bool MatchesVersion(hos::Version hosver) const {
|
||||
const bool min_valid = this->hosver_low == hos::Version_Min;
|
||||
const bool max_valid = this->hosver_high == hos::Version_Max;
|
||||
|
||||
return this->cmd_id == cmd_id && (min_valid || this->hosver_low <= hosver) && (max_valid || hosver <= this->hosver_high);
|
||||
return (min_valid || this->hosver_low <= hosver) && (max_valid || hosver <= this->hosver_high);
|
||||
}
|
||||
|
||||
constexpr inline bool Matches(u32 cmd_id, hos::Version hosver) const {
|
||||
return this->cmd_id == cmd_id && this->MatchesVersion(hosver);
|
||||
}
|
||||
|
||||
constexpr inline decltype(handler) GetHandler() const {
|
||||
return this->handler;
|
||||
}
|
||||
|
||||
constexpr inline bool operator>(const ServiceCommandMeta &rhs) const {
|
||||
if (this->cmd_id > rhs.cmd_id) {
|
||||
return true;
|
||||
} else if (this->cmd_id == rhs.cmd_id && this->hosver_low > rhs.hosver_low) {
|
||||
return true;
|
||||
} else if (this->cmd_id == rhs.cmd_id && this->hosver_low == rhs.hosver_low && this->hosver_high == rhs.hosver_high){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
static_assert(util::is_pod<ServiceCommandMeta>::value && sizeof(ServiceCommandMeta) == 0x18, "sizeof(ServiceCommandMeta)");
|
||||
|
||||
|
||||
@@ -85,16 +85,41 @@ namespace ams::sf::impl {
|
||||
constexpr const auto &BaseEntries = ::ams::sf::cmif::ServiceDispatchTraits<BASECLASS>::DispatchTable.GetEntries(); \
|
||||
constexpr size_t BaseSize = BaseEntries.size(); \
|
||||
\
|
||||
std::array<::ams::sf::cmif::ServiceCommandMeta, BaseSize + CurSize> combined_entries{}; \
|
||||
for (size_t i = 0; i < BaseSize; ++i) { \
|
||||
combined_entries[i] = BaseEntries[i]; \
|
||||
constexpr size_t CombinedSize = BaseSize + CurSize; \
|
||||
\
|
||||
std::array<size_t, CombinedSize> map{}; \
|
||||
for (size_t i = 0; i < CombinedSize; ++i) { map[i] = i; } \
|
||||
\
|
||||
for (size_t i = 1; i < CombinedSize; ++i) { \
|
||||
size_t j = i; \
|
||||
while (j > 0) { \
|
||||
const auto li = map[j]; \
|
||||
const auto ri = map[j - 1]; \
|
||||
\
|
||||
const auto &lhs = (li < BaseSize) ? BaseEntries[li] : cur_entries[li - BaseSize]; \
|
||||
const auto &rhs = (ri < BaseSize) ? BaseEntries[ri] : cur_entries[ri - BaseSize]; \
|
||||
\
|
||||
if (!(rhs > lhs)) { \
|
||||
break; \
|
||||
} \
|
||||
\
|
||||
std::swap(map[j], map[j - 1]); \
|
||||
\
|
||||
--j; \
|
||||
} \
|
||||
} \
|
||||
for (size_t i = 0; i < CurSize; ++i) { \
|
||||
combined_entries[BaseSize + i] = cur_entries[i]; \
|
||||
\
|
||||
std::array<::ams::sf::cmif::ServiceCommandMeta, CombinedSize> combined_entries{}; \
|
||||
for (size_t i = 0; i < CombinedSize; ++i) { \
|
||||
if (map[i] < BaseSize) { \
|
||||
combined_entries[i] = BaseEntries[map[i]]; \
|
||||
} else { \
|
||||
combined_entries[i] = cur_entries[map[i] - BaseSize]; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return ::ams::sf::cmif::ServiceDispatchTable { combined_entries }; \
|
||||
} () \
|
||||
}() \
|
||||
}; \
|
||||
};
|
||||
|
||||
|
||||
@@ -18,41 +18,28 @@
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/os/os_sdk_mutex.hpp>
|
||||
|
||||
#define AMS_SINGLETON_TRAITS(_CLASSNAME_) \
|
||||
private: \
|
||||
NON_COPYABLE(_CLASSNAME_); \
|
||||
NON_MOVEABLE(_CLASSNAME_); \
|
||||
private: \
|
||||
_CLASSNAME_ (); \
|
||||
public: \
|
||||
static _CLASSNAME_ &GetInstance() { \
|
||||
/* Declare singleton instance variables. */ \
|
||||
static constinit ::ams::util::TypedStorage<_CLASSNAME_> s_singleton_storage; \
|
||||
static constinit ::ams::os::SdkMutex s_singleton_mutex; \
|
||||
static constinit bool s_initialized_singleton = false; \
|
||||
\
|
||||
/* Ensure the instance is created. */ \
|
||||
if (AMS_UNLIKELY(!s_initialized_singleton)) { \
|
||||
std::scoped_lock lk(s_singleton_mutex); \
|
||||
\
|
||||
if (AMS_LIKELY(!s_initialized_singleton)) { \
|
||||
new (::ams::util::GetPointer(s_singleton_storage)) _CLASSNAME_; \
|
||||
s_initialized_singleton = true; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return ::ams::util::GetReference(s_singleton_storage); \
|
||||
#define AMS_SINGLETON_TRAITS(_CLASSNAME_) \
|
||||
private: \
|
||||
NON_COPYABLE(_CLASSNAME_); \
|
||||
NON_MOVEABLE(_CLASSNAME_); \
|
||||
private: \
|
||||
_CLASSNAME_ (); \
|
||||
public: \
|
||||
static _CLASSNAME_ &GetInstance() { \
|
||||
AMS_FUNCTION_LOCAL_STATIC(_CLASSNAME_, s_singleton_instance); \
|
||||
\
|
||||
return s_singleton_instance; \
|
||||
}
|
||||
|
||||
#define AMS_CONSTINIT_SINGLETON_TRAITS(_CLASSNAME_) \
|
||||
private: \
|
||||
NON_COPYABLE(_CLASSNAME_); \
|
||||
NON_MOVEABLE(_CLASSNAME_); \
|
||||
private: \
|
||||
constexpr _CLASSNAME_ () = default; \
|
||||
public: \
|
||||
static _CLASSNAME_ &GetInstance() { \
|
||||
/* Declare singleton instance variables. */ \
|
||||
static constinit _CLASSNAME_ s_singleton_instance; \
|
||||
return s_singleton_instance; \
|
||||
#define AMS_CONSTINIT_SINGLETON_TRAITS(_CLASSNAME_) \
|
||||
private: \
|
||||
NON_COPYABLE(_CLASSNAME_); \
|
||||
NON_MOVEABLE(_CLASSNAME_); \
|
||||
private: \
|
||||
constexpr _CLASSNAME_ () = default; \
|
||||
public: \
|
||||
static _CLASSNAME_ &GetInstance() { \
|
||||
/* Declare singleton instance variables. */ \
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(_CLASSNAME_, s_singleton_instance); \
|
||||
return s_singleton_instance; \
|
||||
}
|
||||
|
||||
@@ -73,18 +73,7 @@ namespace ams::erpt::srv {
|
||||
}
|
||||
|
||||
bool IsProductionMode() {
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit bool s_is_prod_mode = true;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
std::scoped_lock lk(s_mutex);
|
||||
|
||||
if (AMS_LIKELY(!s_initialized)) {
|
||||
s_is_prod_mode = IsProductionModeImpl();
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
AMS_FUNCTION_LOCAL_STATIC(bool, s_is_prod_mode, IsProductionModeImpl());
|
||||
|
||||
return s_is_prod_mode;
|
||||
}
|
||||
|
||||
@@ -112,13 +112,13 @@ namespace ams::fssystem {
|
||||
NcaCryptoConfiguration g_nca_crypto_configuration_prod;
|
||||
|
||||
constexpr inline s32 KeySlotCacheEntryCount = 3;
|
||||
KeySlotCache g_key_slot_cache;
|
||||
util::optional<KeySlotCacheEntry> g_key_slot_cache_entry[KeySlotCacheEntryCount];
|
||||
constinit KeySlotCache g_key_slot_cache;
|
||||
constinit util::optional<KeySlotCacheEntry> g_key_slot_cache_entry[KeySlotCacheEntryCount];
|
||||
|
||||
spl::AccessKey &GetNcaKekAccessKey(s32 key_type) {
|
||||
static spl::AccessKey s_nca_kek_access_key_array[KeyAreaEncryptionKeyCount] = {};
|
||||
static spl::AccessKey s_nca_header_kek_access_key = {};
|
||||
static spl::AccessKey s_invalid_nca_kek_access_key = {};
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(spl::AccessKey, s_nca_kek_access_key_array[KeyAreaEncryptionKeyCount]);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(spl::AccessKey, s_nca_header_kek_access_key);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(spl::AccessKey, s_invalid_nca_kek_access_key);
|
||||
|
||||
if (key_type > static_cast<s32>(KeyType::NcaHeaderKey) || IsInvalidKeyTypeValue(key_type)) {
|
||||
return s_invalid_nca_kek_access_key;
|
||||
|
||||
@@ -26,42 +26,20 @@ namespace ams::gpio::driver::impl {
|
||||
alignas(os::MemoryPageSize) u8 g_interrupt_thread_stack[InterruptThreadStackSize];
|
||||
|
||||
gpio::driver::IGpioDriver::List &GetGpioDriverList() {
|
||||
static constinit gpio::driver::IGpioDriver::List s_gpio_driver_list;
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(gpio::driver::IGpioDriver::List, s_gpio_driver_list);
|
||||
return s_gpio_driver_list;
|
||||
}
|
||||
|
||||
ddsf::EventHandlerManager &GetInterruptHandlerManager() {
|
||||
static constinit util::TypedStorage<ddsf::EventHandlerManager> s_interrupt_handler_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
AMS_FUNCTION_LOCAL_STATIC(ddsf::EventHandlerManager, s_interrupt_handler_manager);
|
||||
|
||||
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);
|
||||
return s_interrupt_handler_manager;
|
||||
}
|
||||
|
||||
ddsf::DeviceCodeEntryManager &GetDeviceCodeEntryManager() {
|
||||
static constinit util::TypedStorage<ddsf::DeviceCodeEntryManager> s_device_code_entry_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
AMS_FUNCTION_LOCAL_STATIC(ddsf::DeviceCodeEntryManager, s_device_code_entry_manager, ddsf::GetDeviceCodeEntryHolderMemoryResource());
|
||||
|
||||
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);
|
||||
return s_device_code_entry_manager;
|
||||
}
|
||||
|
||||
void InterruptThreadFunction(void *arg) {
|
||||
|
||||
@@ -95,16 +95,17 @@ namespace ams::i2c::driver::board::nintendo::nx {
|
||||
}
|
||||
}
|
||||
|
||||
constinit util::TypedStorage<impl::I2cBusAccessorManager> g_bus_accessor_manager;
|
||||
constinit util::TypedStorage<impl::I2cDevicePropertyManager> g_device_manager;
|
||||
|
||||
}
|
||||
|
||||
void Initialize() {
|
||||
static constinit util::TypedStorage<impl::I2cBusAccessorManager> s_bus_accessor_manager;
|
||||
static constinit util::TypedStorage<impl::I2cDevicePropertyManager> s_device_manager;
|
||||
/* Initialize managers. */
|
||||
util::ConstructAt(g_bus_accessor_manager, ddsf::GetMemoryResource());
|
||||
util::ConstructAt(g_device_manager, ddsf::GetMemoryResource());
|
||||
|
||||
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));
|
||||
return Initialize(util::GetReference(g_bus_accessor_manager), util::GetReference(g_device_manager));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,25 +24,14 @@ namespace ams::i2c::driver::impl {
|
||||
constinit int g_init_count = 0;
|
||||
|
||||
i2c::driver::II2cDriver::List &GetI2cDriverList() {
|
||||
static constinit i2c::driver::II2cDriver::List s_driver_list;
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(i2c::driver::II2cDriver::List, s_driver_list);
|
||||
return s_driver_list;
|
||||
}
|
||||
|
||||
ddsf::DeviceCodeEntryManager &GetDeviceCodeEntryManager() {
|
||||
static constinit util::TypedStorage<ddsf::DeviceCodeEntryManager> s_device_code_entry_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
AMS_FUNCTION_LOCAL_STATIC(ddsf::DeviceCodeEntryManager, s_device_code_entry_manager, ddsf::GetDeviceCodeEntryHolderMemoryResource());
|
||||
|
||||
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);
|
||||
return s_device_code_entry_manager;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace ams::lm::srv {
|
||||
}
|
||||
|
||||
EventLogTransmitter &EventLogTransmitter::GetDefaultInstance() {
|
||||
static constinit EventLogTransmitter s_default_event_log_transmitter(DefaultFlushFunction);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(EventLogTransmitter, s_default_event_log_transmitter, DefaultFlushFunction);
|
||||
|
||||
return s_default_event_log_transmitter;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,10 @@ namespace ams::lm::srv {
|
||||
}
|
||||
|
||||
bool DefaultFlushFunction(const u8 *data, size_t size) {
|
||||
/* Declare persistent clock-updated state storage. */
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(bool, s_is_user_system_clock_updated, false);
|
||||
|
||||
/* Update clock. */
|
||||
static constinit bool s_is_user_system_clock_updated = false;
|
||||
if (!s_is_user_system_clock_updated) {
|
||||
UpdateUserSystemClock(data, size);
|
||||
s_is_user_system_clock_updated = true;
|
||||
@@ -84,8 +86,8 @@ namespace ams::lm::srv {
|
||||
}
|
||||
|
||||
LogBuffer &LogBuffer::GetDefaultInstance() {
|
||||
static constinit u8 s_default_buffers[128_KB * 2];
|
||||
static constinit LogBuffer s_default_log_buffer(s_default_buffers, sizeof(s_default_buffers), DefaultFlushFunction);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(u8, s_default_buffers[128_KB * 2]);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(LogBuffer, s_default_log_buffer, s_default_buffers, sizeof(s_default_buffers), DefaultFlushFunction);
|
||||
|
||||
return s_default_log_buffer;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
namespace ams::lm::srv {
|
||||
|
||||
CustomSinkBuffer &LogGetterImpl::GetBuffer() {
|
||||
static constinit u8 s_buffer[32_KB];
|
||||
static constinit CustomSinkBuffer s_custom_sink_buffer(s_buffer, sizeof(s_buffer), FlushFunction);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(u8, s_buffer[32_KB]);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(CustomSinkBuffer, s_custom_sink_buffer, s_buffer, sizeof(s_buffer), FlushFunction);
|
||||
|
||||
return s_custom_sink_buffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace ams::lm::srv {
|
||||
size_t carry_size;
|
||||
bool ends_with_text_log;
|
||||
};
|
||||
static constinit PreviousPacketContext s_previous_packet_context = {};
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(PreviousPacketContext, s_previous_packet_context);
|
||||
|
||||
/* Get the packet header. */
|
||||
auto *header = static_cast<const impl::LogPacketHeader *>(buffer);
|
||||
|
||||
@@ -635,7 +635,7 @@ namespace ams::ncm {
|
||||
for (s32 i = 0; i < count; i++) {
|
||||
R_UNLESS(!this->IsCancelRequested(), ncm::ResultCreatePlaceHolderCancelled());
|
||||
|
||||
static constinit os::SdkMutex s_placeholder_mutex;
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(os::SdkMutex, s_placeholder_mutex);
|
||||
std::scoped_lock lk(s_placeholder_mutex);
|
||||
|
||||
InstallContentMeta content_meta;
|
||||
|
||||
@@ -44,7 +44,8 @@ namespace ams::ncm {
|
||||
}
|
||||
|
||||
HeapState &GetHeapState() {
|
||||
static HeapState s_heap_state = {};
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(HeapState, s_heap_state);
|
||||
|
||||
return s_heap_state;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,60 +20,44 @@ namespace ams::powctl::impl {
|
||||
|
||||
namespace {
|
||||
|
||||
os::ThreadType g_interrupt_thread;
|
||||
constinit os::ThreadType g_interrupt_thread;
|
||||
|
||||
constexpr inline size_t InterruptThreadStackSize = os::MemoryPageSize;
|
||||
alignas(os::MemoryPageSize) u8 g_interrupt_thread_stack[InterruptThreadStackSize];
|
||||
|
||||
constinit u8 g_unit_heap_memory[2_KB];
|
||||
constinit lmem::HeapHandle g_unit_heap_handle;
|
||||
constinit sf::UnitHeapMemoryResource g_unit_heap_memory_resource;
|
||||
|
||||
IPowerControlDriver::List &GetDriverList() {
|
||||
static constinit IPowerControlDriver::List s_driver_list;
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(IPowerControlDriver::List, s_driver_list);
|
||||
return s_driver_list;
|
||||
}
|
||||
|
||||
ddsf::EventHandlerManager &GetInterruptHandlerManager() {
|
||||
static constinit util::TypedStorage<ddsf::EventHandlerManager> s_interrupt_handler_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
AMS_FUNCTION_LOCAL_STATIC(ddsf::EventHandlerManager, s_interrupt_handler_manager);
|
||||
|
||||
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);
|
||||
return s_interrupt_handler_manager;
|
||||
}
|
||||
|
||||
ddsf::DeviceCodeEntryManager &GetDeviceCodeEntryManager() {
|
||||
static constinit util::TypedStorage<ddsf::DeviceCodeEntryManager> s_device_code_entry_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
class DeviceCodeEntryManagerWithUnitHeap {
|
||||
private:
|
||||
u8 m_heap_memory[2_KB];
|
||||
sf::UnitHeapMemoryResource m_memory_resource;
|
||||
util::TypedStorage<ddsf::DeviceCodeEntryManager> m_manager;
|
||||
public:
|
||||
DeviceCodeEntryManagerWithUnitHeap() {
|
||||
/* Initialize the memory resource. */
|
||||
m_memory_resource.Attach(lmem::CreateUnitHeap(m_heap_memory, sizeof(m_heap_memory), sizeof(ddsf::DeviceCodeEntryHolder), lmem::CreateOption_ThreadSafe));
|
||||
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
std::scoped_lock lk(s_mutex);
|
||||
/* Construct the entry manager. */
|
||||
util::ConstructAt(m_manager, std::addressof(m_memory_resource));
|
||||
}
|
||||
|
||||
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);
|
||||
ALWAYS_INLINE operator ddsf::DeviceCodeEntryManager &() {
|
||||
return util::GetReference(m_manager);
|
||||
}
|
||||
};
|
||||
AMS_FUNCTION_LOCAL_STATIC(DeviceCodeEntryManagerWithUnitHeap, s_device_code_entry_manager_holder);
|
||||
|
||||
/* Initialize the entry code memory resource. */
|
||||
g_unit_heap_memory_resource.Attach(g_unit_heap_handle);
|
||||
|
||||
/* Make the entry manager using the newly initialized memory resource. */
|
||||
util::ConstructAt(s_device_code_entry_manager, std::addressof(g_unit_heap_memory_resource));
|
||||
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
return util::GetReference(s_device_code_entry_manager);
|
||||
return s_device_code_entry_manager_holder;
|
||||
}
|
||||
|
||||
void InterruptThreadFunction(void *arg) {
|
||||
|
||||
@@ -24,25 +24,14 @@ namespace ams::pwm::driver::impl {
|
||||
constinit int g_init_count = 0;
|
||||
|
||||
pwm::driver::IPwmDriver::List &GetPwmDriverList() {
|
||||
static constinit pwm::driver::IPwmDriver::List s_driver_list;
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(pwm::driver::IPwmDriver::List, s_driver_list);
|
||||
return s_driver_list;
|
||||
}
|
||||
|
||||
ddsf::DeviceCodeEntryManager &GetDeviceCodeEntryManager() {
|
||||
static constinit util::TypedStorage<ddsf::DeviceCodeEntryManager> s_device_code_entry_manager;
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
AMS_FUNCTION_LOCAL_STATIC(ddsf::DeviceCodeEntryManager, s_device_code_entry_manager, ddsf::GetDeviceCodeEntryHolderMemoryResource());
|
||||
|
||||
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);
|
||||
return s_device_code_entry_manager;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -289,14 +289,8 @@ namespace ams::settings::impl {
|
||||
}
|
||||
|
||||
lmem::HeapHandle &GetHeapHandle() {
|
||||
static constinit bool s_is_initialized = false;
|
||||
static constinit lmem::HeapHandle s_heap_handle;
|
||||
static constinit u8 s_heap_memory[HeapMemorySize];
|
||||
|
||||
if (!s_is_initialized) {
|
||||
s_heap_handle = lmem::CreateExpHeap(s_heap_memory, sizeof(s_heap_memory), lmem::CreateOption_None);
|
||||
s_is_initialized = true;
|
||||
}
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(u8, s_heap_memory[HeapMemorySize]);
|
||||
AMS_FUNCTION_LOCAL_STATIC(lmem::HeapHandle, s_heap_handle, lmem::CreateExpHeap(s_heap_memory, sizeof(s_heap_memory), lmem::CreateOption_ThreadSafe));
|
||||
|
||||
return s_heap_handle;
|
||||
}
|
||||
@@ -314,24 +308,15 @@ namespace ams::settings::impl {
|
||||
AMS_ASSERT(out != nullptr);
|
||||
|
||||
/* Declare static instance variables. */
|
||||
static constinit util::TypedStorage<Map> s_storage = {};
|
||||
static constinit bool s_is_initialized = false;
|
||||
static constinit bool s_is_loaded = false;
|
||||
AMS_FUNCTION_LOCAL_STATIC(Map, s_map);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(bool, s_is_map_loaded, false);
|
||||
|
||||
/* Get pointer to the map. */
|
||||
Map *map = util::GetPointer(s_storage);
|
||||
|
||||
/* Construct the map, if we haven't already. */
|
||||
if (AMS_UNLIKELY(!s_is_initialized)) {
|
||||
/* Construct the instance. */
|
||||
util::ConstructAt(s_storage);
|
||||
|
||||
/* Note that we constructed. */
|
||||
s_is_initialized = true;
|
||||
}
|
||||
Map * const map = std::addressof(s_map);
|
||||
|
||||
/* TODO: Mutex? */
|
||||
/* Load the map, if we haven't already. */
|
||||
if (AMS_UNLIKELY(!s_is_loaded)) {
|
||||
if (AMS_UNLIKELY(!s_is_map_loaded)) {
|
||||
/* Attempt to load the map, allowing for failure if acceptable. */
|
||||
const auto result = LoadKeyValueStoreMap(map);
|
||||
|
||||
@@ -340,7 +325,7 @@ namespace ams::settings::impl {
|
||||
}
|
||||
|
||||
/* Note that the map is loaded. */
|
||||
s_is_loaded = true;
|
||||
s_is_map_loaded = true;
|
||||
}
|
||||
|
||||
/* Set the output pointer. */
|
||||
@@ -425,26 +410,13 @@ namespace ams::settings::impl {
|
||||
AMS_ASSERT(out_data != nullptr);
|
||||
|
||||
/* Declare static instance variables. */
|
||||
static constinit util::TypedStorage<SystemData> s_storage = {};
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit bool s_mounted = false;
|
||||
AMS_FUNCTION_LOCAL_STATIC(SystemData, s_data, id, GetSystemDataMountName<T>());
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(bool, s_mounted, false);
|
||||
|
||||
/* Get pointer to the system data. */
|
||||
SystemData *data = util::GetPointer(s_storage);
|
||||
|
||||
/* Construct the system data, if we haven't already. */
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
/* Construct the instance. */
|
||||
util::ConstructAt(s_storage);
|
||||
|
||||
/* Setup system data. */
|
||||
data->SetSystemDataId(id);
|
||||
data->SetMountName(GetSystemDataMountName<T>());
|
||||
|
||||
/* Note that we constructed. */
|
||||
s_initialized = true;
|
||||
}
|
||||
SystemData *data = std::addressof(s_data);
|
||||
|
||||
/* TODO: Mutex? */
|
||||
/* Mount the system data, if we haven't already. */
|
||||
if (AMS_UNLIKELY(!s_mounted)) {
|
||||
/* Mount the system data. */
|
||||
@@ -464,28 +436,11 @@ namespace ams::settings::impl {
|
||||
AMS_ASSERT(out_data != nullptr);
|
||||
|
||||
/* Declare static instance variables. */
|
||||
static constinit util::TypedStorage<SystemSaveData> s_storage = {};
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit bool s_mounted = false;
|
||||
AMS_FUNCTION_LOCAL_STATIC(SystemSaveData, s_data, SystemSaveDataId, SystemSaveDataSize, SystemSaveDataJournalSize, SystemSaveDataFlags, SystemSaveDataMountName);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(bool, s_mounted, false);
|
||||
|
||||
/* Get pointer to the system data. */
|
||||
SystemSaveData *data = util::GetPointer(s_storage);
|
||||
|
||||
/* Construct the system data, if we haven't already. */
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
/* Construct the instance. */
|
||||
util::ConstructAt(s_storage);
|
||||
|
||||
/* Setup system data. */
|
||||
data->SetSystemSaveDataId(SystemSaveDataId);
|
||||
data->SetTotalSize(SystemSaveDataSize);
|
||||
data->SetJournalSize(SystemSaveDataJournalSize);
|
||||
data->SetFlags(SystemSaveDataFlags);
|
||||
data->SetMountName(SystemSaveDataMountName);
|
||||
|
||||
/* Note that we constructed. */
|
||||
s_initialized = true;
|
||||
}
|
||||
/* Get pointer to the system save data. */
|
||||
SystemSaveData *data = std::addressof(s_data);
|
||||
|
||||
/* Mount the system data, if we haven't already. */
|
||||
if (AMS_UNLIKELY(!s_mounted)) {
|
||||
|
||||
@@ -56,27 +56,33 @@ namespace ams::settings::impl {
|
||||
}
|
||||
|
||||
SplConfig GetSplConfig() {
|
||||
static constinit bool s_is_initialized = false;
|
||||
static constinit SplConfig s_config;
|
||||
class SplConfigHolder {
|
||||
NON_COPYABLE(SplConfigHolder);
|
||||
NON_MOVEABLE(SplConfigHolder);
|
||||
private:
|
||||
SplConfig m_config;
|
||||
public:
|
||||
SplConfigHolder() {
|
||||
/* Initialize spl. */
|
||||
spl::Initialize();
|
||||
ON_SCOPE_EXIT { spl::Finalize(); };
|
||||
|
||||
if (!s_is_initialized) {
|
||||
/* Initialize spl. */
|
||||
spl::Initialize();
|
||||
ON_SCOPE_EXIT { spl::Finalize(); };
|
||||
/* Create the config. */
|
||||
m_config = {
|
||||
.is_development = spl::IsDevelopment(),
|
||||
.hardware_type = ConvertToSplHardwareType(spl::GetHardwareType()),
|
||||
.is_quest = IsSplRetailInteractiveDisplayStateEnabled(spl::GetRetailInteractiveDisplayState()),
|
||||
.device_id_low = spl::GetDeviceIdLow(),
|
||||
};
|
||||
}
|
||||
|
||||
/* Create the config. */
|
||||
s_config = {
|
||||
.is_development = spl::IsDevelopment(),
|
||||
.hardware_type = ConvertToSplHardwareType(spl::GetHardwareType()),
|
||||
.is_quest = IsSplRetailInteractiveDisplayStateEnabled(spl::GetRetailInteractiveDisplayState()),
|
||||
.device_id_low = spl::GetDeviceIdLow(),
|
||||
};
|
||||
ALWAYS_INLINE operator SplConfig() {
|
||||
return m_config;
|
||||
}
|
||||
};
|
||||
|
||||
/* Mark as initialized. */
|
||||
s_is_initialized = true;
|
||||
}
|
||||
|
||||
return s_config;
|
||||
AMS_FUNCTION_LOCAL_STATIC(SplConfigHolder, s_config_holder);
|
||||
return s_config_holder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,27 +25,9 @@ namespace ams::settings::impl {
|
||||
StaticObject();
|
||||
public:
|
||||
static T &Get() {
|
||||
/* Declare static instance variables. */
|
||||
static constinit util::TypedStorage<T> s_storage = {};
|
||||
static constinit bool s_initialized = false;
|
||||
static constinit os::SdkMutex s_mutex;
|
||||
AMS_FUNCTION_LOCAL_STATIC(T, s_object);
|
||||
|
||||
/* If we haven't already done so, construct the instance. */
|
||||
if (AMS_UNLIKELY(!s_initialized)) {
|
||||
std::scoped_lock lk(s_mutex);
|
||||
|
||||
/* Check that we didn't concurrently construct the instance. */
|
||||
if (AMS_LIKELY(!s_initialized)) {
|
||||
/* Construct the instance. */
|
||||
util::ConstructAt(s_storage);
|
||||
|
||||
/* Note that we constructed. */
|
||||
s_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the constructed instance. */
|
||||
return util::GetReference(s_storage);
|
||||
return s_object;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,11 @@ namespace ams::settings::impl {
|
||||
public:
|
||||
SystemData() : m_system_data_id(), m_mount_name(), m_file_path() { /* ... */ }
|
||||
|
||||
SystemData(ncm::SystemDataId id, const char *mn) : SystemData() {
|
||||
this->SetSystemDataId(id);
|
||||
this->SetMountName(mn);
|
||||
}
|
||||
|
||||
void SetSystemDataId(ncm::SystemDataId id);
|
||||
void SetMountName(const char *name);
|
||||
Result Mount();
|
||||
|
||||
@@ -30,6 +30,14 @@ namespace ams::settings::impl {
|
||||
public:
|
||||
SystemSaveData() : m_system_save_data_id(0), m_save_data_space_id(fs::SaveDataSpaceId::System), m_total_size(0), m_journal_size(0), m_flags(0) { /* ... */ }
|
||||
|
||||
SystemSaveData(u64 id, s64 total_size, s64 journal_size, u32 flags, const char *mn) : SystemSaveData() {
|
||||
this->SetSystemSaveDataId(id);
|
||||
this->SetTotalSize(total_size);
|
||||
this->SetJournalSize(journal_size);
|
||||
this->SetFlags(flags);
|
||||
this->SetMountName(mn);
|
||||
}
|
||||
|
||||
void SetSystemSaveDataId(u64 id);
|
||||
void SetTotalSize(s64 size);
|
||||
void SetJournalSize(s64 size);
|
||||
|
||||
@@ -17,6 +17,65 @@
|
||||
|
||||
namespace ams::sf::cmif {
|
||||
|
||||
namespace {
|
||||
|
||||
ALWAYS_INLINE decltype(ServiceCommandMeta::handler) FindCommandHandlerByBinarySearch(const ServiceCommandMeta *entries, const size_t entry_count, const u32 cmd_id, const hos::Version hos_version) {
|
||||
/* Binary search for the handler. */
|
||||
ssize_t lo = 0;
|
||||
ssize_t hi = entry_count - 1;
|
||||
while (lo <= hi) {
|
||||
const size_t mid = (lo + hi) / 2;
|
||||
if (entries[mid].cmd_id < cmd_id) {
|
||||
lo = mid + 1;
|
||||
} else if (entries[mid].cmd_id > cmd_id) {
|
||||
hi = mid - 1;
|
||||
} else {
|
||||
/* Find start. */
|
||||
size_t start = mid;
|
||||
while (start > 0 && entries[start - 1].cmd_id == cmd_id) {
|
||||
--start;
|
||||
}
|
||||
|
||||
/* Find end. */
|
||||
size_t end = mid + 1;
|
||||
while (end < entry_count && entries[end].cmd_id == cmd_id) {
|
||||
++end;
|
||||
}
|
||||
|
||||
for (size_t idx = start; idx < end; ++idx) {
|
||||
if (entries[idx].MatchesVersion(hos_version)) {
|
||||
return entries[idx].GetHandler();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE decltype(ServiceCommandMeta::handler) FindCommandHandlerByLinearSearch(const ServiceCommandMeta *entries, const size_t entry_count, const u32 cmd_id, const hos::Version hos_version) {
|
||||
for (size_t i = 0; i < entry_count; ++i) {
|
||||
if (entries[i].Matches(cmd_id, hos_version)) {
|
||||
return entries[i].GetHandler();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE decltype(ServiceCommandMeta::handler) FindCommandHandler(const ServiceCommandMeta *entries, const size_t entry_count, const u32 cmd_id, const hos::Version hos_version) {
|
||||
if (entry_count >= 8) {
|
||||
return FindCommandHandlerByBinarySearch(entries, entry_count, cmd_id, hos_version);
|
||||
} else {
|
||||
return FindCommandHandlerByLinearSearch(entries, entry_count, cmd_id, hos_version);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Result impl::ServiceDispatchTableBase::ProcessMessageImpl(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const ServiceCommandMeta *entries, const size_t entry_count) const {
|
||||
/* Get versioning info. */
|
||||
const auto hos_version = hos::GetVersion();
|
||||
@@ -30,13 +89,7 @@ namespace ams::sf::cmif {
|
||||
const u32 cmd_id = in_header->command_id;
|
||||
|
||||
/* Find a handler. */
|
||||
decltype(ServiceCommandMeta::handler) cmd_handler = nullptr;
|
||||
for (size_t i = 0; i < entry_count; i++) {
|
||||
if (entries[i].Matches(cmd_id, hos_version)) {
|
||||
cmd_handler = entries[i].GetHandler();
|
||||
break;
|
||||
}
|
||||
}
|
||||
const auto cmd_handler = FindCommandHandler(entries, entry_count, cmd_id, hos_version);
|
||||
R_UNLESS(cmd_handler != nullptr, sf::cmif::ResultUnknownCommandId());
|
||||
|
||||
/* Invoke handler. */
|
||||
@@ -73,13 +126,7 @@ namespace ams::sf::cmif {
|
||||
const u32 cmd_id = in_header->command_id;
|
||||
|
||||
/* Find a handler. */
|
||||
decltype(ServiceCommandMeta::handler) cmd_handler = nullptr;
|
||||
for (size_t i = 0; i < entry_count; i++) {
|
||||
if (entries[i].Matches(cmd_id, hos_version)) {
|
||||
cmd_handler = entries[i].GetHandler();
|
||||
break;
|
||||
}
|
||||
}
|
||||
const auto cmd_handler = FindCommandHandler(entries, entry_count, cmd_id, hos_version);
|
||||
|
||||
/* If we didn't find a handler, forward the request. */
|
||||
if (cmd_handler == nullptr) {
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
#define ATMOSPHERE_RELEASE_VERSION_MAJOR 1
|
||||
#define ATMOSPHERE_RELEASE_VERSION_MINOR 2
|
||||
#define ATMOSPHERE_RELEASE_VERSION_MICRO 5
|
||||
#define ATMOSPHERE_RELEASE_VERSION_MICRO 6
|
||||
|
||||
#define ATMOSPHERE_RELEASE_VERSION ATMOSPHERE_RELEASE_VERSION_MAJOR, ATMOSPHERE_RELEASE_VERSION_MINOR, ATMOSPHERE_RELEASE_VERSION_MICRO
|
||||
|
||||
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MAJOR 13
|
||||
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MINOR 2
|
||||
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MICRO 0
|
||||
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MICRO 1
|
||||
|
||||
@@ -66,8 +66,9 @@
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_13_0_0 ATMOSPHERE_TARGET_FIRMWARE(13, 0, 0)
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_13_1_0 ATMOSPHERE_TARGET_FIRMWARE(13, 1, 0)
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_13_2_0 ATMOSPHERE_TARGET_FIRMWARE(13, 2, 0)
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_13_2_1 ATMOSPHERE_TARGET_FIRMWARE(13, 2, 1)
|
||||
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_13_2_0
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_13_2_1
|
||||
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_MIN ATMOSPHERE_TARGET_FIRMWARE(0, 0, 0)
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_MAX ATMOSPHERE_TARGET_FIRMWARE_CURRENT
|
||||
@@ -126,6 +127,7 @@ namespace ams {
|
||||
TargetFirmware_13_0_0 = ATMOSPHERE_TARGET_FIRMWARE_13_0_0,
|
||||
TargetFirmware_13_1_0 = ATMOSPHERE_TARGET_FIRMWARE_13_1_0,
|
||||
TargetFirmware_13_2_0 = ATMOSPHERE_TARGET_FIRMWARE_13_2_0,
|
||||
TargetFirmware_13_2_1 = ATMOSPHERE_TARGET_FIRMWARE_13_2_1,
|
||||
|
||||
TargetFirmware_Current = ATMOSPHERE_TARGET_FIRMWARE_CURRENT,
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
|
||||
#include <vapours/util/util_atomic.hpp>
|
||||
|
||||
#include <vapours/util/util_function_local_static.hpp>
|
||||
|
||||
#ifdef ATMOSPHERE_IS_STRATOSPHERE
|
||||
#include <vapours/util/util_mutex_utils.hpp>
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/util/util_typed_storage.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
#define AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(_TYPE_, _NAME_, ...) static constinit _TYPE_ _NAME_ { __VA_ARGS__ }
|
||||
|
||||
/* NOTE: This must use placement new, to support private constructors. */
|
||||
#define AMS_FUNCTION_LOCAL_STATIC_IMPL(_LOCKTYPE_, _SCOPELOCKTYPE_, _TYPE_, _NAME_, ...) \
|
||||
static constinit ::ams::util::TypedStorage<_TYPE_> s_fls_storage_for_##_NAME_ {}; \
|
||||
static constinit bool s_fls_initialized_##_NAME_ = false; \
|
||||
static constinit _LOCKTYPE_ s_fls_init_lock_##_NAME_ {}; \
|
||||
if (AMS_UNLIKELY(!(s_fls_initialized_##_NAME_))) { \
|
||||
_SCOPELOCKTYPE_ sl_fls_for_##_NAME_ { s_fls_init_lock_##_NAME_ }; \
|
||||
if (AMS_LIKELY(!(s_fls_initialized_##_NAME_))) { \
|
||||
new (::ams::util::impl::GetPointerForConstructAt(s_fls_storage_for_##_NAME_)) _TYPE_( __VA_ARGS__ ); \
|
||||
s_fls_initialized_##_NAME_ = true; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
_TYPE_ & _NAME_ = util::GetReference(s_fls_storage_for_##_NAME_)
|
||||
|
||||
#if defined(ATMOSPHERE_IS_MESOSPHERE)
|
||||
|
||||
#define AMS_FUNCTION_LOCAL_STATIC(_TYPE_, _NAME_, ...) AMS_FUNCTION_LOCAL_STATIC_IMPL(KSpinLock, KScopedSpinLock, _TYPE_, _NAME_, ##__VA_ARGS__)
|
||||
|
||||
#elif defined(ATMOSPHERE_IS_STRATOSPHERE)
|
||||
|
||||
#define AMS_FUNCTION_LOCAL_STATIC(_TYPE_, _NAME_, ...) AMS_FUNCTION_LOCAL_STATIC_IMPL(os::SdkMutex, std::scoped_lock, _TYPE_, _NAME_, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -45,9 +45,18 @@ namespace ams::util {
|
||||
return *GetPointer(ts);
|
||||
}
|
||||
|
||||
namespace impl {
|
||||
|
||||
template<typename T>
|
||||
static ALWAYS_INLINE T *GetPointerForConstructAt(TypedStorage<T> &ts) {
|
||||
return reinterpret_cast<T *>(std::addressof(ts._storage));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
static ALWAYS_INLINE T *ConstructAt(TypedStorage<T> &ts, Args &&... args) {
|
||||
return std::construct_at(reinterpret_cast<T *>(std::addressof(ts._storage)), std::forward<Args>(args)...);
|
||||
return std::construct_at(impl::GetPointerForConstructAt(ts), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user