From 4b4fe020a328e991ffd15ae475ad7a5d38f097a5 Mon Sep 17 00:00:00 2001 From: Amlal Date: Tue, 24 Sep 2024 06:57:42 +0200 Subject: IMP: Working on Paging API... FIX: Fixed the path of filesystem's ESP. Signed-off-by: Amlal --- dev/ddk/DispatchKernelCall.S | 36 ----------- dev/ddk/KernelAlloc.c | 36 ----------- dev/ddk/KernelCall.c | 60 ------------------- dev/ddk/KernelCxxRt.cxx | 29 --------- dev/ddk/KernelDev.c | 29 --------- dev/ddk/KernelPrint.c | 37 ------------ dev/ddk/KernelString.c | 39 ------------ dev/ddk/KernelVersion.c | 25 -------- dev/ddk/ddk.json | 2 +- dev/ddk/src/KernelAlloc.c | 36 +++++++++++ dev/ddk/src/KernelCall.c | 60 +++++++++++++++++++ dev/ddk/src/KernelCallDispatch.S | 36 +++++++++++ dev/ddk/src/KernelCxxRt.cxx | 29 +++++++++ dev/ddk/src/KernelDev.c | 29 +++++++++ dev/ddk/src/KernelPrint.c | 37 ++++++++++++ dev/ddk/src/KernelString.c | 39 ++++++++++++ dev/ddk/src/KernelVersion.c | 25 ++++++++ dev/hpfs/EPM/EBS.i | 29 --------- dev/hpfs/EPM/EPM.asm | 37 ------------ dev/hpfs/EPM/blob.json | 6 -- dev/hpfs/epm/blob.json | 6 ++ dev/hpfs/epm/ebs.i | 29 +++++++++ dev/hpfs/epm/epm.asm | 37 ++++++++++++ dev/hpfs/hpfs_specs.hxx | 3 - dev/hpfs/src/hpfs_main.cxx | 6 +- dev/zba/src/HEL/AMD64/BootMain.cxx | 4 +- dev/zba/src/Root/ZKA/startup.wav | Bin 1045048 -> 0 bytes dev/zba/src/Root/ZKA/urbanist.ttf | Bin 42752 -> 0 bytes dev/zba/src/Root/zka/startup.wav | Bin 0 -> 1045048 bytes dev/zba/src/Root/zka/urbanist.ttf | Bin 0 -> 42752 bytes dev/zka/HALKit/AMD64/HalCPU.cxx | 101 +++++++++++++++++++++++++++++++ dev/zka/HALKit/AMD64/HalCommAPI.cxx | 116 ------------------------------------ dev/zka/HALKit/AMD64/HalPaging.cxx | 75 +++++++++++++++++++++++ dev/zka/KernelKit/Heap.hxx | 2 +- dev/zwm/src/zwm_main.cxx | 5 +- 35 files changed, 550 insertions(+), 490 deletions(-) delete mode 100644 dev/ddk/DispatchKernelCall.S delete mode 100644 dev/ddk/KernelAlloc.c delete mode 100644 dev/ddk/KernelCall.c delete mode 100644 dev/ddk/KernelCxxRt.cxx delete mode 100644 dev/ddk/KernelDev.c delete mode 100644 dev/ddk/KernelPrint.c delete mode 100644 dev/ddk/KernelString.c delete mode 100644 dev/ddk/KernelVersion.c create mode 100644 dev/ddk/src/KernelAlloc.c create mode 100644 dev/ddk/src/KernelCall.c create mode 100644 dev/ddk/src/KernelCallDispatch.S create mode 100644 dev/ddk/src/KernelCxxRt.cxx create mode 100644 dev/ddk/src/KernelDev.c create mode 100644 dev/ddk/src/KernelPrint.c create mode 100644 dev/ddk/src/KernelString.c create mode 100644 dev/ddk/src/KernelVersion.c delete mode 100644 dev/hpfs/EPM/EBS.i delete mode 100644 dev/hpfs/EPM/EPM.asm delete mode 100644 dev/hpfs/EPM/blob.json create mode 100644 dev/hpfs/epm/blob.json create mode 100644 dev/hpfs/epm/ebs.i create mode 100644 dev/hpfs/epm/epm.asm delete mode 100644 dev/zba/src/Root/ZKA/startup.wav delete mode 100644 dev/zba/src/Root/ZKA/urbanist.ttf create mode 100644 dev/zba/src/Root/zka/startup.wav create mode 100644 dev/zba/src/Root/zka/urbanist.ttf create mode 100644 dev/zka/HALKit/AMD64/HalCPU.cxx delete mode 100644 dev/zka/HALKit/AMD64/HalCommAPI.cxx create mode 100644 dev/zka/HALKit/AMD64/HalPaging.cxx (limited to 'dev') diff --git a/dev/ddk/DispatchKernelCall.S b/dev/ddk/DispatchKernelCall.S deleted file mode 100644 index 3a9a57b5..00000000 --- a/dev/ddk/DispatchKernelCall.S +++ /dev/null @@ -1,36 +0,0 @@ -/** - lang: asm - compiler: gnu - */ - -.globl __KernelCallDispatch - -.text - -/* Really simple function, takes our va-list, - and brings it to the trap handler in the Kernel. */ - -#ifdef __DDK_AMD64__ - -/* args rcx, rdx, r8, r9 */ -__KernelCallDispatch: - int $0x33 - ret - -#elif defined(__DDK_POWER64__) - -/* args r8, r9, r10, r11 */ -__KernelCallDispatch: - /* There is no specific interrupt request id for a system call in POWER. */ - sc - blr - -#elif defined(__DDK_ARM64__) - -/* args x0, x8, x9, x10, x11 is kept to tell that this is a Kernel call */ -__KernelCallDispatch: - /* There is no specific interrupt request id for a system call in ARM64 as well. */ - mov x9, #0x33 - svc #0 - -#endif diff --git a/dev/ddk/KernelAlloc.c b/dev/ddk/KernelAlloc.c deleted file mode 100644 index af99f23b..00000000 --- a/dev/ddk/KernelAlloc.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - Purpose: DDK allocator. - -------------------------------------------- */ - -#include - -/** - \brief Allocates a new heap on the Kernel's side. - \param sz the size of the heap block. - \return the newly allocated pointer. -*/ -DK_EXTERN void* KernelAlloc(size_t sz) -{ - if (!sz) - ++sz; - - void* ptr = KernelCall("MmNewKeHeap", 1, &sz, sizeof(size_t)); - - return ptr; -} - -/** - \brief Frees a pointer from the heap. - \param ptr the pointer to free. -*/ -DK_EXTERN void KernelFree(void* ptr) -{ - if (!ptr) - return; - - KernelCall("MmDeleteKeHeap", 1, ptr, 0); -} diff --git a/dev/ddk/KernelCall.c b/dev/ddk/KernelCall.c deleted file mode 100644 index ccb401af..00000000 --- a/dev/ddk/KernelCall.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - Purpose: DDK Kernel call. - -------------------------------------------- */ - -#include -#include - -/// @brief this is an internal call, do not use it. -DK_EXTERN ATTRIBUTE(naked) void* __KernelCallDispatch(const char* name, int32_t cnt, void* data, size_t sz); - -/// @brief Interupt Kernel -/// @param KernelRpcName RPC name -/// @param cnt number of elements in **data** pointer. -/// @param data data pointer. -/// @param sz The size of the whole data pointer. -/// @retval void* Kernel call was successful. -/// @retval nil Kernel call failed, call KernelLastError(void) -DK_EXTERN void* KernelCall(const char* name, int32_t cnt, void* data, size_t sz) -{ - if (!name || *name == 0 || cnt == 0) - return nil; - - return __KernelCallDispatch(name, cnt, data, sz); -} - -/// @brief Add system call. -/// @param slot system call slot -/// @param slotFn, syscall slot. -DK_EXTERN void KernelAddSyscall(const int slot, void (*slotFn)(void* a0)) -{ - KernelCall("IntAddSyscall", slot, slotFn, 1); -} - -/// @brief Get a Kernel property. -/// @param slot property id (always 0) -/// @param name the object's name. -/// @return Object manifest. -DK_EXTERN struct DDK_OBJECT_MANIFEST* KernelGetObject(const int slot, const char* name) -{ - struct DDK_OBJECT_MANIFEST* manifest = (struct DDK_OBJECT_MANIFEST*)KernelCall("RtlGetObject", slot, (void*)name, 1); - - if (!manifest) - return nil; - - return manifest; -} - -/// @brief Set a Kernel property. -/// @param slot property id (always 0) -/// @param name the object's name. -/// @param ddk_pr pointer to a object's DDK_OBJECT_MANIFEST. -/// @return property's object. -DK_EXTERN void* KernelSetObject(const int slot, const struct DDK_OBJECT_MANIFEST* ddk_pr) -{ - return KernelCall("RtlSetObject", slot, (void*)ddk_pr, 1); -} diff --git a/dev/ddk/KernelCxxRt.cxx b/dev/ddk/KernelCxxRt.cxx deleted file mode 100644 index 947e2de7..00000000 --- a/dev/ddk/KernelCxxRt.cxx +++ /dev/null @@ -1,29 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - Purpose: DDK C++ runtime. - -------------------------------------------- */ - -#include - -void* operator new(size_t sz) -{ - return KernelAlloc(sz); -} - -void operator delete(void* ptr) -{ - KernelFree(ptr); -} - -void* operator new[](size_t sz) -{ - return KernelAlloc(sz); -} - -void operator delete[](void* ptr) -{ - KernelFree(ptr); -} diff --git a/dev/ddk/KernelDev.c b/dev/ddk/KernelDev.c deleted file mode 100644 index 3cf7ed48..00000000 --- a/dev/ddk/KernelDev.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - Purpose: DDK Text I/O. - -------------------------------------------- */ - -#include -#include - -/// @brief Open a new binary device from path. -DK_EXTERN KERNEL_DEVICE_PTR KernelOpenDevice(const char* devicePath) -{ - if (!devicePath) - return nil; - - return KernelCall("ZkOpenDevice", 1, (void*)devicePath, KernelStringLength(devicePath)); -} - -/// @brief Close any device. -/// @param device valid device. -DK_EXTERN void KernelCloseDevice(KERNEL_DEVICE_PTR device) -{ - if (!device) - return; - - KernelCall("ZkCloseDevice", 1, device, sizeof(KERNEL_DEVICE)); -} diff --git a/dev/ddk/KernelPrint.c b/dev/ddk/KernelPrint.c deleted file mode 100644 index 7f8c8604..00000000 --- a/dev/ddk/KernelPrint.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - Purpose: DDK Text I/O. - -------------------------------------------- */ - -#include - -DK_EXTERN void KernelPrintChar(const char ch) -{ - char assembled[2] = {0}; - assembled[0] = ch; - assembled[1] = 0; - - KernelCall("SrWriteCharacter", 1, assembled, 1); -} - -/// @brief print string to UART. -/// @param message UART to transmit. -DK_EXTERN void KernelPrintStr(const char* message) -{ - if (!message) - return; - if (*message == 0) - return; - - size_t index = 0; - size_t len = KernelStringLength(message); - - while (index < len) - { - KernelPrintChar(message[index]); - ++index; - } -} diff --git a/dev/ddk/KernelString.c b/dev/ddk/KernelString.c deleted file mode 100644 index 0030aa02..00000000 --- a/dev/ddk/KernelString.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - Purpose: DDK Strings. - -------------------------------------------- */ - -#include - -DK_EXTERN size_t KernelStringLength(const char* in) -{ - if (in == nil) - return 0; - if (*in == 0) - return 0; - - size_t index = 0; - - while (in[index] != 0) - { - ++index; - } - - return index; -} - -DK_EXTERN int KernelStringCopy(char* dst, const char* src, size_t len) -{ - size_t index = 0; - - while (index != len) - { - dst[index] = src[index]; - ++index; - } - - return index; -} diff --git a/dev/ddk/KernelVersion.c b/dev/ddk/KernelVersion.c deleted file mode 100644 index c40e8ff9..00000000 --- a/dev/ddk/KernelVersion.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - Purpose: DDK versioning. - -------------------------------------------- */ - -#include - -#ifndef cDDKVersionHighest -#define cDDKVersionHighest 1 -#endif // !cDDKVersionHighest - -#ifndef cDDKVersionLowest -#define cDDKVersionLowest 1 -#endif // !cDDKVersionLowest - -#ifndef cDDKVersion -#define cDDKVersion 1 -#endif // !cDDKVersion - -int32_t c_api_version_highest = cDDKVersionHighest; -int32_t c_api_version_least = cDDKVersionLowest; -int32_t c_api_version = cDDKVersion; diff --git a/dev/ddk/ddk.json b/dev/ddk/ddk.json index b930f99c..32c32bd1 100644 --- a/dev/ddk/ddk.json +++ b/dev/ddk/ddk.json @@ -2,7 +2,7 @@ "compiler_path": "x86_64-w64-mingw32-gcc", "compiler_std": "c++20", "headers_path": ["../", "./"], - "sources_path": ["*.c", "*.cxx", "*.S"], + "sources_path": ["src/*.c", "src/*.cxx", "src/*.S"], "output_name": "ddk.dll", "compiler_flags": [ "-ffreestanding", diff --git a/dev/ddk/src/KernelAlloc.c b/dev/ddk/src/KernelAlloc.c new file mode 100644 index 00000000..af99f23b --- /dev/null +++ b/dev/ddk/src/KernelAlloc.c @@ -0,0 +1,36 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + Purpose: DDK allocator. + +------------------------------------------- */ + +#include + +/** + \brief Allocates a new heap on the Kernel's side. + \param sz the size of the heap block. + \return the newly allocated pointer. +*/ +DK_EXTERN void* KernelAlloc(size_t sz) +{ + if (!sz) + ++sz; + + void* ptr = KernelCall("MmNewKeHeap", 1, &sz, sizeof(size_t)); + + return ptr; +} + +/** + \brief Frees a pointer from the heap. + \param ptr the pointer to free. +*/ +DK_EXTERN void KernelFree(void* ptr) +{ + if (!ptr) + return; + + KernelCall("MmDeleteKeHeap", 1, ptr, 0); +} diff --git a/dev/ddk/src/KernelCall.c b/dev/ddk/src/KernelCall.c new file mode 100644 index 00000000..ccb401af --- /dev/null +++ b/dev/ddk/src/KernelCall.c @@ -0,0 +1,60 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + Purpose: DDK Kernel call. + +------------------------------------------- */ + +#include +#include + +/// @brief this is an internal call, do not use it. +DK_EXTERN ATTRIBUTE(naked) void* __KernelCallDispatch(const char* name, int32_t cnt, void* data, size_t sz); + +/// @brief Interupt Kernel +/// @param KernelRpcName RPC name +/// @param cnt number of elements in **data** pointer. +/// @param data data pointer. +/// @param sz The size of the whole data pointer. +/// @retval void* Kernel call was successful. +/// @retval nil Kernel call failed, call KernelLastError(void) +DK_EXTERN void* KernelCall(const char* name, int32_t cnt, void* data, size_t sz) +{ + if (!name || *name == 0 || cnt == 0) + return nil; + + return __KernelCallDispatch(name, cnt, data, sz); +} + +/// @brief Add system call. +/// @param slot system call slot +/// @param slotFn, syscall slot. +DK_EXTERN void KernelAddSyscall(const int slot, void (*slotFn)(void* a0)) +{ + KernelCall("IntAddSyscall", slot, slotFn, 1); +} + +/// @brief Get a Kernel property. +/// @param slot property id (always 0) +/// @param name the object's name. +/// @return Object manifest. +DK_EXTERN struct DDK_OBJECT_MANIFEST* KernelGetObject(const int slot, const char* name) +{ + struct DDK_OBJECT_MANIFEST* manifest = (struct DDK_OBJECT_MANIFEST*)KernelCall("RtlGetObject", slot, (void*)name, 1); + + if (!manifest) + return nil; + + return manifest; +} + +/// @brief Set a Kernel property. +/// @param slot property id (always 0) +/// @param name the object's name. +/// @param ddk_pr pointer to a object's DDK_OBJECT_MANIFEST. +/// @return property's object. +DK_EXTERN void* KernelSetObject(const int slot, const struct DDK_OBJECT_MANIFEST* ddk_pr) +{ + return KernelCall("RtlSetObject", slot, (void*)ddk_pr, 1); +} diff --git a/dev/ddk/src/KernelCallDispatch.S b/dev/ddk/src/KernelCallDispatch.S new file mode 100644 index 00000000..3a9a57b5 --- /dev/null +++ b/dev/ddk/src/KernelCallDispatch.S @@ -0,0 +1,36 @@ +/** + lang: asm + compiler: gnu + */ + +.globl __KernelCallDispatch + +.text + +/* Really simple function, takes our va-list, + and brings it to the trap handler in the Kernel. */ + +#ifdef __DDK_AMD64__ + +/* args rcx, rdx, r8, r9 */ +__KernelCallDispatch: + int $0x33 + ret + +#elif defined(__DDK_POWER64__) + +/* args r8, r9, r10, r11 */ +__KernelCallDispatch: + /* There is no specific interrupt request id for a system call in POWER. */ + sc + blr + +#elif defined(__DDK_ARM64__) + +/* args x0, x8, x9, x10, x11 is kept to tell that this is a Kernel call */ +__KernelCallDispatch: + /* There is no specific interrupt request id for a system call in ARM64 as well. */ + mov x9, #0x33 + svc #0 + +#endif diff --git a/dev/ddk/src/KernelCxxRt.cxx b/dev/ddk/src/KernelCxxRt.cxx new file mode 100644 index 00000000..947e2de7 --- /dev/null +++ b/dev/ddk/src/KernelCxxRt.cxx @@ -0,0 +1,29 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + Purpose: DDK C++ runtime. + +------------------------------------------- */ + +#include + +void* operator new(size_t sz) +{ + return KernelAlloc(sz); +} + +void operator delete(void* ptr) +{ + KernelFree(ptr); +} + +void* operator new[](size_t sz) +{ + return KernelAlloc(sz); +} + +void operator delete[](void* ptr) +{ + KernelFree(ptr); +} diff --git a/dev/ddk/src/KernelDev.c b/dev/ddk/src/KernelDev.c new file mode 100644 index 00000000..3cf7ed48 --- /dev/null +++ b/dev/ddk/src/KernelDev.c @@ -0,0 +1,29 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#include +#include + +/// @brief Open a new binary device from path. +DK_EXTERN KERNEL_DEVICE_PTR KernelOpenDevice(const char* devicePath) +{ + if (!devicePath) + return nil; + + return KernelCall("ZkOpenDevice", 1, (void*)devicePath, KernelStringLength(devicePath)); +} + +/// @brief Close any device. +/// @param device valid device. +DK_EXTERN void KernelCloseDevice(KERNEL_DEVICE_PTR device) +{ + if (!device) + return; + + KernelCall("ZkCloseDevice", 1, device, sizeof(KERNEL_DEVICE)); +} diff --git a/dev/ddk/src/KernelPrint.c b/dev/ddk/src/KernelPrint.c new file mode 100644 index 00000000..7f8c8604 --- /dev/null +++ b/dev/ddk/src/KernelPrint.c @@ -0,0 +1,37 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#include + +DK_EXTERN void KernelPrintChar(const char ch) +{ + char assembled[2] = {0}; + assembled[0] = ch; + assembled[1] = 0; + + KernelCall("SrWriteCharacter", 1, assembled, 1); +} + +/// @brief print string to UART. +/// @param message UART to transmit. +DK_EXTERN void KernelPrintStr(const char* message) +{ + if (!message) + return; + if (*message == 0) + return; + + size_t index = 0; + size_t len = KernelStringLength(message); + + while (index < len) + { + KernelPrintChar(message[index]); + ++index; + } +} diff --git a/dev/ddk/src/KernelString.c b/dev/ddk/src/KernelString.c new file mode 100644 index 00000000..0030aa02 --- /dev/null +++ b/dev/ddk/src/KernelString.c @@ -0,0 +1,39 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + Purpose: DDK Strings. + +------------------------------------------- */ + +#include + +DK_EXTERN size_t KernelStringLength(const char* in) +{ + if (in == nil) + return 0; + if (*in == 0) + return 0; + + size_t index = 0; + + while (in[index] != 0) + { + ++index; + } + + return index; +} + +DK_EXTERN int KernelStringCopy(char* dst, const char* src, size_t len) +{ + size_t index = 0; + + while (index != len) + { + dst[index] = src[index]; + ++index; + } + + return index; +} diff --git a/dev/ddk/src/KernelVersion.c b/dev/ddk/src/KernelVersion.c new file mode 100644 index 00000000..c40e8ff9 --- /dev/null +++ b/dev/ddk/src/KernelVersion.c @@ -0,0 +1,25 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + Purpose: DDK versioning. + +------------------------------------------- */ + +#include + +#ifndef cDDKVersionHighest +#define cDDKVersionHighest 1 +#endif // !cDDKVersionHighest + +#ifndef cDDKVersionLowest +#define cDDKVersionLowest 1 +#endif // !cDDKVersionLowest + +#ifndef cDDKVersion +#define cDDKVersion 1 +#endif // !cDDKVersion + +int32_t c_api_version_highest = cDDKVersionHighest; +int32_t c_api_version_least = cDDKVersionLowest; +int32_t c_api_version = cDDKVersion; diff --git a/dev/hpfs/EPM/EBS.i b/dev/hpfs/EPM/EBS.i deleted file mode 100644 index c137b6f4..00000000 --- a/dev/hpfs/EPM/EBS.i +++ /dev/null @@ -1,29 +0,0 @@ -;; FILE: EBS.asm -;; PURPOSE: EXPLICIT BOOT SECTOR STRUCTURE (HPFS RELATED). -;; AUTHOR: AMLAL EL MAHROUSS - -[bits 64] - -;; DUMP THIS BLOB TO DISK, WHEN FORMATTING THE SSD. - -HPFS_EBS_HEADER: - db " HPFS" ;; MAGIC NUMBER OF FILESYSTEM - dw 8 ;; MAGIC NUMBER LENGTH. - dq 0 ;; RESERVED 4 - dw 0x0100 ;; VERSION - dw 0 ;; PARTITION TYPE - dq 0 ;; RESERVED 3 - dw 0 ;; DISK TYPE (INVALID = 0, CDROM = 1, SSD = 2, USB = 3) - dw 0 ;; CHECKSUM OF PARTITION - dw 0 ;; IS IT LOCKED? (DISK ENCRYPTION ON?) - dq 0 ;; SECTOR COUNT - dq 0 ;; RESERVED 2 - dq 512 ;; SECTOR SZ - dq 0 ;; DISK SIZE - dq 0 ;; RESERVED 1 SLOT - dq 1 ;; LOCKER ON? - dq 1 ;; PARTITION MAP TYPE (GPT, MBR, EPM) - dq 16 ;; MASTER FILE TABLE - dq 80 ;; MASTER TRACE TABLE - dq 144 ;; MASTER DIRECTORY TABLE - dw 0xFFFF ;; END OF HEADER WORD diff --git a/dev/hpfs/EPM/EPM.asm b/dev/hpfs/EPM/EPM.asm deleted file mode 100644 index 2197d2cd..00000000 --- a/dev/hpfs/EPM/EPM.asm +++ /dev/null @@ -1,37 +0,0 @@ -;; FILE: EBS.asm -;; PURPOSE: EXPLICIT PARTITION MAP BOOT STRUCTURE (HPFS RELATED). -;; AUTHOR: AMLAL EL MAHROUSS - -[bits 64] - -HPFS_EPM_HEADER: - db "EPMAM", 0 - db "HPFS ", 0 -HPFS_EPM_UUID: - dd 0 - dw 0 - db 0 - db 0 - db 0 - db 0 - db 0 - db 0 - db 0 - db 0 - dd 0xAD ;; EPM revision - dd 0 ;; Number of blocks, set to 0 by default. - dd 512 ;; Sector size, HPFS was made with drives in mind, so 512. - dd 0 - dd 0 - dw 0x1f ;; NewOS (ZKA) present on partition. - dd 1 - db "FileSystem (A:)", 0 - times 401 db 0 -HPFS_EPM_HEADER_END: - - -%include "EBS.i" - -times 16 db 0 - -;; Here the partition starts diff --git a/dev/hpfs/EPM/blob.json b/dev/hpfs/EPM/blob.json deleted file mode 100644 index 4ce4fc1c..00000000 --- a/dev/hpfs/EPM/blob.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compiler_path": "nasm", - "sources_path": ["EPM.asm"], - "output_name": "hpfs.bin", - "compiler_flags": ["-f bin"] -} diff --git a/dev/hpfs/epm/blob.json b/dev/hpfs/epm/blob.json new file mode 100644 index 00000000..4ce4fc1c --- /dev/null +++ b/dev/hpfs/epm/blob.json @@ -0,0 +1,6 @@ +{ + "compiler_path": "nasm", + "sources_path": ["EPM.asm"], + "output_name": "hpfs.bin", + "compiler_flags": ["-f bin"] +} diff --git a/dev/hpfs/epm/ebs.i b/dev/hpfs/epm/ebs.i new file mode 100644 index 00000000..c137b6f4 --- /dev/null +++ b/dev/hpfs/epm/ebs.i @@ -0,0 +1,29 @@ +;; FILE: EBS.asm +;; PURPOSE: EXPLICIT BOOT SECTOR STRUCTURE (HPFS RELATED). +;; AUTHOR: AMLAL EL MAHROUSS + +[bits 64] + +;; DUMP THIS BLOB TO DISK, WHEN FORMATTING THE SSD. + +HPFS_EBS_HEADER: + db " HPFS" ;; MAGIC NUMBER OF FILESYSTEM + dw 8 ;; MAGIC NUMBER LENGTH. + dq 0 ;; RESERVED 4 + dw 0x0100 ;; VERSION + dw 0 ;; PARTITION TYPE + dq 0 ;; RESERVED 3 + dw 0 ;; DISK TYPE (INVALID = 0, CDROM = 1, SSD = 2, USB = 3) + dw 0 ;; CHECKSUM OF PARTITION + dw 0 ;; IS IT LOCKED? (DISK ENCRYPTION ON?) + dq 0 ;; SECTOR COUNT + dq 0 ;; RESERVED 2 + dq 512 ;; SECTOR SZ + dq 0 ;; DISK SIZE + dq 0 ;; RESERVED 1 SLOT + dq 1 ;; LOCKER ON? + dq 1 ;; PARTITION MAP TYPE (GPT, MBR, EPM) + dq 16 ;; MASTER FILE TABLE + dq 80 ;; MASTER TRACE TABLE + dq 144 ;; MASTER DIRECTORY TABLE + dw 0xFFFF ;; END OF HEADER WORD diff --git a/dev/hpfs/epm/epm.asm b/dev/hpfs/epm/epm.asm new file mode 100644 index 00000000..2197d2cd --- /dev/null +++ b/dev/hpfs/epm/epm.asm @@ -0,0 +1,37 @@ +;; FILE: EBS.asm +;; PURPOSE: EXPLICIT PARTITION MAP BOOT STRUCTURE (HPFS RELATED). +;; AUTHOR: AMLAL EL MAHROUSS + +[bits 64] + +HPFS_EPM_HEADER: + db "EPMAM", 0 + db "HPFS ", 0 +HPFS_EPM_UUID: + dd 0 + dw 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + db 0 + dd 0xAD ;; EPM revision + dd 0 ;; Number of blocks, set to 0 by default. + dd 512 ;; Sector size, HPFS was made with drives in mind, so 512. + dd 0 + dd 0 + dw 0x1f ;; NewOS (ZKA) present on partition. + dd 1 + db "FileSystem (A:)", 0 + times 401 db 0 +HPFS_EPM_HEADER_END: + + +%include "EBS.i" + +times 16 db 0 + +;; Here the partition starts diff --git a/dev/hpfs/hpfs_specs.hxx b/dev/hpfs/hpfs_specs.hxx index 4fc24c21..5c82be90 100644 --- a/dev/hpfs/hpfs_specs.hxx +++ b/dev/hpfs/hpfs_specs.hxx @@ -9,7 +9,4 @@ #pragma once -typedef __INT32_TYPE__ HPFS_INT32; -typedef void HPFS_VOID; - #define cHPFSVersion 0x0100 diff --git a/dev/hpfs/src/hpfs_main.cxx b/dev/hpfs/src/hpfs_main.cxx index eaa64dc5..187fb3ce 100644 --- a/dev/hpfs/src/hpfs_main.cxx +++ b/dev/hpfs/src/hpfs_main.cxx @@ -10,11 +10,15 @@ #include #include +static DDK_OBJECT_MANIFEST* cIFSObject = nullptr; + /** @brief HPFS IFS main. */ -HPFS_INT32 ModuleMain(HPFS_VOID) +int32_t ModuleMain(void) { auto ifs_handle = KernelGetObject(0, "IFS_OBJECT"); // TODO: Register this IFS with necessary I/O functions... + cIFSObject = ifs_handle; + return 0; } diff --git a/dev/zba/src/HEL/AMD64/BootMain.cxx b/dev/zba/src/HEL/AMD64/BootMain.cxx index 5557f8dd..11edebdd 100644 --- a/dev/zba/src/HEL/AMD64/BootMain.cxx +++ b/dev/zba/src/HEL/AMD64/BootMain.cxx @@ -204,8 +204,8 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, // Update handover file specific table and phyiscal start field. //-----------------------------------------------------------// - handover_hdr->f_BitMapStart = nullptr; /* # of pages */ - handover_hdr->f_BitMapSize = kHandoverBitMapSz; /* # of pages */ + handover_hdr->f_BitMapStart = nullptr; /* Start of bitmap. */ + handover_hdr->f_BitMapSize = kHandoverBitMapSz; /* Size of bitmap. */ while (BS->AllocatePool(EfiLoaderData, handover_hdr->f_BitMapSize, &handover_hdr->f_BitMapStart) != kEfiOk) { diff --git a/dev/zba/src/Root/ZKA/startup.wav b/dev/zba/src/Root/ZKA/startup.wav deleted file mode 100644 index 524921f5..00000000 Binary files a/dev/zba/src/Root/ZKA/startup.wav and /dev/null differ diff --git a/dev/zba/src/Root/ZKA/urbanist.ttf b/dev/zba/src/Root/ZKA/urbanist.ttf deleted file mode 100644 index e9a6dbb0..00000000 Binary files a/dev/zba/src/Root/ZKA/urbanist.ttf and /dev/null differ diff --git a/dev/zba/src/Root/zka/startup.wav b/dev/zba/src/Root/zka/startup.wav new file mode 100644 index 00000000..524921f5 Binary files /dev/null and b/dev/zba/src/Root/zka/startup.wav differ diff --git a/dev/zba/src/Root/zka/urbanist.ttf b/dev/zba/src/Root/zka/urbanist.ttf new file mode 100644 index 00000000..e9a6dbb0 Binary files /dev/null and b/dev/zba/src/Root/zka/urbanist.ttf differ diff --git a/dev/zka/HALKit/AMD64/HalCPU.cxx b/dev/zka/HALKit/AMD64/HalCPU.cxx new file mode 100644 index 00000000..0af8a921 --- /dev/null +++ b/dev/zka/HALKit/AMD64/HalCPU.cxx @@ -0,0 +1,101 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + File: HalCPU.cxx + Purpose: Platform processor routines. + +------------------------------------------- */ + +#include +#include + +/** + * @file HalCPU.cxx + * @brief CPU Common API. + */ + +namespace Kernel::HAL +{ + Void Out8(UInt16 port, UInt8 value) + { + asm volatile("outb %%al, %1" + : + : "a"(value), "Nd"(port) + : "memory"); + } + + Void Out16(UInt16 port, UInt16 value) + { + asm volatile("outw %%ax, %1" + : + : "a"(value), "Nd"(port) + : "memory"); + } + + Void Out32(UInt16 port, UInt32 value) + { + asm volatile("outl %%eax, %1" + : + : "a"(value), "Nd"(port) + : "memory"); + } + + UInt8 In8(UInt16 port) + { + UInt8 value = 0UL; + asm volatile("inb %1, %%al" + : "=a"(value) + : "Nd"(port) + : "memory"); + + return value; + } + + UInt16 In16(UInt16 port) + { + UInt16 value = 0UL; + asm volatile("inw %1, %%ax" + : "=a"(value) + : "Nd"(port) + : "memory"); + + return value; + } + + UInt32 In32(UInt16 port) + { + UInt32 value = 0UL; + asm volatile("inl %1, %%eax" + : "=a"(value) + : "Nd"(port) + : "memory"); + + return value; + } + + Void rt_halt() + { + asm volatile("hlt"); + } + + Void rt_cli() + { + asm volatile("cli"); + } + + Void rt_sti() + { + asm volatile("sti"); + } + + Void rt_cld() + { + asm volatile("cld"); + } + + Void rt_std() + { + asm volatile("std"); + } +} // namespace Kernel::HAL diff --git a/dev/zka/HALKit/AMD64/HalCommAPI.cxx b/dev/zka/HALKit/AMD64/HalCommAPI.cxx deleted file mode 100644 index 11c442b4..00000000 --- a/dev/zka/HALKit/AMD64/HalCommAPI.cxx +++ /dev/null @@ -1,116 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - - File: HalProcessor.cxx - Purpose: Platform processor routines. - -------------------------------------------- */ - -#include -#include - -/** - * @file HalCommAPI.cxx - * @brief CPU Common API. - */ - -#define PhysShift36(ADDR) ((UInt64)ADDR >> 12) - -namespace Kernel::HAL -{ - /// @brief Maps or allocates a page from virt_addr. - /// @param virt_addr a valid virtual address. - /// @param phys_addr point to physical address. - /// @param flags the flags to put on the page. - /// @return Status code of page manip. - EXTERN_C Int32 mm_map_page(VoidPtr virt_addr, UInt32 flags) - { - ZKA_UNUSED(virt_addr); - ZKA_UNUSED(flags); - - return 0; - } - - Void Out8(UInt16 port, UInt8 value) - { - asm volatile("outb %%al, %1" - : - : "a"(value), "Nd"(port) - : "memory"); - } - - Void Out16(UInt16 port, UInt16 value) - { - asm volatile("outw %%ax, %1" - : - : "a"(value), "Nd"(port) - : "memory"); - } - - Void Out32(UInt16 port, UInt32 value) - { - asm volatile("outl %%eax, %1" - : - : "a"(value), "Nd"(port) - : "memory"); - } - - UInt8 In8(UInt16 port) - { - UInt8 value = 0UL; - asm volatile("inb %1, %%al" - : "=a"(value) - : "Nd"(port) - : "memory"); - - return value; - } - - UInt16 In16(UInt16 port) - { - UInt16 value = 0UL; - asm volatile("inw %1, %%ax" - : "=a"(value) - : "Nd"(port) - : "memory"); - - return value; - } - - UInt32 In32(UInt16 port) - { - UInt32 value = 0UL; - asm volatile("inl %1, %%eax" - : "=a"(value) - : "Nd"(port) - : "memory"); - - return value; - } - - Void rt_halt() - { - asm volatile("hlt"); - } - - Void rt_cli() - { - asm volatile("cli"); - } - - Void rt_sti() - { - asm volatile("sti"); - } - - Void rt_cld() - { - asm volatile("cld"); - } - - Void rt_std() - { - asm volatile("std"); - } -} // namespace Kernel::HAL diff --git a/dev/zka/HALKit/AMD64/HalPaging.cxx b/dev/zka/HALKit/AMD64/HalPaging.cxx new file mode 100644 index 00000000..ac8b1a73 --- /dev/null +++ b/dev/zka/HALKit/AMD64/HalPaging.cxx @@ -0,0 +1,75 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + File: HalProcessor.cxx + Purpose: Platform processor routines. + +------------------------------------------- */ + +#include +#include + +namespace Kernel::HAL +{ + STATIC Void mm_map_page_status(PTE* pte) + { + if (!pte) + return; + + kcout << (pte->Present ? "Present" : "Not Present") << endl; + kcout << (pte->Wr ? "W/R" : "Not W/R") << endl; + kcout << (pte->User ? "User" : "Not User") << endl; + } + + /// @brief Maps or allocates a page from virt_addr. + /// @internal + /// @param virt_addr a valid virtual address. + /// @param phys_addr point to physical address. + /// @param flags the flags to put on the page. + /// @return Status code of page manipulation process. + EXTERN_C Int32 mm_map_page(VoidPtr virt_addr, UInt32 flags) + { + return 0; + } + + /// @brief Maps or allocates a page from virt_addr. + /// @internal + /// @param virt_addr a valid virtual address. + /// @param phys_addr point to physical address. + /// @param flags the flags to put on the page. + /// @return Status code of page manipulation process. + EXTERN_C Int32 _mm_map_page(VoidPtr virt_addr, UInt32 flags, ZKA_PDE* pde, SizeT pte) + { + if (!virt_addr || !pde || !pte) + return -1; + + if (pde->fEntries[pte]->Present) + { + rt_cli(); + + if (flags & ~eFlagsPresent) + pde->fEntries[pte]->Present = false; + else if (flags & eFlagsPresent) + pde->fEntries[pte]->Present = true; + + if (flags & eFlagsRw) + pde->fEntries[pte]->Wr = true; + else if (flags & ~eFlagsRw) + pde->fEntries[pte]->Wr = false; + + if (flags & eFlagsUser) + pde->fEntries[pte]->User = true; + else if (flags & ~eFlagsUser) + pde->fEntries[pte]->User = false; + + mm_map_page_status(pde->fEntries[pte]); + + rt_sti(); + + return 0; + } + + return -2; + } +} // namespace Kernel::HAL diff --git a/dev/zka/KernelKit/Heap.hxx b/dev/zka/KernelKit/Heap.hxx index cb8da37d..53eec98e 100644 --- a/dev/zka/KernelKit/Heap.hxx +++ b/dev/zka/KernelKit/Heap.hxx @@ -53,7 +53,7 @@ namespace Kernel T* cls = (T*)mm_new_heap(sizeof(T), No, No); MUST_PASS(cls); - *cls = T(move(args)...); + *cls = T(move(args)...); return cls; } diff --git a/dev/zwm/src/zwm_main.cxx b/dev/zwm/src/zwm_main.cxx index f5f4024e..7fbd9ccb 100644 --- a/dev/zwm/src/zwm_main.cxx +++ b/dev/zwm/src/zwm_main.cxx @@ -2,13 +2,12 @@ Copyright ZKA Technologies. - FILE: IFSMain.cxx - PURPOSE: HPFS IFS entrypoint. + FILE: main.cxx + PURPOSE: ZWM entrypoint. ------------------------------------------- */ #include -#include static uint32_t cGPUIndexHW = 0U; static struct DDK_OBJECT_MANIFEST* cGPUObject = nullptr; -- cgit v1.2.3