diff --git a/rpcs3/Emu/SysCalls/Modules.cpp b/rpcs3/Emu/SysCalls/Modules.cpp index 07404f49ad..370ad88004 100644 --- a/rpcs3/Emu/SysCalls/Modules.cpp +++ b/rpcs3/Emu/SysCalls/Modules.cpp @@ -63,7 +63,7 @@ static const g_module_list[] = {0x002e, "cellLv2dbg"}, {0x0030, "cellUsbpspcm"}, {0x0031, "cellAvconfExt"}, - {0x0032, "cellSysutilUserinfo"}, + {0x0032, "cellUserInfo"}, {0x0033, "cellSysutilSavedata"}, {0x0034, "cellSubdisplay"}, {0x0035, "cellSysutilRec"}, diff --git a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp new file mode 100644 index 0000000000..3c0a541d56 --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp @@ -0,0 +1,75 @@ +#include "stdafx.h" +#include "Emu/SysCalls/SysCalls.h" +#include "Emu/SysCalls/SC_FUNC.h" + +#include "cellUserInfo.h" + +void cellUserInfo_init(); +Module cellUserInfo(0x0032, cellUserInfo_init); + +int cellUserInfoGetStat(u32 id, mem_ptr_t stat) +{ + cellUserInfo.Warning("cellUserInfoGetStat(id=%d, stat_addr=0x%x)", id, stat.GetAddr()); + + if (!stat.IsGood()) + return CELL_USERINFO_ERROR_PARAM; + if (id > CELL_USERINFO_USER_MAX) + return CELL_USERINFO_ERROR_NOUSER; + + char path [256]; + sprintf(path, "/dev_hdd0/home/%08d", id); + if (!Emu.GetVFS().ExistsDir(path)) + return CELL_USERINFO_ERROR_NOUSER; + + sprintf(path, "/dev_hdd0/home/%08d/localusername", id); + vfsStream* stream = Emu.GetVFS().OpenFile(path, vfsRead); + if (!stream || !(stream->IsOpened())) + return CELL_USERINFO_ERROR_INTERNAL; + + char name [CELL_USERINFO_USERNAME_SIZE]; + memset(name, 0, CELL_USERINFO_USERNAME_SIZE); + stream->Read(name, CELL_USERINFO_USERNAME_SIZE); + stream->Close(); + + stat->id = id; + memcpy(stat->name, name, CELL_USERINFO_USERNAME_SIZE); + return CELL_OK; +} + +int cellUserInfoSelectUser_ListType() +{ + UNIMPLEMENTED_FUNC(cellUserInfo); + return CELL_OK; +} + +int cellUserInfoSelectUser_SetList() +{ + UNIMPLEMENTED_FUNC(cellUserInfo); + return CELL_OK; +} + +int cellUserInfoEnableOverlay() +{ + UNIMPLEMENTED_FUNC(cellUserInfo); + return CELL_OK; +} + +int cellUserInfoGetList(mem32_t listNum, mem_ptr_t listBuf, mem32_t currentUserId) +{ + cellUserInfo.Warning("cellUserInfoGetList(listNum_addr=0x%x, listBuf_addr=0x%x, currentUserId_addr=0x%x)", + listNum.GetAddr(), listBuf.GetAddr(), currentUserId.GetAddr()); + + listNum = 1; + listBuf->userId[0] = 1; + currentUserId = 1; + return CELL_OK; +} + +void cellUserInfo_init() +{ + cellUserInfo.AddFunc(0x2b761140, cellUserInfoGetStat); + cellUserInfo.AddFunc(0x3097cc1c, cellUserInfoSelectUser_ListType); + cellUserInfo.AddFunc(0x55123a25, cellUserInfoSelectUser_SetList); + cellUserInfo.AddFunc(0xb3516536, cellUserInfoEnableOverlay); + cellUserInfo.AddFunc(0xc55e338b, cellUserInfoGetList); +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.h b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.h new file mode 100644 index 0000000000..3498b0293c --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.h @@ -0,0 +1,55 @@ +#pragma once + +// Return Codes +enum +{ + CELL_USERINFO_RET_OK = 0, + CELL_USERINFO_RET_CANCEL = 1, + CELL_USERINFO_ERROR_BUSY = 0x8002c301, + CELL_USERINFO_ERROR_INTERNAL = 0x8002c302, + CELL_USERINFO_ERROR_PARAM = 0x8002c303, + CELL_USERINFO_ERROR_NOUSER = 0x8002c304, +}; + +// Enums +enum CellUserInfoParamSize +{ + CELL_USERINFO_USER_MAX = 16, + CELL_USERINFO_TITLE_SIZE = 256, + CELL_USERINFO_USERNAME_SIZE = 64, +}; + +enum CellUserInfoListType +{ + CELL_USERINFO_LISTTYPE_ALL = 0, + CELL_USERINFO_LISTTYPE_NOCURRENT = 1, +}; + +// Structs +struct CellUserInfoUserStat +{ + u32 id; + u8 name[CELL_USERINFO_USERNAME_SIZE]; +}; + +struct CellUserInfoUserList +{ + u32 userId[CELL_USERINFO_USER_MAX]; +}; + +struct CellUserInfoListSet +{ + u32 title_addr; // (char*) + u32 focus; + u32 fixedListNum; + mem_ptr_t fixedList; + u32 reserved_addr; // (void*) +}; + +struct CellUserInfoTypeSet +{ + u32 title_addr; // (char*) + u32 focus; + CellUserInfoListType type; + u32 reserved_addr; // (void*) +}; diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index cf05cbf3b7..07c7c73a8e 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -270,6 +270,25 @@ int cellFsAioFinish(mem8_ptr_t mount_point) return CELL_OK; } +int cellFsReadWithOffset(u32 fd, u64 offset, u32 buf_addr, u64 buffer_size, mem64_t nread) +{ + sys_fs.Warning("cellFsReadWithOffset(fd=%d, offset=0x%llx, buf_addr=0x%x, buffer_size=%lld nread=0x%llx)", + fd, offset, buf_addr, buffer_size, nread.GetAddr()); + + int ret; + MemoryAllocator> oldPos, newPos; + ret = cellFsLseek(fd, 0, CELL_SEEK_CUR, oldPos.GetAddr()); // Save the current position + if (ret) return ret; + ret = cellFsLseek(fd, offset, CELL_SEEK_SET, newPos.GetAddr()); // Move to the specified offset + if (ret) return ret; + ret = cellFsRead(fd, buf_addr, buffer_size, nread.GetAddr()); // Read the file + if (ret) return ret; + ret = cellFsLseek(fd, Memory.Read64(oldPos.GetAddr()), CELL_SEEK_SET, newPos.GetAddr()); // Return to the old position + if (ret) return ret; + + return CELL_OK; +} + void sys_fs_init() { sys_fs.AddFunc(0x718bf5f8, cellFsOpen); @@ -295,5 +314,6 @@ void sys_fs_init() sys_fs.AddFunc(0x9f951810, cellFsAioFinish); sys_fs.AddFunc(0x1a108ab7, cellFsGetBlockSize); sys_fs.AddFunc(0xaa3b4bcd, cellFsGetFreeSize); + sys_fs.AddFunc(0x0d5b4a14, cellFsReadWithOffset); aio_init = false; } diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 5a9fa6fb3f..1dfb346159 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -304,6 +304,7 @@ + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 6f796ff3fe..b10d1cb470 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -463,6 +463,9 @@ Emu\SysCalls\Modules + + Emu\SysCalls\Modules +