mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-29 14:53:18 +00:00
Support mapping memory to device files
This commit is contained in:
parent
3dac1a2c6a
commit
8b5b34fdba
4 changed files with 18 additions and 0 deletions
|
@ -136,6 +136,7 @@ static auto UserPaths = [] {
|
|||
create_path(PathType::PatchesDir, user_dir / PATCHES_DIR);
|
||||
create_path(PathType::MetaDataDir, user_dir / METADATA_DIR);
|
||||
create_path(PathType::CustomTrophy, user_dir / CUSTOM_TROPHY);
|
||||
create_path(PathType::DevicesDir, user_dir / DEVICES_DIR);
|
||||
|
||||
std::ofstream notice_file(user_dir / CUSTOM_TROPHY / "Notice.txt");
|
||||
if (notice_file.is_open()) {
|
||||
|
|
|
@ -28,6 +28,7 @@ enum class PathType {
|
|||
PatchesDir, // Where patches are stored.
|
||||
MetaDataDir, // Where game metadata (e.g. trophies and menu backgrounds) is stored.
|
||||
CustomTrophy, // Where custom files for trophies are stored.
|
||||
DevicesDir, // Where temporary device files are located.
|
||||
};
|
||||
|
||||
constexpr auto PORTABLE_DIR = "user";
|
||||
|
@ -46,6 +47,7 @@ constexpr auto CHEATS_DIR = "cheats";
|
|||
constexpr auto PATCHES_DIR = "patches";
|
||||
constexpr auto METADATA_DIR = "game_data";
|
||||
constexpr auto CUSTOM_TROPHY = "custom_trophy";
|
||||
constexpr auto DEVICES_DIR = "device";
|
||||
|
||||
// Filenames
|
||||
constexpr auto LOG_FILE = "shad_log.txt";
|
||||
|
|
|
@ -91,6 +91,15 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
|||
file->type = Core::FileSys::FileType::Device;
|
||||
file->m_guest_name = path;
|
||||
file->device = factory(handle, path.data(), flags, mode);
|
||||
|
||||
// Some libraries map memory to their file. We need a host file to support this.
|
||||
file->m_host_name = mnt->GetHostPath(file->m_guest_name);
|
||||
bool exists = std::filesystem::exists(file->m_host_name);
|
||||
if (!exists) {
|
||||
Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write);
|
||||
}
|
||||
auto e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
|
||||
ASSERT(e == 0);
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,6 +245,12 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector<std::str
|
|||
}
|
||||
VideoCore::SetOutputDir(mount_captures_dir, id);
|
||||
|
||||
const auto& devices_dir = Common::FS::GetUserPath(Common::FS::PathType::DevicesDir);
|
||||
if (!std::filesystem::exists(devices_dir)) {
|
||||
std::filesystem::create_directory(devices_dir);
|
||||
}
|
||||
mnt->Mount(devices_dir, "/dev");
|
||||
|
||||
// Initialize kernel and library facilities.
|
||||
Libraries::InitHLELibs(&linker->GetHLESymbols());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue