mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-12 09:09:47 +12:00
[Kernel] Implement File::SetPriority
This commit is contained in:
parent
5966c02737
commit
2ab777fecd
3 changed files with 24 additions and 2 deletions
|
@ -91,14 +91,15 @@ struct FileSession {
|
||||||
FILE* fd = nullptr; // File descriptor for file sessions that require them.
|
FILE* fd = nullptr; // File descriptor for file sessions that require them.
|
||||||
FSPath path;
|
FSPath path;
|
||||||
FSPath archivePath;
|
FSPath archivePath;
|
||||||
|
u32 priority = 0; // TODO: What does this even do
|
||||||
bool isOpen;
|
bool isOpen;
|
||||||
|
|
||||||
FileSession(ArchiveBase* archive, const FSPath& filePath, const FSPath& archivePath, FILE* fd, bool isOpen = true) :
|
FileSession(ArchiveBase* archive, const FSPath& filePath, const FSPath& archivePath, FILE* fd, bool isOpen = true) :
|
||||||
archive(archive), path(filePath), archivePath(archivePath), fd(fd), isOpen(isOpen) {}
|
archive(archive), path(filePath), archivePath(archivePath), fd(fd), isOpen(isOpen), priority(0) {}
|
||||||
|
|
||||||
// For cloning a file session
|
// For cloning a file session
|
||||||
FileSession(const FileSession& other) : archive(other.archive), path(other.path),
|
FileSession(const FileSession& other) : archive(other.archive), path(other.path),
|
||||||
archivePath(other.archivePath), fd(other.fd), isOpen(other.isOpen) {}
|
archivePath(other.archivePath), fd(other.fd), isOpen(other.isOpen), priority(other.priority) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ArchiveSession {
|
struct ArchiveSession {
|
||||||
|
|
|
@ -127,6 +127,7 @@ private:
|
||||||
void writeFile(u32 messagePointer, Handle file);
|
void writeFile(u32 messagePointer, Handle file);
|
||||||
void getFileSize(u32 messagePointer, Handle file);
|
void getFileSize(u32 messagePointer, Handle file);
|
||||||
void openLinkFile(u32 messagePointer, Handle file);
|
void openLinkFile(u32 messagePointer, Handle file);
|
||||||
|
void setFilePriority(u32 messagePointer, Handle file);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Kernel(CPU& cpu, Memory& mem, GPU& gpu);
|
Kernel(CPU& cpu, Memory& mem, GPU& gpu);
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace FileOps {
|
||||||
Write = 0x08030102,
|
Write = 0x08030102,
|
||||||
GetSize = 0x08040000,
|
GetSize = 0x08040000,
|
||||||
Close = 0x08080000,
|
Close = 0x08080000,
|
||||||
|
SetPriority = 0x080A0040,
|
||||||
OpenLinkFile = 0x080C0000
|
OpenLinkFile = 0x080C0000
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -24,6 +25,7 @@ void Kernel::handleFileOperation(u32 messagePointer, Handle file) {
|
||||||
case FileOps::GetSize: getFileSize(messagePointer, file); break;
|
case FileOps::GetSize: getFileSize(messagePointer, file); break;
|
||||||
case FileOps::OpenLinkFile: openLinkFile(messagePointer, file); break;
|
case FileOps::OpenLinkFile: openLinkFile(messagePointer, file); break;
|
||||||
case FileOps::Read: readFile(messagePointer, file); break;
|
case FileOps::Read: readFile(messagePointer, file); break;
|
||||||
|
case FileOps::SetPriority: setFilePriority(messagePointer, file); break;
|
||||||
case FileOps::Write: writeFile(messagePointer, file); break;
|
case FileOps::Write: writeFile(messagePointer, file); break;
|
||||||
default: Helpers::panic("Unknown file operation: %08X", cmd);
|
default: Helpers::panic("Unknown file operation: %08X", cmd);
|
||||||
}
|
}
|
||||||
|
@ -182,4 +184,22 @@ void Kernel::openLinkFile(u32 messagePointer, Handle fileHandle) {
|
||||||
|
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
mem.write32(messagePointer + 12, handle);
|
mem.write32(messagePointer + 12, handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Kernel::setFilePriority(u32 messagePointer, Handle fileHandle) {
|
||||||
|
const u32 priority = mem.read32(messagePointer + 4);
|
||||||
|
logFileIO("Setting priority of file %X to %d\n", fileHandle, priority);
|
||||||
|
|
||||||
|
const auto p = getObject(fileHandle, KernelObjectType::File);
|
||||||
|
if (p == nullptr) [[unlikely]] {
|
||||||
|
Helpers::panic("Called GetFileSize on non-existent file");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileSession* file = p->getData<FileSession>();
|
||||||
|
if (!file->isOpen) {
|
||||||
|
Helpers::panic("Tried to clone closed file");
|
||||||
|
}
|
||||||
|
file->priority = priority;
|
||||||
|
|
||||||
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue