Merge remote-tracking branch 'upstream/master' into memory_rework

This commit is contained in:
wheremyfoodat 2024-11-09 18:29:40 +02:00
commit b89a21444e
233 changed files with 17350 additions and 1024 deletions

View file

@ -1,7 +1,7 @@
#pragma once
#include "helpers.hpp"
using Handle = u32;
using HorizonHandle = u32;
namespace KernelHandles {
enum : u32 {
@ -61,17 +61,17 @@ namespace KernelHandles {
};
// Returns whether "handle" belongs to one of the OS services
static constexpr bool isServiceHandle(Handle handle) {
static constexpr bool isServiceHandle(HorizonHandle handle) {
return handle >= MinServiceHandle && handle <= MaxServiceHandle;
}
// Returns whether "handle" belongs to one of the OS services' shared memory areas
static constexpr bool isSharedMemHandle(Handle handle) {
static constexpr bool isSharedMemHandle(HorizonHandle handle) {
return handle >= MinSharedMemHandle && handle <= MaxSharedMemHandle;
}
// Returns the name of a handle as a string based on the given handle
static const char* getServiceName(Handle handle) {
static const char* getServiceName(HorizonHandle handle) {
switch (handle) {
case AC: return "AC";
case ACT: return "ACT";

View file

@ -16,8 +16,11 @@
#include "services/service_manager.hpp"
class CPU;
struct Scheduler;
class Kernel {
using Handle = HorizonHandle;
std::span<u32, 16> regs;
CPU& cpu;
Memory& mem;
@ -247,6 +250,7 @@ public:
ServiceManager& getServiceManager() { return serviceManager; }
KFcram& getFcramManager() { return fcramManager; }
Scheduler& getScheduler();
void sendGPUInterrupt(GPUInterrupt type) { serviceManager.sendGPUInterrupt(type); }
void clearInstructionCache();

View file

@ -53,7 +53,7 @@ enum class FcramRegion {
struct AddressArbiter {};
struct ResourceLimits {
Handle handle;
HorizonHandle handle;
s32 currentCommit = 0;
};
@ -97,6 +97,8 @@ struct Port {
};
struct Session {
using Handle = HorizonHandle;
Handle portHandle; // The port this session is subscribed to
Session(Handle portHandle) : portHandle(portHandle) {}
};
@ -115,6 +117,8 @@ enum class ThreadStatus {
};
struct Thread {
using Handle = HorizonHandle;
u32 initialSP; // Initial r13 value
u32 entrypoint; // Initial r15 value
u32 priority;
@ -167,6 +171,8 @@ static const char* kernelObjectTypeToString(KernelObjectType t) {
}
struct Mutex {
using Handle = HorizonHandle;
u64 waitlist; // Refer to the getWaitlist function below for documentation
Handle ownerThread = 0; // Index of the thread that holds the mutex if it's locked
Handle handle; // Handle of the mutex itself
@ -209,6 +215,8 @@ struct MemoryBlock {
// Generic kernel object class
struct KernelObject {
using Handle = HorizonHandle;
Handle handle = 0; // A u32 the OS will use to identify objects
void* data = nullptr;
KernelObjectType type;