[Kernel] More threading work

This commit is contained in:
wheremyfoodat 2022-09-20 01:50:32 +03:00
parent 11d8a43bd8
commit 1ac9417d50
2 changed files with 22 additions and 6 deletions

View file

@ -8,12 +8,16 @@ namespace SVCResult {
Success = 0, Success = 0,
Failure = 0xFFFFFFFF, Failure = 0xFFFFFFFF,
ObjectNotFound = 0xD88007FA, ObjectNotFound = 0xD88007FA,
// Different calls return a different value
// Different calls return a different value for these ones
InvalidEnumValue = 0xD8E007ED,
InvalidEnumValueAlt = 0xD8E093ED,
BadHandle = 0xD8E007F7, BadHandle = 0xD8E007F7,
BadHandleAlt = 0xD9001BF7, BadHandleAlt = 0xD9001BF7,
BadThreadPriority = 0xE0E01BFD, BadThreadPriority = 0xE0E01BFD,
PortNameTooLong = 0xE0E0181E, PortNameTooLong = 0xE0E0181E,
}; };
} }

View file

@ -34,7 +34,7 @@ void Kernel::arbitrateAddress() {
const Handle handle = regs[0]; const Handle handle = regs[0];
const u32 address = regs[1]; const u32 address = regs[1];
const u32 type = regs[2]; const u32 type = regs[2];
const u32 value = regs[3]; const s32 value = regs[3];
const s64 ns = s64(u64(regs[4]) | (u64(regs[5]) << 32)); const s64 ns = s64(u64(regs[4]) | (u64(regs[5]) << 32));
printf("ArbitrateAddress(Handle = %X, address = %08X, type = %s, value = %d, ns = %lld)\n", handle, address, printf("ArbitrateAddress(Handle = %X, address = %08X, type = %s, value = %d, ns = %lld)\n", handle, address,
@ -46,13 +46,25 @@ void Kernel::arbitrateAddress() {
return; return;
} }
if (value > 4) { if (address & 3) {
Helpers::panic("ArbitrateAddress: invalid arbitration type"); Helpers::panic("ArbitrateAddres:: Unaligned address");
}
if (value > 4) [[unlikely]] {
regs[0] = SVCResult::InvalidEnumValueAlt;
return;
} }
switch (static_cast<ArbitrationType>(type)) { switch (static_cast<ArbitrationType>(type)) {
case ArbitrationType::WaitIfLess: // Puts this thread to sleep if word < value until another thread signals the address with the type SIGNAL
Helpers::panic("Uwu"); case ArbitrationType::WaitIfLess: {
s32 word = static_cast<s32>(mem.read32(address)); // Yes this is meant to be signed
if (word < value) {
Helpers::panic("Needa sleep");
}
break;
}
default: default:
Helpers::panic("ArbitrateAddress: Unimplemented type %s", arbitrationTypeToString(type)); Helpers::panic("ArbitrateAddress: Unimplemented type %s", arbitrationTypeToString(type));
} }