add exosphere.ini option to determine memory mode from physical memory instead of boot config
This commit is contained in:
@@ -132,10 +132,13 @@ namespace ams::secmon::smc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u32 GetMemoryMode() {
|
u32 GetMemoryMode() {
|
||||||
/* Unless development function is enabled, we're 4 GB. */
|
/* Unless development function is enabled or memory_mode_auto is set, we're 4 GB. */
|
||||||
u32 memory_mode = pkg1::MemoryMode_4GB;
|
u32 memory_mode = pkg1::MemoryMode_4GB;
|
||||||
|
|
||||||
if (const auto &bcd = GetBootConfig().data; bcd.IsDevelopmentFunctionEnabled()) {
|
if (GetSecmonConfiguration().IsMemoryModeAuto()) {
|
||||||
|
/* If memory_mode_auto is set, determine memory mode from physical memory */
|
||||||
|
memory_mode = GetMemoryMode(pkg1::MemoryMode_Auto);
|
||||||
|
} else if (const auto &bcd = GetBootConfig().data; bcd.IsDevelopmentFunctionEnabled()) {
|
||||||
memory_mode = GetMemoryMode(bcd.GetMemoryMode());
|
memory_mode = GetMemoryMode(bcd.GetMemoryMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -463,6 +463,10 @@ namespace ams::nxboot {
|
|||||||
if (entry.value[0] == '1') {
|
if (entry.value[0] == '1') {
|
||||||
storage_ctx.log_flags |= uart::Flag_Inverted;
|
storage_ctx.log_flags |= uart::Flag_Inverted;
|
||||||
}
|
}
|
||||||
|
} else if (std::strcmp(entry.key, "memory_mode_auto") == 0) {
|
||||||
|
if (entry.value[0] == '1') {
|
||||||
|
storage_ctx.memory_mode_auto = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ namespace ams::secmon {
|
|||||||
u8 log_port;
|
u8 log_port;
|
||||||
u8 log_flags;
|
u8 log_flags;
|
||||||
u32 log_baud_rate;
|
u32 log_baud_rate;
|
||||||
u32 reserved1[2];
|
u8 memory_mode_auto;
|
||||||
|
u8 reserved1[7];
|
||||||
EmummcConfiguration emummc_cfg;
|
EmummcConfiguration emummc_cfg;
|
||||||
|
|
||||||
constexpr bool IsValid() const { return this->magic == Magic; }
|
constexpr bool IsValid() const { return this->magic == Magic; }
|
||||||
@@ -62,18 +63,19 @@ namespace ams::secmon {
|
|||||||
u32 flags[2];
|
u32 flags[2];
|
||||||
u16 lcd_vendor;
|
u16 lcd_vendor;
|
||||||
u8 log_flags;
|
u8 log_flags;
|
||||||
u8 reserved0;
|
u8 memory_mode_auto;
|
||||||
u32 log_baud_rate;
|
u32 log_baud_rate;
|
||||||
u32 reserved1[(0x80 - 0x1C) / sizeof(u32)];
|
u32 reserved1[(0x80 - 0x1C) / sizeof(u32)];
|
||||||
|
|
||||||
constexpr void CopyFrom(const SecureMonitorStorageConfiguration &storage) {
|
constexpr void CopyFrom(const SecureMonitorStorageConfiguration &storage) {
|
||||||
this->target_firmware = storage.target_firmware;
|
this->target_firmware = storage.target_firmware;
|
||||||
this->flags[0] = storage.flags[0];
|
this->flags[0] = storage.flags[0];
|
||||||
this->flags[1] = storage.flags[1];
|
this->flags[1] = storage.flags[1];
|
||||||
this->lcd_vendor = storage.lcd_vendor;
|
this->lcd_vendor = storage.lcd_vendor;
|
||||||
this->log_port = storage.log_port;
|
this->log_port = storage.log_port;
|
||||||
this->log_flags = storage.log_flags;
|
this->log_flags = storage.log_flags;
|
||||||
this->log_baud_rate = storage.log_baud_rate != 0 ? storage.log_baud_rate : 115200;
|
this->log_baud_rate = storage.log_baud_rate != 0 ? storage.log_baud_rate : 115200;
|
||||||
|
this->memory_mode_auto = storage.memory_mode_auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetFuseInfo() {
|
void SetFuseInfo() {
|
||||||
@@ -95,6 +97,7 @@ namespace ams::secmon {
|
|||||||
constexpr u32 GetLogBaudRate() const { return this->log_baud_rate; }
|
constexpr u32 GetLogBaudRate() const { return this->log_baud_rate; }
|
||||||
|
|
||||||
constexpr bool IsProduction() const { return this->GetHardwareState() != fuse::HardwareState_Development; }
|
constexpr bool IsProduction() const { return this->GetHardwareState() != fuse::HardwareState_Development; }
|
||||||
|
constexpr bool IsMemoryModeAuto() const { return (this->memory_mode_auto); }
|
||||||
|
|
||||||
constexpr bool IsDevelopmentFunctionEnabledForKernel() const { return (this->flags[0] & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForKernel) != 0; }
|
constexpr bool IsDevelopmentFunctionEnabledForKernel() const { return (this->flags[0] & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForKernel) != 0; }
|
||||||
constexpr bool IsDevelopmentFunctionEnabledForUser() const { return (this->flags[0] & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForUser) != 0; }
|
constexpr bool IsDevelopmentFunctionEnabledForUser() const { return (this->flags[0] & SecureMonitorConfigurationFlag_IsDevelopmentFunctionEnabledForUser) != 0; }
|
||||||
@@ -110,18 +113,18 @@ namespace ams::secmon {
|
|||||||
static_assert(sizeof(SecureMonitorConfiguration) == 0x80);
|
static_assert(sizeof(SecureMonitorConfiguration) == 0x80);
|
||||||
|
|
||||||
constexpr inline const SecureMonitorConfiguration DefaultSecureMonitorConfiguration = {
|
constexpr inline const SecureMonitorConfiguration DefaultSecureMonitorConfiguration = {
|
||||||
.target_firmware = ams::TargetFirmware_Current,
|
.target_firmware = ams::TargetFirmware_Current,
|
||||||
.key_generation = {},
|
.key_generation = {},
|
||||||
.hardware_type = {},
|
.hardware_type = {},
|
||||||
.soc_type = {},
|
.soc_type = {},
|
||||||
.hardware_state = {},
|
.hardware_state = {},
|
||||||
.log_port = uart::Port_ReservedDebug,
|
.log_port = uart::Port_ReservedDebug,
|
||||||
.flags = { SecureMonitorConfigurationFlag_Default, SecureMonitorConfigurationFlag_None },
|
.flags = { SecureMonitorConfigurationFlag_Default, SecureMonitorConfigurationFlag_None },
|
||||||
.lcd_vendor = {},
|
.lcd_vendor = {},
|
||||||
.log_flags = {},
|
.log_flags = {},
|
||||||
.reserved0 = {},
|
.memory_mode_auto = {},
|
||||||
.log_baud_rate = 115200,
|
.log_baud_rate = 115200,
|
||||||
.reserved1 = {},
|
.reserved1 = {},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user