From be8ec12ba13de33616ace33be6e2c310a2b2fe05 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 9 Jul 2024 09:25:20 +0200 Subject: MHR-36: See below. - Add ARM64 linker script. - Replace Drv with Drivers (not really relevant). - Replace ReadMe.md in DDK. Signed-off-by: Amlal El Mahrouss --- Comm/compile_flags.txt | 3 +- Comm/newstd.hxx | 2 +- DDK/ReadMe.md | 9 +++ DDK/ReadMe.txt | 4 - Drivers/.gitkeep | 0 Drivers/Hello/CheckStack.c | 18 +++++ Drivers/Hello/DriverRsrc.rsrc | 25 +++++++ Drivers/Hello/Hello.c | 131 +++++++++++++++++++++++++++++++++ Drivers/Hello/compile_flags.txt | 3 + Drivers/Hello/x86_64.mk | 52 +++++++++++++ Drivers/SampleDriver/CheckStck.c | 11 +++ Drivers/SampleDriver/DriverRsrc.rsrc | 25 +++++++ Drivers/SampleDriver/SampleDriver.c | 20 +++++ Drivers/SampleDriver/compile_flags.txt | 3 + Drivers/SampleDriver/x86_64.mk | 51 +++++++++++++ Drivers/VideoDrv/CheckStck.c | 11 +++ Drivers/VideoDrv/DriverRsrc.rsrc | 25 +++++++ Drivers/VideoDrv/VideoDrv.cxx | 22 ++++++ Drivers/VideoDrv/compile_flags.txt | 3 + Drivers/VideoDrv/x86_64.make | 51 +++++++++++++ Drv/.gitkeep | 0 Drv/Hello/CheckStack.c | 18 ----- Drv/Hello/DriverRsrc.rsrc | 25 ------- Drv/Hello/Hello.c | 131 --------------------------------- Drv/Hello/x86_64.mk | 52 ------------- Drv/SampleDriver/CheckStck.c | 11 --- Drv/SampleDriver/DriverRsrc.rsrc | 25 ------- Drv/SampleDriver/SampleDriver.c | 20 ----- Drv/SampleDriver/x86_64.mk | 51 ------------- Drv/VideoDrv/CheckStck.c | 11 --- Drv/VideoDrv/DriverRsrc.rsrc | 25 ------- Drv/VideoDrv/VideoDrv.cc | 22 ------ Drv/VideoDrv/x86_64.make | 51 ------------- Kernel/Linker/16x0.json | 2 + Kernel/Linker/32x0.json | 2 + Kernel/Linker/64x0.json | 2 + Kernel/Linker/arm64.json | 8 ++ 37 files changed, 477 insertions(+), 448 deletions(-) create mode 100644 DDK/ReadMe.md delete mode 100644 DDK/ReadMe.txt create mode 100644 Drivers/.gitkeep create mode 100644 Drivers/Hello/CheckStack.c create mode 100644 Drivers/Hello/DriverRsrc.rsrc create mode 100644 Drivers/Hello/Hello.c create mode 100644 Drivers/Hello/compile_flags.txt create mode 100644 Drivers/Hello/x86_64.mk create mode 100644 Drivers/SampleDriver/CheckStck.c create mode 100644 Drivers/SampleDriver/DriverRsrc.rsrc create mode 100644 Drivers/SampleDriver/SampleDriver.c create mode 100644 Drivers/SampleDriver/compile_flags.txt create mode 100644 Drivers/SampleDriver/x86_64.mk create mode 100644 Drivers/VideoDrv/CheckStck.c create mode 100644 Drivers/VideoDrv/DriverRsrc.rsrc create mode 100644 Drivers/VideoDrv/VideoDrv.cxx create mode 100644 Drivers/VideoDrv/compile_flags.txt create mode 100644 Drivers/VideoDrv/x86_64.make delete mode 100644 Drv/.gitkeep delete mode 100644 Drv/Hello/CheckStack.c delete mode 100644 Drv/Hello/DriverRsrc.rsrc delete mode 100644 Drv/Hello/Hello.c delete mode 100644 Drv/Hello/x86_64.mk delete mode 100644 Drv/SampleDriver/CheckStck.c delete mode 100644 Drv/SampleDriver/DriverRsrc.rsrc delete mode 100644 Drv/SampleDriver/SampleDriver.c delete mode 100644 Drv/SampleDriver/x86_64.mk delete mode 100644 Drv/VideoDrv/CheckStck.c delete mode 100644 Drv/VideoDrv/DriverRsrc.rsrc delete mode 100644 Drv/VideoDrv/VideoDrv.cc delete mode 100644 Drv/VideoDrv/x86_64.make create mode 100644 Kernel/Linker/arm64.json diff --git a/Comm/compile_flags.txt b/Comm/compile_flags.txt index e1f07ac3..509e3eed 100644 --- a/Comm/compile_flags.txt +++ b/Comm/compile_flags.txt @@ -1,3 +1,4 @@ -I./ --I../Kerne; +-I../Kernel +-I../ -std=c++20 diff --git a/Comm/newstd.hxx b/Comm/newstd.hxx index 2ec50df6..70abe793 100644 --- a/Comm/newstd.hxx +++ b/Comm/newstd.hxx @@ -45,7 +45,7 @@ typedef char UTFChar; typedef UInt32 MBCIType; /** - @brief Application class. + @brief System call class. */ class NSyscall { diff --git a/DDK/ReadMe.md b/DDK/ReadMe.md new file mode 100644 index 00000000..09f7a261 --- /dev/null +++ b/DDK/ReadMe.md @@ -0,0 +1,9 @@ +# DDK (Device Driver Kit) + +A kit used to write kernel HALs, using the NDK compiler suite. + +## How to use + +Simply link against these files. + +###### Copyright 2024 Zeta Electronics Corporation, all rights reserved. diff --git a/DDK/ReadMe.txt b/DDK/ReadMe.txt deleted file mode 100644 index 61feadea..00000000 --- a/DDK/ReadMe.txt +++ /dev/null @@ -1,4 +0,0 @@ -=== Device Driver Kit === - --> A kit used to write kernel HALs. --> Use MPCC to compile the code. diff --git a/Drivers/.gitkeep b/Drivers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Drivers/Hello/CheckStack.c b/Drivers/Hello/CheckStack.c new file mode 100644 index 00000000..3ffbe3e2 --- /dev/null +++ b/Drivers/Hello/CheckStack.c @@ -0,0 +1,18 @@ +/* ------------------------------------------- + + Copyright Zeta Electronics Corporation + +------------------------------------------- */ + +#include +#include +#include + +///! @brief Raised when we get out of bounds. Abort here. +void ___chkstk_ms(void) +{ + kernelPrintStr("Hello: KeStop needs to be raised...\r"); + + char* in = "__chkstk_ms on " __FILE__; + kernelCall("KeStop", 0, in, kernelStringLength(in)); +} diff --git a/Drivers/Hello/DriverRsrc.rsrc b/Drivers/Hello/DriverRsrc.rsrc new file mode 100644 index 00000000..12add0e2 --- /dev/null +++ b/Drivers/Hello/DriverRsrc.rsrc @@ -0,0 +1,25 @@ +1 ICON "../../Icons/app-logo.ico" + +1 VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "Zeta Electronics Corporation" + VALUE "FileDescription", "New OS Zeroconf driver." + VALUE "FileVersion", "1.00" + VALUE "InternalName", "Bonjour." + VALUE "LegalCopyright", "Copyright Zeta Electronics Corporation, all rights reserved." + VALUE "OriginalFilename", "Bonjour.exe" + VALUE "ProductName", "Bonjour." + VALUE "ProductVersion", "1.00" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1252 + END +END diff --git a/Drivers/Hello/Hello.c b/Drivers/Hello/Hello.c new file mode 100644 index 00000000..ba3d9733 --- /dev/null +++ b/Drivers/Hello/Hello.c @@ -0,0 +1,131 @@ +/* ------------------------------------------- + + Copyright Zeta Electronics Corporation + +------------------------------------------- */ + +#include +#include +#include + +struct HelloMasterConfigHeader; +struct HelloMasterConfigHeaderInput; + +struct HelloMasterConfigHeaderInput +{ + size_t fSizeOfOutput; + struct HelloMasterConfigHeader* fOutput; +}; + +/// @file Hello.c +/// @brief Zero configuration protocol, a much more better protocol for zero configuration. + +#define cHMCHMaxDataLength (1024) + +typedef struct HelloMasterConfigHeader +{ + int64_t fMagic; + int64_t fVersion; + int64_t fSourceAddress; + size_t fDataLength; + wchar_t fUTF16Data[cHMCHMaxDataLength]; +} __attribute__((packed)) HelloMasterConfigHeader; + +#define cHMCHDeviceLen 255 + +static kernelDeviceRef cDev = nil; +static char* cDeviceUUID = nil; // 3ed40738-c7d6-4b59-afdf-3c104b05fbf +static HelloMasterConfigHeader* cHeader = nil; + +/// @brief Link to master device to attribute DHCP lease. +static void __hello_link_device(void* a0) +{ + kernelPrintStr("Hello: turning up...\r"); + + if (!cDev) + { + // open raw network device. + cDev = kernelOpenDevice("RAWNET:\\"); + } + + cDev->write("+LINK", kernelStringLength("+LINK")); + cDev->wait(); + + cDev->write((void*)cDeviceUUID, kernelStringLength(cDeviceUUID)); + cDev->wait(); + + if (cHeader) + { + kernelFree(cHeader); + cHeader = nil; + } + + cHeader = cDev->read(nil, sizeof(HelloMasterConfigHeader)); +} + +static void __hello_get_hmch(void* a0) +{ + if (a0 == nil) + return; + + kernelPrintStr("Hello: returning header...\r"); + + struct HelloMasterConfigHeaderInput* in = a0; + in->fOutput = cHeader; + in->fSizeOfOutput = sizeof(in->fOutput); +} + +static void __hello_unlink_device(void* a0) +{ + kernelPrintStr("Hello: shutting down...\r"); + + if (cDev) + { + cDev->write("+UNLINK", kernelStringLength("+UNLINK")); + cDev->wait(); + + /// here is my uuid and my config header. Please disconnect me. + cDev->write((void*)cDeviceUUID, kernelStringLength(cDeviceUUID)); + cDev->write(cHeader, sizeof(cHeader)); + + cDev->wait(); + + kernelCloseDevice(cDev); + cDev = nil; + } + + if (cDeviceUUID) + { + kernelFree((void*)cDeviceUUID); + cDeviceUUID = nil; + } + + cDev = nil; +} + +int __at_enter(void) +{ + kernelPrintStr("Hello: starting up Helloconf...\r"); + + cDeviceUUID = kernelAlloc(sizeof(char) * cHMCHDeviceLen); + + kernelAddSyscall(0, __hello_link_device); + kernelAddSyscall(1, __hello_unlink_device); + kernelAddSyscall(2, __hello_get_hmch); + + return 0; +} + +int __at_exit(void) +{ + kernelPrintStr("Hello: starting up Helloconf...\r"); + + // first unlink. + __hello_unlink_device(nil); + + // then unregister syscalls. + kernelAddSyscall(0, nil); + kernelAddSyscall(1, nil); + + return 0; +} diff --git a/Drivers/Hello/compile_flags.txt b/Drivers/Hello/compile_flags.txt new file mode 100644 index 00000000..10bdb71e --- /dev/null +++ b/Drivers/Hello/compile_flags.txt @@ -0,0 +1,3 @@ +-I../../ +-I../../Kernel +-std=c++20 diff --git a/Drivers/Hello/x86_64.mk b/Drivers/Hello/x86_64.mk new file mode 100644 index 00000000..564fe970 --- /dev/null +++ b/Drivers/Hello/x86_64.mk @@ -0,0 +1,52 @@ +################################################## +# (C) Zeta Electronics Corporation, all rights reserved. +# This is the sample driver makefile. +################################################## + +CC_GNU=x86_64-w64-mingw32-gcc +LD_GNU=x86_64-w64-mingw32-ld + +WINDRES=x86_64-w64-mingw32-windres + +ADD_FILE=touch +COPY=cp +HTTP_GET=wget + +LD_FLAGS=-e __at_enter --subsystem=17 + +OBJ=*.o + + +REM=rm +REM_FLAG=-f + +FLAG_ASM=-f win64 +FLAG_GNU=-fshort-wchar -fno-rtti -fno-exceptions -D__DDK_AMD64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ \ + -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ + +.PHONY: invalid-recipe +invalid-recipe: + @echo "invalid-recipe: Use make all instead." + +.PHONY: all +all: compile-amd64 + $(LD_GNU) $(OBJ) $(LD_FLAGS) -o Hello.exe + +ifneq ($(DEBUG_SUPPORT), ) +DEBUG = -D__DEBUG__ +endif + +.PHONY: compile-amd64 +compile-amd64: + $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o + $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DDK/*.cc) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S) + +.PHONY: clean +clean: + $(REM) $(REM_FLAG) $(OBJ) Hello.exe + +.PHONY: help +help: + @echo "=== HELP ===" + @echo "clean: Clean driver." + @echo "compile-amd64: Build driver." diff --git a/Drivers/SampleDriver/CheckStck.c b/Drivers/SampleDriver/CheckStck.c new file mode 100644 index 00000000..3eb157ba --- /dev/null +++ b/Drivers/SampleDriver/CheckStck.c @@ -0,0 +1,11 @@ +/* ------------------------------------------- + + Copyright Zeta Electronics Corporation + +------------------------------------------- */ + +///! @brief Use this to check your stack, if using MinGW/MSVC/CodeTools. +void ___chkstk_ms(void) +{ + (void)0; +} diff --git a/Drivers/SampleDriver/DriverRsrc.rsrc b/Drivers/SampleDriver/DriverRsrc.rsrc new file mode 100644 index 00000000..54940e43 --- /dev/null +++ b/Drivers/SampleDriver/DriverRsrc.rsrc @@ -0,0 +1,25 @@ +1 ICON "../../Icons/app-logo.ico" + +1 VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "Zeta Electronics Corporation" + VALUE "FileDescription", "New OS driver." + VALUE "FileVersion", "1.00" + VALUE "InternalName", "SampleDriver" + VALUE "LegalCopyright", "Copyright Zeta Electronics Corporation, all rights reserved." + VALUE "OriginalFilename", "SampleDriver.exe" + VALUE "ProductName", "SampleDriver" + VALUE "ProductVersion", "1.00" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1252 + END +END diff --git a/Drivers/SampleDriver/SampleDriver.c b/Drivers/SampleDriver/SampleDriver.c new file mode 100644 index 00000000..85bd8d54 --- /dev/null +++ b/Drivers/SampleDriver/SampleDriver.c @@ -0,0 +1,20 @@ +/* ------------------------------------------- + + Copyright Zeta Electronics Corporation + +------------------------------------------- */ + +#include +#include + +int __ImageStart(void) +{ + kernelPrintStr("SampleDriver: Starting up...\r"); + return 0; +} + +int __ImageEnd(void) +{ + kernelPrintStr("SampleDriver: Shutting down...\r"); + return 0; +} diff --git a/Drivers/SampleDriver/compile_flags.txt b/Drivers/SampleDriver/compile_flags.txt new file mode 100644 index 00000000..10bdb71e --- /dev/null +++ b/Drivers/SampleDriver/compile_flags.txt @@ -0,0 +1,3 @@ +-I../../ +-I../../Kernel +-std=c++20 diff --git a/Drivers/SampleDriver/x86_64.mk b/Drivers/SampleDriver/x86_64.mk new file mode 100644 index 00000000..5655902f --- /dev/null +++ b/Drivers/SampleDriver/x86_64.mk @@ -0,0 +1,51 @@ +################################################## +# (C) Zeta Electronics Corporation, all rights reserved. +# This is the sample driver makefile. +################################################## + +CC_GNU=x86_64-w64-mingw32-gcc +LD_GNU=x86_64-w64-mingw32-ld + +WINDRES=x86_64-w64-mingw32-windres + +ADD_FILE=touch +COPY=cp +HTTP_GET=wget + +LD_FLAGS=-e __at_enter --subsystem=17 + +OBJ=*.o + + +REM=rm +REM_FLAG=-f + +FLAG_ASM=-f win64 +FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ + +.PHONY: invalid-recipe +invalid-recipe: + @echo "invalid-recipe: Use make all instead." + +.PHONY: all +all: compile-amd64 + $(LD_GNU) $(OBJ) $(LD_FLAGS) -o SampleDriver.exe + +ifneq ($(DEBUG_SUPPORT), ) +DEBUG = -D__DEBUG__ +endif + +.PHONY: compile-amd64 +compile-amd64: + $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o + $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S) + +.PHONY: clean +clean: + $(REM) $(REM_FLAG) $(OBJ) SampleDriver.exe + +.PHONY: help +help: + @echo "=== HELP ===" + @echo "clean: Clean driver." + @echo "compile-amd64: Build driver." diff --git a/Drivers/VideoDrv/CheckStck.c b/Drivers/VideoDrv/CheckStck.c new file mode 100644 index 00000000..633636b4 --- /dev/null +++ b/Drivers/VideoDrv/CheckStck.c @@ -0,0 +1,11 @@ +/* ------------------------------------------- + + Copyright Zeta Electronics Corporation + +------------------------------------------- */ + +///! @brief Use this to check your stack, if using MinGW/MSVC/MPCC. +void ___chkstk_ms(void) +{ + (void)0; +} diff --git a/Drivers/VideoDrv/DriverRsrc.rsrc b/Drivers/VideoDrv/DriverRsrc.rsrc new file mode 100644 index 00000000..79d4cc92 --- /dev/null +++ b/Drivers/VideoDrv/DriverRsrc.rsrc @@ -0,0 +1,25 @@ +1 ICON "../../Icons/app-logo.ico" + +1 VERSIONINFO +FILEVERSION 1,0,0,0 +PRODUCTVERSION 1,0,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904E4" + BEGIN + VALUE "CompanyName", "Zeta Electronics Corporation" + VALUE "FileDescription", "CG HW video driver." + VALUE "FileVersion", "1.00" + VALUE "InternalName", "SampleDriver" + VALUE "LegalCopyright", "2024 Copyright Zeta Electronics Corporation, all rights reserved." + VALUE "OriginalFilename", "VideoDrv.exe" + VALUE "ProductName", "VideoDrv" + VALUE "ProductVersion", "1.00" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1252 + END +END diff --git a/Drivers/VideoDrv/VideoDrv.cxx b/Drivers/VideoDrv/VideoDrv.cxx new file mode 100644 index 00000000..1af02b4a --- /dev/null +++ b/Drivers/VideoDrv/VideoDrv.cxx @@ -0,0 +1,22 @@ +/* ------------------------------------------- + + Copyright Zeta Electronics Corporation + +------------------------------------------- */ + +#include +#include + +#include + +DK_EXTERN int __at_enter(void) +{ + kernelPrintStr("VideoDrv: Starting GPU...\r"); + return 0; +} + +DK_EXTERN int __at_exit(void) +{ + kernelPrintStr("VideoDrv: Shutting GPU...\r"); + return 0; +} diff --git a/Drivers/VideoDrv/compile_flags.txt b/Drivers/VideoDrv/compile_flags.txt new file mode 100644 index 00000000..10bdb71e --- /dev/null +++ b/Drivers/VideoDrv/compile_flags.txt @@ -0,0 +1,3 @@ +-I../../ +-I../../Kernel +-std=c++20 diff --git a/Drivers/VideoDrv/x86_64.make b/Drivers/VideoDrv/x86_64.make new file mode 100644 index 00000000..5897aa1e --- /dev/null +++ b/Drivers/VideoDrv/x86_64.make @@ -0,0 +1,51 @@ +################################################## +# (C) Zeta Electronics Corporation, all rights reserved. +# This is the sample driver makefile. +################################################## + +CC_GNU=x86_64-w64-mingw32-gcc +LD_GNU=x86_64-w64-mingw32-ld + +WINDRES=x86_64-w64-mingw32-windres + +ADD_FILE=touch +COPY=cp +HTTP_GET=wget + +LD_FLAGS=-e __at_enter --subsystem=17 + +OBJ=*.o + + +REM=rm +REM_FLAG=-f + +FLAG_ASM=-f win64 +FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ + +.PHONY: invalid-recipe +invalid-recipe: + @echo "invalid-recipe: Use make all instead." + +.PHONY: all +all: compile-amd64 + $(LD_GNU) $(OBJ) $(LD_FLAGS) -o VideoDrv.exe + +ifneq ($(DEBUG_SUPPORT), ) +DEBUG = -D__DEBUG__ +endif + +.PHONY: compile-amd64 +compile-amd64: + $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o + $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.cxx) $(wildcard *.c) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S) + +.PHONY: clean +clean: + $(REM) $(REM_FLAG) $(OBJ) VideoDrv.exe + +.PHONY: help +help: + @echo "=== HELP ===" + @echo "clean: Clean driver." + @echo "compile-amd64: Build driver." diff --git a/Drv/.gitkeep b/Drv/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Drv/Hello/CheckStack.c b/Drv/Hello/CheckStack.c deleted file mode 100644 index 3ffbe3e2..00000000 --- a/Drv/Hello/CheckStack.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -#include -#include -#include - -///! @brief Raised when we get out of bounds. Abort here. -void ___chkstk_ms(void) -{ - kernelPrintStr("Hello: KeStop needs to be raised...\r"); - - char* in = "__chkstk_ms on " __FILE__; - kernelCall("KeStop", 0, in, kernelStringLength(in)); -} diff --git a/Drv/Hello/DriverRsrc.rsrc b/Drv/Hello/DriverRsrc.rsrc deleted file mode 100644 index 12add0e2..00000000 --- a/Drv/Hello/DriverRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -1 ICON "../../Icons/app-logo.ico" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "Zeta Electronics Corporation" - VALUE "FileDescription", "New OS Zeroconf driver." - VALUE "FileVersion", "1.00" - VALUE "InternalName", "Bonjour." - VALUE "LegalCopyright", "Copyright Zeta Electronics Corporation, all rights reserved." - VALUE "OriginalFilename", "Bonjour.exe" - VALUE "ProductName", "Bonjour." - VALUE "ProductVersion", "1.00" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/Drv/Hello/Hello.c b/Drv/Hello/Hello.c deleted file mode 100644 index ba3d9733..00000000 --- a/Drv/Hello/Hello.c +++ /dev/null @@ -1,131 +0,0 @@ -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -#include -#include -#include - -struct HelloMasterConfigHeader; -struct HelloMasterConfigHeaderInput; - -struct HelloMasterConfigHeaderInput -{ - size_t fSizeOfOutput; - struct HelloMasterConfigHeader* fOutput; -}; - -/// @file Hello.c -/// @brief Zero configuration protocol, a much more better protocol for zero configuration. - -#define cHMCHMaxDataLength (1024) - -typedef struct HelloMasterConfigHeader -{ - int64_t fMagic; - int64_t fVersion; - int64_t fSourceAddress; - size_t fDataLength; - wchar_t fUTF16Data[cHMCHMaxDataLength]; -} __attribute__((packed)) HelloMasterConfigHeader; - -#define cHMCHDeviceLen 255 - -static kernelDeviceRef cDev = nil; -static char* cDeviceUUID = nil; // 3ed40738-c7d6-4b59-afdf-3c104b05fbf -static HelloMasterConfigHeader* cHeader = nil; - -/// @brief Link to master device to attribute DHCP lease. -static void __hello_link_device(void* a0) -{ - kernelPrintStr("Hello: turning up...\r"); - - if (!cDev) - { - // open raw network device. - cDev = kernelOpenDevice("RAWNET:\\"); - } - - cDev->write("+LINK", kernelStringLength("+LINK")); - cDev->wait(); - - cDev->write((void*)cDeviceUUID, kernelStringLength(cDeviceUUID)); - cDev->wait(); - - if (cHeader) - { - kernelFree(cHeader); - cHeader = nil; - } - - cHeader = cDev->read(nil, sizeof(HelloMasterConfigHeader)); -} - -static void __hello_get_hmch(void* a0) -{ - if (a0 == nil) - return; - - kernelPrintStr("Hello: returning header...\r"); - - struct HelloMasterConfigHeaderInput* in = a0; - in->fOutput = cHeader; - in->fSizeOfOutput = sizeof(in->fOutput); -} - -static void __hello_unlink_device(void* a0) -{ - kernelPrintStr("Hello: shutting down...\r"); - - if (cDev) - { - cDev->write("+UNLINK", kernelStringLength("+UNLINK")); - cDev->wait(); - - /// here is my uuid and my config header. Please disconnect me. - cDev->write((void*)cDeviceUUID, kernelStringLength(cDeviceUUID)); - cDev->write(cHeader, sizeof(cHeader)); - - cDev->wait(); - - kernelCloseDevice(cDev); - cDev = nil; - } - - if (cDeviceUUID) - { - kernelFree((void*)cDeviceUUID); - cDeviceUUID = nil; - } - - cDev = nil; -} - -int __at_enter(void) -{ - kernelPrintStr("Hello: starting up Helloconf...\r"); - - cDeviceUUID = kernelAlloc(sizeof(char) * cHMCHDeviceLen); - - kernelAddSyscall(0, __hello_link_device); - kernelAddSyscall(1, __hello_unlink_device); - kernelAddSyscall(2, __hello_get_hmch); - - return 0; -} - -int __at_exit(void) -{ - kernelPrintStr("Hello: starting up Helloconf...\r"); - - // first unlink. - __hello_unlink_device(nil); - - // then unregister syscalls. - kernelAddSyscall(0, nil); - kernelAddSyscall(1, nil); - - return 0; -} diff --git a/Drv/Hello/x86_64.mk b/Drv/Hello/x86_64.mk deleted file mode 100644 index 564fe970..00000000 --- a/Drv/Hello/x86_64.mk +++ /dev/null @@ -1,52 +0,0 @@ -################################################## -# (C) Zeta Electronics Corporation, all rights reserved. -# This is the sample driver makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-gcc -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -LD_FLAGS=-e __at_enter --subsystem=17 - -OBJ=*.o - - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -fno-rtti -fno-exceptions -D__DDK_AMD64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ \ - -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make all instead." - -.PHONY: all -all: compile-amd64 - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o Hello.exe - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o - $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DDK/*.cc) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S) - -.PHONY: clean -clean: - $(REM) $(REM_FLAG) $(OBJ) Hello.exe - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "clean: Clean driver." - @echo "compile-amd64: Build driver." diff --git a/Drv/SampleDriver/CheckStck.c b/Drv/SampleDriver/CheckStck.c deleted file mode 100644 index 3eb157ba..00000000 --- a/Drv/SampleDriver/CheckStck.c +++ /dev/null @@ -1,11 +0,0 @@ -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -///! @brief Use this to check your stack, if using MinGW/MSVC/CodeTools. -void ___chkstk_ms(void) -{ - (void)0; -} diff --git a/Drv/SampleDriver/DriverRsrc.rsrc b/Drv/SampleDriver/DriverRsrc.rsrc deleted file mode 100644 index 54940e43..00000000 --- a/Drv/SampleDriver/DriverRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -1 ICON "../../Icons/app-logo.ico" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "Zeta Electronics Corporation" - VALUE "FileDescription", "New OS driver." - VALUE "FileVersion", "1.00" - VALUE "InternalName", "SampleDriver" - VALUE "LegalCopyright", "Copyright Zeta Electronics Corporation, all rights reserved." - VALUE "OriginalFilename", "SampleDriver.exe" - VALUE "ProductName", "SampleDriver" - VALUE "ProductVersion", "1.00" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/Drv/SampleDriver/SampleDriver.c b/Drv/SampleDriver/SampleDriver.c deleted file mode 100644 index 85bd8d54..00000000 --- a/Drv/SampleDriver/SampleDriver.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -#include -#include - -int __ImageStart(void) -{ - kernelPrintStr("SampleDriver: Starting up...\r"); - return 0; -} - -int __ImageEnd(void) -{ - kernelPrintStr("SampleDriver: Shutting down...\r"); - return 0; -} diff --git a/Drv/SampleDriver/x86_64.mk b/Drv/SampleDriver/x86_64.mk deleted file mode 100644 index 5655902f..00000000 --- a/Drv/SampleDriver/x86_64.mk +++ /dev/null @@ -1,51 +0,0 @@ -################################################## -# (C) Zeta Electronics Corporation, all rights reserved. -# This is the sample driver makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-gcc -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -LD_FLAGS=-e __at_enter --subsystem=17 - -OBJ=*.o - - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make all instead." - -.PHONY: all -all: compile-amd64 - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o SampleDriver.exe - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o - $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S) - -.PHONY: clean -clean: - $(REM) $(REM_FLAG) $(OBJ) SampleDriver.exe - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "clean: Clean driver." - @echo "compile-amd64: Build driver." diff --git a/Drv/VideoDrv/CheckStck.c b/Drv/VideoDrv/CheckStck.c deleted file mode 100644 index 633636b4..00000000 --- a/Drv/VideoDrv/CheckStck.c +++ /dev/null @@ -1,11 +0,0 @@ -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -///! @brief Use this to check your stack, if using MinGW/MSVC/MPCC. -void ___chkstk_ms(void) -{ - (void)0; -} diff --git a/Drv/VideoDrv/DriverRsrc.rsrc b/Drv/VideoDrv/DriverRsrc.rsrc deleted file mode 100644 index 79d4cc92..00000000 --- a/Drv/VideoDrv/DriverRsrc.rsrc +++ /dev/null @@ -1,25 +0,0 @@ -1 ICON "../../Icons/app-logo.ico" - -1 VERSIONINFO -FILEVERSION 1,0,0,0 -PRODUCTVERSION 1,0,0,0 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904E4" - BEGIN - VALUE "CompanyName", "Zeta Electronics Corporation" - VALUE "FileDescription", "CG HW video driver." - VALUE "FileVersion", "1.00" - VALUE "InternalName", "SampleDriver" - VALUE "LegalCopyright", "2024 Copyright Zeta Electronics Corporation, all rights reserved." - VALUE "OriginalFilename", "VideoDrv.exe" - VALUE "ProductName", "VideoDrv" - VALUE "ProductVersion", "1.00" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1252 - END -END diff --git a/Drv/VideoDrv/VideoDrv.cc b/Drv/VideoDrv/VideoDrv.cc deleted file mode 100644 index 1af02b4a..00000000 --- a/Drv/VideoDrv/VideoDrv.cc +++ /dev/null @@ -1,22 +0,0 @@ -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -#include -#include - -#include - -DK_EXTERN int __at_enter(void) -{ - kernelPrintStr("VideoDrv: Starting GPU...\r"); - return 0; -} - -DK_EXTERN int __at_exit(void) -{ - kernelPrintStr("VideoDrv: Shutting GPU...\r"); - return 0; -} diff --git a/Drv/VideoDrv/x86_64.make b/Drv/VideoDrv/x86_64.make deleted file mode 100644 index a74a8d21..00000000 --- a/Drv/VideoDrv/x86_64.make +++ /dev/null @@ -1,51 +0,0 @@ -################################################## -# (C) Zeta Electronics Corporation, all rights reserved. -# This is the sample driver makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-gcc -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -LD_FLAGS=-e __at_enter --subsystem=17 - -OBJ=*.o - - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KERNEL__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I./ -c -ffreestanding -std=c17 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make all instead." - -.PHONY: all -all: compile-amd64 - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o VideoDrv.exe - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(WINDRES) DriverRsrc.rsrc -O coff -o DriverRsrc.o - $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S) - -.PHONY: clean -clean: - $(REM) $(REM_FLAG) $(OBJ) VideoDrv.exe - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "clean: Clean driver." - @echo "compile-amd64: Build driver." diff --git a/Kernel/Linker/16x0.json b/Kernel/Linker/16x0.json index 77235537..fd7f167a 100644 --- a/Kernel/Linker/16x0.json +++ b/Kernel/Linker/16x0.json @@ -1,6 +1,8 @@ { + "linker": "link.exe", "executable_type": "kernel", "output_name": "newoskrnl.exe", "start_proc": "__ImageStart", + "arch": "16x0", "format": "PEF" } diff --git a/Kernel/Linker/32x0.json b/Kernel/Linker/32x0.json index 77235537..a827de05 100644 --- a/Kernel/Linker/32x0.json +++ b/Kernel/Linker/32x0.json @@ -1,6 +1,8 @@ { + "linker": "link.exe", "executable_type": "kernel", "output_name": "newoskrnl.exe", "start_proc": "__ImageStart", + "arch": "32x0", "format": "PEF" } diff --git a/Kernel/Linker/64x0.json b/Kernel/Linker/64x0.json index 77235537..f1a6611e 100644 --- a/Kernel/Linker/64x0.json +++ b/Kernel/Linker/64x0.json @@ -1,6 +1,8 @@ { + "linker": "link.exe", "executable_type": "kernel", "output_name": "newoskrnl.exe", "start_proc": "__ImageStart", + "arch": "64x0", "format": "PEF" } diff --git a/Kernel/Linker/arm64.json b/Kernel/Linker/arm64.json new file mode 100644 index 00000000..eb7ff4d2 --- /dev/null +++ b/Kernel/Linker/arm64.json @@ -0,0 +1,8 @@ +{ + "linker": "link.exe", + "executable_type": "kernel", + "output_name": "newoskrnl.exe", + "start_proc": "__ImageStart", + "arch": "arm64", + "format": "PEF" +} -- cgit v1.2.3