Fixed Pokepark 2! Maybe... :D Don't trust save states, although I think they are correct. File fd's were too large. Let me know if file related loading stops working in some games. fds are many to 1, not 1 to 1. ES has two instances available at a time. Sadly a clean up requires changing IWII_IPC_HLE_Device Constructor, as a deviceID doesn't make much sense per device. I won't do this until we have less branches :|

This commit is contained in:
Matthew Parlane
2012-03-18 21:00:23 +13:00
parent 0ed8af2287
commit 6fe495e1aa
5 changed files with 268 additions and 172 deletions
File diff suppressed because it is too large Load Diff
+7 -8
View File
@@ -25,9 +25,9 @@ class IWII_IPC_HLE_Device;
namespace WII_IPC_HLE_Interface
{
#define IPC_FIRST_HARDWARE_ID 0 // first IPC device ID
#define IPC_FIRST_FILEIO_ID 33 // first IPC file ID
#define IPC_FIRST_ID 0x00 // first IPC device ID
#define IPC_MAX_FILES 0x10 // first IPC file ID
// Init
void Init();
@@ -46,14 +46,13 @@ void ES_DIVerify(u8 *_pTMD, u32 _sz);
void SDIO_EventNotify();
int GetDeviceIDByName(const std::string& _rDeviceName);
IWII_IPC_HLE_Device* AccessDeviceByID(u32 _ID);
void DeleteDeviceByID(u32 _ID);
IWII_IPC_HLE_Device* CreateFileIO(u32 _DeviceID, const std::string& _rDeviceName);
IWII_IPC_HLE_Device* GetDeviceByName(const std::string& _rDeviceName);
IWII_IPC_HLE_Device* AccessDeviceByID(u32 _ID);
int getFreeDeviceId();
// Update
void Update();
@@ -39,7 +39,7 @@ class PointerWrap;
#define FS_ENOENT2 (u32)-106 // File not found
#define FS_ENFILE (u32)-107 // Too many fds open
#define FS_EFBIG (u32)-108 // max block count reached?
#define FS_ENFILE2 (u32)-109 // Too many fds open
#define FS_EFDEXHAUSTED (u32)-109 // Too many fds open
#define FS_ENAMELEN (u32)-110 // pathname is too long
#define FS_EFDOPEN (u32)-111 // FD is already open
#define FS_EIO2 (u32)-114 // returned on ECC error
@@ -47,6 +47,7 @@ class PointerWrap;
#define FS_EDIRDEPTH (u32)-116 // max directory depth exceeded
#define FS_EBUSY2 (u32)-118 // Resource busy
//#define FS_EFATAL (u32)-119 // fatal error not used by IOS as fatal ERROR
#define FS_EESEXHAUSTED (u32)-1016 // Max of 2 ES handles at a time
class IWII_IPC_HLE_Device
{
@@ -28,7 +28,7 @@
static Common::replace_v replacements;
// This is used by several of the FileIO and /dev/fs/ functions
// This is used by several of the FileIO and /dev/fs functions
std::string HLE_IPC_BuildFilename(const char* _pFilename, int _size)
{
std::string path_full = File::GetUserPath(D_WIIROOT_IDX);
@@ -128,7 +128,7 @@ bool CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
// The file must exist before we can open it
// It should be created by ISFS_CreateFile, not here
if(File::Exists(m_Filename))
if (File::Exists(m_Filename))
{
INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s == %08X)", m_Name.c_str(), Modes[_Mode], _Mode);
ReturnValue = m_DeviceID;
@@ -149,21 +149,22 @@ bool CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
bool CWII_IPC_HLE_Device_FileIO::OpenFile()
{
switch(m_Mode)
switch (m_Mode)
{
case ISFS_OPEN_READ:
{
m_pFileHandle.Open(m_Filename, "rb");
break;
// "r+b" is technically wrong, but OPEN_WRITE should not truncate the file as "wb" does.
}
case ISFS_OPEN_WRITE:
m_pFileHandle.Open(m_Filename, "r+b");
break;
case ISFS_OPEN_RW:
{
m_pFileHandle.Open(m_Filename, "r+b");
break;
}
default:
PanicAlertT("FileIO: Unknown open mode : 0x%02x", m_Mode);
break;
@@ -178,21 +179,21 @@ void CWII_IPC_HLE_Device_FileIO::CloseFile()
bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
{
u32 ReturnValue = FS_RESULT_FATAL;
const s32 SeekPosition = Memory::Read_U32(_CommandAddress + 0xC);
const s32 Mode = Memory::Read_U32(_CommandAddress + 0x10);
u32 ReturnValue = FS_RESULT_FATAL;
const s32 SeekPosition = Memory::Read_U32(_CommandAddress + 0xC);
const s32 Mode = Memory::Read_U32(_CommandAddress + 0x10);
if(OpenFile())
if (OpenFile())
{
ReturnValue = FS_RESULT_FATAL;
const u64 fileSize = m_pFileHandle.GetSize();
const u64 fileSize = m_pFileHandle.GetSize();
INFO_LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08llx)", SeekPosition, Mode, m_Name.c_str(), fileSize);
switch(Mode){
switch (Mode){
case 0:
{
if(SeekPosition >=0 && SeekPosition <= fileSize)
if (SeekPosition >=0 && SeekPosition <= fileSize)
{
m_SeekPos = SeekPosition;
ReturnValue = m_SeekPos;
@@ -202,7 +203,7 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
case 1:
{
s32 wantedPos = SeekPosition+m_SeekPos;
if(wantedPos >=0 && wantedPos <= fileSize)
if (wantedPos >=0 && wantedPos <= fileSize)
{
m_SeekPos = wantedPos;
ReturnValue = m_SeekPos;
@@ -212,7 +213,7 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
case 2:
{
s32 wantedPos = fileSize+m_SeekPos;
if(wantedPos >=0 && wantedPos <= fileSize)
if (wantedPos >=0 && wantedPos <= fileSize)
{
m_SeekPos = wantedPos;
ReturnValue = m_SeekPos;
@@ -244,7 +245,7 @@ bool CWII_IPC_HLE_Device_FileIO::Read(u32 _CommandAddress)
const u32 Size = Memory::Read_U32(_CommandAddress + 0x10);
if(OpenFile())
if (OpenFile())
{
if (m_Mode == ISFS_OPEN_WRITE)
{
@@ -284,7 +285,7 @@ bool CWII_IPC_HLE_Device_FileIO::Write(u32 _CommandAddress)
const u32 Size = Memory::Read_U32(_CommandAddress + 0x10);
if(OpenFile())
if (OpenFile())
{
if (m_Mode == ISFS_OPEN_READ)
{
@@ -318,21 +319,14 @@ bool CWII_IPC_HLE_Device_FileIO::IOCtl(u32 _CommandAddress)
#if defined(_DEBUG) || defined(DEBUGFAST)
DumpCommands(_CommandAddress);
#endif
const u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC);
const u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC);
u32 ReturnValue = 0;
//u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
//u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
//u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
//u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
// Return Value
u32 ReturnValue = 0; // no error
switch(Parameter)
switch (Parameter)
{
case ISFS_IOCTL_GETFILESTATS:
{
if(OpenFile())
if (OpenFile())
{
u32 m_FileLength = (u32)m_pFileHandle.GetSize();
@@ -37,7 +37,7 @@ public:
virtual bool Close(u32 _CommandAddress, bool _bForce);
virtual bool IOCtlV(u32 _CommandAddress);
u32 ES_DIVerify(u8 *_pTMD, u32 _sz);
static u32 ES_DIVerify(u8 *_pTMD, u32 _sz);
private:
enum