mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-30 07:13:18 +00:00
Merge branch 'main' into miscFixes2
This commit is contained in:
commit
8ce6ed4b59
72 changed files with 1677 additions and 324 deletions
|
@ -28,7 +28,7 @@ constexpr VAddr USER_MAX = 0xFBFFFFFFFFULL;
|
|||
// User area size is normally larger than this. However games are unlikely to map to high
|
||||
// regions of that area, so by default we allocate a smaller virtual address space (about 1/4th).
|
||||
// to save space on page tables.
|
||||
static constexpr size_t UserSize = 1ULL << 38;
|
||||
static constexpr size_t UserSize = 1ULL << 39;
|
||||
static constexpr size_t SystemSize = USER_MIN - SYSTEM_MANAGED_MIN;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include "common/string_util.h"
|
||||
#include "core/file_sys/fs.h"
|
||||
|
||||
namespace Core::FileSys {
|
||||
|
@ -13,6 +14,7 @@ void MntPoints::Mount(const std::filesystem::path& host_folder, const std::strin
|
|||
|
||||
MntPair pair;
|
||||
pair.host_path = host_folder.string();
|
||||
std::replace(pair.host_path.begin(), pair.host_path.end(), '\\', '/');
|
||||
pair.guest_path = guest_folder;
|
||||
|
||||
m_mnt_pairs.push_back(pair);
|
||||
|
@ -50,11 +52,24 @@ std::string MntPoints::GetHostFile(const std::string& guest_file) {
|
|||
for (auto& pair : m_mnt_pairs) {
|
||||
// horrible code but it works :D
|
||||
int find = guest_file.find(pair.guest_path);
|
||||
if (find == 0) {
|
||||
std::string npath = guest_file.substr(pair.guest_path.size(), guest_file.size() - 1);
|
||||
std::replace(pair.host_path.begin(), pair.host_path.end(), '\\', '/');
|
||||
return pair.host_path + npath;
|
||||
if (find != 0) {
|
||||
continue;
|
||||
}
|
||||
std::string npath = guest_file.substr(pair.guest_path.size(), guest_file.size() - 1);
|
||||
const auto host_path = pair.host_path + npath;
|
||||
#ifndef _WIN64
|
||||
const std::filesystem::path path{host_path};
|
||||
if (!std::filesystem::exists(path)) {
|
||||
const auto filename = Common::ToLower(path.filename());
|
||||
for (const auto& file : std::filesystem::directory_iterator(path.parent_path())) {
|
||||
const auto exist_filename = Common::ToLower(file.path().filename());
|
||||
if (filename == exist_filename) {
|
||||
return file.path();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return host_path;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -803,9 +803,9 @@ int PS4_SYSV_ABI sceGnmDrawOpaqueAuto() {
|
|||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceGnmDriverCaptureInProgress() {
|
||||
LOG_ERROR(Lib_GnmDriver, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
bool PS4_SYSV_ABI sceGnmDriverCaptureInProgress() {
|
||||
LOG_TRACE(Lib_GnmDriver, "called");
|
||||
return false;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceGnmDriverInternalRetrieveGnmInterface() {
|
||||
|
@ -1962,7 +1962,7 @@ s32 PS4_SYSV_ABI sceGnmSubmitCommandBuffers(u32 count, const u32* dcb_gpu_addrs[
|
|||
if (Config::dumpPM4()) {
|
||||
static auto last_frame_num = -1LL;
|
||||
static u32 seq_num{};
|
||||
if (last_frame_num == frames_submitted) {
|
||||
if (last_frame_num == frames_submitted && cbpair == 0) {
|
||||
++seq_num;
|
||||
} else {
|
||||
last_frame_num = frames_submitted;
|
||||
|
|
|
@ -63,7 +63,7 @@ u32 PS4_SYSV_ABI sceGnmDrawInitDefaultHardwareState350(u32* cmdbuf, u32 size);
|
|||
u32 PS4_SYSV_ABI sceGnmDrawInitToDefaultContextState(u32* cmdbuf, u32 size);
|
||||
u32 PS4_SYSV_ABI sceGnmDrawInitToDefaultContextState400(u32* cmdbuf, u32 size);
|
||||
int PS4_SYSV_ABI sceGnmDrawOpaqueAuto();
|
||||
int PS4_SYSV_ABI sceGnmDriverCaptureInProgress();
|
||||
bool PS4_SYSV_ABI sceGnmDriverCaptureInProgress();
|
||||
int PS4_SYSV_ABI sceGnmDriverInternalRetrieveGnmInterface();
|
||||
int PS4_SYSV_ABI sceGnmDriverInternalRetrieveGnmInterfaceForGpuDebugger();
|
||||
int PS4_SYSV_ABI sceGnmDriverInternalRetrieveGnmInterfaceForGpuException();
|
||||
|
|
|
@ -161,7 +161,6 @@ s32 PS4_SYSV_ABI sceKernelMapFlexibleMemory(void** addr_in_out, std::size_t len,
|
|||
}
|
||||
|
||||
int PS4_SYSV_ABI sceKernelQueryMemoryProtection(void* addr, void** start, void** end, u32* prot) {
|
||||
LOG_WARNING(Kernel_Vmm, "called");
|
||||
auto* memory = Core::Memory::Instance();
|
||||
return memory->QueryProtection(std::bit_cast<VAddr>(addr), start, end, prot);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <semaphore.h>
|
||||
#include "common/alignment.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/error.h"
|
||||
#include "common/logging/log.h"
|
||||
|
@ -16,6 +17,8 @@
|
|||
#include "core/linker.h"
|
||||
#ifdef _WIN64
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
namespace Libraries::Kernel {
|
||||
|
@ -46,7 +49,8 @@ void init_pthreads() {
|
|||
}
|
||||
|
||||
void pthreadInitSelfMainThread() {
|
||||
g_pthread_self = new PthreadInternal{};
|
||||
auto* pthread_pool = g_pthread_cxt->GetPthreadPool();
|
||||
g_pthread_self = pthread_pool->Create();
|
||||
scePthreadAttrInit(&g_pthread_self->attr);
|
||||
g_pthread_self->pth = pthread_self();
|
||||
g_pthread_self->name = "Main_Thread";
|
||||
|
@ -926,31 +930,25 @@ int PS4_SYSV_ABI scePthreadCreate(ScePthread* thread, const ScePthreadAttr* attr
|
|||
if ((*thread)->attr != nullptr) {
|
||||
scePthreadAttrDestroy(&(*thread)->attr);
|
||||
}
|
||||
|
||||
scePthreadAttrInit(&(*thread)->attr);
|
||||
|
||||
int result = pthread_copy_attributes(&(*thread)->attr, attr);
|
||||
ASSERT(result == 0);
|
||||
|
||||
if (result == 0) {
|
||||
if (name != NULL) {
|
||||
(*thread)->name = name;
|
||||
} else {
|
||||
(*thread)->name = "no-name";
|
||||
}
|
||||
(*thread)->entry = start_routine;
|
||||
(*thread)->arg = arg;
|
||||
(*thread)->is_almost_done = false;
|
||||
(*thread)->is_detached = (*attr)->detached;
|
||||
(*thread)->is_started = false;
|
||||
|
||||
result = pthread_create(&(*thread)->pth, &(*attr)->pth_attr, run_thread, *thread);
|
||||
if (name != NULL) {
|
||||
(*thread)->name = name;
|
||||
} else {
|
||||
(*thread)->name = "no-name";
|
||||
}
|
||||
(*thread)->entry = start_routine;
|
||||
(*thread)->arg = arg;
|
||||
(*thread)->is_almost_done = false;
|
||||
(*thread)->is_detached = (*attr)->detached;
|
||||
(*thread)->is_started = false;
|
||||
|
||||
pthread_attr_setstacksize(&(*attr)->pth_attr, 2_MB);
|
||||
result = pthread_create(&(*thread)->pth, &(*attr)->pth_attr, run_thread, *thread);
|
||||
|
||||
if (result == 0) {
|
||||
while (!(*thread)->is_started) {
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(1000));
|
||||
}
|
||||
}
|
||||
LOG_INFO(Kernel_Pthread, "thread create name = {}", (*thread)->name);
|
||||
|
||||
switch (result) {
|
||||
|
@ -979,7 +977,16 @@ ScePthread PThreadPool::Create() {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
auto* ret = new PthreadInternal{};
|
||||
#else
|
||||
// TODO: Linux specific hack
|
||||
static u8* hint_address = reinterpret_cast<u8*>(0x7FFFFC000ULL);
|
||||
auto* ret = reinterpret_cast<PthreadInternal*>(
|
||||
mmap(hint_address, sizeof(PthreadInternal), PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0));
|
||||
hint_address += Common::AlignUp(sizeof(PthreadInternal), 4_KB);
|
||||
#endif
|
||||
|
||||
ret->is_free = false;
|
||||
ret->is_detached = false;
|
||||
|
|
|
@ -129,7 +129,11 @@ public:
|
|||
const auto end = std::chrono::high_resolution_clock::now();
|
||||
const auto time =
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
|
||||
*timeout -= time;
|
||||
if (status == std::cv_status::timeout) {
|
||||
*timeout = 0;
|
||||
} else {
|
||||
*timeout -= time;
|
||||
}
|
||||
return GetResult(status == std::cv_status::timeout);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -420,6 +420,7 @@ s32 saveDataMount(u32 user_id, char* dir_name, u32 mount_mode,
|
|||
switch (mount_mode) {
|
||||
case ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY:
|
||||
case ORBIS_SAVE_DATA_MOUNT_MODE_RDWR:
|
||||
case ORBIS_SAVE_DATA_MOUNT_MODE_RDWR | ORBIS_SAVE_DATA_MOUNT_MODE_DESTRUCT_OFF:
|
||||
case ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY | ORBIS_SAVE_DATA_MOUNT_MODE_DESTRUCT_OFF: {
|
||||
if (!std::filesystem::exists(mount_dir)) {
|
||||
return ORBIS_SAVE_DATA_ERROR_NOT_FOUND;
|
||||
|
@ -432,6 +433,8 @@ s32 saveDataMount(u32 user_id, char* dir_name, u32 mount_mode,
|
|||
case ORBIS_SAVE_DATA_MOUNT_MODE_CREATE:
|
||||
case ORBIS_SAVE_DATA_MOUNT_MODE_CREATE | ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY:
|
||||
case ORBIS_SAVE_DATA_MOUNT_MODE_CREATE | ORBIS_SAVE_DATA_MOUNT_MODE_RDWR:
|
||||
case ORBIS_SAVE_DATA_MOUNT_MODE_CREATE | ORBIS_SAVE_DATA_MOUNT_MODE_RDWR |
|
||||
ORBIS_SAVE_DATA_MOUNT_MODE_DESTRUCT_OFF:
|
||||
case ORBIS_SAVE_DATA_MOUNT_MODE_CREATE | ORBIS_SAVE_DATA_MOUNT_MODE_RDWR |
|
||||
ORBIS_SAVE_DATA_MOUNT_MODE_COPY_ICON:
|
||||
case ORBIS_SAVE_DATA_MOUNT_MODE_CREATE | ORBIS_SAVE_DATA_MOUNT_MODE_DESTRUCT_OFF |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue