diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-03 18:20:35 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-03 18:20:35 +0200 |
| commit | a7c741c93cb0a53aea686eb2f342f2464bc12c14 (patch) | |
| tree | 5e90743873451c7f1bc6313d2fb210c470af2cd1 /Drv/Hello | |
| parent | 8c8822fff78f9ff9cd640271da9b3634c4c2f97f (diff) | |
COMMIT-07-03-2024-MHR-36
IMP: DDK specification and implementation done.
- Kernel calls I/O support for DDK.
- System calls I/O support for DDK.
- Add Allocation routines for DDK.
- Add Helloconf driver.
- One generic device.
IMPRV:
- GPU driver is now C++ based.
- Fixed icon path inside makefiles.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Drv/Hello')
| -rw-r--r-- | Drv/Hello/CheckStack.c | 11 | ||||
| -rw-r--r-- | Drv/Hello/DriverRsrc.rsrc | 25 | ||||
| -rw-r--r-- | Drv/Hello/Hello.c | 103 | ||||
| -rw-r--r-- | Drv/Hello/x86_64.mk | 52 |
4 files changed, 191 insertions, 0 deletions
diff --git a/Drv/Hello/CheckStack.c b/Drv/Hello/CheckStack.c new file mode 100644 index 00000000..a3c6621b --- /dev/null +++ b/Drv/Hello/CheckStack.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/Drv/Hello/DriverRsrc.rsrc b/Drv/Hello/DriverRsrc.rsrc new file mode 100644 index 00000000..dbfc3f73 --- /dev/null +++ b/Drv/Hello/DriverRsrc.rsrc @@ -0,0 +1,25 @@ +1 ICON "../../Icons/driver-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 new file mode 100644 index 00000000..cba37b84 --- /dev/null +++ b/Drv/Hello/Hello.c @@ -0,0 +1,103 @@ +/* ------------------------------------------- + + Copyright Zeta Electronics Corporation + +------------------------------------------- */ + +#include <DDK/KernelString.h> +#include <DDK/KernelPrint.h> +#include <DDK/KernelDev.h> + +/// @file Hello.c +/// @brief Zero configuration protocol, a much more better protocol for zero configuration. + +typedef struct HelloMasterConfigHeader +{ + int fMagic; + int fVersion; + int fProviderAddress; + char fDHCPLease[255]; +} __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) +{ + if (!cDev) + { + cDev = kernelOpenDevice("NET:\\HMCH\\0.0.0.0"); + } + + 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_unlink_device(void* a0) +{ + kernelPrintStr("Hello: shutting down Hello...\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); + + 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 new file mode 100644 index 00000000..564fe970 --- /dev/null +++ b/Drv/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." |
