Add a graphics card device stub

libSceGnmDriver LLE requires implementing the "/dev/gc" device
This commit is contained in:
Stephen Miller 2025-04-21 15:02:15 -05:00
parent c547ab8901
commit 3dac1a2c6a
4 changed files with 112 additions and 1 deletions

View file

@ -701,6 +701,8 @@ set(CORE src/core/aerolib/stubs.cpp
src/core/address_space.h src/core/address_space.h
src/core/devices/base_device.cpp src/core/devices/base_device.cpp
src/core/devices/base_device.h src/core/devices/base_device.h
src/core/devices/gc_device.cpp
src/core/devices/gc_device.h
src/core/devices/ioccom.h src/core/devices/ioccom.h
src/core/devices/logger.cpp src/core/devices/logger.cpp
src/core/devices/logger.h src/core/devices/logger.h

View file

@ -0,0 +1,74 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/logging/log.h"
#include "gc_device.h"
namespace Core::Devices {
std::shared_ptr<BaseDevice> GcDevice::Create(u32 handle, const char*, int, u16) {
return std::shared_ptr<BaseDevice>(
reinterpret_cast<Devices::BaseDevice*>(new GcDevice(handle)));
}
int GcDevice::ioctl(u64 cmd, Common::VaCtx* args) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
s64 GcDevice::write(const void* buf, size_t nbytes) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
size_t GcDevice::writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
size_t GcDevice::readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
s64 GcDevice::preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
s64 GcDevice::lseek(s64 offset, int whence) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
s64 GcDevice::read(void* buf, size_t nbytes) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
int GcDevice::fstat(Libraries::Kernel::OrbisKernelStat* sb) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
s32 GcDevice::fsync() {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
int GcDevice::ftruncate(s64 length) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
int GcDevice::getdents(void* buf, u32 nbytes, s64* basep) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
s64 GcDevice::pwrite(const void* buf, size_t nbytes, u64 offset) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
}
} // namespace Core::Devices

View file

@ -0,0 +1,33 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include "base_device.h"
namespace Core::Devices {
class GcDevice final : BaseDevice {
u32 handle;
public:
static std::shared_ptr<BaseDevice> Create(u32 handle, const char*, int, u16);
explicit GcDevice(u32 handle) : handle(handle) {}
~GcDevice() override = default;
int ioctl(u64 cmd, Common::VaCtx* args) override;
s64 write(const void* buf, size_t nbytes) override;
size_t readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override;
size_t writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) override;
s64 preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) override;
s64 lseek(s64 offset, int whence) override;
s64 read(void* buf, size_t nbytes) override;
int fstat(Libraries::Kernel::OrbisKernelStat* sb) override;
s32 fsync() override;
int ftruncate(s64 length) override;
int getdents(void* buf, u32 nbytes, s64* basep) override;
s64 pwrite(const void* buf, size_t nbytes, u64 offset) override;
};
} // namespace Core::Devices

View file

@ -10,6 +10,7 @@
#include "common/singleton.h" #include "common/singleton.h"
#include "core/devices/console_device.h" #include "core/devices/console_device.h"
#include "core/devices/deci_tty6_device.h" #include "core/devices/deci_tty6_device.h"
#include "core/devices/gc_device.h"
#include "core/devices/logger.h" #include "core/devices/logger.h"
#include "core/devices/nop_device.h" #include "core/devices/nop_device.h"
#include "core/devices/random_device.h" #include "core/devices/random_device.h"
@ -52,7 +53,8 @@ static std::map<std::string, FactoryDevice> available_device = {
{"/dev/random", &D::RandomDevice::Create }, {"/dev/random", &D::RandomDevice::Create },
{"/dev/srandom", &D::SRandomDevice::Create }, {"/dev/srandom", &D::SRandomDevice::Create },
{"/dev/console", &D::ConsoleDevice::Create }, {"/dev/console", &D::ConsoleDevice::Create },
{"/dev/deci_tty6",&D::DeciTty6Device::Create } {"/dev/deci_tty6",&D::DeciTty6Device::Create },
{"/dev/gc", &D::GcDevice::Create }
// clang-format on // clang-format on
}; };