[rpcsx-os/orbis-kernel] random bugfixes

ipmi: fixed respond sync, get message, try get message, try send message
event: detach event emitter from file
signals: basic implementation
linker: fixed zero symbol relocation, fixed exec relocation
shared_cv/mutex: implement eintr response support
shared_cv: fixed possible loop instead of wait
ipmi: implement invoke async, respond async, get result, get client app id, client get name
rpcsx-os: add safemode flag
This commit is contained in:
DH 2024-01-13 20:57:02 +03:00
parent 8791312d4f
commit 65e653f5ef
81 changed files with 2586 additions and 761 deletions

View file

@ -3,10 +3,10 @@
#include "orbis/KernelAllocator.hpp"
#include "orbis/error/ErrorCode.hpp"
#include "orbis/file.hpp"
#include "orbis/thread/Process.hpp"
#include "orbis/thread/Thread.hpp"
#include "orbis/utils/Logs.hpp"
#include "orbis/utils/SharedMutex.hpp"
#include "orbis/thread/Thread.hpp"
#include "orbis/thread/Process.hpp"
#include "vm.hpp"
#include <cstdio>
#include <cstring>
@ -21,18 +21,18 @@ struct VideoOutBuffer {
};
struct RegisterBuffer {
std::uint64_t canary; //arg5 data in FlipControlArgs:0: *arg5
std::uint32_t index; //buffer index
std::uint32_t vid; //video output port id ?
std::uint64_t address; //left buffer ptr
std::uint64_t address2; //right buffer ptr (Stereo)
std::uint64_t canary; // arg5 data in FlipControlArgs:0: *arg5
std::uint32_t index; // buffer index
std::uint32_t vid; // video output port id ?
std::uint64_t address; // left buffer ptr
std::uint64_t address2; // right buffer ptr (Stereo)
};
struct RegisterBufferAttributeArgs {
std::uint64_t canary; //arg5 data in FlipControlArgs:0: *arg5
std::uint8_t vid; //video output port id ?
std::uint8_t submit; //0 = RegisterBuffers ; 1 = SubmitChangeBufferAttribute
std::uint16_t unk3; //0
std::uint64_t canary; // arg5 data in FlipControlArgs:0: *arg5
std::uint8_t vid; // video output port id ?
std::uint8_t submit; // 0 = RegisterBuffers ; 1 = SubmitChangeBufferAttribute
std::uint16_t unk3; // 0
std::uint32_t pixelFormat;
std::uint32_t tilingMode; // 1 // tilingMode?
std::uint32_t pitch;
@ -45,29 +45,30 @@ struct RegisterBufferAttributeArgs {
std::uint32_t reserved2;
};
struct FlipRequestArgs { //submit_flip
std::uint64_t canary; //arg5 data in FlipControlArgs:0: *arg5
struct FlipRequestArgs { // submit_flip
std::uint64_t canary; // arg5 data in FlipControlArgs:0: *arg5
std::uint64_t displayBufferIndex;
std::uint32_t flipMode; // flip mode?
std::uint32_t unk1;
std::uint64_t flipArg;
std::uint64_t flipArg2; //not used
std::uint64_t flipArg2; // not used
std::uint32_t eop_nz;
std::uint32_t unk2;
std::uint32_t eop_val;
std::uint32_t unk3;
std::uint64_t unk4;
std::uint64_t* rout; //extraout of result error
std::uint64_t *rout; // extraout of result error
};
struct FlipControlStatus {
std::uint64_t flipArg;
std::uint64_t flipArg2; //not used
std::uint64_t flipArg2; // not used
std::uint64_t count;
std::uint64_t processTime;
std::uint64_t tsc;
std::uint32_t currentBuffer;
std::uint32_t flipPendingNum0; //flipPendingNum = flipPendingNum0 + gcQueueNum + flipPendingNum1
std::uint32_t flipPendingNum0; // flipPendingNum = flipPendingNum0 +
// gcQueueNum + flipPendingNum1
std::uint32_t gcQueueNum;
std::uint32_t flipPendingNum1;
std::uint32_t submitTsc;
@ -76,7 +77,7 @@ struct FlipControlStatus {
struct FlipControlArgs {
std::uint32_t id;
// std::uint32_t padding;
std::uint32_t padding;
std::uint64_t arg2;
void *ptr;
std::uint64_t size; // 0x48 // size?
@ -91,31 +92,31 @@ struct ResolutionStatus {
std::uint32_t paneHeight;
std::uint32_t refreshHz;
std::uint32_t screenSizeInInch;
std::byte padding[20];
std::byte padding[20];
};
//refreshRate = 0 REFRESH_RATE_UNKNOWN
//refreshRate = 3; result.refreshHz = 0x426fc28f REFRESH_RATE_59_94HZ
//refreshRate = 2, result.refreshHz = 0x42480000 REFRESH_RATE_50HZ
//refreshRate = 1, result.refreshHz = 0x41bfd70a REFRESH_RATE_23_98HZ
//refreshRate = 4, result.refreshHz = 0x41c00000
//refreshRate = 5, result.refreshHz = 0x41f00000
//refreshRate = 6, result.refreshHz = 0x41efc28f REFRESH_RATE_29_97HZ
//refreshRate = 7, result.refreshHz = 0x41c80000
//refreshRate = 9, result.refreshHz = 0x42700000
//refreshRate = 10, result.refreshHz = 0x42400000
//refreshRate = 0xb, result.refreshHz = 0x423fcccd
//refreshRate = 0xc, result.refreshHz = 0x42c80000
//refreshRate = 0xd, result.refreshHz = 0x42efc28f REFRESH_RATE_119_88HZ
//refreshRate = 0xe, result.refreshHz = 0x42f00000
//refreshRate = 0xf, result.refreshHz = 0x43480000
//refreshRate = 0x10, result.refreshHz = 0x436fc28f
//refreshRate = 0x11, result.refreshHz = 0x43700000
//refreshRate = 0x14, result.refreshHz = 0x413fd70a
//refreshRate = 0x15, result.refreshHz = 0x41400000
//refreshRate = 0x16, result.refreshHz = 0x416fd70a
//refreshRate = 0x17, result.refreshHz = 0x41700000
//refreshRate = 0x23, result.refreshHz = 0x42b3d1ec REFRESH_RATE_89_91HZ
// refreshRate = 0 REFRESH_RATE_UNKNOWN
// refreshRate = 3; result.refreshHz = 0x426fc28f REFRESH_RATE_59_94HZ
// refreshRate = 2, result.refreshHz = 0x42480000 REFRESH_RATE_50HZ
// refreshRate = 1, result.refreshHz = 0x41bfd70a REFRESH_RATE_23_98HZ
// refreshRate = 4, result.refreshHz = 0x41c00000
// refreshRate = 5, result.refreshHz = 0x41f00000
// refreshRate = 6, result.refreshHz = 0x41efc28f REFRESH_RATE_29_97HZ
// refreshRate = 7, result.refreshHz = 0x41c80000
// refreshRate = 9, result.refreshHz = 0x42700000
// refreshRate = 10, result.refreshHz = 0x42400000
// refreshRate = 0xb, result.refreshHz = 0x423fcccd
// refreshRate = 0xc, result.refreshHz = 0x42c80000
// refreshRate = 0xd, result.refreshHz = 0x42efc28f REFRESH_RATE_119_88HZ
// refreshRate = 0xe, result.refreshHz = 0x42f00000
// refreshRate = 0xf, result.refreshHz = 0x43480000
// refreshRate = 0x10, result.refreshHz = 0x436fc28f
// refreshRate = 0x11, result.refreshHz = 0x43700000
// refreshRate = 0x14, result.refreshHz = 0x413fd70a
// refreshRate = 0x15, result.refreshHz = 0x41400000
// refreshRate = 0x16, result.refreshHz = 0x416fd70a
// refreshRate = 0x17, result.refreshHz = 0x41700000
// refreshRate = 0x23, result.refreshHz = 0x42b3d1ec REFRESH_RATE_89_91HZ
struct DceFile : public orbis::File {};
@ -182,6 +183,11 @@ static orbis::ErrorCode dce_ioctl(orbis::File *file, std::uint64_t request,
std::memcpy(args->ptr, &flipStatus, sizeof(FlipControlStatus));
} else if (args->id == 12) {
*(std::uint64_t *)args->ptr = 0;
} else if (args->id == 18) {
// ORBIS_LOG_NOTICE("dce: get vblank status", args->size);
if (args->size) {
*(std::uint32_t *)args->size = 0xffff'0000;
}
} else if (args->id == 19) {
// get resolution status
auto status = (ResolutionStatus *)args->ptr;
@ -189,21 +195,29 @@ static orbis::ErrorCode dce_ioctl(orbis::File *file, std::uint64_t request,
status->heigth = 1080;
status->paneWidth = 1920;
status->paneHeight = 1080;
status->refreshHz = 0x426fc28f;
status->screenSizeInInch = 867;
} else if (args->id == 9) {
ORBIS_LOG_NOTICE("dce: FlipControl allocate", args->id, args->arg2,
args->ptr, args->size);
*(std::uint64_t *)args->ptr = 0; // dev offset
*(std::uint64_t *)args->size = 0x100000; // size
} else if (args->id == 31) {
rx::bridge.header->bufferInUseAddress = args->size;
// if ((std::uint64_t)args->ptr == 0xc) {
// rx::bridge.header->bufferInUseAddress = args->size;
// } else {
// ORBIS_LOG_ERROR("buffer in use", args->ptr, args->size);
// thread->where();
// }
// std::abort();
return {};
} else if (args->id == 33) { // adjust color
std::printf("adjust color\n");
return {};
} else if (args->id == 0x1e) {
// TODO
return{};
} else if (args->id != 0 && args->id != 1) { // used during open/close
return {};
} else if (args->id != 1) { // used during open/close
ORBIS_LOG_NOTICE("dce: UNIMPLEMENTED FlipControl", args->id, args->arg2,
args->ptr, args->size);
@ -242,8 +256,8 @@ static orbis::ErrorCode dce_ioctl(orbis::File *file, std::uint64_t request,
ORBIS_LOG_ERROR("dce: RegisterBufferAttributes", args->canary, args->vid,
args->submit, args->unk3, args->pixelFormat,
args->tilingMode, args->pitch, args->width, args->height,
args->unk4_zero, args->unk5_zero, args->options, args->reserved1,
args->reserved2);
args->unk4_zero, args->unk5_zero, args->options,
args->reserved1, args->reserved2);
device->bufferAttributes.pixelFormat = args->pixelFormat;
device->bufferAttributes.tilingMode = args->tilingMode;
@ -257,12 +271,22 @@ static orbis::ErrorCode dce_ioctl(orbis::File *file, std::uint64_t request,
// flip request
auto args = reinterpret_cast<FlipRequestArgs *>(argp);
// ORBIS_LOG_ERROR("dce: FlipRequestArgs", args->arg1,
// args->displayBufferIndex, args->flipMode, args->flipArg,
// args->arg5, args->arg6, args->arg7, args->arg8);
// ORBIS_LOG_ERROR("dce: FlipRequestArgs", args->canary,
// args->displayBufferIndex, args->flipMode, args->unk1,
// args->flipArg, args->flipArg2, args->eop_nz, args->unk2,
// args->eop_val, args->unk3, args->unk4, args->rout);
rx::bridge.sendFlip(thread->tproc->pid, args->displayBufferIndex,
/*args->flipMode,*/ args->flipArg);
// *args->rout = 0;
// rx::bridge.header->flipBuffer = args->displayBufferIndex;
// rx::bridge.header->flipArg = args->flipArg;
// rx::bridge.header->flipCount += 1;
// *reinterpret_cast<std::uint64_t *>(rx::bridge.header->bufferInUseAddress)
// =
// 0;
return {};
}