From 95c6ac699b654e9c7ad35a5c63a9113db60ba125 Mon Sep 17 00:00:00 2001 From: elad Date: Mon, 12 Feb 2018 00:12:05 +0200 Subject: [PATCH] hle: gpio syscalls * add sys_gpio_get, sys_gpio_set --- rpcs3/Emu/Cell/lv2/lv2.cpp | 5 +++-- rpcs3/Emu/Cell/lv2/sys_gpio.cpp | 38 +++++++++++++++++++++++++++++++++ rpcs3/Emu/Cell/lv2/sys_gpio.h | 11 ++++++++++ rpcs3/emucore.vcxproj | 2 ++ rpcs3/emucore.vcxproj.filters | 6 ++++++ 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 rpcs3/Emu/Cell/lv2/sys_gpio.cpp create mode 100644 rpcs3/Emu/Cell/lv2/sys_gpio.h diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index d52abbe339..d049e3aa2d 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -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 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) diff --git a/rpcs3/Emu/Cell/lv2/sys_gpio.cpp b/rpcs3/Emu/Cell/lv2/sys_gpio.cpp new file mode 100644 index 0000000000..a667cfe1c2 --- /dev/null +++ b/rpcs3/Emu/Cell/lv2/sys_gpio.cpp @@ -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 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; +} diff --git a/rpcs3/Emu/Cell/lv2/sys_gpio.h b/rpcs3/Emu/Cell/lv2/sys_gpio.h new file mode 100644 index 0000000000..4dfe7e7873 --- /dev/null +++ b/rpcs3/Emu/Cell/lv2/sys_gpio.h @@ -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 value); +error_code sys_gpio_set(u64 device_id, u64 mask, u64 value); diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index a37d8c5e76..80b4db042a 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -112,6 +112,7 @@ + @@ -389,6 +390,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 90de377ef9..2b0fb84aa1 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -740,6 +740,9 @@ Emu\GPU\RSX + + Emu\Cell\lv2 + @@ -1408,5 +1411,8 @@ Emu\GPU\RSX + + Emu\Cell\lv2 + \ No newline at end of file