void Reset(bool _bHard) { CoreTiming::RemoveAllEvents(enque_reply); u32 i; for (i=0; i<IPC_MAX_FDS; i++) { if (g_FdMap[i] != NULL && !g_FdMap[i]->IsHardware()) { // close all files and delete their resources g_FdMap[i]->Close(0, true); delete g_FdMap[i]; } g_FdMap[i] = NULL; } u32 j; for (j=0; j<ES_MAX_COUNT; j++) { es_inuse[j] = false; } TDeviceMap::iterator itr = g_DeviceMap.begin(); while (itr != g_DeviceMap.end()) { if (itr->second) { // Force close itr->second->Close(0, true); // Hardware should not be deleted unless it is a hard reset if (_bHard) delete itr->second; } ++itr; } if (_bHard) { g_DeviceMap.erase(g_DeviceMap.begin(), g_DeviceMap.end()); } request_queue.clear(); // lock due to using reply_queue { std::lock_guard<std::mutex> lk(s_reply_queue); reply_queue.clear(); } last_reply_time = 0; }
void UpdateDevices() { // Check if a hardware device must be updated for (TDeviceMap::const_iterator itr = g_DeviceMap.begin(); itr != g_DeviceMap.end(); ++itr) { if (itr->second->IsOpened() && itr->second->Update()) { break; } } }
IWII_IPC_HLE_Device* GetDeviceByName(const std::string& _rDeviceName) { TDeviceMap::const_iterator itr = g_DeviceMap.begin(); while (itr != g_DeviceMap.end()) { if (itr->second && itr->second->GetDeviceName() == _rDeviceName) return itr->second; ++itr; } return NULL; }
void SetDefaultContentFile(const std::string& _rFilename) { TDeviceMap::const_iterator itr = g_DeviceMap.begin(); while (itr != g_DeviceMap.end()) { if (itr->second && itr->second->GetDeviceName().find(std::string("/dev/es")) == 0) { ((CWII_IPC_HLE_Device_es*)itr->second)->LoadWAD(_rFilename); } ++itr; } }
void Reset(bool _bHard) { CoreTiming::RemoveAllEvents(event_enqueue); for (IWII_IPC_HLE_Device*& dev : g_FdMap) { if (dev != nullptr && !dev->IsHardware()) { // close all files and delete their resources dev->Close(0, true); delete dev; } dev = nullptr; } for (bool& in_use : es_inuse) { in_use = false; } for (const auto& entry : g_DeviceMap) { if (entry.second) { // Force close entry.second->Close(0, true); // Hardware should not be deleted unless it is a hard reset if (_bHard) delete entry.second; } } if (_bHard) { g_DeviceMap.erase(g_DeviceMap.begin(), g_DeviceMap.end()); } request_queue.clear(); reply_queue.clear(); last_reply_time = 0; }
void DoState(PointerWrap &p) { std::lock_guard<std::mutex> lk(s_reply_queue); p.Do(request_queue); p.Do(reply_queue); p.Do(last_reply_time); TDeviceMap::const_iterator itr; itr = g_DeviceMap.begin(); while (itr != g_DeviceMap.end()) { if (itr->second->IsHardware()) { itr->second->DoState(p); } ++itr; } if (p.GetMode() == PointerWrap::MODE_READ) { u32 i; for (i=0; i<IPC_MAX_FDS; i++) { u32 exists = 0; p.Do(exists); if (exists) { u32 isHw = 0; p.Do(isHw); if (isHw) { u32 hwId = 0; p.Do(hwId); g_FdMap[i] = AccessDeviceByID(hwId); } else { g_FdMap[i] = new CWII_IPC_HLE_Device_FileIO(i, ""); g_FdMap[i]->DoState(p); } } else { g_FdMap[i] = NULL; } } for (i=0; i<ES_MAX_COUNT; i++) { p.Do(es_inuse[i]); u32 handleID = es_handles[i]->GetDeviceID(); p.Do(handleID); es_handles[i] = AccessDeviceByID(handleID); } } else { u32 i; for (i=0; i<IPC_MAX_FDS; i++) { u32 exists = g_FdMap[i] ? 1 : 0; p.Do(exists); if (exists) { u32 isHw = g_FdMap[i]->IsHardware() ? 1 : 0; p.Do(isHw); if (isHw) { u32 hwId = g_FdMap[i]->GetDeviceID(); p.Do(hwId); } else { g_FdMap[i]->DoState(p); } } } for (i=0; i<ES_MAX_COUNT; i++) { p.Do(es_inuse[i]); u32 handleID = es_handles[i]->GetDeviceID(); p.Do(handleID); } } }