From 9bf228de3e1e33ea62ed18b51853e5de6b4c4b41 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 24 Jan 2019 08:10:18 -0800 Subject: [PATCH] Add wrappers for new SMC extensions --- include/stratosphere/utilities.hpp | 32 ++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/include/stratosphere/utilities.hpp b/include/stratosphere/utilities.hpp index d8ee3093..2f0a8bb0 100644 --- a/include/stratosphere/utilities.hpp +++ b/include/stratosphere/utilities.hpp @@ -20,7 +20,35 @@ static inline void RebootToRcm() { SecmonArgs args = {0}; args.X[0] = 0xC3000401; /* smcSetConfig */ - args.X[1] = 65001; /* Exosphere reboot to rcm */ - args.X[3] = 1; /* Perform reboot. */ + args.X[1] = 65001; /* Exosphere reboot */ + args.X[3] = 1; /* Perform reboot to RCM. */ + svcCallSecureMonitor(&args); +} + +static inline void RebootToIramPayload() { + SecmonArgs args = {0}; + args.X[0] = 0xC3000401; /* smcSetConfig */ + args.X[1] = 65001; /* Exosphere reboot */ + args.X[3] = 2; /* Perform reboot to payload at 0x40010000 in IRAM. */ + svcCallSecureMonitor(&args); +} + +static inline void CopyToIram(uintptr_t iram_addr, void *src_addr, size_t size) { + SecmonArgs args = {0}; + args.X[0] = 0xF0000201; /* smcAmsIramCopy */ + args.X[1] = (u64)src_addr; /* DRAM address */ + args.X[2] = (u64)iram_addr; /* IRAM address */ + args.X[3] = size; /* Amount to copy */ + args.X[4] = 1; /* 1 = Write */ + svcCallSecureMonitor(&args); +} + +static inline void CopyFromIram(void *dst_addr, uintptr_t iram_addr, size_t size) { + SecmonArgs args = {0}; + args.X[0] = 0xF0000201; /* smcAmsIramCopy */ + args.X[1] = (u64)dst_addr; /* DRAM address */ + args.X[2] = (u64)iram_addr; /* IRAM address */ + args.X[3] = size; /* Amount to copy */ + args.X[4] = 0; /* 0 = Read */ svcCallSecureMonitor(&args); }