From 9c94a6943d5948febbcff541e4360b6cc6c1849c Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 2 Sep 2014 02:22:13 +0400 Subject: [PATCH] mem_bptr_t replaced --- rpcs3/Emu/Memory/Memory.h | 3 - rpcs3/Emu/Memory/vm_ptr.h | 74 ++++++++++++++++--- rpcs3/Emu/SysCalls/Modules/cellGame.cpp | 4 +- rpcs3/Emu/SysCalls/Modules/cellGame.h | 2 +- rpcs3/Emu/SysCalls/Modules/cellSysutil.h | 2 +- .../SysCalls/Modules/cellSysutil_SaveData.cpp | 54 +++++++------- .../SysCalls/Modules/cellSysutil_SaveData.h | 16 ++-- rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp | 4 +- rpcs3/Emu/SysCalls/lv2/sys_semaphore.h | 2 +- 9 files changed, 107 insertions(+), 54 deletions(-) diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index 127428d0d8..fc1a989a87 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -650,9 +650,6 @@ public: template operator const mem_ptr_t&() const { return (const mem_ptr_t&)*this; } }; -template -class mem_beptr_t : public mem_ptr_t> {}; - template class mem_t : public mem_base_t { public: diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index c7dd6d2c0e..693bc5d183 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -314,7 +314,7 @@ namespace vm namespace ps3 { - template class ptr; + template struct ptr; } template @@ -413,32 +413,88 @@ namespace vm }; //BE pointer to LE data - template class bptrl : public _ptr_base::type> {}; + template struct bptrl : public _ptr_base::type> + { + static bptrl make(AT addr) + { + return (bptrl&)addr; + } + + using _ptr_base::type>::operator=; + }; + //BE pointer to BE data - template class bptrb : public _ptr_base::type, lvl, typename to_be_t::type> {}; + template struct bptrb : public _ptr_base::type, lvl, typename to_be_t::type> + { + static bptrb make(AT addr) + { + return (bptrb&)addr; + } + + using _ptr_base::type, lvl, typename to_be_t::type>::operator=; + }; + //LE pointer to BE data - template class lptrb : public _ptr_base::type, lvl, AT> {}; + template struct lptrb : public _ptr_base::type, lvl, AT> + { + static lptrb make(AT addr) + { + return (lptrb&)addr; + } + + using _ptr_base::type, lvl, AT>::operator=; + }; + //LE pointer to LE data - template class lptrl : public _ptr_base {}; + template struct lptrl : public _ptr_base + { + static lptrl make(AT addr) + { + return (lptrl&)addr; + } + + using _ptr_base::operator=; + }; + namespace ps3 { //default pointer for HLE functions (LE ptrerence to BE data) - template class ptr : public lptrb + template struct ptr : public lptrb { - public: static ptr make(AT addr) { return (ptr&)addr; } + + using lptrb::operator=; }; + //default pointer for HLE structures (BE ptrerence to BE data) - template class bptr : public bptrb {}; + template struct bptr : public bptrb + { + static bptr make(AT addr) + { + return (bptr&)addr; + } + + using bptrb::operator=; + }; } + namespace psv { //default pointer for HLE functions & structures (LE ptrerence to LE data) - template class ptr : public lptrl {}; + template struct ptr : public lptrl + { + static ptr make(AT addr) + { + return (ptr&)addr; + } + + using lptrl::operator=; + }; } + //PS3 emulation is main now, so lets it be as default using namespace ps3; } \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index ba2aadd2a5..20ac617af6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -267,10 +267,10 @@ int cellGameDataCheckCreate2(u32 version, vm::ptr dirName, u32 errDi funcStat(cbResult, cbGet, cbSet); - if (cbSet->setParam.GetAddr()) + if (cbSet->setParam) { // TODO: write PARAM.SFO from cbSet - cellGame->Todo("cellGameDataCheckCreate2(): writing PARAM.SFO parameters (addr=0x%x)", cbSet->setParam.GetAddr()); + cellGame->Todo("cellGameDataCheckCreate2(): writing PARAM.SFO parameters (addr=0x%x)", cbSet->setParam.addr()); } switch ((s32)cbResult->result) diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.h b/rpcs3/Emu/SysCalls/Modules/cellGame.h index 12a0165eba..0e7f6e3e95 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.h +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.h @@ -197,6 +197,6 @@ struct CellGameDataStatGet struct CellGameDataStatSet { - mem_beptr_t setParam; + vm::bptr setParam; be_t reserved; }; \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.h b/rpcs3/Emu/SysCalls/Modules/cellSysutil.h index 5a82805bd8..de53898d1c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.h @@ -202,7 +202,7 @@ struct CellHddGameStatGet struct CellHddGameStatSet { - mem_beptr_t setParam; + vm::bptr setParam; be_t reserved_addr; // void* }; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp index 6361e3d7b4..8b2d444f4b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp @@ -145,7 +145,7 @@ void setSaveDataFixed(std::vector& saveEntries, mem_ptr_tnewIcon.GetAddr()) + if (fixedSet->newIcon) { saveEntries[0].iconBuf = Memory.VirtualToRealAddr(fixedSet->newIcon->iconBuf_addr); saveEntries[0].iconBufSize = fixedSet->newIcon->iconBufSize; @@ -177,7 +177,7 @@ void getSaveDataStat(SaveDataEntry entry, mem_ptr_t statGet memcpy(statGet->getParam.listParam, entry.listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE); statGet->fileNum = 0; - statGet->fileList.SetAddr(be_t::MakeFromBE(0)); + statGet->fileList = vm::bptr::make(0); statGet->fileListNum = 0; std::string saveDir = "/dev_hdd0/home/00000001/savedata/" + entry.dirName; // TODO: Get the path of the current user vfsDir dir(saveDir); @@ -209,7 +209,7 @@ void getSaveDataStat(SaveDataEntry entry, mem_ptr_t statGet } } - statGet->fileList.SetAddr(be_t::MakeFromLE((u32)Memory.Alloc(sizeof(CellSaveDataFileStat) * (u32)fileEntries.size(), sizeof(CellSaveDataFileStat)))); + statGet->fileList = vm::bptr::make(be_t::MakeFromLE((u32)Memory.Alloc(sizeof(CellSaveDataFileStat) * (u32)fileEntries.size(), sizeof(CellSaveDataFileStat)))); for (u32 i=0; ifileList[i], &fileEntries[i], sizeof(CellSaveDataFileStat)); } @@ -325,8 +325,8 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m // Sort the entries and fill the listGet->dirList array std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); - listGet->dirList.SetAddr(setBuf->buf_addr); - CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + listGet->dirList = vm::bptr::make(setBuf->buf_addr); + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr()); for (u32 i=0; i setList, m return CELL_SAVEDATA_ERROR_CBRESULT; } - setSaveDataList(saveEntries, (u32)listSet->fixedList.GetAddr(), listSet->fixedListNum); - if (listSet->newData.GetAddr()) - addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr()); + setSaveDataList(saveEntries, (u32)listSet->fixedList.addr(), listSet->fixedListNum); + if (listSet->newData) + addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr()); if (saveEntries.size() == 0) { cellSysutil->Warning("cellSaveDataListSave2: No save entries found!"); // TODO: Find a better way to handle this error return CELL_SAVEDATA_RET_OK; @@ -355,7 +355,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m result->userdata_addr = userdata_addr; funcStat(result, statGet, statSet); - Memory.Free(statGet->fileList.GetAddr()); + Memory.Free(statGet->fileList.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; @@ -410,8 +410,8 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m // Sort the entries and fill the listGet->dirList array std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); - listGet->dirList.SetAddr(setBuf->buf_addr); - CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + listGet->dirList = vm::bptr::make(setBuf->buf_addr); + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr()); for (u32 i=0; i setList, m return CELL_SAVEDATA_ERROR_CBRESULT; } - setSaveDataList(saveEntries, (u32)listSet->fixedList.GetAddr(), listSet->fixedListNum); - if (listSet->newData.GetAddr()) - addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr()); + setSaveDataList(saveEntries, (u32)listSet->fixedList.addr(), listSet->fixedListNum); + if (listSet->newData) + addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr()); if (saveEntries.size() == 0) { cellSysutil->Warning("cellSaveDataListLoad2: No save entries found!"); // TODO: Find a better way to handle this error return CELL_SAVEDATA_RET_OK; @@ -440,7 +440,7 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m result->userdata_addr = userdata_addr; funcStat(result, statGet, statSet); - Memory.Free(statGet->fileList.GetAddr()); + Memory.Free(statGet->fileList.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; @@ -493,8 +493,8 @@ int cellSaveDataFixedSave2(u32 version, mem_ptr_t setList, // Sort the entries and fill the listGet->dirList array std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); - listGet->dirList.SetAddr(setBuf->buf_addr); - CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + listGet->dirList = vm::bptr::make(setBuf->buf_addr); + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr()); for (u32 i = 0; i setList, result->userdata_addr = userdata_addr; funcStat(result, statGet, statSet); - Memory.Free(statGet->fileList.GetAddr()); + Memory.Free(statGet->fileList.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataFixedSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; @@ -562,8 +562,8 @@ int cellSaveDataFixedLoad2(u32 version, mem_ptr_t setList, // Sort the entries and fill the listGet->dirList array std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); - listGet->dirList.SetAddr(setBuf->buf_addr); - CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + listGet->dirList = vm::bptr::make(setBuf->buf_addr); + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr()); for (u32 i = 0; i setList, result->userdata_addr = userdata_addr; funcStat(result, statGet, statSet); - Memory.Free(statGet->fileList.GetAddr()); + Memory.Free(statGet->fileList.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataFixedLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; @@ -632,7 +632,7 @@ int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ result->userdata_addr = userdata_addr; funcStat(result, statGet, statSet); - Memory.Free(statGet->fileList.GetAddr()); + Memory.Free(statGet->fileList.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataAutoSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; @@ -682,7 +682,7 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ result->userdata_addr = userdata_addr; funcStat(result, statGet, statSet); - Memory.Free(statGet->fileList.GetAddr()); + Memory.Free(statGet->fileList.addr()); if (result->result < 0) { cellSysutil->Error("cellSaveDataAutoLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; @@ -735,8 +735,8 @@ int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_tdirList array std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); - listGet->dirList.SetAddr(setBuf->buf_addr); - CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + listGet->dirList = vm::bptr::make(setBuf->buf_addr); + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr()); for (u32 i = 0; idirList array std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); - listGet->dirList.SetAddr(setBuf->buf_addr); - CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + listGet->dirList = vm::bptr::make(setBuf->buf_addr); + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr()); for (u32 i = 0; i iconPosition; be_t dirName_addr; // char* - mem_beptr_t icon; + vm::bptr icon; }; struct CellSaveDataDirList @@ -129,7 +129,7 @@ struct CellSaveDataListGet { be_t dirNum; be_t dirListNum; - mem_beptr_t dirList; + vm::bptr dirList; }; struct CellSaveDataListSet @@ -137,15 +137,15 @@ struct CellSaveDataListSet be_t focusPosition; be_t focusDirName_addr; // char* be_t fixedListNum; - mem_beptr_t fixedList; - mem_beptr_t newData; + vm::bptr fixedList; + vm::bptr newData; be_t reserved_addr; // void* }; struct CellSaveDataFixedSet { be_t dirName_addr; // char* - mem_beptr_t newIcon; + vm::bptr newIcon; be_t option; }; @@ -191,7 +191,7 @@ struct CellSaveDataStatGet be_t sysSizeKB; be_t fileNum; be_t fileListNum; - mem_beptr_t fileList; + vm::bptr fileList; }; struct CellSaveDataAutoIndicator @@ -205,9 +205,9 @@ struct CellSaveDataAutoIndicator struct CellSaveDataStatSet { - mem_beptr_t setParam; + vm::bptr setParam; be_t reCreateMode; - mem_beptr_t indicator; + vm::bptr indicator; }; struct CellSaveDataFileGet diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp index 858bd25940..52ff26cbbc 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp @@ -11,7 +11,7 @@ SysCallBase sys_semaphore("sys_semaphore"); -s32 sys_semaphore_create(vm::ref sem, mem_ptr_t attr, int initial_count, int max_count) +s32 sys_semaphore_create(vm::ptr> sem, mem_ptr_t attr, int initial_count, int max_count) { sys_semaphore.Warning("sys_semaphore_create(sem_addr=0x%x, attr_addr=0x%x, initial_count=%d, max_count=%d)", sem.addr(), attr.GetAddr(), initial_count, max_count); @@ -38,7 +38,7 @@ s32 sys_semaphore_create(vm::ref sem, mem_ptr_t at } u32 id = sys_semaphore.GetNewId(new Semaphore(initial_count, max_count, attr->protocol, attr->name_u64), TYPE_SEMAPHORE); - sem = id; + *sem = id; sys_semaphore.Notice("*** semaphore created [%s] (protocol=0x%x): id = %d", std::string(attr->name, 8).c_str(), (u32)attr->protocol, id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h index 079c9c4130..a27691405a 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h @@ -38,7 +38,7 @@ struct Semaphore }; // SysCalls -s32 sys_semaphore_create(vm::ref sem, mem_ptr_t attr, int initial_count, int max_count); +s32 sys_semaphore_create(vm::ptr> sem, mem_ptr_t attr, int initial_count, int max_count); s32 sys_semaphore_destroy(u32 sem_id); s32 sys_semaphore_wait(u32 sem_id, u64 timeout); s32 sys_semaphore_trywait(u32 sem_id);