wip: IPC and Runtime

This commit is contained in:
karina
2026-05-03 21:57:20 +04:00
parent 5f343c991b
commit 39b2af7626
25 changed files with 371 additions and 66 deletions
+7
View File
@@ -0,0 +1,7 @@
#pragma once
#include "Arch/Exceptions.h"
#include <Types.h>
#include <OS/Scheduler.h>
UInt64 IPCSend(OSTask* sender, UInt64 handleID, UInt64 data);
void IPCReceive(ExceptionsContext* receiverFrame);
+2 -1
View File
@@ -1,5 +1,6 @@
#pragma once
#include <Types.h>
#include "../Common/bootinfo.h"
#include <OS/Scheduler.h>
void ModuleLoad(BootModule* module);
OSTask* ModuleLoad(BootModule* module);
+28 -6
View File
@@ -4,12 +4,31 @@
#pragma once
#include <Types.h>
typedef enum {
kOSHandleTypeNone = 0,
kOSHandleTypeTask
} OSHandleType;
typedef struct {
OSHandleType type;
Pointer object;
} OSHandle;
enum {
kOSSchedulerTaskStackSize = 16 * 1024,
kOSSchedulerExceptionNumber = 0xF0F0,
kOSMaxHandlesPerProcess = 256,
};
typedef enum OSTaskState {
OSTaskStateDead,
OSTaskStateRunning,
OSTaskStateReady,
OSTaskStateBlocked,
OSTaskStateSleeping,
OSTaskStateBlockedReceive,
OSTaskStateBlockedSend,
} OSTaskState;
typedef struct OSProcess {
@@ -20,11 +39,12 @@ typedef struct OSProcess {
Address heapCurrent;
struct OSProcess* parent;
ASCII name[32];
OSHandle handles[kOSMaxHandlesPerProcess];
} OSProcess;
typedef struct OSTask {
Address stackPointer;
struct OSTask* next;
UInt32 id;
UInt32 sleepTicks;
OSTaskState state;
@@ -32,12 +52,10 @@ typedef struct OSTask {
Pointer kernelStackBase;
OSProcess* process;
Int32 waitingForProcessId;
} OSTask;
enum {
kOSSchedulerTaskStackSize = 16 * 1024,
kOSSchedulerExceptionNumber = 0xF0F0
};
struct OSTask* next;
struct OSTask* senderWaiting;
} OSTask;
extern UInt32 gOSSchedulerNextProcessID;
@@ -46,3 +64,7 @@ OSTask* SchedulerSpawn(void(*entryPoint)(), OSProcess* owner, Boolean isUser, Ad
Address SchedulerNext(Address stackPointer);
void SchedulerYield(UInt64 ticks);
UInt64 SchedulerGetNextProcessID();
void SchedulerBlockCurrentTask(UInt32 newState);
OSTask* SchedulerGetCurrentTask();
Int32 SchedulerProcessAllocateHandle(OSProcess* process, OSHandleType type, Pointer object);
Pointer SchedulerProcessGetHandle(OSProcess* process, UInt32 handleId, OSHandleType expectedType);
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#include <Types.h>
#include <Arch/Exceptions.h>
enum Syscalls {
kSyscallSend,
kSyscallReceive,
};
Address SyscallDispatch(ExceptionsContext* frame);