Implemented MFF_HIDDEN for VNIDs

Minor refactoring
Now possible: ```REF_FUNC(...).flag(MFF_HIDDEN);```
This commit is contained in:
Nekotekina 2017-09-16 20:39:41 +03:00
parent be44024a1a
commit e789b969b0
10 changed files with 55 additions and 26 deletions

View File

@ -152,7 +152,7 @@ s32 cellVideoOutSetCopyControl(u32 videoOut, u32 control)
DECLARE(ppu_module_manager::cellAvconfExt)("cellSysutilAvconfExt", []() DECLARE(ppu_module_manager::cellAvconfExt)("cellSysutilAvconfExt", []()
{ {
REG_VNID(cellSysutilAvconfExt, 0x00000000u, g_gamma).init = [] REG_VAR(cellSysutilAvconfExt, g_gamma).flag(MFF_HIDDEN).init = []
{ {
// Test // Test
*g_gamma = 1.0f; *g_gamma = 1.0f;

View File

@ -1035,22 +1035,22 @@ DECLARE(ppu_module_manager::cellFs)("sys_fs", []()
REG_FUNC(sys_fs, cellFsChangeFileSizeWithoutAllocation); REG_FUNC(sys_fs, cellFsChangeFileSizeWithoutAllocation);
REG_FUNC(sys_fs, cellFsChmod); REG_FUNC(sys_fs, cellFsChmod);
REG_FUNC(sys_fs, cellFsChown); REG_FUNC(sys_fs, cellFsChown);
REG_FUNC(sys_fs, cellFsClose).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsClose).flag(MFF_PERFECT);
REG_FUNC(sys_fs, cellFsClosedir).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsClosedir).flag(MFF_PERFECT);
REG_FUNC(sys_fs, cellFsFcntl); REG_FUNC(sys_fs, cellFsFcntl);
REG_FUNC(sys_fs, cellFsFdatasync); REG_FUNC(sys_fs, cellFsFdatasync);
REG_FUNC(sys_fs, cellFsFGetBlockSize).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsFGetBlockSize).flag(MFF_PERFECT);
REG_FUNC(sys_fs, cellFsFGetBlockSize2); REG_FUNC(sys_fs, cellFsFGetBlockSize2);
REG_FUNC(sys_fs, cellFsFstat).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsFstat).flags = MFF_PERFECT;
REG_FUNC(sys_fs, cellFsFsync); REG_FUNC(sys_fs, cellFsFsync);
REG_FUNC(sys_fs, cellFsFtruncate).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsFtruncate).flag(MFF_PERFECT);
REG_FUNC(sys_fs, cellFsGetBlockSize); REG_FUNC(sys_fs, cellFsGetBlockSize);
REG_FUNC(sys_fs, cellFsGetBlockSize2); REG_FUNC(sys_fs, cellFsGetBlockSize2);
REG_FUNC(sys_fs, cellFsGetDirectoryEntries); REG_FUNC(sys_fs, cellFsGetDirectoryEntries);
REG_FUNC(sys_fs, cellFsGetFreeSize); REG_FUNC(sys_fs, cellFsGetFreeSize);
REG_FUNC(sys_fs, cellFsGetPath); REG_FUNC(sys_fs, cellFsGetPath);
REG_FUNC(sys_fs, cellFsLink); REG_FUNC(sys_fs, cellFsLink);
REG_FUNC(sys_fs, cellFsLseek).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsLseek).flag(MFF_PERFECT);
REG_FUNC(sys_fs, cellFsLsnGetCDA); REG_FUNC(sys_fs, cellFsLsnGetCDA);
REG_FUNC(sys_fs, cellFsLsnGetCDASize); REG_FUNC(sys_fs, cellFsLsnGetCDASize);
REG_FUNC(sys_fs, cellFsLsnLock); REG_FUNC(sys_fs, cellFsLsnLock);
@ -1063,8 +1063,8 @@ DECLARE(ppu_module_manager::cellFs)("sys_fs", []()
REG_FUNC(sys_fs, cellFsOpen); REG_FUNC(sys_fs, cellFsOpen);
REG_FUNC(sys_fs, cellFsOpen2); REG_FUNC(sys_fs, cellFsOpen2);
REG_FUNC(sys_fs, cellFsOpendir); REG_FUNC(sys_fs, cellFsOpendir);
REG_FUNC(sys_fs, cellFsRead).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsRead).flag(MFF_PERFECT);
REG_FUNC(sys_fs, cellFsReaddir).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsReaddir).flag(MFF_PERFECT);
REG_FUNC(sys_fs, cellFsReadWithOffset); REG_FUNC(sys_fs, cellFsReadWithOffset);
REG_FUNC(sys_fs, cellFsRegisterConversionCallback); REG_FUNC(sys_fs, cellFsRegisterConversionCallback);
REG_FUNC(sys_fs, cellFsRename); REG_FUNC(sys_fs, cellFsRename);
@ -1095,6 +1095,6 @@ DECLARE(ppu_module_manager::cellFs)("sys_fs", []()
REG_FUNC(sys_fs, cellFsUnlink); REG_FUNC(sys_fs, cellFsUnlink);
REG_FUNC(sys_fs, cellFsUnregisterL10nCallbacks); REG_FUNC(sys_fs, cellFsUnregisterL10nCallbacks);
REG_FUNC(sys_fs, cellFsUtime); REG_FUNC(sys_fs, cellFsUtime);
REG_FUNC(sys_fs, cellFsWrite).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsWrite).flag(MFF_PERFECT);
REG_FUNC(sys_fs, cellFsWriteWithOffset); REG_FUNC(sys_fs, cellFsWriteWithOffset);
}); });

View File

@ -1484,5 +1484,5 @@ DECLARE(ppu_module_manager::cellGcmSys)("cellGcmSys", []()
REG_FUNC(cellGcmSys, cellGcmGpadCaptureSnapshot); REG_FUNC(cellGcmSys, cellGcmGpadCaptureSnapshot);
// Special // Special
REG_FUNC(cellGcmSys, cellGcmCallback).flags = MFF_HIDDEN; REG_FUNC(cellGcmSys, cellGcmCallback).flag(MFF_HIDDEN);
}); });

View File

@ -1083,7 +1083,7 @@ s32 cellSaveDataUserGetListItem(u32 userId, vm::cptr<char> dirName, vm::ptr<Cell
void cellSysutil_SaveData_init() void cellSysutil_SaveData_init()
{ {
REG_VNID(cellSysutil, 0x00000000u, g_savedata_context); REG_VAR(cellSysutil, g_savedata_context).flag(MFF_HIDDEN);
// libsysutil functions: // libsysutil functions:
REG_FUNC(cellSysutil, cellSaveDataEnableOverlay); REG_FUNC(cellSysutil, cellSaveDataEnableOverlay);

View File

@ -66,5 +66,5 @@ error_code cellSpudllHandleConfigSetDefaultValues(vm::ptr<CellSpudllHandleConfig
DECLARE(ppu_module_manager::cellSpudll)("cellSpudll", []() DECLARE(ppu_module_manager::cellSpudll)("cellSpudll", []()
{ {
REG_FUNC(cellSpudll, cellSpudllGetImageSize); REG_FUNC(cellSpudll, cellSpudllGetImageSize);
REG_FUNC(cellSpudll, cellSpudllHandleConfigSetDefaultValues).flags = MFF_PERFECT; REG_FUNC(cellSpudll, cellSpudllHandleConfigSetDefaultValues).flag(MFF_PERFECT);
}); });

View File

@ -256,7 +256,7 @@ s32 cellVideoOutUnregisterCallback(u32 slot)
void cellSysutil_VideoOut_init() void cellSysutil_VideoOut_init()
{ {
REG_FUNC(cellSysutil, cellVideoOutGetState); REG_FUNC(cellSysutil, cellVideoOutGetState);
REG_FUNC(cellSysutil, cellVideoOutGetResolution).flags = MFF_PERFECT; REG_FUNC(cellSysutil, cellVideoOutGetResolution).flag(MFF_PERFECT);
REG_FUNC(cellSysutil, cellVideoOutConfigure); REG_FUNC(cellSysutil, cellVideoOutConfigure);
REG_FUNC(cellSysutil, cellVideoOutGetConfiguration); REG_FUNC(cellSysutil, cellVideoOutGetConfiguration);
REG_FUNC(cellSysutil, cellVideoOutGetDeviceInfo); REG_FUNC(cellSysutil, cellVideoOutGetDeviceInfo);

View File

@ -16,5 +16,5 @@ void sys_libc_memcpy(vm::ptr<void> dst, vm::cptr<void> src, u32 size)
DECLARE(ppu_module_manager::sys_libc)("sys_libc", []() DECLARE(ppu_module_manager::sys_libc)("sys_libc", []()
{ {
REG_FNID(sys_libc, "memcpy", sys_libc_memcpy).flags = MFF_FORCED_HLE; REG_FNID(sys_libc, "memcpy", sys_libc_memcpy).flag(MFF_FORCED_HLE);
}); });

View File

@ -266,12 +266,12 @@ error_code sys_interrupt_thread_disestablish(ppu_thread& ppu, u32 ih)
void sysPrxForUser_sys_ppu_thread_init() void sysPrxForUser_sys_ppu_thread_init()
{ {
// Private // Private
REG_VNID(sysPrxForUser, 0x00000000u, g_ppu_atexit_lwm); REG_VAR(sysPrxForUser, g_ppu_atexit_lwm).flag(MFF_HIDDEN);
REG_VNID(sysPrxForUser, 0x00000001u, g_ppu_once_mutex); REG_VAR(sysPrxForUser, g_ppu_once_mutex).flag(MFF_HIDDEN);
REG_VNID(sysPrxForUser, 0x00000002u, g_ppu_atexit); REG_VAR(sysPrxForUser, g_ppu_atexit).flag(MFF_HIDDEN);
REG_VNID(sysPrxForUser, 0x00000003u, g_ppu_prx_lwm); REG_VAR(sysPrxForUser, g_ppu_prx_lwm).flag(MFF_HIDDEN);
REG_FUNC(sysPrxForUser, sys_initialize_tls); REG_FUNC(sysPrxForUser, sys_initialize_tls).args = {"main_thread_id", "tls_seg_addr", "tls_seg_size", "tls_mem_size"}; // Test
REG_FUNC(sysPrxForUser, sys_ppu_thread_create); REG_FUNC(sysPrxForUser, sys_ppu_thread_create);
REG_FUNC(sysPrxForUser, sys_ppu_thread_get_id); REG_FUNC(sysPrxForUser, sys_ppu_thread_get_id);
REG_FUNC(sysPrxForUser, sys_ppu_thread_exit); REG_FUNC(sysPrxForUser, sys_ppu_thread_exit);

View File

@ -327,7 +327,7 @@ static void ppu_initialize_modules(const std::shared_ptr<ppu_linkage_info>& link
// Allocate HLE variable // Allocate HLE variable
if (variable.second.size >= 4096 || variable.second.align >= 4096) if (variable.second.size >= 4096 || variable.second.align >= 4096)
{ {
variable.second.var->set(vm::alloc(variable.second.size, vm::main, std::max<u32>(variable.second.align, 4096))); variable.second.addr = vm::alloc(variable.second.size, vm::main, std::max<u32>(variable.second.align, 4096));
} }
else else
{ {
@ -343,10 +343,15 @@ static void ppu_initialize_modules(const std::shared_ptr<ppu_linkage_info>& link
alloc_addr = next; alloc_addr = next;
} }
variable.second.var->set(alloc_addr); variable.second.addr = alloc_addr;
alloc_addr += variable.second.size; alloc_addr += variable.second.size;
} }
if (variable.second.var)
{
variable.second.var->set(variable.second.addr);
}
LOG_TRACE(LOADER, "Allocated HLE variable %s.%s at 0x%x", module->name, variable.second.name, variable.second.var->addr()); LOG_TRACE(LOADER, "Allocated HLE variable %s.%s at 0x%x", module->name, variable.second.name, variable.second.var->addr());
// Initialize HLE variable // Initialize HLE variable
@ -355,10 +360,13 @@ static void ppu_initialize_modules(const std::shared_ptr<ppu_linkage_info>& link
variable.second.init(); variable.second.init();
} }
auto& vlink = linkage.variables[variable.first]; if ((variable.second.flags & MFF_HIDDEN) == 0)
{
auto& vlink = linkage.variables[variable.first];
vlink.hle = true; vlink.hle = true;
vlink.export_addr = variable.second.var->addr(); vlink.export_addr = variable.second.var->addr();
}
} }
} }
} }

View File

@ -27,7 +27,7 @@ constexpr u32 ppu_generate_id(u32 id)
} }
// Flags set with REG_FUNC // Flags set with REG_FUNC
enum ppu_static_function_flags : u32 enum ppu_static_module_flags : u32
{ {
MFF_FORCED_HLE = (1 << 0), // Always call HLE function MFF_FORCED_HLE = (1 << 0), // Always call HLE function
MFF_PERFECT = (1 << 1), // Indicates complete implementation and LLE interchangeability MFF_PERFECT = (1 << 1), // Indicates complete implementation and LLE interchangeability
@ -40,6 +40,14 @@ struct ppu_static_function
const char* name; const char* name;
u32 index; // Index for ppu_function_manager u32 index; // Index for ppu_function_manager
u32 flags; u32 flags;
const char* type;
std::vector<const char*> args; // Arg names
ppu_static_function& flag(ppu_static_module_flags value)
{
flags |= value;
return *this;
}
}; };
// HLE variable information // HLE variable information
@ -50,6 +58,15 @@ struct ppu_static_variable
void(*init)(); // Variable initialization function void(*init)(); // Variable initialization function
u32 size; u32 size;
u32 align; u32 align;
const char* type;
u32 flags;
u32 addr;
ppu_static_variable& flag(ppu_static_module_flags value)
{
flags |= value;
return *this;
}
}; };
// HLE module information // HLE module information
@ -103,6 +120,7 @@ public:
info.name = name; info.name = name;
info.index = ppu_function_manager::register_function<T, Func>(func); info.index = ppu_function_manager::register_function<T, Func>(func);
info.flags = 0; info.flags = 0;
info.type = typeid(T).name();
return info; return info;
} }
@ -119,6 +137,9 @@ public:
info.init = [] {}; info.init = [] {};
info.size = SIZE_32(typename T::type); info.size = SIZE_32(typename T::type);
info.align = ALIGN_32(typename T::type); info.align = ALIGN_32(typename T::type);
info.type = typeid(T).name();
info.flags = 0;
info.addr = 0;
return info; return info;
} }