mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +12:00
[Kernel] Fix DuplicateHandle, fix typo, panic on FS::OpenFileDirectly
This commit is contained in:
parent
fca54b99a7
commit
88c93645e3
4 changed files with 21 additions and 4 deletions
|
@ -12,6 +12,7 @@ class FSService {
|
|||
// Service commands
|
||||
void initialize(u32 messagePointer);
|
||||
void openArchive(u32 messagePointer);
|
||||
void openFileDirectly(u32 messagePointer);
|
||||
|
||||
public:
|
||||
FSService(Memory& mem) : mem(mem) {}
|
||||
|
|
|
@ -173,10 +173,11 @@ void Kernel::duplicateHandle() {
|
|||
logSVC("DuplicateHandle(handle = %X)\n", original);
|
||||
|
||||
if (original == KernelHandles::CurrentThread) {
|
||||
printf("[Warning] Duplicated current thread. This might be horribly broken!\n");
|
||||
const auto& t = threads[currentThreadIndex];
|
||||
regs[0] = SVCResult::Success;
|
||||
regs[1] = makeThread(t.entrypoint, t.initialSP, t.priority, t.processorID, t.arg, t.status);
|
||||
Handle ret = makeObject(KernelObjectType::Thread);
|
||||
objects[ret].data = &threads[currentThreadIndex];
|
||||
|
||||
regs[1] = ret;
|
||||
} else {
|
||||
Helpers::panic("DuplicateHandle: unimplemented handle type");
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ std::optional<u32> Memory::findPaddr(u32 size) {
|
|||
candidatePage = i + 1;
|
||||
counter = 0;
|
||||
}
|
||||
else { // Our candidate page has 1 mor
|
||||
else { // The paddr we're testing has 1 more free page
|
||||
counter++;
|
||||
// Check if there's enough free memory to use this page
|
||||
// We use == instead of >= because some software does 0-byte allocations
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace FSCommands {
|
||||
enum : u32 {
|
||||
Initialize = 0x08010002,
|
||||
OpenFileDirectly = 0x08030204,
|
||||
OpenArchive = 0x080C00C2
|
||||
};
|
||||
}
|
||||
|
@ -21,6 +22,7 @@ void FSService::handleSyncRequest(u32 messagePointer) {
|
|||
switch (command) {
|
||||
case FSCommands::Initialize: initialize(messagePointer); break;
|
||||
case FSCommands::OpenArchive: openArchive(messagePointer); break;
|
||||
case FSCommands::OpenFileDirectly: openFileDirectly(messagePointer); break;
|
||||
default: Helpers::panic("FS service requested. Command: %08X\n", command);
|
||||
}
|
||||
}
|
||||
|
@ -33,4 +35,17 @@ void FSService::initialize(u32 messagePointer) {
|
|||
void FSService::openArchive(u32 messagePointer) {
|
||||
log("FS::OpenArchive (failure)\n");
|
||||
mem.write32(messagePointer + 4, Result::Failure);
|
||||
}
|
||||
|
||||
void FSService::openFileDirectly(u32 messagePointer) {
|
||||
const u32 archiveID = mem.read32(messagePointer + 8);
|
||||
const u32 archivePathType = mem.read32(messagePointer + 12);
|
||||
const u32 filePathType = mem.read32(messagePointer + 20);
|
||||
const u32 archivePathPointer = mem.read32(messagePointer + 40);
|
||||
const u32 filePathPointer = mem.read32(messagePointer + 48);
|
||||
|
||||
log("FS::OpenFileDirectly (failure)\n");
|
||||
|
||||
mem.write32(messagePointer + 4, Result::Failure);
|
||||
Helpers::panic("[FS::OpenFileDirectly] Tried to open file. Archive ID = %d\n", archiveID);
|
||||
}
|
Loading…
Add table
Reference in a new issue