added urandom,srandom,random,console,deci_tty6 devices

This commit is contained in:
georgemoralis 2025-01-19 11:52:41 +02:00
parent 50a46b4613
commit 70d8b2598a
12 changed files with 144 additions and 73 deletions

View File

@ -557,8 +557,8 @@ set(CORE src/core/aerolib/stubs.cpp
src/core/devices/logger.cpp src/core/devices/logger.cpp
src/core/devices/logger.h src/core/devices/logger.h
src/core/devices/nop_device.h src/core/devices/nop_device.h
src/core/devices/console.cpp src/core/devices/dev_console.cpp
src/core/devices/console.h src/core/devices/dev_console.h
src/core/devices/deci_tty6.cpp src/core/devices/deci_tty6.cpp
src/core/devices/deci_tty6.h src/core/devices/deci_tty6.h
src/core/devices/random.cpp src/core/devices/random.cpp

View File

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

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
#include <memory>
#include "base_device.h" #include "base_device.h"
namespace Core::Devices { namespace Core::Devices {
@ -10,6 +11,7 @@ class DeciTty6Device final : BaseDevice {
u32 handle; u32 handle;
public: public:
static std::shared_ptr<BaseDevice> Create(u32 handle, const char*, int, u16);
explicit DeciTty6Device(u32 handle) : handle(handle) {} explicit DeciTty6Device(u32 handle) : handle(handle) {}
~DeciTty6Device() override = default; ~DeciTty6Device() override = default;

View File

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

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
#include <memory>
#include "base_device.h" #include "base_device.h"
namespace Core::Devices { namespace Core::Devices {
@ -10,6 +11,7 @@ class ConsoleDevice final : BaseDevice {
u32 handle; u32 handle;
public: public:
static std::shared_ptr<BaseDevice> Create(u32 handle, const char*, int, u16);
explicit ConsoleDevice(u32 handle) : handle(handle) {} explicit ConsoleDevice(u32 handle) : handle(handle) {}
~ConsoleDevice() override = default; ~ConsoleDevice() override = default;

View File

@ -2,51 +2,67 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/libraries/kernel/file_system.h"
#include "logger.h"
#include "random.h" #include "random.h"
namespace Core::Devices { namespace Core::Devices {
std::shared_ptr<BaseDevice> RandomDevice::Create(u32 handle, const char*, int, u16) {
std::srand(std::time(nullptr));
return std::shared_ptr<BaseDevice>(
reinterpret_cast<Devices::BaseDevice*>(new RandomDevice(handle)));
}
int RandomDevice::ioctl(u64 cmd, Common::VaCtx* args) { int RandomDevice::ioctl(u64 cmd, Common::VaCtx* args) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
s64 RandomDevice::write(const void* buf, size_t nbytes) { s64 RandomDevice::write(const void* buf, size_t nbytes) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
size_t RandomDevice::writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) { size_t RandomDevice::writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) {
return size_t(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
size_t RandomDevice::readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) { size_t RandomDevice::readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) {
return size_t(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
s64 RandomDevice::preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) { s64 RandomDevice::preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
s64 RandomDevice::lseek(s64 offset, int whence) { s64 RandomDevice::lseek(s64 offset, int whence) {
return s64(); return 0;
} }
s64 RandomDevice::read(void* buf, size_t nbytes) { s64 RandomDevice::read(void* buf, size_t nbytes) {
return s64(); auto rbuf = static_cast<char*>(buf);
for (size_t i = 0; i < nbytes; i++)
rbuf[i] = std::rand() & 0xFF;
return nbytes;
} }
int RandomDevice::fstat(Libraries::Kernel::OrbisKernelStat* sb) { int RandomDevice::fstat(Libraries::Kernel::OrbisKernelStat* sb) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
s32 RandomDevice::fsync() { s32 RandomDevice::fsync() {
return s32(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
int RandomDevice::ftruncate(s64 length) { int RandomDevice::ftruncate(s64 length) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
int RandomDevice::getdents(void* buf, u32 nbytes, s64* basep) { int RandomDevice::getdents(void* buf, u32 nbytes, s64* basep) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
s64 RandomDevice::pwrite(const void* buf, size_t nbytes, u64 offset) { s64 RandomDevice::pwrite(const void* buf, size_t nbytes, u64 offset) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
} // namespace Core::Devices } // namespace Core::Devices

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
#include <memory>
#include "base_device.h" #include "base_device.h"
namespace Core::Devices { namespace Core::Devices {
@ -10,6 +11,7 @@ class RandomDevice final : BaseDevice {
u32 handle; u32 handle;
public: public:
static std::shared_ptr<BaseDevice> Create(u32 handle, const char*, int, u16);
explicit RandomDevice(u32 handle) : handle(handle) {} explicit RandomDevice(u32 handle) : handle(handle) {}
~RandomDevice() override = default; ~RandomDevice() override = default;

View File

@ -2,51 +2,68 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/libraries/kernel/file_system.h"
#include "logger.h"
#include "srandom.h" #include "srandom.h"
namespace Core::Devices { namespace Core::Devices {
std::shared_ptr<BaseDevice> SRandomDevice::Create(u32 handle, const char*, int, u16) {
std::srand(std::time(nullptr));
return std::shared_ptr<BaseDevice>(
reinterpret_cast<Devices::BaseDevice*>(new SRandomDevice(handle)));
}
int SRandomDevice::ioctl(u64 cmd, Common::VaCtx* args) { int SRandomDevice::ioctl(u64 cmd, Common::VaCtx* args) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
s64 SRandomDevice::write(const void* buf, size_t nbytes) { s64 SRandomDevice::write(const void* buf, size_t nbytes) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
size_t SRandomDevice::writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) { size_t SRandomDevice::writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) {
return size_t(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
size_t SRandomDevice::readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) { size_t SRandomDevice::readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) {
return size_t(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
s64 SRandomDevice::preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) { s64 SRandomDevice::preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
s64 SRandomDevice::lseek(s64 offset, int whence) { s64 SRandomDevice::lseek(s64 offset, int whence) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
s64 SRandomDevice::read(void* buf, size_t nbytes) { s64 SRandomDevice::read(void* buf, size_t nbytes) {
return s64(); auto rbuf = static_cast<char*>(buf);
for (size_t i = 0; i < nbytes; i++)
rbuf[i] = std::rand();
return nbytes;
} }
int SRandomDevice::fstat(Libraries::Kernel::OrbisKernelStat* sb) { int SRandomDevice::fstat(Libraries::Kernel::OrbisKernelStat* sb) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
s32 SRandomDevice::fsync() { s32 SRandomDevice::fsync() {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return s32(); return s32();
} }
int SRandomDevice::ftruncate(s64 length) { int SRandomDevice::ftruncate(s64 length) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
int SRandomDevice::getdents(void* buf, u32 nbytes, s64* basep) { int SRandomDevice::getdents(void* buf, u32 nbytes, s64* basep) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
s64 SRandomDevice::pwrite(const void* buf, size_t nbytes, u64 offset) { s64 SRandomDevice::pwrite(const void* buf, size_t nbytes, u64 offset) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
} // namespace Core::Devices } // namespace Core::Devices

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
#include <memory>
#include "base_device.h" #include "base_device.h"
namespace Core::Devices { namespace Core::Devices {
@ -10,6 +11,7 @@ class SRandomDevice final : BaseDevice {
u32 handle; u32 handle;
public: public:
static std::shared_ptr<BaseDevice> Create(u32 handle, const char*, int, u16);
explicit SRandomDevice(u32 handle) : handle(handle) {} explicit SRandomDevice(u32 handle) : handle(handle) {}
~SRandomDevice() override = default; ~SRandomDevice() override = default;

View File

@ -2,57 +2,70 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/libraries/kernel/file_system.h"
#include "logger.h"
#include "urandom.h" #include "urandom.h"
namespace Core::Devices { namespace Core::Devices {
std::shared_ptr<BaseDevice> URandomDevice::Create(u32 handle, const char*, int, u16) { std::shared_ptr<BaseDevice> URandomDevice::Create(u32 handle, const char*, int, u16) {
std::srand(std::time(nullptr));
return std::shared_ptr<BaseDevice>( return std::shared_ptr<BaseDevice>(
reinterpret_cast<Devices::BaseDevice*>(new URandomDevice(handle))); reinterpret_cast<Devices::BaseDevice*>(new URandomDevice(handle)));
} }
int URandomDevice::ioctl(u64 cmd, Common::VaCtx* args) { int URandomDevice::ioctl(u64 cmd, Common::VaCtx* args) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
s64 URandomDevice::write(const void* buf, size_t nbytes) { s64 URandomDevice::write(const void* buf, size_t nbytes) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
size_t URandomDevice::writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) { size_t URandomDevice::writev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) {
return size_t(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
size_t URandomDevice::readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) { size_t URandomDevice::readv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt) {
return size_t(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
s64 URandomDevice::preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) { s64 URandomDevice::preadv(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
s64 URandomDevice::lseek(s64 offset, int whence) { s64 URandomDevice::lseek(s64 offset, int whence) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
s64 URandomDevice::read(void* buf, size_t nbytes) { s64 URandomDevice::read(void* buf, size_t nbytes) {
return s64(); auto rbuf = static_cast<char*>(buf);
for (size_t i = 0; i < nbytes; i++)
rbuf[i] = std::rand() & 0xFF;
return nbytes;
} }
int URandomDevice::fstat(Libraries::Kernel::OrbisKernelStat* sb) { int URandomDevice::fstat(Libraries::Kernel::OrbisKernelStat* sb) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
s32 URandomDevice::fsync() { s32 URandomDevice::fsync() {
return s32(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
int URandomDevice::ftruncate(s64 length) { int URandomDevice::ftruncate(s64 length) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
int URandomDevice::getdents(void* buf, u32 nbytes, s64* basep) { int URandomDevice::getdents(void* buf, u32 nbytes, s64* basep) {
LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0; return 0;
} }
s64 URandomDevice::pwrite(const void* buf, size_t nbytes, u64 offset) { s64 URandomDevice::pwrite(const void* buf, size_t nbytes, u64 offset) {
return s64(); LOG_ERROR(Kernel_Pthread, "(STUBBED) called");
return 0;
} }
} // namespace Core::Devices } // namespace Core::Devices

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
#include <memory>
#include "base_device.h" #include "base_device.h"
namespace Core::Devices { namespace Core::Devices {

View File

@ -8,8 +8,12 @@
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/scope_exit.h" #include "common/scope_exit.h"
#include "common/singleton.h" #include "common/singleton.h"
#include "core/devices/deci_tty6.h"
#include "core/devices/dev_console.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.h"
#include "core/devices/srandom.h"
#include "core/devices/urandom.h" #include "core/devices/urandom.h"
#include "core/file_sys/fs.h" #include "core/file_sys/fs.h"
#include "core/libraries/kernel/file_system.h" #include "core/libraries/kernel/file_system.h"
@ -43,7 +47,11 @@ static std::map<std::string, FactoryDevice> available_device = {
{"/dev/null", GET_DEVICE_FD(0)}, // fd0 (stdin) is a nop device {"/dev/null", GET_DEVICE_FD(0)}, // fd0 (stdin) is a nop device
{"/dev/urandom", &D::URandomDevice::Create } {"/dev/urandom", &D::URandomDevice::Create },
{"/dev/random", &D::RandomDevice::Create },
{"/dev/srandom", &D::SRandomDevice::Create },
{"/dev/console", &D::ConsoleDevice::Create },
{"/dev/deci_tty6",&D::DeciTty6Device::Create }
// clang-format on // clang-format on
}; };
@ -70,17 +78,6 @@ int PS4_SYSV_ABI sceKernelOpen(const char* raw_path, int flags, u16 mode) {
bool directory = (flags & ORBIS_KERNEL_O_DIRECTORY) != 0; bool directory = (flags & ORBIS_KERNEL_O_DIRECTORY) != 0;
std::string_view path{raw_path}; std::string_view path{raw_path};
if (path == "/dev/console") {
return 2000;
}
if (path == "/dev/deci_tty6") {
return 2001;
}
if (path == "/dev/urandom") {
return 2003;
}
u32 handle = h->CreateHandle(); u32 handle = h->CreateHandle();
auto* file = h->GetFile(handle); auto* file = h->GetFile(handle);
@ -170,9 +167,6 @@ int PS4_SYSV_ABI sceKernelClose(int d) {
if (d < 3) { // d probably hold an error code if (d < 3) { // d probably hold an error code
return ORBIS_KERNEL_ERROR_EPERM; return ORBIS_KERNEL_ERROR_EPERM;
} }
if (d == 2003) { // dev/urandom case
return ORBIS_OK;
}
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance(); auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* file = h->GetFile(d); auto* file = h->GetFile(d);
if (file == nullptr) { if (file == nullptr) {
@ -340,13 +334,6 @@ s64 PS4_SYSV_ABI posix_lseek(int d, s64 offset, int whence) {
} }
s64 PS4_SYSV_ABI sceKernelRead(int d, void* buf, size_t nbytes) { s64 PS4_SYSV_ABI sceKernelRead(int d, void* buf, size_t nbytes) {
if (d == 2003) // dev urandom case
{
auto rbuf = static_cast<char*>(buf);
for (size_t i = 0; i < nbytes; i++)
rbuf[i] = std::rand() & 0xFF;
return nbytes;
}
auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance(); auto* h = Common::Singleton<Core::FileSys::HandleTable>::Instance();
auto* file = h->GetFile(d); auto* file = h->GetFile(d);
if (file == nullptr) { if (file == nullptr) {