Skip to content

Commit

Permalink
[rpcsx-os] simulate environment objects without vsh
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Nov 15, 2023
1 parent 0a957b8 commit f3643aa
Show file tree
Hide file tree
Showing 3 changed files with 309 additions and 39 deletions.
29 changes: 27 additions & 2 deletions orbis-kernel/include/orbis/ipmi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,34 @@ struct IpmiCreateServerConfig {

static_assert(sizeof(IpmiCreateServerConfig) == 0x38);

ErrorCode ipmiCreateClient(Thread *thread, void *clientImpl, const char *name,
struct IpmiBufferInfo {
ptr<void> data;
uint64_t size;
};

static_assert(sizeof(IpmiBufferInfo) == 0x10);

struct IpmiDataInfo {
ptr<void> data;
uint64_t size;
uint64_t capacity; //?
};

static_assert(sizeof(IpmiDataInfo) == 0x18);

struct IpmiSyncMessageHeader {
orbis::ptr<void> sessionImpl;
orbis::uint pid;
orbis::uint methodId;
orbis::uint numInData;
orbis::uint numOutData;
};

static_assert(sizeof(IpmiSyncMessageHeader) == 0x18);

ErrorCode ipmiCreateClient(Process *proc, void *clientImpl, const char *name,
void *config, Ref<IpmiClient> &result);
ErrorCode ipmiCreateServer(Thread *thread, void *serverImpl, const char *name,
ErrorCode ipmiCreateServer(Process *proc, void *serverImpl, const char *name,
const IpmiCreateServerConfig &config,
Ref<IpmiServer> &result);
ErrorCode ipmiCreateSession(Thread *thread, void *sessionImpl,
Expand Down
43 changes: 8 additions & 35 deletions orbis-kernel/src/ipmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,7 @@
#include "thread/Process.hpp"
#include "utils/Logs.hpp"

namespace orbis {
struct IpmiBufferInfo {
ptr<void> data;
uint64_t size;
};

static_assert(sizeof(IpmiBufferInfo) == 0x10);

struct IpmiDataInfo {
ptr<void> data;
uint64_t size;
uint64_t capacity; //?
};

static_assert(sizeof(IpmiDataInfo) == 0x18);
} // namespace orbis

orbis::ErrorCode orbis::ipmiCreateClient(Thread *thread, void *clientImpl,
orbis::ErrorCode orbis::ipmiCreateClient(Process *proc, void *clientImpl,
const char *name, void *config,
Ref<IpmiClient> &result) {
auto client = knew<IpmiClient>(name);
Expand All @@ -30,12 +13,12 @@ orbis::ErrorCode orbis::ipmiCreateClient(Thread *thread, void *clientImpl,

client->clientImpl = clientImpl;
client->name = name;
client->pid = thread->tproc->pid;
client->pid = proc->pid;
result = client;
return {};
}

orbis::ErrorCode orbis::ipmiCreateServer(Thread *thread, void *serverImpl,
orbis::ErrorCode orbis::ipmiCreateServer(Process *proc, void *serverImpl,
const char *name,
const IpmiCreateServerConfig &config,
Ref<IpmiServer> &result) {
Expand All @@ -45,7 +28,7 @@ orbis::ErrorCode orbis::ipmiCreateServer(Thread *thread, void *serverImpl,
server->serverImpl = serverImpl;
server->userData = config.userData;
server->eventHandler = config.eventHandler;
server->pid = thread->tproc->pid;
server->pid = proc->pid;
result = server;
return {};
}
Expand Down Expand Up @@ -116,7 +99,7 @@ orbis::SysResult orbis::sysIpmiCreateClient(Thread *thread, ptr<uint> result,
ORBIS_RET_ON_ERROR(uread(_params, ptr<IpmiCreateClientParams>(params)));
ORBIS_RET_ON_ERROR(ureadString(_name, sizeof(_name), _params.name));
ORBIS_RET_ON_ERROR(
ipmiCreateClient(thread, _params.clientImpl, _name, nullptr, client));
ipmiCreateClient(thread->tproc, _params.clientImpl, _name, nullptr, client));

auto kid = thread->tproc->ipmiMap.insert(std::move(client));

Expand Down Expand Up @@ -152,7 +135,7 @@ orbis::SysResult orbis::sysIpmiCreateServer(Thread *thread, ptr<uint> result,
ORBIS_RET_ON_ERROR(uread(_config, _params.config));
ORBIS_RET_ON_ERROR(ureadString(_name, sizeof(_name), _params.name));
ORBIS_RET_ON_ERROR(
ipmiCreateServer(thread, _params.serverImpl, _name, _config, server));
ipmiCreateServer(thread->tproc, _params.serverImpl, _name, _config, server));
auto kid = thread->tproc->ipmiMap.insert(std::move(server));

if (kid == -1) {
Expand Down Expand Up @@ -396,16 +379,6 @@ orbis::sysIpmiClientInvokeSyncMethod(Thread *thread, ptr<uint> result, uint kid,

static_assert(sizeof(IpmiSyncCallParams) == 0x30);

struct MessageHeader {
ptr<void> sessionImpl;
uint pid;
uint methodId;
uint numInData;
uint numOutData;
};

static_assert(sizeof(MessageHeader) == 0x18);

if (paramsSz != sizeof(IpmiSyncCallParams)) {
return ErrorCode::INVAL;
}
Expand Down Expand Up @@ -463,12 +436,12 @@ orbis::sysIpmiClientInvokeSyncMethod(Thread *thread, ptr<uint> result, uint kid,
outSize += data.size;
}

auto size = sizeof(MessageHeader) + inSize + outSize +
auto size = sizeof(IpmiSyncMessageHeader) + inSize + outSize +
_params.numInData * sizeof(uint32_t) +
_params.numOutData * sizeof(uint32_t);

kvector<std::byte> message(size);
auto msg = new (message.data()) MessageHeader;
auto msg = new (message.data()) IpmiSyncMessageHeader;
msg->sessionImpl = session->sessionImpl;
msg->pid = thread->tproc->pid;
msg->methodId = _params.method;
Expand Down
Loading

0 comments on commit f3643aa

Please sign in to comment.