Implement svcGetInfo

This commit is contained in:
Ryan Teal 2019-07-02 22:45:34 +01:00
parent 040121340a
commit 13b1354a00
No known key found for this signature in database
GPG Key ID: 8DBEE0F12C7E2D23

View File

@ -8,8 +8,7 @@
using namespace core::cpu; using namespace core::cpu;
namespace core::kernel { namespace core::kernel {
static uint32_t OutputDebugString() static uint32_t OutputDebugString() {
{
std::string debug(GetRegister(UC_ARM64_REG_X1), '\0'); std::string debug(GetRegister(UC_ARM64_REG_X1), '\0');
memory::Read((void*)debug.data(), GetRegister(UC_ARM64_REG_X0), GetRegister(UC_ARM64_REG_X1)); memory::Read((void*)debug.data(), GetRegister(UC_ARM64_REG_X0), GetRegister(UC_ARM64_REG_X1));
@ -17,6 +16,19 @@ namespace core::kernel {
return 0; 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<int, uint32_t(*)()> svcTable[] = std::pair<int, uint32_t(*)()> svcTable[] =
{ {
{0x00, nullptr}, {0x00, nullptr},
@ -60,7 +72,7 @@ namespace core::kernel {
{0x26, nullptr}, {0x26, nullptr},
{0x27, OutputDebugString}, {0x27, OutputDebugString},
{0x28, nullptr}, {0x28, nullptr},
{0x29, nullptr}, {0x29, GetInfo},
{0x2a, nullptr}, {0x2a, nullptr},
{0x2b, nullptr}, {0x2b, nullptr},
{0x2c, nullptr}, {0x2c, nullptr},
@ -153,8 +165,11 @@ namespace core::kernel {
{ {
std::pair<int, uint32_t(*)()>* result = &(svcTable[svc]); std::pair<int, uint32_t(*)()>* result = &(svcTable[svc]);
if (result->second) if(result->second) {
return result->second(); uint32_t returnCode = result->second();
SetRegister(UC_ARM64_REG_W0, returnCode);
return returnCode;
}
else else
{ {
syslog(LOG_ERR, "Unimplemented SVC 0x%02x", svc); syslog(LOG_ERR, "Unimplemented SVC 0x%02x", svc);