From 13b1354a008c5b47397e64d81649e9d2cc87b286 Mon Sep 17 00:00:00 2001 From: Ryan Teal Date: Tue, 2 Jul 2019 22:45:34 +0100 Subject: [PATCH] Implement svcGetInfo --- app/src/main/cpp/core/hos/kernel/svc.cpp | 25 +++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/app/src/main/cpp/core/hos/kernel/svc.cpp b/app/src/main/cpp/core/hos/kernel/svc.cpp index eec203c5..c6d4a9e6 100644 --- a/app/src/main/cpp/core/hos/kernel/svc.cpp +++ b/app/src/main/cpp/core/hos/kernel/svc.cpp @@ -8,8 +8,7 @@ using namespace core::cpu; namespace core::kernel { - static uint32_t OutputDebugString() - { + static uint32_t OutputDebugString() { std::string debug(GetRegister(UC_ARM64_REG_X1), '\0'); memory::Read((void*)debug.data(), GetRegister(UC_ARM64_REG_X0), GetRegister(UC_ARM64_REG_X1)); @@ -17,6 +16,19 @@ namespace core::kernel { return 0; } + static uint32_t GetInfo() { + switch(GetRegister(UC_ARM64_REG_X1)) { + case 12: + SetRegister(UC_ARM64_REG_X1, BASE_ADDRESS); + break; + default: + syslog(LOG_ERR, "Unimplemented GetInfo id id1=%i,id2=%i", GetRegister(UC_ARM64_REG_X1), GetRegister(UC_ARM64_REG_X3)); + return 0x177202; + } + + return 0; + } + std::pair svcTable[] = { {0x00, nullptr}, @@ -60,7 +72,7 @@ namespace core::kernel { {0x26, nullptr}, {0x27, OutputDebugString}, {0x28, nullptr}, - {0x29, nullptr}, + {0x29, GetInfo}, {0x2a, nullptr}, {0x2b, nullptr}, {0x2c, nullptr}, @@ -153,8 +165,11 @@ namespace core::kernel { { std::pair* result = &(svcTable[svc]); - if (result->second) - return result->second(); + if(result->second) { + uint32_t returnCode = result->second(); + SetRegister(UC_ARM64_REG_W0, returnCode); + return returnCode; + } else { syslog(LOG_ERR, "Unimplemented SVC 0x%02x", svc);