mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-03-16 02:04:51 +01:00
[rpcsx-os] stub /dev/urandom
This commit is contained in:
parent
ef4f11f2ad
commit
4f3495117c
|
|
@ -21,6 +21,7 @@ add_executable(rpcsx-os
|
|||
iodev/rng.cpp
|
||||
iodev/sbl_srv.cpp
|
||||
iodev/shm.cpp
|
||||
iodev/urandom.cpp
|
||||
iodev/zero.cpp
|
||||
|
||||
main.cpp
|
||||
|
|
|
|||
|
|
@ -21,3 +21,4 @@ IoDevice *createConsoleCharacterDevice();
|
|||
IoDevice *createSblSrvCharacterDevice();
|
||||
IoDevice *createShmDevice();
|
||||
IoDevice *createBlockPoolDevice();
|
||||
IoDevice *createUrandomCharacterDevice();
|
||||
|
|
|
|||
38
rpcsx-os/iodev/urandom.cpp
Normal file
38
rpcsx-os/iodev/urandom.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include "io-device.hpp"
|
||||
#include "orbis/KernelAllocator.hpp"
|
||||
#include "orbis/uio.hpp"
|
||||
#include <cstring>
|
||||
#include <span>
|
||||
|
||||
struct UrandomDevice : public IoDevice {
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override;
|
||||
};
|
||||
struct UrandomFile : public orbis::File {};
|
||||
|
||||
static orbis::ErrorCode zero_read(orbis::File *file, orbis::Uio *uio,
|
||||
orbis::Thread *) {
|
||||
for (auto entry : std::span(uio->iov, uio->iovcnt)) {
|
||||
std::memset(entry.base, 0, entry.len);
|
||||
uio->offset += entry.len;
|
||||
}
|
||||
uio->resid = 0;
|
||||
return {};
|
||||
}
|
||||
|
||||
static const orbis::FileOps ops = {
|
||||
.read = zero_read,
|
||||
};
|
||||
|
||||
orbis::ErrorCode UrandomDevice::open(orbis::Ref<orbis::File> *file,
|
||||
const char *path, std::uint32_t flags,
|
||||
std::uint32_t mode, orbis::Thread *thread) {
|
||||
auto newFile = orbis::knew<UrandomFile>();
|
||||
newFile->device = this;
|
||||
newFile->ops = &ops;
|
||||
*file = newFile;
|
||||
return {};
|
||||
}
|
||||
|
||||
IoDevice *createUrandomCharacterDevice() { return orbis::knew<UrandomDevice>(); }
|
||||
|
|
@ -344,6 +344,7 @@ static int ps4Exec(orbis::Thread *mainThread,
|
|||
rx::vfs::mount("/dev/rng", createRngCharacterDevice());
|
||||
rx::vfs::mount("/dev/sbl_srv", createSblSrvCharacterDevice());
|
||||
rx::vfs::mount("/dev/ajm", createAjmCharacterDevice());
|
||||
rx::vfs::mount("/dev/urandom", createUrandomCharacterDevice());
|
||||
|
||||
orbis::Ref<orbis::File> stdinFile;
|
||||
orbis::Ref<orbis::File> stdoutFile;
|
||||
|
|
|
|||
Loading…
Reference in a new issue