csrts: Add CSRTS stub and load from kernel
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -72,6 +72,10 @@ build() {
|
||||
service/urt/ \
|
||||
"Building user runtime lib..."
|
||||
|
||||
make_build \
|
||||
service/csrts \
|
||||
"Building CSRTS..."
|
||||
|
||||
make_build \
|
||||
service/ptos/ \
|
||||
"Building kernel..."
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Copyright (c) 2026, Chloe M.
|
||||
# Provided under the BSD-3 clause
|
||||
#
|
||||
# Description: Client server runtime service build script
|
||||
# Author: Chloe M.
|
||||
#
|
||||
|
||||
include ../mk/user.mk
|
||||
|
||||
.PHONY: all
|
||||
all: server
|
||||
|
||||
.PHONY: server
|
||||
server:
|
||||
cd server/; $(MAKE) $(PASSDOWN_ARGS)
|
||||
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright (c) 2026, Chloe M.
|
||||
# Provided under the BSD-3 clause
|
||||
#
|
||||
# Description: Client server runtime service build script
|
||||
# Author: Chloe M.
|
||||
#
|
||||
|
||||
CFILES = $(shell find . -name "*.c")
|
||||
OFILES = $(CFILES:.c=.o)
|
||||
|
||||
CFLAGS = $(SYS_CFLAGS)
|
||||
CRT_FILES = $(shell find $(PT_URT_CRT) -name "*.o")
|
||||
|
||||
SERVER_OUT = \
|
||||
$(PT_PROJECT_ROOT)/service/base/boot/csrts.sys
|
||||
|
||||
.PHONY: all
|
||||
all: $(SERVER_OUT)
|
||||
|
||||
.PHONY: $(SERVER_OUT)
|
||||
$(SERVER_OUT): $(OFILES)
|
||||
$(SYS_LD) $(OFILES) $(CRT_FILES) -T$(USER_LDS) -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(SYS_CC) -c $< $(CFLAGS) -o $@
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Chloe M.
|
||||
* Provided under the BSD-3 clause.
|
||||
*
|
||||
* Description: CSRTS init
|
||||
* Author: Chloe M.
|
||||
*/
|
||||
|
||||
#include <ptdef.h>
|
||||
|
||||
VOID
|
||||
Main(VOID)
|
||||
{
|
||||
}
|
||||
+39
-1
@@ -12,7 +12,9 @@
|
||||
#include <ke/sched.h>
|
||||
#include <ex/trace.h>
|
||||
#include <ex/pbi.h>
|
||||
#include <ex/loader.h>
|
||||
#include <ps/process.h>
|
||||
#include <ps/thread.h>
|
||||
#include <mm/pm.h>
|
||||
#include <mm/vm.h>
|
||||
#include <hal/prim.h>
|
||||
@@ -26,6 +28,7 @@
|
||||
/* Globals */
|
||||
static KPCR BootstrapCore;
|
||||
static PROCESS *RootProcess;
|
||||
static THREAD *RootThread;
|
||||
|
||||
/*
|
||||
* Display the copyright for legal reasons
|
||||
@@ -44,11 +47,13 @@ static VOID
|
||||
InitializeRootProcess(VOID)
|
||||
{
|
||||
PT_STATUS Status;
|
||||
PBI_FILE File;
|
||||
LOADER_PROGRAM Csrts;
|
||||
|
||||
/* Create the client server runtime service */
|
||||
Status = PsCreateProcess(
|
||||
"csrts.sys",
|
||||
0,
|
||||
PS_USER,
|
||||
&RootProcess
|
||||
);
|
||||
|
||||
@@ -58,6 +63,39 @@ InitializeRootProcess(VOID)
|
||||
"could not create csrts.sys process\n"
|
||||
);
|
||||
}
|
||||
|
||||
/* Get the CSRTS binary */
|
||||
Status = ExPbiLookup("/boot/csrts.sys", &File);
|
||||
if (PT_ERROR(Status)) {
|
||||
KeBugCheck(
|
||||
BUGCHECK_MISC,
|
||||
"unable to locate /boot/csrts.sys\n"
|
||||
);
|
||||
}
|
||||
|
||||
/* Now load the program */
|
||||
Status = ExLoadProgramOf(
|
||||
LOADER_ELF64,
|
||||
&RootProcess->Vas,
|
||||
File.Data,
|
||||
&Csrts
|
||||
);
|
||||
|
||||
if (PT_ERROR(Status)) {
|
||||
KeBugCheck(
|
||||
BUGCHECK_MISC,
|
||||
"unable to load csrts.sys\n"
|
||||
);
|
||||
}
|
||||
|
||||
Status = PsCreateThread(
|
||||
RootProcess,
|
||||
0,
|
||||
Csrts.EntryPoint,
|
||||
&RootThread
|
||||
);
|
||||
|
||||
KeSchedEnqueue(&BootstrapCore.SchedQueue, RootThread);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user