From 3ad06ac1f87017e862d9c8bf08f4a5d15758bc6a Mon Sep 17 00:00:00 2001 From: "Chloe M." Date: Mon, 22 Jun 2026 01:24:57 +0000 Subject: [PATCH] paw: spkg: Add support package groundwork Signed-off-by: Chloe M. --- build.sh | 4 ++++ paw/Makefile | 16 ++++++++++++++++ paw/spkg/Makefile | 25 +++++++++++++++++++++++++ paw/spkg/head/string.h | 25 +++++++++++++++++++++++++ paw/spkg/lib/memcmp.c | 32 ++++++++++++++++++++++++++++++++ paw/stos/arch/amd64/Makefile | 1 + paw/stos/ke/Makefile | 4 +++- 7 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 paw/Makefile create mode 100644 paw/spkg/Makefile create mode 100644 paw/spkg/head/string.h create mode 100644 paw/spkg/lib/memcmp.c diff --git a/build.sh b/build.sh index 46b3c16..e571941 100755 --- a/build.sh +++ b/build.sh @@ -63,6 +63,10 @@ make_build() { build() { mkdir -p artifacts/ + make_build \ + paw/ \ + "Building world..." + make_build \ paw/host \ "Building host utils..." diff --git a/paw/Makefile b/paw/Makefile new file mode 100644 index 0000000..5f9edbc --- /dev/null +++ b/paw/Makefile @@ -0,0 +1,16 @@ +# +# Copyright (c) 2026, Chloe M. +# Provided under the BSD-3 clause +# +# Description: OS world build script +# Author: Chloe M. +# + +include mk/stos.mk + +.PHONY: all +all: spkg + +.PHONY: spkg +spkg: + cd spkg/; $(MAKE) $(PASSDOWN_ARGS) diff --git a/paw/spkg/Makefile b/paw/spkg/Makefile new file mode 100644 index 0000000..b2e88c2 --- /dev/null +++ b/paw/spkg/Makefile @@ -0,0 +1,25 @@ +# +# Copyright (c) 2026, Chloe M. +# Provided under the BSD-3 clause +# +# Description: Support package build script +# Author: Chloe M. +# + +.SILENT: +include ../mk/stos.mk + +CFILES = $(shell find . -name "*.c") +OFILES = $(CFILES:.c=.o) + +CFLAGS = \ + $(SYS_CFLAGS) \ + -Ihead \ + -I$(ST_PROJECT_ROOT)/sdk/head + +.PHONY: all +all: $(OFILES) + +%.o: %.c + $(PROMPT) "CC" $< + $(SYS_CC) -c $(CFLAGS) $< -o $@ diff --git a/paw/spkg/head/string.h b/paw/spkg/head/string.h new file mode 100644 index 0000000..d7cfbf3 --- /dev/null +++ b/paw/spkg/head/string.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause. + * + * Description: String helpers + * Author: Chloe M. + */ + +#ifndef _SPKG_STRING_H_ +#define _SPKG_STRING_H_ 1 + +#include + +/* + * Compare the differences between two strings + * + * @Buffer1: First buffer to compare + * @Buffer2: Second buffer to compare + * @Length: Number of bytes to compare + * + * Returns the differences + */ +LONG RtlMemCmp(const VOID *Buffer1, const VOID *Buffer2, USIZE Length); + +#endif /* !_SPKG_STRING_H_ */ diff --git a/paw/spkg/lib/memcmp.c b/paw/spkg/lib/memcmp.c new file mode 100644 index 0000000..5b57ec8 --- /dev/null +++ b/paw/spkg/lib/memcmp.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause. + * + * Description: RtlMemCmp() implementation + * Author: Chloe M. + */ + +#include + +LONG +RtlMemCmp(const VOID *Buffer1, const VOID *Buffer2, USIZE Length) +{ + const UCHAR *Ptr1 = Buffer1; + const UCHAR *Ptr2 = Buffer2; + + if (Buffer1 == NULL || Buffer2 == NULL) { + return 0; + } + + if (Length == 0) { + return 0; + } + + do { + if (*Ptr1++ != *Ptr2++) { + return (*--Ptr1 - *--Ptr2); + } + } while (--Length != 0); + + return 0; +} diff --git a/paw/stos/arch/amd64/Makefile b/paw/stos/arch/amd64/Makefile index 1c6b0aa..d7fc37f 100644 --- a/paw/stos/arch/amd64/Makefile +++ b/paw/stos/arch/amd64/Makefile @@ -13,6 +13,7 @@ ASMFILES = $(shell find . -name "*.S") ASMOFILES = $(ASMFILES:.S=.S.o) MISC_OFILES = $(ASMOFILES) +MISC_OFILES += $(shell find $(ST_PROJECT_ROOT)/paw/spkg/ -name "*.o") MISC_OFILES += $(shell find $(ST_PROJECT_ROOT)/paw/stos/ -name "*.o" | grep -v "arch") KERNEL_PATH = \ diff --git a/paw/stos/ke/Makefile b/paw/stos/ke/Makefile index f60939d..dcfa06f 100644 --- a/paw/stos/ke/Makefile +++ b/paw/stos/ke/Makefile @@ -23,7 +23,9 @@ CFLAGS = \ -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T \ -DPRINTF_DISABLE_SUPPORT_FLOAT \ -I../head \ - -I$(ST_PROJECT_ROOT)/sdk/head + -I$(ST_PROJECT_ROOT)/paw/spkg/head \ + -I$(ST_PROJECT_ROOT)/sdk/head \ + -D_BOOT_PROTO="\"$(ST_BOOT_PROTOCOL)\"" .PHONY: all all: $(OFILES)