summaryrefslogtreecommitdiffhomepage
path: root/Drv
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-03 18:20:35 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-03 18:20:35 +0200
commita7c741c93cb0a53aea686eb2f342f2464bc12c14 (patch)
tree5e90743873451c7f1bc6313d2fb210c470af2cd1 /Drv
parent8c8822fff78f9ff9cd640271da9b3634c4c2f97f (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')
-rw-r--r--Drv/Bonjour/Bonjour.c20
-rw-r--r--Drv/Hello/CheckStack.c11
-rw-r--r--Drv/Hello/DriverRsrc.rsrc (renamed from Drv/Bonjour/DriverRsrc.rsrc)2
-rw-r--r--Drv/Hello/Hello.c103
-rw-r--r--Drv/Hello/x86_64.mk (renamed from Drv/Bonjour/x86_64.mk)13
-rw-r--r--Drv/SampleDriver/x86_64.mk2
-rw-r--r--Drv/VideoDrv/CheckStck.c2
-rw-r--r--Drv/VideoDrv/VideoDrv.cc (renamed from Drv/VideoDrv/VideoDrv.c)9
-rw-r--r--Drv/VideoDrv/x86_64.make2
9 files changed, 130 insertions, 34 deletions
diff --git a/Drv/Bonjour/Bonjour.c b/Drv/Bonjour/Bonjour.c
deleted file mode 100644
index 9bebdb32..00000000
--- a/Drv/Bonjour/Bonjour.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* -------------------------------------------
-
- Copyright Zeta Electronics Corporation
-
-------------------------------------------- */
-
-#include <DDK/KernelString.h>
-#include <DDK/KernelPrint.h>
-
-int __ImageStart(void)
-{
- kernelPrintStr("Bonjour: Starting up zeroconf...\r");
- return 0;
-}
-
-int __ImageEnd(void)
-{
- kernelPrintStr("Bonjour: Shutting down zeroconf...\r");
- return 0;
-}
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/Bonjour/DriverRsrc.rsrc b/Drv/Hello/DriverRsrc.rsrc
index 5b86834f..dbfc3f73 100644
--- a/Drv/Bonjour/DriverRsrc.rsrc
+++ b/Drv/Hello/DriverRsrc.rsrc
@@ -1,4 +1,4 @@
-1 ICON "../../Boot/Icons/driver-logo.ico"
+1 ICON "../../Icons/driver-logo.ico"
1 VERSIONINFO
FILEVERSION 1,0,0,0
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/Bonjour/x86_64.mk b/Drv/Hello/x86_64.mk
index 9114f4b4..564fe970 100644
--- a/Drv/Bonjour/x86_64.mk
+++ b/Drv/Hello/x86_64.mk
@@ -12,7 +12,7 @@ ADD_FILE=touch
COPY=cp
HTTP_GET=wget
-LD_FLAGS=-e __ImageStart --subsystem=17
+LD_FLAGS=-e __at_enter --subsystem=17
OBJ=*.o
@@ -21,15 +21,16 @@ 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./
+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."
+ @echo "invalid-recipe: Use make all instead."
.PHONY: all
all: compile-amd64
- $(LD_GNU) $(OBJ) $(LD_FLAGS) -o Bonjour.exe
+ $(LD_GNU) $(OBJ) $(LD_FLAGS) -o Hello.exe
ifneq ($(DEBUG_SUPPORT), )
DEBUG = -D__DEBUG__
@@ -38,11 +39,11 @@ 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)
+ $(CC_GNU) $(FLAG_GNU) $(DEBUG) $(wildcard *.c) $(wildcard ../../DDK/*.cc) $(wildcard ../../DDK/*.c) $(wildcard ../../DDK/*.S)
.PHONY: clean
clean:
- $(REM) $(REM_FLAG) $(OBJ) Bonjour.exe
+ $(REM) $(REM_FLAG) $(OBJ) Hello.exe
.PHONY: help
help:
diff --git a/Drv/SampleDriver/x86_64.mk b/Drv/SampleDriver/x86_64.mk
index ec7e09f6..5655902f 100644
--- a/Drv/SampleDriver/x86_64.mk
+++ b/Drv/SampleDriver/x86_64.mk
@@ -12,7 +12,7 @@ ADD_FILE=touch
COPY=cp
HTTP_GET=wget
-LD_FLAGS=-e __ImageStart --subsystem=17
+LD_FLAGS=-e __at_enter --subsystem=17
OBJ=*.o
diff --git a/Drv/VideoDrv/CheckStck.c b/Drv/VideoDrv/CheckStck.c
index 3eb157ba..633636b4 100644
--- a/Drv/VideoDrv/CheckStck.c
+++ b/Drv/VideoDrv/CheckStck.c
@@ -4,7 +4,7 @@
------------------------------------------- */
-///! @brief Use this to check your stack, if using MinGW/MSVC/CodeTools.
+///! @brief Use this to check your stack, if using MinGW/MSVC/MPCC.
void ___chkstk_ms(void)
{
(void)0;
diff --git a/Drv/VideoDrv/VideoDrv.c b/Drv/VideoDrv/VideoDrv.cc
index 742abaf2..1af02b4a 100644
--- a/Drv/VideoDrv/VideoDrv.c
+++ b/Drv/VideoDrv/VideoDrv.cc
@@ -6,16 +6,17 @@
#include <DDK/KernelString.h>
#include <DDK/KernelPrint.h>
+
#include <Modules/CoreCG/CoreCG.hxx>
-int __at_enter(void)
+DK_EXTERN int __at_enter(void)
{
- kernelPrintStr("VideoDrv: Starting up GPU...\r");
+ kernelPrintStr("VideoDrv: Starting GPU...\r");
return 0;
}
-int __at_exit(void)
+DK_EXTERN int __at_exit(void)
{
- kernelPrintStr("VideoDrv: Shutting down GPU...\r");
+ kernelPrintStr("VideoDrv: Shutting GPU...\r");
return 0;
}
diff --git a/Drv/VideoDrv/x86_64.make b/Drv/VideoDrv/x86_64.make
index 8ec42277..a74a8d21 100644
--- a/Drv/VideoDrv/x86_64.make
+++ b/Drv/VideoDrv/x86_64.make
@@ -12,7 +12,7 @@ ADD_FILE=touch
COPY=cp
HTTP_GET=wget
-LD_FLAGS=-e __ImageStart --subsystem=17
+LD_FLAGS=-e __at_enter --subsystem=17
OBJ=*.o