Implement getargc and getargv (#3562)

* Implement getargc and getargv

* update copyright year

* the loathsome clang-formatter
This commit is contained in:
kalaposfos13
2025-09-09 23:58:22 +02:00
committed by GitHub
parent c05695fde5
commit 4abc6b3010
4 changed files with 22 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <thread> #include <thread>
@@ -35,6 +35,7 @@
#include <common/singleton.h> #include <common/singleton.h>
#include <core/libraries/network/net_error.h> #include <core/libraries/network/net_error.h>
#include <core/libraries/network/sockets.h> #include <core/libraries/network/sockets.h>
#include <core/linker.h>
#include "aio.h" #include "aio.h"
namespace Libraries::Kernel { namespace Libraries::Kernel {
@@ -47,6 +48,8 @@ static std::condition_variable_any cv_asio_req;
static std::atomic<u32> asio_requests; static std::atomic<u32> asio_requests;
static std::jthread service_thread; static std::jthread service_thread;
Core::EntryParams entry_params{};
void KernelSignalRequest() { void KernelSignalRequest() {
std::unique_lock lock{m_asio_req}; std::unique_lock lock{m_asio_req};
++asio_requests; ++asio_requests;
@@ -245,6 +248,14 @@ s32 PS4_SYSV_ABI sceKernelGetSystemSwVersion(SwVersionStruct* ret) {
return ORBIS_OK; return ORBIS_OK;
} }
s32 PS4_SYSV_ABI getargc() {
return entry_params.argc;
}
const char** PS4_SYSV_ABI getargv() {
return entry_params.argv;
}
void RegisterLib(Core::Loader::SymbolsResolver* sym) { void RegisterLib(Core::Loader::SymbolsResolver* sym) {
service_thread = std::jthread{KernelServiceThread}; service_thread = std::jthread{KernelServiceThread};
@@ -314,6 +325,8 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("4oXYe9Xmk0Q", "libkernel", 1, "libkernel", sceKernelGetGPI); LIB_FUNCTION("4oXYe9Xmk0Q", "libkernel", 1, "libkernel", sceKernelGetGPI);
LIB_FUNCTION("ca7v6Cxulzs", "libkernel", 1, "libkernel", sceKernelSetGPO); LIB_FUNCTION("ca7v6Cxulzs", "libkernel", 1, "libkernel", sceKernelSetGPO);
LIB_FUNCTION("iKJMWrAumPE", "libkernel", 1, "libkernel", getargc);
LIB_FUNCTION("FJmglmTMdr4", "libkernel", 1, "libkernel", getargv);
} }
} // namespace Libraries::Kernel } // namespace Libraries::Kernel

View File

@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
#include "common/types.h" #include "common/types.h"
#include "core/libraries/kernel/orbis_error.h" #include "core/libraries/kernel/orbis_error.h"
#include "core/linker.h"
namespace Core::Loader { namespace Core::Loader {
class SymbolsResolver; class SymbolsResolver;
@@ -17,6 +18,8 @@ s32 ErrnoToSceKernelError(s32 e);
void SetPosixErrno(s32 e); void SetPosixErrno(s32 e);
s32* PS4_SYSV_ABI __Error(); s32* PS4_SYSV_ABI __Error();
extern Core::EntryParams entry_params;
template <class F, F f> template <class F, F f>
struct OrbisWrapperImpl; struct OrbisWrapperImpl;

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "common/alignment.h" #include "common/alignment.h"
@@ -13,6 +13,7 @@
#include "core/aerolib/aerolib.h" #include "core/aerolib/aerolib.h"
#include "core/aerolib/stubs.h" #include "core/aerolib/stubs.h"
#include "core/devtools/widget/module_list.h" #include "core/devtools/widget/module_list.h"
#include "core/libraries/kernel/kernel.h"
#include "core/libraries/kernel/memory.h" #include "core/libraries/kernel/memory.h"
#include "core/libraries/kernel/threads.h" #include "core/libraries/kernel/threads.h"
#include "core/linker.h" #include "core/linker.h"
@@ -135,7 +136,7 @@ void Linker::Execute(const std::vector<std::string> args) {
ASSERT_MSG(result == 0, "Unable to emulate libSceGnmDriver initialization"); ASSERT_MSG(result == 0, "Unable to emulate libSceGnmDriver initialization");
// Start main module. // Start main module.
EntryParams params{}; EntryParams& params = Libraries::Kernel::entry_params;
params.argc = 1; params.argc = 1;
params.argv[0] = "eboot.bin"; params.argv[0] = "eboot.bin";
if (!args.empty()) { if (!args.empty()) {

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
@@ -17,10 +17,6 @@
#include "video_core/texture_cache/sampler.h" #include "video_core/texture_cache/sampler.h"
#include "video_core/texture_cache/tile_manager.h" #include "video_core/texture_cache/tile_manager.h"
namespace Core::Libraries::VideoOut {
struct BufferAttributeGroup;
}
namespace VideoCore { namespace VideoCore {
class BufferCache; class BufferCache;