hle: gpio syscalls

* add sys_gpio_get, sys_gpio_set
This commit is contained in:
elad 2018-02-12 00:12:05 +02:00 committed by Ivan
parent 9caceeacd7
commit 95c6ac699b
5 changed files with 60 additions and 2 deletions

View File

@ -32,6 +32,7 @@
#include "sys_dbg.h"
#include "sys_gamepad.h"
#include "sys_ss.h"
#include "sys_gpio.h"
extern std::string ppu_get_syscall_name(u64 code);
@ -602,8 +603,8 @@ const std::array<ppu_function_t, 1024> s_ppu_syscall_table
null_func,//BIND_FUNC(sys_io_buffer_free) //627 (0x273)
null_func, //628 (0x274) UNS
null_func, //629 (0x275) UNS
null_func,//BIND_FUNC(sys_gpio_set) //630 (0x276)
null_func,//BIND_FUNC(sys_gpio_get) //631 (0x277)
BIND_FUNC(sys_gpio_set), //630 (0x276)
BIND_FUNC(sys_gpio_get), //631 (0x277)
null_func, //632 (0x278) UNS
null_func,//BIND_FUNC(sys_fsw_connect_event) //633 (0x279)
null_func,//BIND_FUNC(sys_fsw_disconnect_event) //634 (0x27A)

View File

@ -0,0 +1,38 @@
#include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/ErrorCodes.h"
#include "sys_gpio.h"
error_code sys_gpio_get(u64 device_id, vm::ptr<u64> value)
{
if (device_id != SYS_GPIO_LED_DEVICE_ID && device_id != SYS_GPIO_DIP_SWITCH_DEVICE_ID)
{
return CELL_ESRCH;
}
if (!vm::check_addr(value.addr(), sizeof(u64), vm::page_writable))
{
return CELL_EFAULT;
}
// Retail consoles dont have LEDs or DIPs switches, hence always sets 0 in paramenter
*value = 0;
return CELL_OK;
}
error_code sys_gpio_set(u64 device_id, u64 mask, u64 value)
{
// Retail consoles dont have LEDs or DIPs switches, hence the syscall can't modify devices's value
switch (device_id)
{
case SYS_GPIO_LED_DEVICE_ID: return CELL_OK;
case SYS_GPIO_DIP_SWITCH_DEVICE_ID: return CELL_EINVAL;
}
return CELL_ESRCH;
}

View File

@ -0,0 +1,11 @@
#pragma once
enum : u64
{
SYS_GPIO_UNKNOWN_DEVICE_ID,
SYS_GPIO_LED_DEVICE_ID,
SYS_GPIO_DIP_SWITCH_DEVICE_ID,
};
error_code sys_gpio_get(u64 device_id, vm::ptr<u64> value);
error_code sys_gpio_set(u64 device_id, u64 mask, u64 value);

View File

@ -112,6 +112,7 @@
<ClCompile Include="..\Utilities\Thread.cpp" />
<ClCompile Include="..\Utilities\version.cpp" />
<ClCompile Include="..\Utilities\VirtualMemory.cpp" />
<ClCompile Include="Emu\Cell\lv2\sys_gpio.cpp" />
<ClCompile Include="Emu\Cell\lv2\sys_net.cpp" />
<ClCompile Include="Emu\Cell\PPUAnalyser.cpp" />
<ClCompile Include="Emu\Cell\PPUTranslator.cpp">
@ -389,6 +390,7 @@
<ClInclude Include="Crypto\unself.h" />
<ClInclude Include="Crypto\utils.h" />
<ClInclude Include="define_new_memleakdetect.h" />
<ClInclude Include="Emu\Cell\lv2\sys_gpio.h" />
<ClInclude Include="Emu\Cell\lv2\sys_net.h" />
<ClInclude Include="Emu\Cell\Modules\cellOskDialog.h" />
<ClInclude Include="Emu\Cell\PPUAnalyser.h" />

View File

@ -740,6 +740,9 @@
<ClCompile Include="Emu\RSX\overlays.cpp">
<Filter>Emu\GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="Emu\Cell\lv2\sys_gpio.cpp">
<Filter>Emu\Cell\lv2</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Crypto\aes.h">
@ -1408,5 +1411,8 @@
<ClInclude Include="Emu\RSX\overlays.h">
<Filter>Emu\GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\Cell\lv2\sys_gpio.h">
<Filter>Emu\Cell\lv2</Filter>
</ClInclude>
</ItemGroup>
</Project>