1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 04:02:42 +01:00

Conflicts fixed

This commit is contained in:
Nekotekina 2014-08-22 18:30:39 +04:00
commit 7a466b7fb7
33 changed files with 397 additions and 162 deletions

View File

@ -3,7 +3,32 @@
#define rID_ANY -1 // was wxID_ANY
typedef u32 ID_TYPE;
enum IDType
{
// Special objects
TYPE_MEM,
TYPE_MUTEX,
TYPE_COND,
TYPE_RWLOCK,
TYPE_INTR_TAG,
TYPE_INTR_SERVICE_HANDLE,
TYPE_EVENT_QUEUE,
TYPE_EVENT_PORT,
TYPE_TRACE,
TYPE_SPUIMAGE,
TYPE_PRX,
TYPE_SPUPORT,
TYPE_LWMUTEX,
TYPE_TIMER,
TYPE_SEMAPHORE,
TYPE_FS_FILE,
TYPE_FS_DIR,
TYPE_LWCOND,
TYPE_EVENT_FLAG,
// Any other objects
TYPE_OTHER,
};
class IDData
{
@ -37,13 +62,13 @@ public:
struct ID
{
std::string m_name;
u32 m_attr;
IDData* m_data;
IDType m_type;
template<typename T>
ID(const std::string& name, T* data, const u32 attr)
ID(const std::string& name, T* data, const IDType type)
: m_name(name)
, m_attr(attr)
, m_type(type)
{
m_data = new IDData(data, [](void *ptr) -> void { delete (T*)ptr; });
}
@ -55,14 +80,14 @@ struct ID
ID(ID&& other)
{
m_name = other.m_name;
m_attr = other.m_attr;
m_type = other.m_type;
m_data = other.m_data;
other.m_data = nullptr;
}
ID& operator=(ID&& other)
{
std::swap(m_name,other.m_name);
std::swap(m_attr,other.m_attr);
std::swap(m_type,other.m_type);
std::swap(m_data,other.m_data);
return *this;
}
@ -75,13 +100,14 @@ struct ID
class IdManager
{
static const ID_TYPE s_first_id = 1;
static const ID_TYPE s_max_id = -1;
static const u32 s_first_id = 1;
static const u32 s_max_id = -1;
std::unordered_map<ID_TYPE, ID> m_id_map;
std::unordered_map<u32, ID> m_id_map;
std::set<u32> m_types[TYPE_OTHER];
std::mutex m_mtx_main;
ID_TYPE m_cur_id;
u32 m_cur_id;
public:
IdManager() : m_cur_id(s_first_id)
@ -93,7 +119,7 @@ public:
Clear();
}
bool CheckID(const ID_TYPE id)
bool CheckID(const u32 id)
{
std::lock_guard<std::mutex> lock(m_mtx_main);
@ -104,8 +130,7 @@ public:
{
std::lock_guard<std::mutex> lock(m_mtx_main);
for(auto& i : m_id_map)
{
for(auto& i : m_id_map) {
i.second.Kill();
}
@ -118,16 +143,19 @@ public:
= char
#endif
>
ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u32 attr = 0)
u32 GetNewID(const std::string& name = "", T* data = nullptr, const IDType type = TYPE_OTHER)
{
std::lock_guard<std::mutex> lock(m_mtx_main);
m_id_map[m_cur_id] = ID(name, data, attr);
m_id_map[m_cur_id] = ID(name, data, type);
if (type < TYPE_OTHER) {
m_types[type].insert(m_cur_id);
}
return m_cur_id++;
}
ID& GetID(const ID_TYPE id)
ID& GetID(const u32 id)
{
std::lock_guard<std::mutex> lock(m_mtx_main);
@ -135,14 +163,12 @@ public:
}
template<typename T>
bool GetIDData(const ID_TYPE id, T*& result)
bool GetIDData(const u32 id, T*& result)
{
std::lock_guard<std::mutex> lock(m_mtx_main);
auto f = m_id_map.find(id);
if(f == m_id_map.end())
{
if (f == m_id_map.end()) {
return false;
}
@ -156,24 +182,43 @@ public:
{
std::lock_guard<std::mutex> lock(m_mtx_main);
if(id == rID_ANY)
if(id == rID_ANY) {
return m_id_map.begin() != m_id_map.end();
}
}
return CheckID(id);
}
bool RemoveID(const ID_TYPE id)
bool RemoveID(const u32 id)
{
std::lock_guard<std::mutex> lock(m_mtx_main);
auto item = m_id_map.find(id);
if(item == m_id_map.end()) return false;
if (item == m_id_map.end()) {
return false;
}
if (item->second.m_type < TYPE_OTHER) {
m_types[item->second.m_type].erase(id);
}
item->second.Kill();
m_id_map.erase(item);
return true;
}
u32 GetTypeCount(IDType type)
{
if (type < TYPE_OTHER) {
return m_types[type].size();
}
return 1;
}
const std::set<u32>& GetTypeIDs(IDType type)
{
assert(type < TYPE_OTHER);
return m_types[type];
}
};

View File

@ -203,7 +203,7 @@ void GLGSRender::EnableVertexData(bool indexed_draw)
GL_FALSE,
};
if (m_vertex_data[i].type < 1 && m_vertex_data[i].type > 7) {
if (m_vertex_data[i].type < 1 || m_vertex_data[i].type > 7) {
LOG_ERROR(RSX, "GLGSRender::EnableVertexData: Bad vertex data type (%d)!", m_vertex_data[i].type);
}

View File

@ -90,23 +90,23 @@ public:
return true;
}
template<typename T> bool CheckId(u32 id, T*& data, u32& attr)
template<typename T> bool CheckId(u32 id, T*& data, IDType& type)
{
ID* id_data;
if(!CheckID(id, id_data)) return false;
data = id_data->m_data->get<T>();
attr = id_data->m_attr;
type = id_data->m_type;
return true;
}
bool CheckID(u32 id, ID*& _id) const;
template<typename T>
u32 GetNewId(T* data, u8 flags = 0)
u32 GetNewId(T* data, IDType type = TYPE_OTHER)
{
return Emu.GetIdManager().GetNewID<T>(GetName(), data, flags);
return Emu.GetIdManager().GetNewID<T>(GetName(), data, type);
}
template<typename T> __forceinline void AddFunc(u32 id, T func);

View File

@ -189,12 +189,15 @@ int _OEM2Wide(unsigned int oem_code, const std::string src, std::wstring& dst)
{
//Such length returned should include the '\0' character.
int length = MultiByteToWideChar(oem_code, 0, src.c_str(), -1, NULL, 0);
wchar_t *store = new wchar_t[length];
memset(store, 0, (length)*sizeof(wchar_t));
wchar_t *store = new wchar_t[length]();
MultiByteToWideChar(oem_code, 0, src.c_str(), -1, (LPWSTR)store, length);
std::wstring result(store);
dst = result;
delete store; store = NULL;
delete[] store;
store = nullptr;
return length - 1;
}
@ -203,12 +206,15 @@ int _Wide2OEM(unsigned int oem_code, const std::wstring src, std::string& dst)
{
//Such length returned should include the '\0' character.
int length = WideCharToMultiByte(oem_code, 0, src.c_str(), -1, NULL, 0, NULL, NULL);
char *store = new char[length];
memset(store, 0, (length)*sizeof(char));
char *store = new char[length]();
WideCharToMultiByte(oem_code, 0, src.c_str(), -1, store, length, NULL, NULL);
std::string result(store);
dst = result;
delete store; store = NULL;
delete[] store;
store = nullptr;
return length - 1;
}

View File

@ -128,7 +128,7 @@ int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
int ret = sdata_unpack(path, unpacked_path);
if (ret) return ret;
fd = sys_fs->GetNewId(Emu.GetVFS().OpenFile(unpacked_path, vfsRead), flags);
fd = sys_fs->GetNewId(Emu.GetVFS().OpenFile(unpacked_path, vfsRead), TYPE_FS_FILE);
return CELL_OK;*/

View File

@ -78,9 +78,9 @@ public:
}
template<typename T>
u32 GetNewId(T* data, u8 flags = 0)
u32 GetNewId(T* data, IDType type = TYPE_OTHER)
{
return Emu.GetIdManager().GetNewID<T>(GetName(), data, flags);
return Emu.GetIdManager().GetNewID<T>(GetName(), data, type);
}
};
@ -133,4 +133,4 @@ public:
static const u64 name ## _table[] = {__VA_ARGS__ , 0}; \
module->AddFuncSub(group, name ## _table, #name, name)
#define REG_FUNC(module, name) module->AddFunc(getFunctionId(#name), name)
#define REG_FUNC(module, name) module->AddFunc(getFunctionId(#name), name)

View File

@ -13,12 +13,6 @@
extern Module *sys_fs;
enum
{
IDFlag_File = 1,
IDFlag_Dir = 2,
};
struct FsRingBufferConfig
{
CellFsRingBuffer m_ring_buffer; // Currently unused after assignment
@ -117,7 +111,7 @@ s32 cellFsOpen(u32 path_addr, s32 flags, mem32_t fd, mem32_t arg, u64 size)
return CELL_ENOENT;
}
fd = sys_fs->GetNewId(stream, IDFlag_File);
fd = sys_fs->GetNewId(stream, TYPE_FS_FILE);
LOG_NOTICE(HLE, "\"%s\" opened: fd = %d", path.c_str(), fd.GetValue());
return CELL_OK;
@ -181,7 +175,7 @@ s32 cellFsOpendir(u32 path_addr, mem32_t fd)
return CELL_ENOENT;
}
fd = sys_fs->GetNewId(dir, IDFlag_Dir);
fd = sys_fs->GetNewId(dir, TYPE_FS_DIR);
return CELL_OK;
}
@ -263,9 +257,11 @@ s32 cellFsFstat(u32 fd, mem_ptr_t<CellFsStat> sb)
{
sys_fs->Log("cellFsFstat(fd=%d, sb_addr: 0x%x)", fd, sb.GetAddr());
u32 attr;
IDType type;
vfsStream* file;
if(!sys_fs->CheckId(fd, file, attr) || attr != IDFlag_File) return CELL_ESRCH;
if(!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) {
return CELL_ESRCH;
}
sb->st_mode =
CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR |
@ -398,9 +394,11 @@ s32 cellFsLseek(u32 fd, s64 offset, u32 whence, mem64_t pos)
return CELL_EINVAL;
}
u32 attr;
IDType type;
vfsStream* file;
if(!sys_fs->CheckId(fd, file, attr) || attr != IDFlag_File) return CELL_ESRCH;
if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) {
return CELL_ESRCH;
}
pos = file->Seek(offset, seek_mode);
return CELL_OK;
}
@ -408,9 +406,12 @@ s32 cellFsLseek(u32 fd, s64 offset, u32 whence, mem64_t pos)
s32 cellFsFtruncate(u32 fd, u64 size)
{
sys_fs->Log("cellFsFtruncate(fd=%d, size=%lld)", fd, size);
u32 attr;
IDType type;
vfsStream* file;
if(!sys_fs->CheckId(fd, file, attr) || attr != IDFlag_File) return CELL_ESRCH;
if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) {
return CELL_ESRCH;
}
u64 initialSize = file->GetSize();
if (initialSize < size)

View File

@ -32,7 +32,7 @@ s32 sys_cond_create(mem32_t cond_id, u32 mutex_id, mem_ptr_t<sys_cond_attribute>
}
Cond* cond = new Cond(mutex, attr->name_u64);
u32 id = sys_cond.GetNewId(cond);
u32 id = sys_cond.GetNewId(cond, TYPE_COND);
cond_id = id;
mutex->cond_count++;
sys_cond.Warning("*** condition created [%s] (mutex_id=%d): id = %d", std::string(attr->name, 8).c_str(), mutex_id, cond_id.GetValue());

View File

@ -50,7 +50,7 @@ s32 sys_event_queue_create(mem32_t equeue_id, mem_ptr_t<sys_event_queue_attr> at
return CELL_EAGAIN;
}
equeue_id = sys_event.GetNewId(eq);
equeue_id = sys_event.GetNewId(eq, TYPE_EVENT_QUEUE);
sys_event.Warning("*** event_queue created [%s] (protocol=0x%x, type=0x%x): id = %d",
std::string(attr->name, 8).c_str(), (u32)attr->protocol, (int)attr->type, equeue_id.GetValue());
@ -237,7 +237,7 @@ s32 sys_event_port_create(mem32_t eport_id, int port_type, u64 name)
}
EventPort* eport = new EventPort();
u32 id = sys_event.GetNewId(eport);
u32 id = sys_event.GetNewId(eport, TYPE_EVENT_PORT);
eport->name = name ? name : ((u64)sys_process_getpid() << 32) | (u64)id;
eport_id = id;
sys_event.Warning("*** sys_event_port created: id = %d", id);
@ -360,4 +360,4 @@ s32 sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
}
return CELL_OK;
}
}

View File

@ -36,7 +36,7 @@ s32 sys_event_flag_create(mem32_t eflag_id, mem_ptr_t<sys_event_flag_attr> attr,
default: return CELL_EINVAL;
}
eflag_id = sys_event_flag.GetNewId(new EventFlag(init, (u32)attr->protocol, (int)attr->type));
eflag_id = sys_event_flag.GetNewId(new EventFlag(init, (u32)attr->protocol, (int)attr->type), TYPE_EVENT_FLAG);
sys_event_flag.Warning("*** event_flag created [%s] (protocol=0x%x, type=0x%x): id = %d",
std::string(attr->name, 8).c_str(), (u32)attr->protocol, (int)attr->type, eflag_id.GetValue());

View File

@ -14,7 +14,7 @@ s32 sys_lwcond_create(mem_ptr_t<sys_lwcond_t> lwcond, mem_ptr_t<sys_lwmutex_t> l
sys_lwcond.Log("sys_lwcond_create(lwcond_addr=0x%x, lwmutex_addr=0x%x, attr_addr=0x%x)",
lwcond.GetAddr(), lwmutex.GetAddr(), attr.GetAddr());
u32 id = sys_lwcond.GetNewId(new Lwcond(attr->name_u64));
u32 id = sys_lwcond.GetNewId(new Lwcond(attr->name_u64), TYPE_LWCOND);
lwcond->lwmutex = lwmutex.GetAddr();
lwcond->lwcond_queue = id;

View File

@ -36,7 +36,7 @@ s32 sys_lwmutex_create(mem_ptr_t<sys_lwmutex_t> lwmutex, mem_ptr_t<sys_lwmutex_a
lwmutex->pad = 0;
lwmutex->recursive_count = 0;
u32 sq_id = sc_lwmutex.GetNewId(new SleepQueue(attr->name_u64));
u32 sq_id = sc_lwmutex.GetNewId(new SleepQueue(attr->name_u64), TYPE_LWMUTEX);
lwmutex->sleep_queue = sq_id;
sc_lwmutex.Warning("*** lwmutex created [%s] (attribute=0x%x): sq_id = %d",

View File

@ -122,7 +122,7 @@ s32 sys_memory_container_create(mem32_t cid, u32 yield_size)
// Wrap the allocated memory in a memory container.
MemoryContainerInfo *ct = new MemoryContainerInfo(addr, yield_size);
cid = sc_mem.GetNewId(ct);
cid = sc_mem.GetNewId(ct, TYPE_MEM);
sc_mem.Warning("*** memory_container created(addr=0x%llx): id = %d", addr, cid.GetValue());

View File

@ -121,7 +121,7 @@ s32 sys_mmapper_allocate_memory_from_container(u32 size, u32 cid, u64 flags, mem
ct->size = size;
// Generate a new mem ID.
mem_id = sys_mmapper.GetNewId(new mmapper_info(ct->addr, ct->size, flags));
mem_id = sys_mmapper.GetNewId(new mmapper_info(ct->addr, ct->size, flags), TYPE_MEM);
return CELL_OK;
}

View File

@ -55,7 +55,7 @@ s32 sys_mutex_create(mem32_t mutex_id, mem_ptr_t<sys_mutex_attribute> attr)
u32 tid = GetCurrentPPUThread().GetId();
Mutex* mutex = new Mutex((u32)attr->protocol, is_recursive, attr->name_u64);
u32 id = sys_mtx.GetNewId(mutex);
u32 id = sys_mtx.GetNewId(mutex, TYPE_MUTEX);
mutex->m_mutex.lock(tid);
mutex->id = id;
mutex_id = id;

View File

@ -8,8 +8,6 @@
SysCallBase sc_p("Process");
sysProcessObjects_t procObjects;
s32 process_getpid()
{
// TODO: get current process id
@ -147,23 +145,26 @@ s32 sys_process_get_number_of_object(u32 object, mem32_t nump)
switch(object)
{
case SYS_MEM_OBJECT: nump = procObjects.mem_objects.size(); break;
case SYS_MUTEX_OBJECT: nump = procObjects.mutex_objects.size(); break;
case SYS_COND_OBJECT: nump = procObjects.cond_objects.size(); break;
case SYS_RWLOCK_OBJECT: nump = procObjects.rwlock_objects.size(); break;
case SYS_INTR_TAG_OBJECT: nump = procObjects.intr_tag_objects.size(); break;
case SYS_INTR_SERVICE_HANDLE_OBJECT: nump = procObjects.intr_service_handle_objects.size(); break;
case SYS_EVENT_QUEUE_OBJECT: nump = procObjects.event_queue_objects.size(); break;
case SYS_EVENT_PORT_OBJECT: nump = procObjects.event_port_objects.size(); break;
case SYS_TRACE_OBJECT: nump = procObjects.trace_objects.size(); break;
case SYS_SPUIMAGE_OBJECT: nump = procObjects.spuimage_objects.size(); break;
case SYS_PRX_OBJECT: nump = procObjects.prx_objects.size(); break;
case SYS_SPUPORT_OBJECT: nump = procObjects.spuport_objects.size(); break;
case SYS_LWMUTEX_OBJECT: nump = procObjects.lwmutex_objects.size(); break;
case SYS_TIMER_OBJECT: nump = procObjects.timer_objects.size(); break;
case SYS_SEMAPHORE_OBJECT: nump = procObjects.semaphore_objects.size(); break;
case SYS_FS_FD_OBJECT: nump = procObjects.fs_fd_objects.size(); break;
case SYS_LWCOND_OBJECT: nump = procObjects.lwcond_objects.size(); break;
case SYS_MEM_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_MEM); break;
case SYS_MUTEX_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_MUTEX); break;
case SYS_COND_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_COND); break;
case SYS_RWLOCK_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_RWLOCK); break;
case SYS_INTR_TAG_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_INTR_TAG); break;
case SYS_INTR_SERVICE_HANDLE_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_INTR_SERVICE_HANDLE); break;
case SYS_EVENT_QUEUE_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_QUEUE); break;
case SYS_EVENT_PORT_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_PORT); break;
case SYS_TRACE_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_TRACE); break;
case SYS_SPUIMAGE_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_SPUIMAGE); break;
case SYS_PRX_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_PRX); break;
case SYS_SPUPORT_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_SPUPORT); break;
case SYS_LWMUTEX_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_LWMUTEX); break;
case SYS_TIMER_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_TIMER); break;
case SYS_SEMAPHORE_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_SEMAPHORE); break;
case SYS_LWCOND_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_LWCOND); break;
case SYS_EVENT_FLAG_OBJECT: nump = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_FLAG); break;
case SYS_FS_FD_OBJECT:
nump = Emu.GetIdManager().GetTypeCount(TYPE_FS_FILE) + Emu.GetIdManager().GetTypeCount(TYPE_FS_DIR);
break;
default:
return CELL_EINVAL;
@ -180,31 +181,32 @@ s32 sys_process_get_id(u32 object, mem32_ptr_t buffer, u32 size, mem32_t set_siz
switch(object)
{
#define ADD_OBJECTS(objects) { \
#define ADD_OBJECTS(type) { \
u32 i=0; \
const auto& objects = Emu.GetIdManager().GetTypeIDs(type); \
for(auto id=objects.begin(); i<size && id!=objects.end(); id++, i++) \
buffer[i] = *id; \
set_size = i; \
}
case SYS_MEM_OBJECT: ADD_OBJECTS(procObjects.mem_objects); break;
case SYS_MUTEX_OBJECT: ADD_OBJECTS(procObjects.mutex_objects); break;
case SYS_COND_OBJECT: ADD_OBJECTS(procObjects.cond_objects); break;
case SYS_RWLOCK_OBJECT: ADD_OBJECTS(procObjects.rwlock_objects); break;
case SYS_INTR_TAG_OBJECT: ADD_OBJECTS(procObjects.intr_tag_objects); break;
case SYS_INTR_SERVICE_HANDLE_OBJECT: ADD_OBJECTS(procObjects.intr_service_handle_objects); break;
case SYS_EVENT_QUEUE_OBJECT: ADD_OBJECTS(procObjects.event_queue_objects); break;
case SYS_EVENT_PORT_OBJECT: ADD_OBJECTS(procObjects.event_port_objects); break;
case SYS_TRACE_OBJECT: ADD_OBJECTS(procObjects.trace_objects); break;
case SYS_SPUIMAGE_OBJECT: ADD_OBJECTS(procObjects.spuimage_objects); break;
case SYS_PRX_OBJECT: ADD_OBJECTS(procObjects.prx_objects); break;
case SYS_SPUPORT_OBJECT: ADD_OBJECTS(procObjects.spuport_objects); break;
case SYS_LWMUTEX_OBJECT: ADD_OBJECTS(procObjects.lwmutex_objects); break;
case SYS_TIMER_OBJECT: ADD_OBJECTS(procObjects.timer_objects); break;
case SYS_SEMAPHORE_OBJECT: ADD_OBJECTS(procObjects.semaphore_objects); break;
case SYS_FS_FD_OBJECT: ADD_OBJECTS(procObjects.fs_fd_objects); break;
case SYS_LWCOND_OBJECT: ADD_OBJECTS(procObjects.lwcond_objects); break;
case SYS_EVENT_FLAG_OBJECT: ADD_OBJECTS(procObjects.event_flag_objects); break;
case SYS_MEM_OBJECT: ADD_OBJECTS(TYPE_MEM); break;
case SYS_MUTEX_OBJECT: ADD_OBJECTS(TYPE_MUTEX); break;
case SYS_COND_OBJECT: ADD_OBJECTS(TYPE_COND); break;
case SYS_RWLOCK_OBJECT: ADD_OBJECTS(TYPE_RWLOCK); break;
case SYS_INTR_TAG_OBJECT: ADD_OBJECTS(TYPE_INTR_TAG); break;
case SYS_INTR_SERVICE_HANDLE_OBJECT: ADD_OBJECTS(TYPE_INTR_SERVICE_HANDLE); break;
case SYS_EVENT_QUEUE_OBJECT: ADD_OBJECTS(TYPE_EVENT_QUEUE); break;
case SYS_EVENT_PORT_OBJECT: ADD_OBJECTS(TYPE_EVENT_PORT); break;
case SYS_TRACE_OBJECT: ADD_OBJECTS(TYPE_TRACE); break;
case SYS_SPUIMAGE_OBJECT: ADD_OBJECTS(TYPE_SPUIMAGE); break;
case SYS_PRX_OBJECT: ADD_OBJECTS(TYPE_PRX); break;
case SYS_SPUPORT_OBJECT: ADD_OBJECTS(TYPE_SPUPORT); break;
case SYS_LWMUTEX_OBJECT: ADD_OBJECTS(TYPE_LWMUTEX); break;
case SYS_TIMER_OBJECT: ADD_OBJECTS(TYPE_TIMER); break;
case SYS_SEMAPHORE_OBJECT: ADD_OBJECTS(TYPE_SEMAPHORE); break;
case SYS_FS_FD_OBJECT: ADD_OBJECTS(TYPE_FS_FILE);/*TODO:DIR*/ break;
case SYS_LWCOND_OBJECT: ADD_OBJECTS(TYPE_LWCOND); break;
case SYS_EVENT_FLAG_OBJECT: ADD_OBJECTS(TYPE_EVENT_FLAG); break;
#undef ADD_OBJECTS

View File

@ -23,34 +23,6 @@ enum
SYS_EVENT_FLAG_OBJECT = (0x98UL),
};
// Datatypes
// TODO: Would it be better if improved the existing IDManager, instead of creating this datatype?
// Another option would be improving SysCallBase::GetNewId
struct sysProcessObjects_t
{
std::set<u32> mem_objects;
std::set<u32> mutex_objects;
std::set<u32> cond_objects;
std::set<u32> rwlock_objects;
std::set<u32> intr_tag_objects;
std::set<u32> intr_service_handle_objects;
std::set<u32> event_queue_objects;
std::set<u32> event_port_objects;
std::set<u32> trace_objects;
std::set<u32> spuimage_objects;
std::set<u32> prx_objects;
std::set<u32> spuport_objects;
std::set<u32> lwmutex_objects;
std::set<u32> timer_objects;
std::set<u32> semaphore_objects;
std::set<u32> fs_fd_objects;
std::set<u32> lwcond_objects;
std::set<u32> event_flag_objects;
};
// Extern
extern sysProcessObjects_t procObjects;
// Auxiliary functions
s32 process_getpid();
s32 process_get_sdk_version(u32 pid, s32& ver);

View File

@ -4,6 +4,7 @@
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/FS/vfsFile.h"
#include "Crypto/unself.h"
#include "sys_prx.h"
SysCallBase sys_prx("sys_prx");
@ -13,19 +14,31 @@ s32 sys_prx_load_module(u32 path_addr, u64 flags, mem_ptr_t<sys_prx_load_module_
std::string path = Memory.ReadString(path_addr);
sys_prx.Todo("sys_prx_load_module(path=\"%s\", flags=0x%llx, pOpt=0x%x)", path.c_str(), flags, pOpt.GetAddr());
// Check if the file is SPRX
std::string local_path;
Emu.GetVFS().GetDevice(path, local_path);
if (IsSelf(local_path)) {
if (!DecryptSelf(local_path+".prx", local_path)) {
return CELL_PRX_ERROR_ILLEGAL_LIBRARY;
}
path += ".prx";
}
vfsFile f(path);
if (!f.IsOpened()) {
return CELL_PRX_ERROR_UNKNOWN_MODULE;
}
// Load the PRX into memory
u64 prx_size = f.GetSize();
u32 prx_address = Memory.Alloc(prx_size, 4);
f.Read(Memory.VirtualToRealAddr(prx_address), prx_size);
// Create the PRX object and return its id
sys_prx_t* prx = new sys_prx_t(prx_size, prx_address);
u32 id = sys_prx.GetNewId(prx);
sys_prx_t* prx = new sys_prx_t();
prx->size = f.GetSize();
prx->address = Memory.Alloc(prx->size, 4);
prx->path = path;
// Load the PRX into memory
f.Read(Memory.VirtualToRealAddr(prx->address), prx->size);
u32 id = sys_prx.GetNewId(prx, TYPE_PRX);
return id;
}

View File

@ -51,15 +51,15 @@ struct sys_prx_unload_module_option_t
};
// Auxiliary data types
struct sys_prx_t {
struct sys_prx_t
{
u32 size;
u32 address;
std::string path;
bool isStarted;
sys_prx_t(u32 prx_size, u32 prx_address)
: size(prx_size)
, address(prx_address)
, isStarted(false)
sys_prx_t()
: isStarted(false)
{
}
};

View File

@ -28,7 +28,7 @@ s32 sys_rwlock_create(mem32_t rw_lock_id, mem_ptr_t<sys_rwlock_attribute_t> attr
return CELL_EINVAL;
}
rw_lock_id = sys_rwlock.GetNewId(new RWLock((u32)attr->attr_protocol, attr->name_u64));
rw_lock_id = sys_rwlock.GetNewId(new RWLock((u32)attr->attr_protocol, attr->name_u64), TYPE_RWLOCK);
sys_rwlock.Warning("*** rwlock created [%s] (protocol=0x%x): id = %d",
std::string(attr->name, 8).c_str(), (u32)attr->attr_protocol, rw_lock_id.GetValue());

View File

@ -35,7 +35,7 @@ s32 sys_semaphore_create(mem32_t sem, mem_ptr_t<sys_semaphore_attribute> attr, i
default: sys_sem.Error("Unknown protocol attribute(0x%x)", (u32)attr->protocol); return CELL_EINVAL;
}
sem = sys_sem.GetNewId(new Semaphore(initial_count, max_count, attr->protocol, attr->name_u64));
sem = sys_sem.GetNewId(new Semaphore(initial_count, max_count, attr->protocol, attr->name_u64), TYPE_SEMAPHORE);
LOG_NOTICE(HLE, "*** semaphore created [%s] (protocol=0x%x): id = %d",
std::string(attr->name, 8).c_str(), (u32)attr->protocol, sem.GetValue());

View File

@ -11,7 +11,7 @@ s32 sys_timer_create(mem32_t timer_id)
{
sys_timer.Warning("sys_timer_create(timer_id_addr=0x%x)", timer_id.GetAddr());
timer_id = sys_timer.GetNewId(new timer);
timer_id = sys_timer.GetNewId(new timer, TYPE_TIMER);
return CELL_OK;
}

View File

@ -0,0 +1,167 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "KernelExplorer.h"
KernelExplorer::KernelExplorer(wxWindow* parent)
: wxFrame(parent, wxID_ANY, "Kernel Explorer", wxDefaultPosition, wxSize(700, 450))
{
this->SetBackgroundColour(wxColour(240,240,240)); //This fix the ugly background color under Windows
wxBoxSizer* s_panel = new wxBoxSizer(wxVERTICAL);
// Buttons
wxBoxSizer* box_buttons = new wxBoxSizer(wxHORIZONTAL);
wxButton* b_refresh = new wxButton(this, wxID_ANY, "Refresh");
box_buttons->AddSpacer(10);
box_buttons->Add(b_refresh);
box_buttons->AddSpacer(10);
wxStaticBoxSizer* box_tree = new wxStaticBoxSizer(wxHORIZONTAL, this, "Kernel");
m_tree = new wxTreeCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(600,300));
box_tree->Add(m_tree);
// Merge and display everything
s_panel->AddSpacer(10);
s_panel->Add(box_buttons);
s_panel->AddSpacer(10);
s_panel->Add(box_tree, 0, 0, 100);
s_panel->AddSpacer(10);
SetSizerAndFit(s_panel);
// Events
b_refresh->Bind(wxEVT_BUTTON, &KernelExplorer::OnRefresh, this);
// Fill the wxTreeCtrl
Update();
};
void KernelExplorer::Update()
{
int count;
char name[4096];
m_tree->DeleteAllItems();
const auto& root = m_tree->AddRoot("Process, ID = 0x00000001, Total Memory Usage = 0x???????? (???.? MB)");
// TODO: PPU Threads
// TODO: SPU/RawSPU Threads
// TODO: FileSystem
// Semaphores
count = Emu.GetIdManager().GetTypeCount(TYPE_SEMAPHORE);
if (count) {
sprintf(name, "Semaphores (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_SEMAPHORE);
for (const auto& id : objects) {
sprintf(name, "Semaphore: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// Mutexes
count = Emu.GetIdManager().GetTypeCount(TYPE_MUTEX);
if (count) {
sprintf(name, "Mutexes (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_MUTEX);
for (const auto& id : objects) {
sprintf(name, "Mutex: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// Light Weight Mutexes
count = Emu.GetIdManager().GetTypeCount(TYPE_LWMUTEX);
if (count) {
sprintf(name, "Light Weight Mutexes (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_LWMUTEX);
for (const auto& id : objects) {
sprintf(name, "LW Mutex: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// Condition Variables
count = Emu.GetIdManager().GetTypeCount(TYPE_COND);
if (count) {
sprintf(name, "Condition Variables (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_COND);
for (const auto& id : objects) {
sprintf(name, "Condition Variable: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// Light Weight Condition Variables
count = Emu.GetIdManager().GetTypeCount(TYPE_LWCOND);
if (count) {
sprintf(name, "Light Weight Condition Variables (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_LWCOND);
for (const auto& id : objects) {
sprintf(name, "LW Condition Variable: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// Event Queues
count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_QUEUE);
if (count) {
sprintf(name, "Event Queues (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_QUEUE);
for (const auto& id : objects) {
sprintf(name, "Event Queue: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// Modules
count = Emu.GetIdManager().GetTypeCount(TYPE_PRX);
if (count) {
sprintf(name, "Modules (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_PRX);
sprintf(name, "Segment List (%d)", 2 * objects.size()); // TODO: Assuming 2 segments per PRX file is not good
m_tree->AppendItem(node, name);
for (const auto& id : objects) {
sprintf(name, "PRX: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// Memory Containers
count = Emu.GetIdManager().GetTypeCount(TYPE_MEM);
if (count) {
sprintf(name, "Memory Containers (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_MEM);
for (const auto& id : objects) {
sprintf(name, "Memory Container: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// Event Flags
count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_FLAG);
if (count) {
sprintf(name, "Event Flags (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_FLAG);
for (const auto& id : objects) {
sprintf(name, "Event Flag: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
m_tree->Expand(root);
}
void KernelExplorer::OnRefresh(wxCommandEvent& WXUNUSED(event))
{
Update();
}

View File

@ -0,0 +1,14 @@
#pragma once
#include <wx/treectrl.h>
class KernelExplorer : public wxFrame
{
wxTreeCtrl* m_tree;
public:
KernelExplorer(wxWindow* parent);
void Update();
void OnRefresh(wxCommandEvent& WXUNUSED(event));
};

View File

@ -4,20 +4,22 @@
#include "Emu/System.h"
#include "rpcs3.h"
#include "MainFrame.h"
#include "CompilerELF.h"
#include "MemoryViewer.h"
#include "RSXDebugger.h"
#include "PADManager.h"
#include "git-version.h"
#include "Ini.h"
#include "Emu/RSX/sysutil_video.h"
#include "Gui/PADManager.h"
#include "Gui/VHDDManager.h"
#include "Gui/VFSManager.h"
#include "Gui/AboutDialog.h"
#include "Gui/GameViewer.h"
#include "Gui/CompilerELF.h"
#include "Gui/AutoPauseManager.h"
#include "Gui/SaveDataUtility.h"
#include "Gui/KernelExplorer.h"
#include "Gui/MemoryViewer.h"
#include "Gui/RSXDebugger.h"
#include <wx/dynlib.h>
#include "Loader/PKG.h"
@ -42,6 +44,7 @@ enum IDs
id_config_autopause_manager,
id_config_savedata_manager,
id_tools_compiler,
id_tools_kernel_explorer,
id_tools_memory_viewer,
id_tools_rsx_debugger,
id_help_about,
@ -98,6 +101,7 @@ MainFrame::MainFrame()
wxMenu* menu_tools = new wxMenu();
menubar->Append(menu_tools, "Tools");
menu_tools->Append(id_tools_compiler, "ELF Compiler");
menu_tools->Append(id_tools_kernel_explorer, "Kernel Explorer")->Enable(false);
menu_tools->Append(id_tools_memory_viewer, "Memory Viewer")->Enable(false);
menu_tools->Append(id_tools_rsx_debugger, "RSX Debugger")->Enable(false);
@ -134,6 +138,7 @@ MainFrame::MainFrame()
Bind(wxEVT_MENU, &MainFrame::ConfigSaveData, this, id_config_savedata_manager);
Bind(wxEVT_MENU, &MainFrame::OpenELFCompiler, this, id_tools_compiler);
Bind(wxEVT_MENU, &MainFrame::OpenKernelExplorer, this, id_tools_kernel_explorer);
Bind(wxEVT_MENU, &MainFrame::OpenMemoryViewer, this, id_tools_memory_viewer);
Bind(wxEVT_MENU, &MainFrame::OpenRSXDebugger, this, id_tools_rsx_debugger);
@ -635,6 +640,11 @@ void MainFrame::OpenELFCompiler(wxCommandEvent& WXUNUSED(event))
(new CompilerELF(this)) -> Show();
}
void MainFrame::OpenKernelExplorer(wxCommandEvent& WXUNUSED(event))
{
(new KernelExplorer(this)) -> Show();
}
void MainFrame::OpenMemoryViewer(wxCommandEvent& WXUNUSED(event))
{
(new MemoryViewerPanel(this)) -> Show();
@ -732,8 +742,10 @@ void MainFrame::UpdateUI(wxCommandEvent& event)
send_exit.Enable(enable_commands);
// Tools
wxMenuItem& memory_viewer = *menubar.FindItem( id_tools_memory_viewer );
wxMenuItem& rsx_debugger = *menubar.FindItem( id_tools_rsx_debugger);
wxMenuItem& kernel_explorer = *menubar.FindItem(id_tools_kernel_explorer);
wxMenuItem& memory_viewer = *menubar.FindItem(id_tools_memory_viewer);
wxMenuItem& rsx_debugger = *menubar.FindItem(id_tools_rsx_debugger);
kernel_explorer.Enable(!is_stopped);
memory_viewer.Enable(!is_stopped);
rsx_debugger.Enable(!is_stopped);

View File

@ -41,6 +41,7 @@ private:
void ConfigAutoPause(wxCommandEvent& event);
void ConfigSaveData(wxCommandEvent& event);
void OpenELFCompiler(wxCommandEvent& evt);
void OpenKernelExplorer(wxCommandEvent& evt);
void OpenMemoryViewer(wxCommandEvent& evt);
void OpenRSXDebugger(wxCommandEvent& evt);
void OpenFnIdGenerator(wxCommandEvent& evt);

View File

@ -141,29 +141,24 @@ void Ini::Save(const std::string& section, const std::string& key, WindowInfo va
int Ini::Load(const std::string& section, const std::string& key, const int def_value)
{
return m_Config->GetLongValue(section.c_str(), key.c_str(), def_value);
saveIniFile();
}
bool Ini::Load(const std::string& section, const std::string& key, const bool def_value)
{
return StringToBool(m_Config->GetValue(section.c_str(), key.c_str(), BoolToString(def_value).c_str()));
saveIniFile();
}
std::pair<int, int> Ini::Load(const std::string& section, const std::string& key, const std::pair<int, int> def_value)
{
return StringToSize(m_Config->GetValue(section.c_str(), key.c_str(), SizeToString(def_value).c_str()));
saveIniFile();
}
std::string Ini::Load(const std::string& section, const std::string& key, const std::string& def_value)
{
return std::string(m_Config->GetValue(section.c_str(), key.c_str(), def_value.c_str()));
saveIniFile();
}
WindowInfo Ini::Load(const std::string& section, const std::string& key, const WindowInfo& def_value)
{
return StringToWindowInfo(m_Config->GetValue(section.c_str(), key.c_str(), WindowInfoToString(def_value).c_str()));
saveIniFile();
}

View File

@ -5,10 +5,9 @@
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/SC_FUNC.h"
#include "Emu/SysCalls/Modules.h"
#include "ELF64.h"
#include "Emu/Cell/PPUInstrTable.h"
#include "Emu/System.h"
#include "Emu/SysCalls/ModuleManager.h"
#include "ELF64.h"
using namespace PPU_instr;

View File

@ -218,7 +218,6 @@
<ItemGroup>
<ClInclude Include="..\Utilities\AutoPause.h" />
<ClInclude Include="..\Utilities\BEType.h" />
<ClInclude Include="..\Utilities\IdManager.h" />
<ClInclude Include="..\Utilities\MTRingbuffer.h" />
<ClInclude Include="..\Utilities\rFile.h" />
<ClInclude Include="..\Utilities\Log.h" />
@ -291,6 +290,7 @@
<ClInclude Include="Emu\FS\vfsStreamMemory.h" />
<ClInclude Include="Emu\GameInfo.h" />
<ClInclude Include="Emu\HDD\HDD.h" />
<ClInclude Include="Emu\IdManager.h" />
<ClInclude Include="Emu\Io\Keyboard.h" />
<ClInclude Include="Emu\Io\KeyboardHandler.h" />
<ClInclude Include="Emu\Io\Mouse.h" />

View File

@ -937,9 +937,6 @@
<ClInclude Include="..\Utilities\BEType.h">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="..\Utilities\IdManager.h">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="..\Utilities\SMutex.h">
<Filter>Utilities</Filter>
</ClInclude>
@ -1158,6 +1155,9 @@
</ClInclude>
<ClInclude Include="Emu\SysCalls\Modules\cellL10n.h">
<Filter>Emu\SysCalls\Modules</Filter>
</ClInclude>
<ClInclude Include="Emu\IdManager.h">
<Filter>Emu</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -173,6 +173,7 @@
<ClCompile Include="Gui\GLGSFrame.cpp" />
<ClCompile Include="Gui\GSFrame.cpp" />
<ClCompile Include="Gui\InterpreterDisAsm.cpp" />
<ClCompile Include="Gui\KernelExplorer.cpp" />
<ClCompile Include="Gui\MainFrame.cpp" />
<ClCompile Include="Gui\MemoryViewer.cpp" />
<ClCompile Include="Gui\PADManager.cpp" />
@ -218,6 +219,7 @@
<ClInclude Include="Gui\GLGSFrame.h" />
<ClInclude Include="Gui\GSFrame.h" />
<ClInclude Include="Gui\InterpreterDisAsm.h" />
<ClInclude Include="Gui\KernelExplorer.h" />
<ClInclude Include="Gui\MainFrame.h" />
<ClInclude Include="Gui\MemoryViewer.h" />
<ClInclude Include="Gui\RegisterEditor.h" />

View File

@ -101,6 +101,9 @@
</ClCompile>
<ClCompile Include="Gui\SaveDataUtility.cpp">
<Filter>Gui</Filter>
</ClCompile>
<ClCompile Include="Gui\KernelExplorer.cpp">
<Filter>Gui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@ -214,6 +217,9 @@
</ClInclude>
<ClInclude Include="Gui\SaveDataUtility.h">
<Filter>Gui</Filter>
</ClInclude>
<ClInclude Include="Gui\KernelExplorer.h">
<Filter>Gui</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -60,7 +60,7 @@ typedef int64_t s64;
#include "Utilities/BEType.h"
#include "Utilities/rFile.h"
#include "Utilities/Thread.h"
#include "Utilities/IdManager.h"
#include "Emu/IdManager.h"
#define _PRGNAME_ "RPCS3"
#define _PRGVER_ "0.0.0.5"