From d8fed2d0898957f89b99658fe619421a0d073f37 Mon Sep 17 00:00:00 2001 From: "Chloe M." Date: Wed, 15 Jul 2026 07:53:40 +0000 Subject: [PATCH] csrts: Add CSRTS stub and load from kernel Signed-off-by: Chloe M. --- build.sh | 4 ++++ service/csrts/Makefile | 16 ++++++++++++++ service/csrts/server/Makefile | 26 +++++++++++++++++++++++ service/csrts/server/init.c | 14 ++++++++++++ service/ptos/ke/init.c | 40 ++++++++++++++++++++++++++++++++++- 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 service/csrts/Makefile create mode 100644 service/csrts/server/Makefile create mode 100644 service/csrts/server/init.c diff --git a/build.sh b/build.sh index ee0705f..f3d9dd9 100755 --- a/build.sh +++ b/build.sh @@ -72,6 +72,10 @@ build() { service/urt/ \ "Building user runtime lib..." + make_build \ + service/csrts \ + "Building CSRTS..." + make_build \ service/ptos/ \ "Building kernel..." diff --git a/service/csrts/Makefile b/service/csrts/Makefile new file mode 100644 index 0000000..0e6ca6f --- /dev/null +++ b/service/csrts/Makefile @@ -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) diff --git a/service/csrts/server/Makefile b/service/csrts/server/Makefile new file mode 100644 index 0000000..4649a9f --- /dev/null +++ b/service/csrts/server/Makefile @@ -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 $@ diff --git a/service/csrts/server/init.c b/service/csrts/server/init.c new file mode 100644 index 0000000..45596a0 --- /dev/null +++ b/service/csrts/server/init.c @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause. + * + * Description: CSRTS init + * Author: Chloe M. + */ + +#include + +VOID +Main(VOID) +{ +} diff --git a/service/ptos/ke/init.c b/service/ptos/ke/init.c index 3aa2676..73d0578 100644 --- a/service/ptos/ke/init.c +++ b/service/ptos/ke/init.c @@ -12,7 +12,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -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); } /*