rpcsx/rpcs3/Emu/Cell/lv2/sys_gpio.cpp

39 lines
886 B
C++
Raw Normal View History

#include "stdafx.h"
2018-07-27 21:07:34 +02:00
#include "Emu/Memory/vm.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;
}
2018-04-01 21:13:56 +02:00
if (!vm::check_addr(value.addr(), sizeof(u64), vm::page_allocated | 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;
}