mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
[rpcsx-os][orbis-kernel] Remove hacks
Removed evf_create, osem_create, ipmi and shm hacks
This commit is contained in:
parent
4096df70f4
commit
37295c16a1
|
|
@ -192,7 +192,7 @@ orbis::SysResult orbis::sys_evf_delete(Thread *thread, sint id) {
|
|||
ORBIS_LOG_WARNING(__FUNCTION__, id);
|
||||
Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
if (evf == nullptr) {
|
||||
return ErrorCode::SRCH;
|
||||
return ErrorCode::NOENT;
|
||||
}
|
||||
|
||||
thread->tproc->evfMap.destroy(id);
|
||||
|
|
@ -209,29 +209,7 @@ orbis::SysResult orbis::sys_evf_open(Thread *thread, ptr<const char[32]> name) {
|
|||
auto eventFlag = thread->tproc->context->findEventFlag(_name);
|
||||
|
||||
if (eventFlag == nullptr) {
|
||||
// if (_name[0] == '\0') {
|
||||
// return ErrorCode::NOENT;
|
||||
// }
|
||||
|
||||
// HACK :)
|
||||
if (std::string_view(_name).starts_with("SceAppMessaging")) {
|
||||
// change pattern on system window open
|
||||
return sys_evf_create(thread, name, kEvfAttrShared, 1);
|
||||
}
|
||||
|
||||
if (std::string_view("SceShellCoreUtilPowerControl") == _name) {
|
||||
return sys_evf_create(thread, name, kEvfAttrShared, 0x400000);
|
||||
}
|
||||
|
||||
if (std::string_view("SceShellCoreUtilAppFocus") == _name) {
|
||||
return sys_evf_create(thread, name, kEvfAttrShared, 1);
|
||||
}
|
||||
|
||||
if (std::string_view("SceBootStatusFlags") == _name) {
|
||||
return sys_evf_create(thread, name, kEvfAttrShared, 0x2408);
|
||||
}
|
||||
return sys_evf_create(thread, name, kEvfAttrShared, 0);
|
||||
return ErrorCode::SRCH;
|
||||
return ErrorCode::NOENT;
|
||||
}
|
||||
|
||||
thread->retval[0] = thread->tproc->evfMap.insert(eventFlag);
|
||||
|
|
@ -240,7 +218,7 @@ orbis::SysResult orbis::sys_evf_open(Thread *thread, ptr<const char[32]> name) {
|
|||
orbis::SysResult orbis::sys_evf_close(Thread *thread, sint id) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, thread->tid, id);
|
||||
if (!thread->tproc->evfMap.close(id)) {
|
||||
return ErrorCode::SRCH;
|
||||
return ErrorCode::NOENT;
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
@ -436,20 +414,6 @@ orbis::SysResult orbis::sys_osem_open(Thread *thread,
|
|||
|
||||
auto sem = thread->tproc->context->findSemaphore(_name);
|
||||
if (sem == nullptr) {
|
||||
// FIXME: hack :)
|
||||
if (std::string_view(_name).starts_with("SceLncSuspendBlock")) {
|
||||
auto result = sys_osem_create(thread, name, kSemaAttrShared, 1, 10000);
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, _name, result.value(), thread->retval[0]);
|
||||
return result;
|
||||
} else if (std::string_view(_name).starts_with("SceAppMessaging")) {
|
||||
auto result = sys_osem_create(thread, name, kSemaAttrShared, 1, 10000);
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, _name, result.value(), thread->retval[0]);
|
||||
return result;
|
||||
} else {
|
||||
auto result = sys_osem_create(thread, name, kSemaAttrShared, 0, 10000);
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, _name, result.value(), thread->retval[0]);
|
||||
return result;
|
||||
}
|
||||
return ErrorCode::NOENT;
|
||||
}
|
||||
|
||||
|
|
@ -1116,437 +1080,7 @@ orbis::SysResult orbis::sys_ipmimgr_call(Thread *thread, uint op, uint kid,
|
|||
ORBIS_LOG_TODO("sys_ipmimgr_call", thread->tid, op, kid, result, params,
|
||||
paramsSz, arg6);
|
||||
thread->where();
|
||||
|
||||
if (op == kImpiCreateServer) {
|
||||
if (paramsSz != sizeof(IpmiCreateServerParams)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
auto createParams = (ptr<IpmiCreateServerParams>)params;
|
||||
|
||||
ORBIS_LOG_TODO("IPMI: create server", createParams->arg0,
|
||||
createParams->name, createParams->arg2);
|
||||
|
||||
auto [server, inserted] = g_context.createIpmiServer(createParams->name);
|
||||
if (!inserted) {
|
||||
return ErrorCode::EXIST;
|
||||
}
|
||||
|
||||
auto id = thread->tproc->ipmiServerMap.insert(server);
|
||||
return uwrite<uint>(result, id);
|
||||
}
|
||||
|
||||
if (op == 0x10) {
|
||||
// IPMI server start?
|
||||
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
|
||||
if (op == 0x201) {
|
||||
// IPMI server receive packet?
|
||||
return uwrite<uint>(result, 0x80020023);
|
||||
}
|
||||
|
||||
if (op == kIpmiCreateClient) {
|
||||
if (paramsSz != sizeof(IpmiCreateClientParams)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
auto createParams = (ptr<IpmiCreateClientParams>)params;
|
||||
|
||||
ORBIS_LOG_TODO("IPMI: create client", createParams->arg0,
|
||||
createParams->name, createParams->arg2);
|
||||
// auto server = g_context.findIpmiServer(createParams->name);
|
||||
|
||||
// if (server == nullptr) {
|
||||
// ORBIS_LOG_TODO("IPMI: failed to find server", createParams->name);
|
||||
// }
|
||||
|
||||
auto ipmiClient = knew<IpmiClient>(createParams->name);
|
||||
// ipmiClient->connection = server;
|
||||
auto id = thread->tproc->ipmiClientMap.insert(ipmiClient);
|
||||
return uwrite<uint>(result, id);
|
||||
}
|
||||
|
||||
if (op == kImpiDestroyClient) {
|
||||
ORBIS_LOG_TODO("IPMI: destroy client");
|
||||
thread->tproc->ipmiClientMap.close(kid);
|
||||
if (result) {
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
auto client = thread->tproc->ipmiClientMap.get(kid);
|
||||
|
||||
if (client == nullptr) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
if (op == 0x241) {
|
||||
if (result) {
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (op == 0x400) {
|
||||
if (paramsSz != sizeof(IpmiClientConnectParams)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
auto connectParams = (ptr<IpmiClientConnectParams>)params;
|
||||
ORBIS_LOG_TODO("IPMI: connect?", client->name, connectParams->arg0,
|
||||
connectParams->name, connectParams->arg2,
|
||||
connectParams->arg3);
|
||||
if (result) {
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (op == 0x320) {
|
||||
ORBIS_LOG_TODO("IPMI: invoke sync method");
|
||||
|
||||
if (paramsSz != sizeof(IpmiSyncCallParams)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
IpmiSyncCallParams syncCallParams;
|
||||
auto errorCode = uread(syncCallParams, (ptr<IpmiSyncCallParams>)params);
|
||||
if (errorCode != ErrorCode{}) {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
ORBIS_LOG_TODO("IPMI: invokeSyncMethod", client->name,
|
||||
syncCallParams.method, syncCallParams.dataCount,
|
||||
syncCallParams.flags, syncCallParams.pData,
|
||||
syncCallParams.pBuffers, syncCallParams.pResult,
|
||||
syncCallParams.resultCount);
|
||||
|
||||
IpmiDataInfo dataInfo;
|
||||
uread(dataInfo, syncCallParams.pData);
|
||||
|
||||
ORBIS_LOG_TODO("", dataInfo.data, dataInfo.size);
|
||||
|
||||
if (client->name == "SceMbusIpc") {
|
||||
if (syncCallParams.method == 0xce110007) { // SceMbusIpcAddHandleByUserId
|
||||
struct SceMbusIpcAddHandleByUserIdMethodArgs {
|
||||
uint32_t unk; // 0
|
||||
uint32_t deviceId;
|
||||
uint32_t userId;
|
||||
uint32_t type;
|
||||
uint32_t index;
|
||||
uint32_t reserved;
|
||||
uint32_t pid;
|
||||
};
|
||||
|
||||
static_assert(sizeof(SceMbusIpcAddHandleByUserIdMethodArgs) == 0x1c);
|
||||
|
||||
if (dataInfo.size != sizeof(SceMbusIpcAddHandleByUserIdMethodArgs)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
SceMbusIpcAddHandleByUserIdMethodArgs args;
|
||||
uread(args, ptr<SceMbusIpcAddHandleByUserIdMethodArgs>(dataInfo.data));
|
||||
|
||||
ORBIS_LOG_TODO("IPMI: SceMbusIpcAddHandleByUserId", args.unk,
|
||||
args.deviceId, args.userId, args.type, args.index,
|
||||
args.reserved, args.pid);
|
||||
} else if (syncCallParams.method == 0xce11002a ||
|
||||
syncCallParams.method == 0xce110029) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(60));
|
||||
} else {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
return uwrite<uint>(result, 1);
|
||||
} else if (client->name == "SceUserService") {
|
||||
ORBIS_LOG_TODO("SceUserService");
|
||||
if (syncCallParams.method == 0x30011) { // get initial user id
|
||||
ORBIS_LOG_TODO("SceUserService: get_initial_user_id");
|
||||
auto err = uwrite(syncCallParams.pResult, 0);
|
||||
if (err != ErrorCode{}) {
|
||||
return err;
|
||||
}
|
||||
IpmiBufferInfo bufferInfo;
|
||||
err = uread(bufferInfo, syncCallParams.pBuffers);
|
||||
if (err != ErrorCode{}) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (bufferInfo.size != sizeof(uint32_t)) {
|
||||
return uwrite<uint>(result, -1);
|
||||
}
|
||||
|
||||
err = uwrite((ptr<uint32_t>)bufferInfo.data, 1u); // initial user id
|
||||
if (err != ErrorCode{}) {
|
||||
return err;
|
||||
}
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
} else if (client->name == "SceLncService") {
|
||||
if (syncCallParams.method == 0x30010 ||
|
||||
syncCallParams.method == 0x30013) { // get app status
|
||||
// returns pending system events
|
||||
ORBIS_LOG_TODO("SceUserService: get_app_status");
|
||||
auto err = uwrite(syncCallParams.pResult, 0);
|
||||
if (err != ErrorCode{}) {
|
||||
return err;
|
||||
}
|
||||
IpmiBufferInfo bufferInfo;
|
||||
err = uread(bufferInfo, syncCallParams.pBuffers);
|
||||
if (err != ErrorCode{}) {
|
||||
return err;
|
||||
}
|
||||
|
||||
struct Result {
|
||||
std::uint32_t unk0;
|
||||
std::uint32_t unk1;
|
||||
std::uint32_t unk2;
|
||||
};
|
||||
|
||||
static_assert(sizeof(Result) == 0xc);
|
||||
|
||||
if (bufferInfo.size != sizeof(Result)) {
|
||||
return uwrite<uint>(result, -1);
|
||||
}
|
||||
|
||||
Result bufferResult{
|
||||
.unk0 = 1,
|
||||
.unk1 = 1,
|
||||
.unk2 = 1,
|
||||
};
|
||||
|
||||
err = uwrite((ptr<Result>)bufferInfo.data, bufferResult);
|
||||
if (err != ErrorCode{}) {
|
||||
return err;
|
||||
}
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
} else if (client->name == "SceSysAudioSystemIpc") {
|
||||
if (syncCallParams.method == 0x12340000) { // check shared memory control
|
||||
struct SceSysAudioSystemIpcCheckSharedMemoryControlMethodArgs {
|
||||
uint32_t channelId;
|
||||
};
|
||||
|
||||
static_assert(
|
||||
sizeof(SceSysAudioSystemIpcCheckSharedMemoryControlMethodArgs) ==
|
||||
0x4);
|
||||
|
||||
if (dataInfo.size !=
|
||||
sizeof(SceSysAudioSystemIpcCheckSharedMemoryControlMethodArgs)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
SceSysAudioSystemIpcCheckSharedMemoryControlMethodArgs args;
|
||||
uread(args, ptr<SceSysAudioSystemIpcCheckSharedMemoryControlMethodArgs>(
|
||||
dataInfo.data));
|
||||
|
||||
ORBIS_LOG_TODO(
|
||||
"impi: SceSysAudioSystemIpcCheckSharedMemoryControlMethodArgs",
|
||||
args.channelId);
|
||||
if (auto audioOut = g_context.audioOut) {
|
||||
audioOut->channelInfo.idControl = args.channelId;
|
||||
}
|
||||
} else if (syncCallParams.method == 0x1234000f) { // create event flag
|
||||
struct SceSysAudioSystemIpcCreateEventFlagMethodArgs {
|
||||
uint32_t channelId;
|
||||
};
|
||||
|
||||
static_assert(sizeof(SceSysAudioSystemIpcCreateEventFlagMethodArgs) ==
|
||||
0x4);
|
||||
|
||||
if (dataInfo.size !=
|
||||
sizeof(SceSysAudioSystemIpcCreateEventFlagMethodArgs)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
SceSysAudioSystemIpcCreateEventFlagMethodArgs args;
|
||||
uread(args, ptr<SceSysAudioSystemIpcCreateEventFlagMethodArgs>(
|
||||
dataInfo.data));
|
||||
|
||||
if (auto audioOut = g_context.audioOut) {
|
||||
// very bad
|
||||
char buffer[32];
|
||||
std::snprintf(buffer, sizeof(buffer), "sceAudioOutMix%x",
|
||||
args.channelId);
|
||||
// const char* eventName = &buffer;
|
||||
auto [eventFlag, inserted] = thread->tproc->context->createEventFlag(
|
||||
buffer, kEvfAttrShared, 0);
|
||||
|
||||
if (!inserted) {
|
||||
return ErrorCode::EXIST; // FIXME: verify
|
||||
}
|
||||
|
||||
audioOut->channelInfo.evf = eventFlag;
|
||||
}
|
||||
} else if (syncCallParams.method ==
|
||||
0x12340001) { // check shared memory audio
|
||||
struct SceSysAudioSystemIpcCheckSharedMemoryAudioMethodArgs {
|
||||
uint32_t audioPort;
|
||||
uint32_t channelId;
|
||||
};
|
||||
|
||||
static_assert(
|
||||
sizeof(SceSysAudioSystemIpcCheckSharedMemoryAudioMethodArgs) ==
|
||||
0x8);
|
||||
|
||||
if (dataInfo.size !=
|
||||
sizeof(SceSysAudioSystemIpcCheckSharedMemoryAudioMethodArgs)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
SceSysAudioSystemIpcCheckSharedMemoryAudioMethodArgs args;
|
||||
uread(args, ptr<SceSysAudioSystemIpcCheckSharedMemoryAudioMethodArgs>(
|
||||
dataInfo.data));
|
||||
|
||||
ORBIS_LOG_TODO(
|
||||
"IPMI: SceSysAudioSystemIpcCheckSharedMemoryAudioMethodArgs",
|
||||
args.audioPort, args.channelId);
|
||||
if (auto audioOut = g_context.audioOut) {
|
||||
audioOut->channelInfo.port = args.audioPort;
|
||||
audioOut->channelInfo.channel = args.channelId;
|
||||
}
|
||||
} else if (syncCallParams.method == 0x12340002) { // something like open
|
||||
struct SceSysAudioSystemIpcSomethingMethodArgs {
|
||||
uint32_t audioPort;
|
||||
uint32_t channelId;
|
||||
};
|
||||
|
||||
static_assert(sizeof(SceSysAudioSystemIpcSomethingMethodArgs) == 0x8);
|
||||
|
||||
if (dataInfo.size != sizeof(SceSysAudioSystemIpcSomethingMethodArgs)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
SceSysAudioSystemIpcSomethingMethodArgs args;
|
||||
uread(args,
|
||||
ptr<SceSysAudioSystemIpcSomethingMethodArgs>(dataInfo.data));
|
||||
|
||||
ORBIS_LOG_TODO("IPMI: SceSysAudioSystemIpcSomethingMethodArgs",
|
||||
args.audioPort, args.channelId);
|
||||
|
||||
if (auto audioOut = g_context.audioOut) {
|
||||
// here startToListen
|
||||
audioOut->start();
|
||||
}
|
||||
} else if (syncCallParams.method == 0x12340006) { // close port
|
||||
struct SceSysAudioSystemIpcCloseAudioMethodArgs {
|
||||
uint32_t audioPort;
|
||||
uint32_t channelId;
|
||||
};
|
||||
|
||||
static_assert(sizeof(SceSysAudioSystemIpcCloseAudioMethodArgs) == 0x8);
|
||||
|
||||
if (dataInfo.size != sizeof(SceSysAudioSystemIpcCloseAudioMethodArgs)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
SceSysAudioSystemIpcCloseAudioMethodArgs args;
|
||||
uread(args,
|
||||
ptr<SceSysAudioSystemIpcCloseAudioMethodArgs>(dataInfo.data));
|
||||
|
||||
ORBIS_LOG_TODO("IPMI: SceSysAudioSystemIpcCloseAudioMethodArgs",
|
||||
args.audioPort, args.channelId);
|
||||
}
|
||||
}
|
||||
|
||||
if (result != nullptr) {
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
if (op == 0x310) {
|
||||
ORBIS_LOG_TODO("IPMI: disconnect?");
|
||||
if (result) {
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
if (op == 0x252) {
|
||||
ORBIS_LOG_TODO("IPMI: client:tryGet", client->name);
|
||||
thread->where();
|
||||
|
||||
struct SceIpmiClientTryGetArgs {
|
||||
uint32_t unk; // 0
|
||||
uint32_t padding;
|
||||
ptr<void> message;
|
||||
ptr<uint64_t> pSize;
|
||||
uint64_t maxSize;
|
||||
};
|
||||
|
||||
static_assert(sizeof(SceIpmiClientTryGetArgs) == 0x20);
|
||||
|
||||
if (paramsSz != sizeof(SceIpmiClientTryGetArgs)) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
SceIpmiClientTryGetArgs tryGetParams;
|
||||
auto errorCode = uread(tryGetParams, (ptr<SceIpmiClientTryGetArgs>)params);
|
||||
if (errorCode != ErrorCode{}) {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
ORBIS_LOG_WARNING("IPMI: client: tryGet", tryGetParams.unk,
|
||||
tryGetParams.message, tryGetParams.pSize,
|
||||
tryGetParams.maxSize);
|
||||
|
||||
if (client->name == "SceUserService") {
|
||||
static bool isFirst = true; // TODO: implement ipmi hooks at os side
|
||||
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
|
||||
struct SceUserServiceEvent {
|
||||
std::uint32_t eventType; // 0 - login, 1 - logout
|
||||
std::uint32_t user;
|
||||
};
|
||||
|
||||
if (tryGetParams.maxSize < sizeof(SceUserServiceEvent)) {
|
||||
return uwrite<uint>(result, 0x80020003);
|
||||
}
|
||||
|
||||
errorCode = uwrite(tryGetParams.pSize, sizeof(SceUserServiceEvent));
|
||||
if (errorCode != ErrorCode{}) {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
errorCode = uwrite((ptr<SceUserServiceEvent>)tryGetParams.message,
|
||||
{.eventType = 0, .user = 1});
|
||||
|
||||
if (errorCode != ErrorCode{}) {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
return uwrite<uint>(result, 0);
|
||||
} else {
|
||||
return uwrite<uint>(result, 0x80020003);
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
return uwrite<uint>(result, 0x80020003);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
if (op == 0x46b) {
|
||||
thread->retval[0] = -0x40004; // HACK
|
||||
return {};
|
||||
}
|
||||
|
||||
if (op == 0x243) {
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
|
||||
if (op == 0x491) {
|
||||
return uwrite<uint>(result, 0);
|
||||
}
|
||||
|
||||
return ErrorCode::INVAL;
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_get_gpo(Thread *thread /* TODO */) {
|
||||
return ErrorCode::NOSYS;
|
||||
|
|
|
|||
|
|
@ -32,31 +32,7 @@ orbis::ErrorCode ShmDevice::open(orbis::Ref<orbis::File> *file,
|
|||
auto realFlags = O_RDWR; // TODO
|
||||
|
||||
std::size_t size = 0;
|
||||
if (~flags & 0x200) {
|
||||
if (name == "/rpcsx-SceShellCoreUtil") {
|
||||
// TODO
|
||||
realFlags |= O_CREAT;
|
||||
size = 0x4000;
|
||||
} else if (name == "/rpcsx-vmicDdShmAin") {
|
||||
// TODO
|
||||
realFlags |= O_CREAT;
|
||||
size = 0x4000;
|
||||
} else if (name == "/rpcsx-SceNpTpip") {
|
||||
// TODO
|
||||
realFlags |= O_CREAT;
|
||||
size = 0x4000;
|
||||
} else if (name == "/rpcsx-SceNpPlusLogger") {
|
||||
realFlags |= O_CREAT;
|
||||
size = 0x4400;
|
||||
} else if (name == "/rpcsx-SceAvSetting") {
|
||||
realFlags |= O_CREAT;
|
||||
size = 0x4400;
|
||||
} else {
|
||||
ORBIS_LOG_ERROR("SHM: unknown shared memory", path);
|
||||
thread->where();
|
||||
std::abort();
|
||||
}
|
||||
} else {
|
||||
if (flags & 0x200) {
|
||||
realFlags |= O_CREAT;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue