mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Io: Open sce_lbn references and whole ISO faster.
This commit is contained in:
parent
91427c1f4e
commit
49abe9ed6c
@ -108,8 +108,8 @@ int BlobFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 out
|
||||
return -1;
|
||||
}
|
||||
|
||||
int BlobFileSystem::DevType(u32 handle) {
|
||||
return PSP_DEV_TYPE_FILE;
|
||||
PSPDevType BlobFileSystem::DevType(u32 handle) {
|
||||
return PSPDevType::FILE;
|
||||
}
|
||||
|
||||
bool BlobFileSystem::MkDir(const std::string &dirname) {
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
PSPFileInfo GetFileInfo(std::string filename) override;
|
||||
bool OwnsHandle(u32 handle) override;
|
||||
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
|
||||
int DevType(u32 handle) override;
|
||||
PSPDevType DevType(u32 handle) override;
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::FLASH; }
|
||||
|
||||
bool MkDir(const std::string &dirname) override;
|
||||
|
@ -663,8 +663,8 @@ int DirectoryFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u3
|
||||
return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int DirectoryFileSystem::DevType(u32 handle) {
|
||||
return PSP_DEV_TYPE_FILE;
|
||||
PSPDevType DirectoryFileSystem::DevType(u32 handle) {
|
||||
return PSPDevType::FILE;
|
||||
}
|
||||
|
||||
size_t DirectoryFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size) {
|
||||
@ -1121,8 +1121,8 @@ int VFSFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outd
|
||||
return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int VFSFileSystem::DevType(u32 handle) {
|
||||
return PSP_DEV_TYPE_FILE;
|
||||
PSPDevType VFSFileSystem::DevType(u32 handle) {
|
||||
return PSPDevType::FILE;
|
||||
}
|
||||
|
||||
size_t VFSFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size) {
|
||||
|
@ -20,8 +20,7 @@
|
||||
// TODO: Remove the Windows-specific code, FILE is fine there too.
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "../Core/FileSystems/FileSystem.h"
|
||||
#include "Core/FileSystems/FileSystem.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef void * HANDLE;
|
||||
@ -102,7 +101,7 @@ public:
|
||||
PSPFileInfo GetFileInfo(std::string filename) override;
|
||||
bool OwnsHandle(u32 handle) override;
|
||||
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
|
||||
int DevType(u32 handle) override;
|
||||
PSPDevType DevType(u32 handle) override;
|
||||
|
||||
bool MkDir(const std::string &dirname) override;
|
||||
bool RmDir(const std::string &dirname) override;
|
||||
@ -147,7 +146,7 @@ public:
|
||||
PSPFileInfo GetFileInfo(std::string filename) override;
|
||||
bool OwnsHandle(u32 handle) override;
|
||||
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
|
||||
int DevType(u32 handle) override;
|
||||
PSPDevType DevType(u32 handle) override;
|
||||
|
||||
bool MkDir(const std::string &dirname) override;
|
||||
bool RmDir(const std::string &dirname) override;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#include "Core/HLE/sceKernel.h"
|
||||
|
||||
@ -44,11 +45,15 @@ enum FileType {
|
||||
FILETYPE_DIRECTORY = 2
|
||||
};
|
||||
|
||||
enum DevType {
|
||||
PSP_DEV_TYPE_BLOCK = 0x04,
|
||||
PSP_DEV_TYPE_FILE = 0x10,
|
||||
PSP_DEV_TYPE_ALIAS = 0x20,
|
||||
enum class PSPDevType {
|
||||
INVALID = 0,
|
||||
BLOCK = 0x04,
|
||||
FILE = 0x10,
|
||||
ALIAS = 0x20,
|
||||
EMU_MASK = 0xFF,
|
||||
EMU_LBN = 0x10000,
|
||||
};
|
||||
ENUM_CLASS_BITOPS(PSPDevType);
|
||||
|
||||
enum class FileSystemFlags {
|
||||
NONE = 0,
|
||||
@ -57,13 +62,7 @@ enum class FileSystemFlags {
|
||||
CARD = 4,
|
||||
FLASH = 8,
|
||||
};
|
||||
|
||||
inline FileSystemFlags operator |(const FileSystemFlags &lhs, const FileSystemFlags &rhs) {
|
||||
return FileSystemFlags((int)lhs | (int)rhs);
|
||||
}
|
||||
inline bool operator &(const FileSystemFlags &lhs, const FileSystemFlags &rhs) {
|
||||
return ((int)lhs & (int)rhs) != 0;
|
||||
}
|
||||
ENUM_CLASS_BITOPS(FileSystemFlags);
|
||||
|
||||
class IHandleAllocator {
|
||||
public:
|
||||
@ -136,7 +135,7 @@ public:
|
||||
virtual bool RemoveFile(const std::string &filename) = 0;
|
||||
virtual bool GetHostPath(const std::string &inpath, std::string &outpath) = 0;
|
||||
virtual int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) = 0;
|
||||
virtual int DevType(u32 handle) = 0;
|
||||
virtual PSPDevType DevType(u32 handle) = 0;
|
||||
virtual FileSystemFlags Flags() = 0;
|
||||
virtual u64 FreeSpace(const std::string &path) = 0;
|
||||
};
|
||||
@ -162,7 +161,7 @@ public:
|
||||
virtual bool RemoveFile(const std::string &filename) override {return false;}
|
||||
virtual bool GetHostPath(const std::string &inpath, std::string &outpath) override {return false;}
|
||||
virtual int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override {return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED; }
|
||||
virtual int DevType(u32 handle) override { return 0; }
|
||||
virtual PSPDevType DevType(u32 handle) override { return PSPDevType::INVALID; }
|
||||
virtual FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
|
||||
virtual u64 FreeSpace(const std::string &path) override { return 0; }
|
||||
};
|
||||
|
@ -461,10 +461,12 @@ int ISOFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outd
|
||||
return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int ISOFileSystem::DevType(u32 handle)
|
||||
{
|
||||
PSPDevType ISOFileSystem::DevType(u32 handle) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
return iter->second.isBlockSectorMode ? PSP_DEV_TYPE_BLOCK : PSP_DEV_TYPE_FILE;
|
||||
PSPDevType type = iter->second.isBlockSectorMode ? PSPDevType::BLOCK : PSPDevType::FILE;
|
||||
if (iter->second.isRawSector)
|
||||
type |= PSPDevType::EMU_LBN;
|
||||
return type;
|
||||
}
|
||||
|
||||
FileSystemFlags ISOFileSystem::Flags() {
|
||||
@ -613,6 +615,7 @@ PSPFileInfo ISOFileSystem::GetFileInfo(std::string filename) {
|
||||
PSPFileInfo fileInfo;
|
||||
fileInfo.name = filename;
|
||||
fileInfo.exists = true;
|
||||
fileInfo.type = FILETYPE_NORMAL;
|
||||
fileInfo.size = readSize;
|
||||
fileInfo.startSector = sectorStart;
|
||||
fileInfo.isOnSectorSystem = true;
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
PSPFileInfo GetFileInfo(std::string filename) override;
|
||||
bool OwnsHandle(u32 handle) override;
|
||||
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
|
||||
int DevType(u32 handle) override;
|
||||
PSPDevType DevType(u32 handle) override;
|
||||
FileSystemFlags Flags() override;
|
||||
u64 FreeSpace(const std::string &path) override { return 0; }
|
||||
|
||||
@ -134,7 +134,7 @@ public:
|
||||
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override {
|
||||
return isoFileSystem_->Ioctl(handle, cmd, indataPtr, inlen, outdataPtr, outlen, usec);
|
||||
}
|
||||
int DevType(u32 handle) override {
|
||||
PSPDevType DevType(u32 handle) override {
|
||||
return isoFileSystem_->DevType(handle);
|
||||
}
|
||||
FileSystemFlags Flags() override { return isoFileSystem_->Flags(); }
|
||||
|
@ -538,13 +538,13 @@ int MetaFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 out
|
||||
return SCE_KERNEL_ERROR_ERROR;
|
||||
}
|
||||
|
||||
int MetaFileSystem::DevType(u32 handle)
|
||||
PSPDevType MetaFileSystem::DevType(u32 handle)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
IFileSystem *sys = GetHandleOwner(handle);
|
||||
if (sys)
|
||||
return sys->DevType(handle);
|
||||
return SCE_KERNEL_ERROR_ERROR;
|
||||
return PSPDevType::INVALID;
|
||||
}
|
||||
|
||||
void MetaFileSystem::CloseFile(u32 handle)
|
||||
|
@ -118,7 +118,7 @@ public:
|
||||
int RenameFile(const std::string &from, const std::string &to) override;
|
||||
bool RemoveFile(const std::string &filename) override;
|
||||
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
|
||||
int DevType(u32 handle) override;
|
||||
PSPDevType DevType(u32 handle) override;
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::NONE; }
|
||||
u64 FreeSpace(const std::string &path) override;
|
||||
|
||||
|
@ -552,9 +552,9 @@ int VirtualDiscFileSystem::Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen,
|
||||
return SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int VirtualDiscFileSystem::DevType(u32 handle) {
|
||||
PSPDevType VirtualDiscFileSystem::DevType(u32 handle) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
return iter->second.type == VFILETYPE_ISO ? PSP_DEV_TYPE_BLOCK : PSP_DEV_TYPE_FILE;
|
||||
return iter->second.type == VFILETYPE_ISO ? PSPDevType::BLOCK : PSPDevType::FILE;
|
||||
}
|
||||
|
||||
PSPFileInfo VirtualDiscFileSystem::GetFileInfo(std::string filename) {
|
||||
@ -569,6 +569,7 @@ PSPFileInfo VirtualDiscFileSystem::GetFileInfo(std::string filename) {
|
||||
PSPFileInfo fileInfo;
|
||||
fileInfo.name = filename;
|
||||
fileInfo.exists = true;
|
||||
fileInfo.type = FILETYPE_NORMAL;
|
||||
fileInfo.size = readSize;
|
||||
fileInfo.startSector = sectorStart;
|
||||
fileInfo.isOnSectorSystem = true;
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
PSPFileInfo GetFileInfo(std::string filename) override;
|
||||
bool OwnsHandle(u32 handle) override;
|
||||
int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override;
|
||||
int DevType(u32 handle) override;
|
||||
PSPDevType DevType(u32 handle) override;
|
||||
bool GetHostPath(const std::string &inpath, std::string &outpath) override;
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path) override;
|
||||
FileSystemFlags Flags() override { return FileSystemFlags::UMD; }
|
||||
|
@ -1245,7 +1245,7 @@ static u32 sceIoWriteAsync(int id, u32 data_addr, int size) {
|
||||
static u32 sceIoGetDevType(int id) {
|
||||
if (id == PSP_STDOUT || id == PSP_STDERR || id == PSP_STDIN) {
|
||||
DEBUG_LOG(SCEIO, "sceIoGetDevType(%d)", id);
|
||||
return PSP_DEV_TYPE_FILE;
|
||||
return (u32)PSPDevType::FILE;
|
||||
}
|
||||
|
||||
u32 error;
|
||||
@ -1254,7 +1254,7 @@ static u32 sceIoGetDevType(int id) {
|
||||
if (f) {
|
||||
// TODO: When would this return PSP_DEV_TYPE_ALIAS?
|
||||
WARN_LOG(SCEIO, "sceIoGetDevType(%d - %s)", id, f->fullpath.c_str());
|
||||
result = pspFileSystem.DevType(f->handle);
|
||||
result = (u32)pspFileSystem.DevType(f->handle) & (u32)PSPDevType::EMU_MASK;
|
||||
} else {
|
||||
ERROR_LOG(SCEIO, "sceIoGetDevType: unknown id %d", id);
|
||||
result = SCE_KERNEL_ERROR_BADF;
|
||||
@ -1496,6 +1496,11 @@ static u32 sceIoOpen(const char *filename, int flags, int mode) {
|
||||
return hleLogError(SCEIO, hleDelayResult(id, "file opened", 1000), "out of fds");
|
||||
} else {
|
||||
asyncParams[id].priority = asyncDefaultPriority;
|
||||
IFileSystem *sys = pspFileSystem.GetSystemFromFilename(filename);
|
||||
if (sys && (sys->DevType(f->handle) & (PSPDevType::BLOCK | PSPDevType::EMU_LBN))) {
|
||||
// These are fast to open, no delay or even rescheduling happens.
|
||||
return hleLogSuccessI(SCEIO, id);
|
||||
}
|
||||
// UMD: Speed varies from 1-6ms.
|
||||
// Card: Path depth matters, but typically between 10-13ms on a standard Pro Duo.
|
||||
int delay = pspFileSystem.FlagsFromFilename(filename) & FileSystemFlags::UMD ? 4000 : 10000;
|
||||
@ -2712,11 +2717,20 @@ static int IoAsyncFinish(int id) {
|
||||
case IoAsyncOp::OPEN:
|
||||
{
|
||||
// See notes on timing in sceIoOpen.
|
||||
FileSystemFlags flags = pspFileSystem.FlagsFromFilename(Memory::GetCharPointer(params.open.filenameAddr));
|
||||
if (f->asyncResult == (int)SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND)
|
||||
us = flags & FileSystemFlags::UMD ? 6000 : 10000;
|
||||
else
|
||||
us = flags & FileSystemFlags::UMD ? 4000 : 10000;
|
||||
const std::string filename = Memory::GetCharPointer(params.open.filenameAddr);
|
||||
IFileSystem *sys = pspFileSystem.GetSystemFromFilename(filename);
|
||||
if (sys) {
|
||||
if (f->asyncResult == (int)SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND) {
|
||||
us = sys->Flags() & FileSystemFlags::UMD ? 6000 : 10000;
|
||||
} else if (sys->DevType(f->handle) & (PSPDevType::BLOCK | PSPDevType::EMU_LBN)) {
|
||||
// These are fast to open, no delay or even rescheduling happens.
|
||||
us = 80;
|
||||
} else {
|
||||
us = sys->Flags() & FileSystemFlags::UMD ? 4000 : 10000;
|
||||
}
|
||||
} else {
|
||||
us = 80;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "GPU/Common/ShaderCommon.h"
|
||||
|
||||
struct CardboardSettings {
|
||||
@ -59,17 +60,7 @@ enum class OutputFlags {
|
||||
BACKBUFFER_FLIPPED = 0x0004,
|
||||
POSITION_FLIPPED = 0x0008,
|
||||
};
|
||||
|
||||
inline OutputFlags operator | (const OutputFlags &lhs, const OutputFlags &rhs) {
|
||||
return OutputFlags((int)lhs | (int)rhs);
|
||||
}
|
||||
inline OutputFlags operator |= (OutputFlags &lhs, const OutputFlags &rhs) {
|
||||
lhs = lhs | rhs;
|
||||
return lhs;
|
||||
}
|
||||
inline bool operator & (const OutputFlags &lhs, const OutputFlags &rhs) {
|
||||
return ((int)lhs & (int)rhs) != 0;
|
||||
}
|
||||
ENUM_CLASS_BITOPS(OutputFlags);
|
||||
|
||||
class PresentationCommon {
|
||||
public:
|
||||
|
@ -36,14 +36,7 @@ enum class BrowseFlags {
|
||||
HOMEBREW_STORE = 8,
|
||||
STANDARD = 1 | 2 | 4,
|
||||
};
|
||||
|
||||
static inline BrowseFlags operator |(const BrowseFlags &lhs, const BrowseFlags &rhs) {
|
||||
return BrowseFlags((int)lhs | (int)rhs);
|
||||
}
|
||||
|
||||
static inline bool operator &(const BrowseFlags &lhs, const BrowseFlags &rhs) {
|
||||
return ((int)lhs & (int)rhs) != 0;
|
||||
}
|
||||
ENUM_CLASS_BITOPS(BrowseFlags);
|
||||
|
||||
class GameBrowser : public UI::LinearLayout {
|
||||
public:
|
||||
|
@ -928,7 +928,7 @@ namespace MainWindow {
|
||||
u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ, "");
|
||||
// Note: len may be in blocks.
|
||||
size_t len = pspFileSystem.SeekFile(handle, 0, FILEMOVE_END);
|
||||
bool isBlockMode = pspFileSystem.DevType(handle) == PSP_DEV_TYPE_BLOCK;
|
||||
bool isBlockMode = pspFileSystem.DevType(handle) & PSPDevType::BLOCK;
|
||||
|
||||
FILE *fp = File::OpenCFile(fn, "wb");
|
||||
pspFileSystem.SeekFile(handle, 0, FILEMOVE_BEGIN);
|
||||
|
@ -14,6 +14,20 @@
|
||||
void operator =(const t &other) = delete;
|
||||
#endif
|
||||
|
||||
#ifndef ENUM_CLASS_BITOPS
|
||||
#define ENUM_CLASS_BITOPS(T) \
|
||||
static inline T operator |(const T &lhs, const T &rhs) { \
|
||||
return T((int)lhs | (int)rhs); \
|
||||
} \
|
||||
static inline T &operator |= (T &lhs, const T &rhs) { \
|
||||
lhs = lhs | rhs; \
|
||||
return lhs; \
|
||||
} \
|
||||
static inline bool operator &(const T &lhs, const T &rhs) { \
|
||||
return ((int)lhs & (int)rhs) != 0; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
typedef intptr_t ssize_t;
|
||||
|
Loading…
Reference in New Issue
Block a user