exo2: resolve remaining erista TODOs, clean up debugging code
This commit is contained in:
@@ -239,40 +239,6 @@ namespace ams::secmon::smc {
|
||||
return info.handler(args);
|
||||
}
|
||||
|
||||
constinit std::atomic<int> g_logged = 0;
|
||||
|
||||
constexpr int LogMin = 0x1000000;
|
||||
constexpr int LogMax = 0x1000000;
|
||||
|
||||
constexpr size_t LogBufSize = 0x5000;
|
||||
|
||||
void DebugLog(SmcArguments &args) {
|
||||
const int current = g_logged.fetch_add(1);
|
||||
|
||||
if (current == 0) {
|
||||
std::memset(MemoryRegionVirtualDebug.GetPointer<void>(), 0xCC, LogBufSize);
|
||||
}
|
||||
|
||||
if (current < LogMin) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int ind = current - LogMin;
|
||||
const int ofs = (ind * sizeof(args)) % LogBufSize;
|
||||
|
||||
for (size_t i = 0; i < sizeof(args) / sizeof(u32); ++i) {
|
||||
((volatile u32 *)(MemoryRegionVirtualDebug.GetAddress() + ofs))[i] = reinterpret_cast<u32 *>(std::addressof(args))[i];
|
||||
}
|
||||
|
||||
if (current >= LogMax) {
|
||||
*(volatile u32 *)(MemoryRegionVirtualDevicePmc.GetAddress() + 0x50) = 0x02;
|
||||
*(volatile u32 *)(MemoryRegionVirtualDevicePmc.GetAddress() + 0x00) = 0x10;
|
||||
|
||||
util::WaitMicroSeconds(1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConfigureSmcHandlersForTargetFirmware() {
|
||||
@@ -288,45 +254,11 @@ namespace ams::secmon::smc {
|
||||
/* Get the table. */
|
||||
const auto &table = GetHandlerTable(static_cast<HandlerType>(type), args.r[0]);
|
||||
|
||||
if (std::addressof(table) == std::addressof(g_handler_tables[HandlerType_User])) {
|
||||
DebugLog(args);
|
||||
}
|
||||
|
||||
/* Get the handler info. */
|
||||
const auto &info = GetHandlerInfo(table, args.r[0]);
|
||||
|
||||
/* Set the invocation result. */
|
||||
args.r[0] = static_cast<u64>(InvokeSmcHandler(info, args));
|
||||
|
||||
if (std::addressof(table) == std::addressof(g_handler_tables[HandlerType_User])) {
|
||||
DebugLog(args);
|
||||
}
|
||||
|
||||
/* TODO: For debugging. Remove this when exo2 is complete. */
|
||||
#if 1
|
||||
if (args.r[0] == static_cast<u64>(SmcResult::NotImplemented)) {
|
||||
*(volatile u32 *)(MemoryRegionVirtualDebug.GetAddress()) = 0xBBBBBBBB;
|
||||
*(volatile u32 *)(MemoryRegionVirtualDebug.GetAddress() + 0x10) = static_cast<u32>(info.function_id);
|
||||
for (size_t i = 0; i < sizeof(args) / sizeof(u32); ++i) {
|
||||
((volatile u32 *)(MemoryRegionVirtualDebug.GetAddress() + 0x20))[i] = reinterpret_cast<u32 *>(std::addressof(args))[i];
|
||||
}
|
||||
*(volatile u32 *)(MemoryRegionVirtualDevicePmc.GetAddress() + 0x50) = 0x02;
|
||||
*(volatile u32 *)(MemoryRegionVirtualDevicePmc.GetAddress() + 0x00) = 0x10;
|
||||
|
||||
util::WaitMicroSeconds(1000);
|
||||
}
|
||||
if (args.r[0] != static_cast<u64>(SmcResult::Success) && info.function_id != 0xC3000007 /* generate aes key fails during SetupKekAccessKeys */) {
|
||||
*(volatile u32 *)(MemoryRegionVirtualDebug.GetAddress()) = 0xCCCCCCCC;
|
||||
*(volatile u32 *)(MemoryRegionVirtualDebug.GetAddress() + 0x10) = static_cast<u32>(info.function_id);
|
||||
for (size_t i = 0; i < sizeof(args) / sizeof(u32); ++i) {
|
||||
((volatile u32 *)(MemoryRegionVirtualDebug.GetAddress() + 0x20))[i] = reinterpret_cast<u32 *>(std::addressof(args))[i];
|
||||
}
|
||||
*(volatile u32 *)(MemoryRegionVirtualDevicePmc.GetAddress() + 0x50) = 0x02;
|
||||
*(volatile u32 *)(MemoryRegionVirtualDevicePmc.GetAddress() + 0x00) = 0x10;
|
||||
|
||||
util::WaitMicroSeconds(1000);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user