Rename Handle to HorizonHandle, add metal-cpp submodule, format

This commit is contained in:
wheremyfoodat 2024-07-23 15:22:15 +03:00
parent 855a374f67
commit 0f80d0af7a
46 changed files with 150 additions and 60 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

@ -18,6 +18,8 @@ class CPU;
struct Scheduler;
class Kernel {
using Handle = HorizonHandle;
std::span<u32, 16> regs;
CPU& cpu;
Memory& mem;

View file

@ -47,7 +47,7 @@ enum class ProcessorID : s32 {
struct AddressArbiter {};
struct ResourceLimits {
Handle handle;
HorizonHandle handle;
s32 currentCommit = 0;
};
@ -91,6 +91,8 @@ struct Port {
};
struct Session {
using Handle = HorizonHandle;
Handle portHandle; // The port this session is subscribed to
Session(Handle portHandle) : portHandle(portHandle) {}
};
@ -109,6 +111,8 @@ enum class ThreadStatus {
};
struct Thread {
using Handle = HorizonHandle;
u32 initialSP; // Initial r13 value
u32 entrypoint; // Initial r15 value
u32 priority;
@ -161,6 +165,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
@ -203,6 +209,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;