add kip detection
This commit is contained in:
@@ -19,9 +19,9 @@
|
||||
#include "../i2c/i2cDrv.h"
|
||||
#include "../mgr/clock_manager.hpp"
|
||||
#include "file_utils.hpp"
|
||||
#include "../mapping/mem_map.hpp"
|
||||
#include "kip.hpp"
|
||||
|
||||
|
||||
namespace kip {
|
||||
|
||||
bool kipAvailable = false;
|
||||
@@ -172,6 +172,24 @@ namespace kip {
|
||||
}
|
||||
}
|
||||
|
||||
bool IsKipLoaded() {
|
||||
constexpr u32 ExpectedMagic = 0x686F634D;
|
||||
constexpr uintptr_t LoadMagicAddress = 0x4003DC00;
|
||||
u32 iramValue = {};
|
||||
|
||||
SmcCopyFromIram(&iramValue, LoadMagicAddress, sizeof(iramValue));
|
||||
|
||||
if (iramValue == ExpectedMagic) {
|
||||
iramValue = 0;
|
||||
SmcCopyToIram(LoadMagicAddress, &iramValue, sizeof(iramValue));
|
||||
return true;
|
||||
}
|
||||
|
||||
notification::writeNotification("Kip is not loaded!");
|
||||
fileUtils::LogLine("Kip was not loaded!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// I know this is very hacky, but the config system in the sysmodule doesn't really support writing
|
||||
|
||||
void GetKipData() {
|
||||
@@ -231,6 +249,7 @@ namespace kip {
|
||||
return;
|
||||
}
|
||||
|
||||
clockManager::gContext.isKipLoaded = IsKipLoaded();
|
||||
clockManager::gContext.kipVersion = kipVersion;
|
||||
configValues.values[KipConfigValue_custRev] = cust_get_cust_rev(&table);
|
||||
configValues.values[KipConfigValue_KipVersion] = cust_get_kip_version(&table); // Run this after the check so we can do migration process
|
||||
@@ -350,4 +369,5 @@ namespace kip {
|
||||
}
|
||||
config::SetConfigValues(&configValues, true);
|
||||
}
|
||||
|
||||
} // namespace kip
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "../file/file_utils.hpp"
|
||||
|
||||
|
||||
Result QueryMemoryMapping(u64 *virtaddr, u64 physaddr, u64 size) {
|
||||
if (hosversionAtLeast(10, 0, 0)) {
|
||||
u64 out_size;
|
||||
@@ -37,3 +36,33 @@ Result MapAddress(u64 &va, const u64 &physAddr, const char *name) {
|
||||
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
Result SmcCopyFromIram(void *dest, uintptr_t src, u32 size) {
|
||||
SecmonArgs args;
|
||||
args.X[0] = 0xF0000201;
|
||||
args.X[1] = (u64)dest;
|
||||
args.X[2] = (u64)src;
|
||||
args.X[3] = size;
|
||||
args.X[4] = 0;
|
||||
svcCallSecureMonitor(&args);
|
||||
Result rc = 0;
|
||||
if (args.X[0] != 0) {
|
||||
rc = (26u | ((u32)args.X[0] << 9u));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result SmcCopyToIram(uintptr_t dest, const void *src, u32 size) {
|
||||
SecmonArgs args;
|
||||
args.X[0] = 0xF0000201;
|
||||
args.X[1] = (u64)src;
|
||||
args.X[2] = (u64)dest;
|
||||
args.X[3] = size;
|
||||
args.X[4] = 1;
|
||||
svcCallSecureMonitor(&args);
|
||||
Result rc = 0;
|
||||
if (args.X[0] != 0) {
|
||||
rc = (26u | ((u32)args.X[0] << 9u));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -20,3 +20,5 @@
|
||||
|
||||
Result QueryMemoryMapping(u64 *virtaddr, u64 physaddr, u64 size);
|
||||
Result MapAddress(u64 &va, const u64 &physAddr, const char *name);
|
||||
Result SmcCopyFromIram(void *dest, uintptr_t src, u32 size);
|
||||
Result SmcCopyToIram(uintptr_t dest, const void *src, u32 size);
|
||||
|
||||
Reference in New Issue
Block a user