diff options
53 files changed, 570 insertions, 70 deletions
@@ -1,5 +1,5 @@ # boot, libsci, and kernel are owned by amlal@nekernel.org.
/dev/kernel/ @amlel-el-mahrouss
/dev/boot/ @amlel-el-mahrouss
-/dev/SCIKit/ @amlel-el-mahrouss
+/dev/user/ @amlel-el-mahrouss
# some other parts (tooling, frameworks) need ownership too.
\ No newline at end of file diff --git a/compile_flags.txt b/compile_flags.txt index 92deb23d..be580689 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,6 +1,6 @@ -Idev/kernel -Idev/ --Idev/SCIKit +-Idev/user -Idev/boot/ -Ipublic/tools -Ipublic/tools/make_app diff --git a/dev/HintsKit/CompilerHint.h b/dev/HintKit/CompilerHint.h index 9a1be9f6..9a1be9f6 100644 --- a/dev/HintsKit/CompilerHint.h +++ b/dev/HintKit/CompilerHint.h diff --git a/dev/SCIKit/doc/LibSCI.drawio b/dev/SCIKit/doc/LibSCI.drawio deleted file mode 100644 index 4f566c57..00000000 --- a/dev/SCIKit/doc/LibSCI.drawio +++ /dev/null @@ -1,28 +0,0 @@ -<mxfile host="65bd71144e"> - <diagram name="Page-1" id="_vc7fxBdNKI2W8YhI8VA"> - <mxGraphModel dx="756" dy="528" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"> - <root> - <mxCell id="0"/> - <mxCell id="1" parent="0"/> - <mxCell id="eRehIIeIVOPW1y23kRkx-9" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="eRehIIeIVOPW1y23kRkx-2" target="eRehIIeIVOPW1y23kRkx-8" edge="1"> - <mxGeometry relative="1" as="geometry"/> - </mxCell> - <mxCell id="eRehIIeIVOPW1y23kRkx-2" value="libsci Header (Foundation.h)" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1"> - <mxGeometry x="200" y="450" width="226" height="60" as="geometry"/> - </mxCell> - <mxCell id="eRehIIeIVOPW1y23kRkx-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="eRehIIeIVOPW1y23kRkx-3" target="eRehIIeIVOPW1y23kRkx-2" edge="1"> - <mxGeometry relative="1" as="geometry"/> - </mxCell> - <mxCell id="eRehIIeIVOPW1y23kRkx-3" value="libsci" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" parent="1" vertex="1"> - <mxGeometry x="283" y="290" width="60" height="80" as="geometry"/> - </mxCell> - <mxCell id="eRehIIeIVOPW1y23kRkx-8" value="WindowMgr" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1"> - <mxGeometry x="253" y="570" width="120" height="60" as="geometry"/> - </mxCell> - <mxCell id="eRehIIeIVOPW1y23kRkx-10" value="<h1 style="margin-top: 0px;">System Call Interface</h1><p>A set of core functions made to call the microkernel.</p><p>These calls takes care of I/O, Heap and process control.</p>" style="text;html=1;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1"> - <mxGeometry x="450" y="240" width="320" height="100" as="geometry"/> - </mxCell> - </root> - </mxGraphModel> - </diagram> -</mxfile>
\ No newline at end of file diff --git a/dev/boot/amd64-desktop.make b/dev/boot/amd64-desktop.make index 22023923..5a827643 100644 --- a/dev/boot/amd64-desktop.make +++ b/dev/boot/amd64-desktop.make @@ -75,7 +75,7 @@ BOOTLOADER=bootz.exe KERNEL=neoskrnl.exe SYSCHK=syschk.sys STARTUP=startup.sys -SCIKIT=libSCIKit.dylib +SCIKIT=libuser.dylib .PHONY: invalid-recipe invalid-recipe: @@ -90,7 +90,7 @@ all: compile-amd64 $(COPY) src/$(BOOTLOADER) src/Root/EFI/BOOT/BOOTZ.EFI $(COPY) ../kernel/$(KERNEL) src/Root/$(KERNEL) $(COPY) ./modules/SysChk/$(SYSCHK) src/Root/$(SYSCHK) - $(COPY) ../SCIKit/$(SCIKIT) src/Root/$(SCIKIT) + $(COPY) ../user/$(SCIKIT) src/Root/$(SCIKIT) $(COPY) src/$(BOOTLOADER) src/Root/$(BOOTLOADER) .PHONY: disk diff --git a/dev/boot/modules/NetBoot/NetBoot.cc b/dev/boot/modules/NetBoot/NetBoot.cc index 16a9ae1e..1787045e 100644 --- a/dev/boot/modules/NetBoot/NetBoot.cc +++ b/dev/boot/modules/NetBoot/NetBoot.cc @@ -15,7 +15,7 @@ EXTERN_C Int32 ModuleMain(NeOS::HEL::BootInfoHeader* handover) { NETBOOT_INTERNET_HEADER inet{}; - /// TODO: Read Packet from localhost + /// TODO: Read packet from JSON file 'netboot.json' if (inet.PatchLength < 0) { @@ -27,7 +27,7 @@ EXTERN_C Int32 ModuleMain(NeOS::HEL::BootInfoHeader* handover) if (!inet.EEPROM) { - Boot::BootThread thread(inet.Data); + Boot::BootThread thread(inet.PatchData); if (thread.IsValid()) return thread.Start(handover, YES); @@ -35,7 +35,9 @@ EXTERN_C Int32 ModuleMain(NeOS::HEL::BootInfoHeader* handover) else { Boot::BootTextWriter writer; - writer.Write("NetBootLauncher: EEPROM flash not available for now.\r"); + writer.Write("NetBootLauncher: EEPROM flash is not available as of right now.\r"); + + /// TODO: Program new firmware to EEPROM (if crc and size matches) return kEfiFail; // TODO: Add support for EEPROM firmware update. } diff --git a/dev/boot/modules/NetBoot/NetBoot.h b/dev/boot/modules/NetBoot/NetBoot.h index aeeaf18b..e250ef27 100644 --- a/dev/boot/modules/NetBoot/NetBoot.h +++ b/dev/boot/modules/NetBoot/NetBoot.h @@ -29,5 +29,5 @@ typedef struct NETBOOT_INTERNET_HEADER NeOS::Char PatchTarget[kNetBootNameLen]; /// the target file. NeOS::Boolean EEPROM : 1; /// does it imply an EEPROM reprogram? NeOS::Boolean Preflight : 1; /// is it a preflight packet. - NeOS::Char Data[]; /// non preflight packet has a patch blob for a **PatchTarget** + NeOS::Char PatchData[]; /// non preflight packet has a patch blob for a **PatchTarget** } ATTRIBUTE(packed) NETBOOT_INTERNET_HEADER; diff --git a/dev/boot/modules/NetBoot/build.json b/dev/boot/modules/NetBoot/build.json index 2c92567d..db035094 100644 --- a/dev/boot/modules/NetBoot/build.json +++ b/dev/boot/modules/NetBoot/build.json @@ -2,10 +2,9 @@ "compiler_path": "x86_64-w64-mingw32-g++", "compiler_std": "c++20", "headers_path": ["../", "../../", "../../../kernel", "../../../", "./"], - "sources_path": [".cc", "*.S"], + "sources_path": ["*.cc", "*.S", "../../src/HEL/AMD64/*.cc", "../../src/HEL/AMD64/*.S", "../../src/*.cc"], "output_name": "netboot.sys", "compiler_flags": [ - "-ffreestanding", "-nostdlib", "-std=c++20", "-fPIC", @@ -16,6 +15,7 @@ "cpp_macros": [ "__NEOSKRNL__", "__BOOTZ__", + "__BOOTLDR_STANDALONE__", "__NE_AMD64__", "kNetBootVersionHighest=0x0100", "kNetBootVersionLowest=0x0100", diff --git a/dev/boot/src/HEL/AMD64/BootEFI.cc b/dev/boot/src/HEL/AMD64/BootEFI.cc index 5af3643b..0840bc31 100644 --- a/dev/boot/src/HEL/AMD64/BootEFI.cc +++ b/dev/boot/src/HEL/AMD64/BootEFI.cc @@ -280,7 +280,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr image_handle, } UInt32 sz_ver = sizeof(UInt64); - UInt64 ver = KERNEL_VERSION_BCD; + UInt64 ver = KERNEL_VERSION_BCD; ST->RuntimeServices->GetVariable(L"/props/kern_ver", kEfiGlobalNamespaceVarGUID, nullptr, &sz_ver, &ver); diff --git a/dev/ddk/ddk.h b/dev/ddk/ddk.h new file mode 100644 index 00000000..f6f8d48e --- /dev/null +++ b/dev/ddk/ddk.h @@ -0,0 +1,112 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + FILE: ddk.h + PURPOSE: DDK Driver model base header. + +------------------------------------------- */ + +#pragma once + +#include <stdint.h> +#include <stddef.h> + +#if defined(__cplusplus) +#define BOOL bool +#define YES true +#define NO false +#define DDK_EXTERN extern "C" __declspec(dllexport) +#define nil nullptr +#undef NULL +#define NULL 0 +#define DDK_FINAL final +#else +#define BOOL char +#define YES 1 +#define NO 0 +#define DDK_EXTERN extern __declspec(dllexport) +#define nil ((void*)0) +#undef NULL +#define NULL ((void*)0) +#define DDK_FINAL +#endif // defined(__cplusplus) + +#ifndef __DDK__ +#undef DDK_EXTERN +#if defined(__cplusplus) +#define DDK_EXTERN extern "C" __declspec(dllimport) +#else +#define DDK_EXTERN __declspec(dllimport) +#endif +#endif + +#define ATTRIBUTE(X) __attribute__((X)) + +#ifndef __NEOSKRNL__ +#error !!! Do not include header in EL0/Ring 3 mode !!! +#endif // __MINOSKRNL__ + +struct DDK_STATUS_STRUCT; +struct DDK_OBJECT_MANIFEST; + +/// \brief Object handle manifest. +struct DDK_OBJECT_MANIFEST DDK_FINAL +{ + char* p_name; + int32_t p_kind; + void* p_object; +}; + +/// \brief DDK status ping structure. +struct DDK_STATUS_STRUCT DDK_FINAL +{ + int32_t s_action_id; + int32_t s_issuer_id; + int32_t s_group_id; + void* s_object; +}; + +/// @brief Call Kernel procedure. +/// @param name the procedure name. +/// @param cnt number of elements in **dat** +/// @param dat data argument pointer. +/// @param sz sz of whole data argument pointer. +/// @return result of call +DDK_EXTERN void* ke_call(const char* name, int32_t cnt, void* dat, size_t sz); + +/// @brief add a system call. +/// @param slot system call slot id. +/// @param slotFn, syscall slot. +DDK_EXTERN void ke_add_syscall(const int32_t slot, void (*slotFn)(void* a0)); + +/// @brief Allocates an heap ptr. +/// @param sz size of the allocated struct/type. +/// @return the pointer allocated or **nil**. +DDK_EXTERN void* kalloc(size_t sz); + +/// @brief Frees an heap ptr. +/// @param pointer kernel pointer to free. +DDK_EXTERN void kfree(void* the_ptr); + +/// @brief Gets a Kernel object. +/// @param slot object id (can be 0) +/// @param name the property's name. +/// @return DDK_OBJECT_MANIFEST. +DDK_EXTERN struct DDK_OBJECT_MANIFEST* ke_get_obj(const int slot, const char* name); + +/// @brief Set a Kernel object. +/// @param slot object id (can be 0) +/// @param name the property's name. +/// @param ddk_pr pointer to a object's DDK_OBJECT_MANIFEST. +/// @return returned object. +DDK_EXTERN void* ke_set_obj(const int32_t slot, const struct DDK_OBJECT_MANIFEST* ddk_pr); + +/// @brief The highest API version of the DDK. +DDK_EXTERN int32_t kApiVersionHighest; + +/// @brief The lowest API version of the DDK. +DDK_EXTERN int32_t kApiVersionLowest; + +/// @brief API version in BCD. +DDK_EXTERN int32_t kApiVersion; diff --git a/dev/ddk/ddk.json b/dev/ddk/ddk.json new file mode 100644 index 00000000..ffc05f5f --- /dev/null +++ b/dev/ddk/ddk.json @@ -0,0 +1,23 @@ +{ + "compiler_path": "x86_64-w64-mingw32-gcc", + "compiler_std": "c++20", + "headers_path": ["../", "./"], + "sources_path": ["src/*.c", "src/*.cc", "src/*.S"], + "output_name": "ddk.sys", + "compiler_flags": [ + "-ffreestanding", + "-shared", + "-std=c17", + "-fno-rtti", + "-fno-exceptions", + "-Wl,--subsystem=17" + ], + "cpp_macros": [ + "__NEOSKRNL__", + "__DDK_AMD64__", + "__DDK__", + "kDDKVersionHighest=0x0100", + "kDDKVersionLowest=0x0100", + "kDDKVersion=0x0100" + ] +} diff --git a/dev/ddk/dev.h b/dev/ddk/dev.h new file mode 100644 index 00000000..98979e52 --- /dev/null +++ b/dev/ddk/dev.h @@ -0,0 +1,35 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + File: dev.h + Purpose: DDK device support. + +------------------------------------------- */ + +#pragma once + +#include <ddk/ddk.h> + +struct _DDK_DEVICE; + +#define DDK_DEVICE_NAME_LEN (255) + +/// @brief Kernel Device driver. +typedef struct _DDK_DEVICE DDK_FINAL +{ + char d_name[DDK_DEVICE_NAME_LEN]; // the device name. Could be /./DEVICE_NAME/ + void* (*d_read)(void* arg, int len); // read from device. + void (*d_write)(void* arg, int len); + void (*d_wait)(void); // write to device. + struct _DDK_DEVICE* (*d_open)(const char* path); // open device. + void (*d_close)(struct _DDK_DEVICE* dev); // close device. +} DDK_DEVICE, *DDK_DEVICE_PTR; + +/// @brief Open a new device from path. +/// @param path the device's path. +DDK_EXTERN DDK_DEVICE_PTR open(const char* path); + +/// @brief Close any device. +/// @param device valid device. +DDK_EXTERN BOOL close(DDK_DEVICE_PTR device); diff --git a/dev/ddk/docs/SPECIFICATION_DDK.md b/dev/ddk/docs/SPECIFICATION_DDK.md new file mode 100644 index 00000000..5fbff990 --- /dev/null +++ b/dev/ddk/docs/SPECIFICATION_DDK.md @@ -0,0 +1,18 @@ +=================================== + +# 0: General Information + +=================================== + +- Programming Language: C/C++ +- Build System: Make/BTB +- Purpose: Driver Tool Kit, which you link against libddk.sys + +=================================== + +# 1: How It works + +=================================== + +- Driver shall directly call the kernel at specific ports. (Or a kernel call) +- Kernel must respond according to kernel call, otherwise a panic will occur.
\ No newline at end of file diff --git a/dev/ddk/io.h b/dev/ddk/io.h new file mode 100644 index 00000000..cfd6d2d2 --- /dev/null +++ b/dev/ddk/io.h @@ -0,0 +1,18 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#pragma once + +#include <ddk/str.h> + +/// @brief print character into UART. +DDK_EXTERN void kputc(const char ch); + +/// @brief print string to UART. +/// @param message string to transmit to UART. +DDK_EXTERN void kprint(const char* message); diff --git a/dev/ddk/src/ddk_alloc.c b/dev/ddk/src/ddk_alloc.c new file mode 100644 index 00000000..9d0ac0db --- /dev/null +++ b/dev/ddk/src/ddk_alloc.c @@ -0,0 +1,36 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK allocator. + +------------------------------------------- */ + +#include <ddk/ddk.h> + +/** + \brief Allocates a new heap on the Kernel's side. + \param sz the size of the heap block. + \return the newly allocated pointer. +*/ +DDK_EXTERN void* kalloc(size_t sz) +{ + if (!sz) + ++sz; + + void* ptr = ke_call("mm_new_heap", 1, &sz, sizeof(size_t)); + + return ptr; +} + +/** + \brief Frees a pointer from the heap. + \param ptr the pointer to free. +*/ +DDK_EXTERN void kfree(void* ptr) +{ + if (!ptr) + return; + + ke_call("mm_delete_heap", 1, ptr, 0); +} diff --git a/dev/ddk/src/ddk_dev.c b/dev/ddk/src/ddk_dev.c new file mode 100644 index 00000000..7514bf84 --- /dev/null +++ b/dev/ddk/src/ddk_dev.c @@ -0,0 +1,30 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#include <ddk/dev.h> +#include <ddk/str.h> + +/// @brief Open a new binary device from path. +DDK_EXTERN DDK_DEVICE_PTR open(const char* devicePath) +{ + if (!devicePath) + return nil; + + return ke_call("sk_open_dev", 1, (void*)devicePath, kstrlen(devicePath)); +} + +/// @brief Close any device. +/// @param device valid device. +DDK_EXTERN BOOL close(DDK_DEVICE_PTR device) +{ + if (!device) + return NO; + + ke_call("sk_close_dev", 1, device, sizeof(DDK_DEVICE)); + return YES; +} diff --git a/dev/ddk/src/ddk_io.c b/dev/ddk/src/ddk_io.c new file mode 100644 index 00000000..0e10a0ad --- /dev/null +++ b/dev/ddk/src/ddk_io.c @@ -0,0 +1,37 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK Text I/O. + +------------------------------------------- */ + +#include <ddk/io.h> + +DDK_EXTERN void kputc(const char ch) +{ + char assembled[2] = {0}; + assembled[0] = ch; + assembled[1] = 0; + + ke_call("ke_put_string", 1, assembled, 1); +} + +/// @brief print string to UART. +/// @param message UART to transmit. +DDK_EXTERN void kprint(const char* message) +{ + if (!message) + return; + if (*message == 0) + return; + + size_t index = 0; + size_t len = kstrlen(message); + + while (index < len) + { + kputc(message[index]); + ++index; + } +} diff --git a/dev/ddk/src/ddk_kernel_call.c b/dev/ddk/src/ddk_kernel_call.c new file mode 100644 index 00000000..71dbebeb --- /dev/null +++ b/dev/ddk/src/ddk_kernel_call.c @@ -0,0 +1,60 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK Kernel call. + +------------------------------------------- */ + +#include <ddk/ddk.h> +#include <stdarg.h> + +/// @brief this is an internal call, do not use it. +DDK_EXTERN ATTRIBUTE(naked) void* ke_call_dispatch(const char* name, int32_t cnt, void* data, size_t sz); + +/// @brief Interupt Kernel and call it's RPC. +/// @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) +DDK_EXTERN void* ke_call(const char* name, int32_t cnt, void* data, size_t sz) +{ + if (!name || *name == 0 || cnt == 0) + return nil; + + return ke_call_dispatch(name, cnt, data, sz); +} + +/// @brief Add system call. +/// @param slot system call slot +/// @param slotFn, syscall slot. +DDK_EXTERN void ke_add_syscall(const int slot, void (*slotFn)(void* a0)) +{ + ke_call("ke_add_syscall", slot, slotFn, 1); +} + +/// @brief Get a Kernel object. +/// @param slot property id (always 0) +/// @param name the object's name. +/// @return Object manifest. +DDK_EXTERN struct DDK_OBJECT_MANIFEST* ke_get_obj(const int slot, const char* name) +{ + struct DDK_OBJECT_MANIFEST* manifest = (struct DDK_OBJECT_MANIFEST*)ke_call("cf_get_kobj", slot, (void*)name, 1); + + if (!manifest) + return nil; + + return manifest; +} + +/// @brief Set a Kernel object. +/// @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. +DDK_EXTERN void* ke_set_obj(const int slot, const struct DDK_OBJECT_MANIFEST* ddk_pr) +{ + return ke_call("cf_set_kobj", slot, (void*)ddk_pr, 1); +} diff --git a/dev/ddk/src/ddk_kernel_call_dispatch.S b/dev/ddk/src/ddk_kernel_call_dispatch.S new file mode 100644 index 00000000..9b32d0c2 --- /dev/null +++ b/dev/ddk/src/ddk_kernel_call_dispatch.S @@ -0,0 +1,36 @@ +/** + lang: asm + compiler: gnu + */ + +.globl ke_call_dispatch + +.text + +/* Really simple function, takes our va-list, + and brings it to the trap handler in the Kernel. */ + +#if defined(__DDK_AMD64__) + +/* args rcx, rdx, r8, r9 */ +ke_call_dispatch: + int $0x33 + ret + +#elif defined(__DDK_POWER64__) + +/* args r8, r9, r10, r11 */ +ke_call_dispatch: + /* 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 */ +ke_call_dispatch: + /* 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/ddk_rt_cxx.cc b/dev/ddk/src/ddk_rt_cxx.cc new file mode 100644 index 00000000..1ac66457 --- /dev/null +++ b/dev/ddk/src/ddk_rt_cxx.cc @@ -0,0 +1,29 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK C++ runtime. + +------------------------------------------- */ + +#include <ddk/ddk.h> + +void* operator new(size_t sz) +{ + return kalloc(sz); +} + +void operator delete(void* ptr) +{ + kfree(ptr); +} + +void* operator new[](size_t sz) +{ + return kalloc(sz); +} + +void operator delete[](void* ptr) +{ + kfree(ptr); +} diff --git a/dev/ddk/src/ddk_str.c b/dev/ddk/src/ddk_str.c new file mode 100644 index 00000000..1558e636 --- /dev/null +++ b/dev/ddk/src/ddk_str.c @@ -0,0 +1,40 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK Strings. + +------------------------------------------- */ + +#include <ddk/str.h> + +DDK_EXTERN size_t kstrlen(const char* in) +{ + if (in == nil) + return 0; + + if (*in == 0) + return 0; + + size_t index = 0; + + while (in[index] != 0) + { + ++index; + } + + return index; +} + +DDK_EXTERN int kstrncpy(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/ddk_ver.c b/dev/ddk/src/ddk_ver.c new file mode 100644 index 00000000..9641fb34 --- /dev/null +++ b/dev/ddk/src/ddk_ver.c @@ -0,0 +1,25 @@ +/* -------------------------------------------
+
+ Copyright Amlal EL Mahrouss.
+
+ Purpose: DDK version symbols.
+
+------------------------------------------- */
+
+#include <ddk/ddk.h>
+
+#ifndef kDDKVersionHighest
+#define kDDKVersionHighest 1
+#endif // !kDDKVersionHighest
+
+#ifndef kDDKVersionLowest
+#define kDDKVersionLowest 1
+#endif // !kDDKVersionLowest
+
+#ifndef kDDKVersion
+#define kDDKVersion 1
+#endif // !kDDKVersion
+
+int32_t kApiVersionHighest = kDDKVersionHighest;
+int32_t kApiVersionLowest = kDDKVersionLowest;
+int32_t kApiVersion = kDDKVersion;
diff --git a/dev/ddk/str.h b/dev/ddk/str.h new file mode 100644 index 00000000..e1e206a8 --- /dev/null +++ b/dev/ddk/str.h @@ -0,0 +1,17 @@ +/* ------------------------------------------- + + Copyright Amlal EL Mahrouss. + + Purpose: DDK Strings. + +------------------------------------------- */ + +#pragma once + +#include <ddk/ddk.h> + +/// @brief DDK equivalent of POSIX's string.h +/// @file str.h + +DDK_EXTERN size_t kstrlen(const char* in); +DDK_EXTERN int kstrncpy(char* dst, const char* src, size_t len); diff --git a/dev/kernel/FSKit/NeFS.h b/dev/kernel/FSKit/NeFS.h index b2f7095d..8ff9d9d2 100644 --- a/dev/kernel/FSKit/NeFS.h +++ b/dev/kernel/FSKit/NeFS.h @@ -17,7 +17,7 @@ default. #pragma once #include <CompilerKit/CompilerKit.h> -#include <HintsKit/CompilerHint.h> +#include <HintKit/CompilerHint.h> #include <KernelKit/DriveMgr.h> #include <NewKit/Defines.h> #include <NewKit/KString.h> diff --git a/dev/kernel/KernelKit/FileMgr.h b/dev/kernel/KernelKit/FileMgr.h index 59203998..fec83d17 100644 --- a/dev/kernel/KernelKit/FileMgr.h +++ b/dev/kernel/KernelKit/FileMgr.h @@ -30,7 +30,7 @@ #endif // __FSKIT_INCLUDES_HeFS__ #include <CompilerKit/CompilerKit.h> -#include <HintsKit/CompilerHint.h> +#include <HintKit/CompilerHint.h> #include <KernelKit/KPC.h> #include <KernelKit/DebugOutput.h> #include <NewKit/Stream.h> diff --git a/dev/kernel/KernelKit/LoaderInterface.h b/dev/kernel/KernelKit/LoaderInterface.h index 04e197aa..19c21ddb 100644 --- a/dev/kernel/KernelKit/LoaderInterface.h +++ b/dev/kernel/KernelKit/LoaderInterface.h @@ -7,7 +7,7 @@ #pragma once #include <CompilerKit/CompilerKit.h> -#include <HintsKit/CompilerHint.h> +#include <HintKit/CompilerHint.h> #include <NewKit/Defines.h> #include <NewKit/ErrorOr.h> diff --git a/dev/kernel/KernelKit/MemoryMgr.h b/dev/kernel/KernelKit/MemoryMgr.h index 23a4721b..03bd4a2d 100644 --- a/dev/kernel/KernelKit/MemoryMgr.h +++ b/dev/kernel/KernelKit/MemoryMgr.h @@ -13,7 +13,7 @@ #include <NewKit/KernelPanic.h> #include <KernelKit/KPC.h> -#include <HintsKit/CompilerHint.h> +#include <HintKit/CompilerHint.h> namespace NeOS { diff --git a/dev/kernel/NetworkKit/IPC.h b/dev/kernel/NetworkKit/IPC.h index e8f0898f..0d28c080 100644 --- a/dev/kernel/NetworkKit/IPC.h +++ b/dev/kernel/NetworkKit/IPC.h @@ -12,7 +12,7 @@ #include <NewKit/Defines.h> #include <NewKit/KString.h> -#include <HintsKit/CompilerHint.h> +#include <HintKit/CompilerHint.h> /// @file IPC.h /// @brief IPC comm. protocol. diff --git a/dev/kernel/NewKit/Variant.h b/dev/kernel/NewKit/Variant.h index 99768016..3fa04496 100644 --- a/dev/kernel/NewKit/Variant.h +++ b/dev/kernel/NewKit/Variant.h @@ -9,7 +9,7 @@ #include <NewKit/Defines.h> #include <NewKit/KString.h> #include <NewKit/Json.h> -#include <SwapKit/SwapDisk.h> +#include <SwapKit/DiskSwap.h> namespace NeOS { @@ -24,6 +24,7 @@ namespace NeOS kJson, kXML, kSwap, + kInvalid, }; public: diff --git a/dev/kernel/SwapKit/SwapDisk.h b/dev/kernel/SwapKit/DiskSwap.h index b9c31a65..b9c31a65 100644 --- a/dev/kernel/SwapKit/SwapDisk.h +++ b/dev/kernel/SwapKit/DiskSwap.h diff --git a/dev/kernel/amd64-ci.make b/dev/kernel/amd64-ci.make index 692b7b54..71f49082 100644 --- a/dev/kernel/amd64-ci.make +++ b/dev/kernel/amd64-ci.make @@ -49,7 +49,7 @@ WINDRES=x86_64-w64-mingw32-windres .PHONY: newos-amd64-epm newos-amd64-epm: clean - $(WINDRES) KernelRsrc.rsrc -O coff -o KernelRsrc.obj + $(WINDRES) kernel_rsrc.rsrc -O coff -o kernel_rsrc.obj $(CXX) $(CCFLAGS) $(DISK_DRV) $(DEBUG_MACRO) $(wildcard src/*.cc) $(wildcard HALKit/AMD64/PCI/*.cc) $(wildcard src/Network/*.cc) $(wildcard src/Storage/*.cc) $(wildcard src/FS/*.cc) $(wildcard HALKit/AMD64/Storage/*.cc) $(wildcard HALKit/AMD64/*.cc) $(wildcard src/Swap/*.cc) $(wildcard HALKit/AMD64/*.s) $(ASM) $(ASMFLAGS) HALKit/AMD64/HalInterruptAPI.asm $(ASM) $(ASMFLAGS) HALKit/AMD64/HalCommonAPI.asm diff --git a/dev/kernel/amd64-desktop.make b/dev/kernel/amd64-desktop.make index 692b7b54..71f49082 100644 --- a/dev/kernel/amd64-desktop.make +++ b/dev/kernel/amd64-desktop.make @@ -49,7 +49,7 @@ WINDRES=x86_64-w64-mingw32-windres .PHONY: newos-amd64-epm newos-amd64-epm: clean - $(WINDRES) KernelRsrc.rsrc -O coff -o KernelRsrc.obj + $(WINDRES) kernel_rsrc.rsrc -O coff -o kernel_rsrc.obj $(CXX) $(CCFLAGS) $(DISK_DRV) $(DEBUG_MACRO) $(wildcard src/*.cc) $(wildcard HALKit/AMD64/PCI/*.cc) $(wildcard src/Network/*.cc) $(wildcard src/Storage/*.cc) $(wildcard src/FS/*.cc) $(wildcard HALKit/AMD64/Storage/*.cc) $(wildcard HALKit/AMD64/*.cc) $(wildcard src/Swap/*.cc) $(wildcard HALKit/AMD64/*.s) $(ASM) $(ASMFLAGS) HALKit/AMD64/HalInterruptAPI.asm $(ASM) $(ASMFLAGS) HALKit/AMD64/HalCommonAPI.asm diff --git a/dev/kernel/KernelRsrc.rsrc b/dev/kernel/kernel_rsrc.rsrc index d437c176..b5273787 100644 --- a/dev/kernel/KernelRsrc.rsrc +++ b/dev/kernel/kernel_rsrc.rsrc @@ -9,12 +9,12 @@ BEGIN BLOCK "080904E4" BEGIN VALUE "CompanyName", "Amlal El Mahrouss." - VALUE "FileDescription", "NeKernel." + VALUE "FileDescription", "NeKernel" VALUE "FileVersion", KERNEL_VERSION VALUE "InternalName", "neoskrnl" - VALUE "LegalCopyright", "(c) 2024 Amlal El Mahrouss, all rights reserved." + VALUE "LegalCopyright", "(c) 2024-2025 Amlal El Mahrouss, all rights reserved" VALUE "OriginalFilename", "neoskrnl.exe" - VALUE "ProductName", "NeKernel." + VALUE "ProductName", "NeKernel" VALUE "ProductVersion", KERNEL_VERSION END END diff --git a/dev/kernel/src/Swap/SwapDisk.cc b/dev/kernel/src/Swap/DiskSwap.cc index fbc63b2f..c50a96a9 100644 --- a/dev/kernel/src/Swap/SwapDisk.cc +++ b/dev/kernel/src/Swap/DiskSwap.cc @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <SwapKit/SwapDisk.h> +#include <SwapKit/DiskSwap.h> #include <KernelKit/FileMgr.h> namespace NeOS diff --git a/dev/SCIKit/LPC.h b/dev/user/LPC.h index b0bb2d83..87e5e500 100644 --- a/dev/SCIKit/LPC.h +++ b/dev/user/LPC.h @@ -6,7 +6,7 @@ #pragma once -#include <SCIKit/Macros.h> +#include <user/Macros.h> /// @file LPC.h /// @brief Local Procedure Code type and values. diff --git a/dev/SCIKit/Macros.h b/dev/user/Macros.h index 174d644a..e2759258 100644 --- a/dev/SCIKit/Macros.h +++ b/dev/user/Macros.h @@ -10,11 +10,11 @@ Purpose: libsci Macros header. #pragma once /***********************************************************************************/ -/// @file SCIKit/Macros.h -/// @brief Macros and Core types. +/// @file user/Macros.h +/// @brief Macros and Core types of the SCI (System Call Interface). /***********************************************************************************/ -#include <HintsKit/CompilerHint.h> +#include <HintKit/CompilerHint.h> #define ATTRIBUTE(X) __attribute__((X)) diff --git a/dev/SCIKit/SystemCalls.h b/dev/user/SystemCalls.h index 7615a2d1..6a0c2845 100644 --- a/dev/SCIKit/SystemCalls.h +++ b/dev/user/SystemCalls.h @@ -10,7 +10,7 @@ Purpose: System Call Interface. #ifndef SCI_SCI_H
#define SCI_SCI_H
-#include <SCIKit/Macros.h>
+#include <user/Macros.h>
// ------------------------------------------------------------------------------------------ //
/// @brief Types API.
diff --git a/dev/user/docs/SPECIFICATION_SYSCALLS.md b/dev/user/docs/SPECIFICATION_SYSCALLS.md new file mode 100644 index 00000000..b01018c7 --- /dev/null +++ b/dev/user/docs/SPECIFICATION_SYSCALLS.md @@ -0,0 +1,9 @@ +=================================== + +# 0: General Information + +=================================== + +- Programming Language: C/C++ +- Build System: Make/BTB +- Purpose: System Call Interface diff --git a/dev/SCIKit/libsci.json b/dev/user/libsci.json index 453e29dc..ed9a8739 100644 --- a/dev/SCIKit/libsci.json +++ b/dev/user/libsci.json @@ -3,7 +3,7 @@ "compiler_std": "c++20", "headers_path": ["../", "./"], "sources_path": ["src/*.cc", "src/*.o"], - "output_name": "libSCIKit.dylib", + "output_name": "libuser.dylib", "compiler_flags": [ "-fPIC", "-ffreestanding", diff --git a/dev/SCIKit/src/Makefile b/dev/user/src/GNUmakefile index f8f9fbe4..471e22d1 100644 --- a/dev/SCIKit/src/Makefile +++ b/dev/user/src/GNUmakefile @@ -13,4 +13,4 @@ error: .PHONY: sci_asm_io_x64 sci_asm_io_x64: - $(ASM) $(FLAGS) libsci+IO.asm -o libsci+IO.o + $(ASM) $(FLAGS) SystemCall+IO.asm -o SystemCall+IO.o diff --git a/dev/SCIKit/src/LPC.cc b/dev/user/src/LPC.cc index f4433161..f3f320b7 100644 --- a/dev/SCIKit/src/LPC.cc +++ b/dev/user/src/LPC.cc @@ -7,4 +7,4 @@ Purpose: Local Procedure Codes. ------------------------------------------- */ -#include <SCIKit/LPC.h> +#include <user/LPC.h> diff --git a/dev/SCIKit/src/LibSCI+IO.asm b/dev/user/src/SystemCall+IO.asm index 769ae513..769ae513 100644 --- a/dev/SCIKit/src/LibSCI+IO.asm +++ b/dev/user/src/SystemCall+IO.asm diff --git a/dev/SCIKit/src/SCI.cc b/dev/user/src/SystemCalls.cc index 6556754d..eadb07ce 100644 --- a/dev/SCIKit/src/SCI.cc +++ b/dev/user/src/SystemCalls.cc @@ -4,7 +4,7 @@ ------------------------------------------- */
-#include <SCIKit/SystemCalls.h>
+#include <user/SystemCalls.h>
/// @file libsci.cc
/// @brief Source file for the memory functions of the libsci.
diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Array.h b/public/frameworks/CoreFoundation.fwrk/headers/Array.h index 8d7e6e90..00251590 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Array.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Array.h @@ -6,7 +6,7 @@ #pragma once -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> namespace CF { diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h index c2399376..0a46503c 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h @@ -10,7 +10,7 @@ #pragma once -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> namespace CF { diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Property.h b/public/frameworks/CoreFoundation.fwrk/headers/Property.h index aac883ee..878c0217 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Property.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Property.h @@ -7,7 +7,7 @@ #ifndef _PROPS_H #define _PROPS_H -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> #include <CoreFoundation.fwrk/headers/Ref.h> #define kMaxPropLen (256U) diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h index 9941bece..1d0e0208 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h @@ -8,7 +8,7 @@ #ifndef _REF_H_ #define _REF_H_ -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> #include <CoreFoundation.fwrk/headers/Object.h> namespace CF diff --git a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h index 1e8f1e16..98aa194a 100644 --- a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h +++ b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h @@ -9,7 +9,7 @@ #pragma once -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> #include <NewKit/Defines.h> #define kDISectorSz (512) diff --git a/public/tools/cc/src/CommandLine.cc b/public/tools/cc/src/CommandLine.cc index 7c5ccfaf..9ce90a8b 100644 --- a/public/tools/cc/src/CommandLine.cc +++ b/public/tools/cc/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2024 Amlal EL Mahrouss */ -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> /// @brief Placeholder program. diff --git a/public/tools/fwrkld/src/CommandLine.cc b/public/tools/fwrkld/src/CommandLine.cc index d3860453..972ecdd4 100644 --- a/public/tools/fwrkld/src/CommandLine.cc +++ b/public/tools/fwrkld/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2024 Amlal EL Mahrouss */ -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> /// @brief This program loads a code framework into NeOS's memory. diff --git a/public/tools/ld/src/CommandLine.cc b/public/tools/ld/src/CommandLine.cc index 710b2a41..87c85db8 100644 --- a/public/tools/ld/src/CommandLine.cc +++ b/public/tools/ld/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2024 Amlal EL Mahrouss */ -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> /// @brief Placeholder program. diff --git a/public/tools/make_app/Common.h b/public/tools/make_app/Common.h index e54cf701..97d320c8 100644 --- a/public/tools/make_app/Common.h +++ b/public/tools/make_app/Common.h @@ -6,7 +6,7 @@ #ifndef APPS_COMMON_H #define APPS_COMMON_H -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> #include <CoreFoundation.fwrk/headers/Foundation.h> #endif // APPS_COMMON_H diff --git a/public/tools/open/src/CommandLine.cc b/public/tools/open/src/CommandLine.cc index c0fa0925..4e53ebcf 100644 --- a/public/tools/open/src/CommandLine.cc +++ b/public/tools/open/src/CommandLine.cc @@ -4,7 +4,7 @@ * Copyright (c) 2024 Amlal EL Mahrouss */ -#include <SCIKit/SystemCalls.h> +#include <user/SystemCalls.h> /// @brief This program opens an application from **OPEN_APP_BASE_PATH** |
