From ecf2a09a48ef029d09075af744c04e643661ec27 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 7 Jan 2025 07:39:26 +0100 Subject: ADD: Moved system call handler in HalCommonAPI.asm (AMD64) ADD: Replace make_container with make_app. ADD: Reference SwapDisk.h and TeamScheduler.h in unix_layer for future POSIX work too. Signed-off-by: Amlal El Mahrouss --- .gitignore | 2 +- dev/Kernel/HALKit/AMD64/HalCommonAPI.asm | 27 +++++++++ dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc | 8 +-- dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm | 28 --------- dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc | 16 +++--- dev/Kernel/POSIXKit/unix_layer.h | 2 + public/tools/.keep | 0 public/tools/Common.h | 19 ------ public/tools/Framework.h | 17 ------ public/tools/Steps.h | 14 ----- public/tools/make_app/Common.h | 19 ++++++ public/tools/make_app/Framework.h | 17 ++++++ public/tools/make_app/Steps.h | 14 +++++ public/tools/make_app/dist/.keep | 0 public/tools/make_app/make_app.json | 12 ++++ public/tools/make_app/src/CLI.cc | 80 ++++++++++++++++++++++++++ public/tools/make_application.sh | 3 - public/tools/make_container.json | 12 ---- public/tools/src/CLI.cc | 80 -------------------------- 19 files changed, 184 insertions(+), 186 deletions(-) create mode 100644 public/tools/.keep delete mode 100644 public/tools/Common.h delete mode 100644 public/tools/Framework.h delete mode 100644 public/tools/Steps.h create mode 100644 public/tools/make_app/Common.h create mode 100644 public/tools/make_app/Framework.h create mode 100644 public/tools/make_app/Steps.h create mode 100644 public/tools/make_app/dist/.keep create mode 100644 public/tools/make_app/make_app.json create mode 100644 public/tools/make_app/src/CLI.cc delete mode 100644 public/tools/make_application.sh delete mode 100644 public/tools/make_container.json delete mode 100644 public/tools/src/CLI.cc diff --git a/.gitignore b/.gitignore index fc9558d6..d55396d1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ xcuserdata/ */xcuserdata/* *.xcworkspacedata -public/tools/make_container +public/tools/make_app/dist/make_app minoskrnl/minoskrnl.xcodeproj/project.xcworkspace/xcshareddata/ diff --git a/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm b/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm index 6339fa8d..dd3901e8 100644 --- a/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm +++ b/dev/Kernel/HALKit/AMD64/HalCommonAPI.asm @@ -51,3 +51,30 @@ rt_in32: mov rdx, rcx in eax, dx ret + +extern hal_system_call_enter +global mp_system_call_handler + +mp_system_call_handler: + + push r8 + push r9 + push r10 + push r11 + push r12 + push r13 + push r14 + push r15 + + jmp hal_system_call_enter + + pop r15 + pop r14 + pop r13 + pop r12 + pop r11 + pop r10 + pop r9 + pop r8 + + o64 sysret diff --git a/dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc b/dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc index 680aa6ed..2edbdc60 100644 --- a/dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc +++ b/dev/Kernel/HALKit/AMD64/HalDescriptorLoader.cc @@ -7,7 +7,7 @@ #include #include -#define kPITDefaultTicks (100U) +#define kPITDefaultTicks (1000U) namespace Kernel::HAL { @@ -26,11 +26,11 @@ namespace Kernel::HAL // Configure PIT to receieve scheduler interrupts. - UInt16 cCommDivisor = kPITFrequency / ticks; // 100 Hz. + UInt16 kPITCommDivisor = kPITFrequency / ticks; // 100 Hz. HAL::rt_out8(kPITControlPort, 0x36); // Command to PIT - HAL::rt_out8(kPITChannel0Port, cCommDivisor & 0xFF); // Send low byte - HAL::rt_out8(kPITChannel0Port, (cCommDivisor >> 8) & 0xFF); // Send high byte + HAL::rt_out8(kPITChannel0Port, kPITCommDivisor & 0xFF); // Send low byte + HAL::rt_out8(kPITChannel0Port, (kPITCommDivisor >> 8) & 0xFF); // Send high byte hal_clear_irq_mask(32); } diff --git a/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm b/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm index 02031c4c..53654d08 100644 --- a/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm +++ b/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm @@ -369,34 +369,6 @@ hal_reload_segments: ret global hal_load_idt -global hal_user_code_start - -extern hal_system_call_enter -global mp_system_call_handler - -mp_system_call_handler: - - push r8 - push r9 - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - - jmp hal_system_call_enter - - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - pop r9 - pop r8 - - o64 sysret hal_load_idt: lidt [rcx] diff --git a/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc b/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc index 9fc261ef..1829a25a 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc @@ -37,18 +37,18 @@ Boolean drv_std_wait_io(UInt16 IO) rt_in8(IO + ATA_REG_STATUS); ATAWaitForIO_Retry: - auto statRdy = rt_in8(IO + ATA_REG_STATUS); + auto rdy = rt_in8(IO + ATA_REG_STATUS); - if ((statRdy & ATA_SR_BSY)) + if ((rdy & ATA_SR_BSY)) goto ATAWaitForIO_Retry; ATAWaitForIO_Retry2: - statRdy = rt_in8(IO + ATA_REG_STATUS); + rdy = rt_in8(IO + ATA_REG_STATUS); - if (statRdy & ATA_SR_ERR) + if (rdy & ATA_SR_ERR) return false; - if (!(statRdy & ATA_SR_DRDY)) + if (!(rdy & ATA_SR_DRDY)) goto ATAWaitForIO_Retry2; return true; @@ -74,16 +74,16 @@ ATAInit_Retry: // identify until it's good - auto statRdy = rt_in8(IO + ATA_REG_STATUS); + auto rdy = rt_in8(IO + ATA_REG_STATUS); - if (statRdy & ATA_SR_ERR) + if (rdy & ATA_SR_ERR) { kcout << "ATA Error, aborting...\r"; return false; } - if ((statRdy & ATA_SR_BSY)) + if ((rdy & ATA_SR_BSY)) { kcout << "Retrying as controller is busy...\r"; goto ATAInit_Retry; diff --git a/dev/Kernel/POSIXKit/unix_layer.h b/dev/Kernel/POSIXKit/unix_layer.h index d6c0fa1c..5da6d24b 100644 --- a/dev/Kernel/POSIXKit/unix_layer.h +++ b/dev/Kernel/POSIXKit/unix_layer.h @@ -9,3 +9,5 @@ #include #include #include +#include +#include \ No newline at end of file diff --git a/public/tools/.keep b/public/tools/.keep new file mode 100644 index 00000000..e69de29b diff --git a/public/tools/Common.h b/public/tools/Common.h deleted file mode 100644 index 65748608..00000000 --- a/public/tools/Common.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - Sat Oct 26 07:03:28 AM CEST 2024 - (c) Theater Quality Corp. -*/ - -#ifndef APPS_COMMON_H -#define APPS_COMMON_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // APPS_COMMON_H diff --git a/public/tools/Framework.h b/public/tools/Framework.h deleted file mode 100644 index bd2adf08..00000000 --- a/public/tools/Framework.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - Thu Oct 17 07:57:43 CEST 2024 - (c) Theater Quality Corp. -*/ - -#ifndef APPS_FRAMEWORK_H -#define APPS_FRAMEWORK_H - -#include - -#define kExecDirectory "ML/Exec/" -#define kRsrcDirectory "ML/Resources/" -#define kRootDirectory "ML/" -#define kFKExtension ".fwrk" -#define kAppExtension ".app" - -#endif // !APPS_FRAMEWORK_H diff --git a/public/tools/Steps.h b/public/tools/Steps.h deleted file mode 100644 index c503c56c..00000000 --- a/public/tools/Steps.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - Thu Oct 17 07:57:43 CEST 2024 - (c) Theater Quality Corp. -*/ - -#ifndef APPS_STEPS_H -#define APPS_STEPS_H - -#include -#include - -#define kStepsExtension ".steps" - -#endif // ifndef APPS_STEPS_H \ No newline at end of file diff --git a/public/tools/make_app/Common.h b/public/tools/make_app/Common.h new file mode 100644 index 00000000..65748608 --- /dev/null +++ b/public/tools/make_app/Common.h @@ -0,0 +1,19 @@ +/** + Sat Oct 26 07:03:28 AM CEST 2024 + (c) Theater Quality Corp. +*/ + +#ifndef APPS_COMMON_H +#define APPS_COMMON_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // APPS_COMMON_H diff --git a/public/tools/make_app/Framework.h b/public/tools/make_app/Framework.h new file mode 100644 index 00000000..bd2adf08 --- /dev/null +++ b/public/tools/make_app/Framework.h @@ -0,0 +1,17 @@ +/** + Thu Oct 17 07:57:43 CEST 2024 + (c) Theater Quality Corp. +*/ + +#ifndef APPS_FRAMEWORK_H +#define APPS_FRAMEWORK_H + +#include + +#define kExecDirectory "ML/Exec/" +#define kRsrcDirectory "ML/Resources/" +#define kRootDirectory "ML/" +#define kFKExtension ".fwrk" +#define kAppExtension ".app" + +#endif // !APPS_FRAMEWORK_H diff --git a/public/tools/make_app/Steps.h b/public/tools/make_app/Steps.h new file mode 100644 index 00000000..c503c56c --- /dev/null +++ b/public/tools/make_app/Steps.h @@ -0,0 +1,14 @@ +/** + Thu Oct 17 07:57:43 CEST 2024 + (c) Theater Quality Corp. +*/ + +#ifndef APPS_STEPS_H +#define APPS_STEPS_H + +#include +#include + +#define kStepsExtension ".steps" + +#endif // ifndef APPS_STEPS_H \ No newline at end of file diff --git a/public/tools/make_app/dist/.keep b/public/tools/make_app/dist/.keep new file mode 100644 index 00000000..e69de29b diff --git a/public/tools/make_app/make_app.json b/public/tools/make_app/make_app.json new file mode 100644 index 00000000..ba103467 --- /dev/null +++ b/public/tools/make_app/make_app.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "g++", + "compiler_std": "c++20", + "headers_path": ["./"], + "sources_path": ["src/CLI.cc"], + "output_name": "./dist/make_app", + "cpp_macros": [ + "kMKFVersion=0x0100", + "kMKFVersionHighest=0x0100", + "kMKFVersionLowest=0x0100" + ] +} diff --git a/public/tools/make_app/src/CLI.cc b/public/tools/make_app/src/CLI.cc new file mode 100644 index 00000000..ed686294 --- /dev/null +++ b/public/tools/make_app/src/CLI.cc @@ -0,0 +1,80 @@ +/* + * Created on Thu Oct 17 08:00:42 CEST 2024 + * + * Copyright (c) 2024 Theater Quality Corp + */ + +#include +#include + +/// @brief This program makes a framework directory for ZKA OS. + +int main(int argc, char* argv[]) +{ + std::vector files; + + auto ext = kFKExtension; + + for (size_t i = 2UL; i < argc; ++i) + { + if (strcmp(argv[i], "-h") == 0) + { + std::cout << "make_container: Framework/Application Creation Tool.\n"; + std::cout << "make_container: © Theater Quality Corp, All rights reserved.\n"; + + std::cout << "make_container: -app: Application directory.\n"; + std::cout << "make_container: -steps: Steps directory.\n"; + std::cout << "make_container: -fwrk: Framework directory.\n"; + + return EXIT_SUCCESS; + } + + if (strcmp(argv[i], "-app") == 0) + { + ext = kAppExtension; + continue; + } + else if (strcmp(argv[i], "-steps") == 0) + { + ext = kStepsExtension; + continue; + } + else if (strcmp(argv[i], "-fwrk") == 0) + { + ext = kFKExtension; + continue; + } + + files.push_back(argv[i]); + } + + auto path = std::string(argv[1]); + + if (!std::filesystem::exists(path)) + return EXIT_FAILURE; + + std::filesystem::path path_arg = path + ext; + + if (std::filesystem::create_directory(path_arg)) + { + std::filesystem::create_directory(path_arg / kRootDirectory); + std::filesystem::create_directory(path_arg / kExecDirectory); + + for (auto& file : files) + { + std::string file_cpy = file; + + while (file_cpy.find("/") != std::string::npos) + { + file_cpy.erase(0, file_cpy.find("/")); + file_cpy.erase(file_cpy.find("/"), 1); + } + + std::filesystem::copy(path, path_arg / kExecDirectory / file_cpy); + } + + return EXIT_SUCCESS; + } + + return EXIT_FAILURE; +} diff --git a/public/tools/make_application.sh b/public/tools/make_application.sh deleted file mode 100644 index 2878f5b6..00000000 --- a/public/tools/make_application.sh +++ /dev/null @@ -1,3 +0,0 @@ -# !/bin/sh - -cp make_framework.o make_application.o \ No newline at end of file diff --git a/public/tools/make_container.json b/public/tools/make_container.json deleted file mode 100644 index 1f66e5af..00000000 --- a/public/tools/make_container.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compiler_path": "g++", - "compiler_std": "c++20", - "headers_path": ["./"], - "sources_path": ["src/CLI.cc"], - "output_name": "make_container", - "cpp_macros": [ - "kMKFVersion=0x0100", - "kMKFVersionHighest=0x0100", - "kMKFVersionLowest=0x0100" - ] -} diff --git a/public/tools/src/CLI.cc b/public/tools/src/CLI.cc deleted file mode 100644 index ed686294..00000000 --- a/public/tools/src/CLI.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Created on Thu Oct 17 08:00:42 CEST 2024 - * - * Copyright (c) 2024 Theater Quality Corp - */ - -#include -#include - -/// @brief This program makes a framework directory for ZKA OS. - -int main(int argc, char* argv[]) -{ - std::vector files; - - auto ext = kFKExtension; - - for (size_t i = 2UL; i < argc; ++i) - { - if (strcmp(argv[i], "-h") == 0) - { - std::cout << "make_container: Framework/Application Creation Tool.\n"; - std::cout << "make_container: © Theater Quality Corp, All rights reserved.\n"; - - std::cout << "make_container: -app: Application directory.\n"; - std::cout << "make_container: -steps: Steps directory.\n"; - std::cout << "make_container: -fwrk: Framework directory.\n"; - - return EXIT_SUCCESS; - } - - if (strcmp(argv[i], "-app") == 0) - { - ext = kAppExtension; - continue; - } - else if (strcmp(argv[i], "-steps") == 0) - { - ext = kStepsExtension; - continue; - } - else if (strcmp(argv[i], "-fwrk") == 0) - { - ext = kFKExtension; - continue; - } - - files.push_back(argv[i]); - } - - auto path = std::string(argv[1]); - - if (!std::filesystem::exists(path)) - return EXIT_FAILURE; - - std::filesystem::path path_arg = path + ext; - - if (std::filesystem::create_directory(path_arg)) - { - std::filesystem::create_directory(path_arg / kRootDirectory); - std::filesystem::create_directory(path_arg / kExecDirectory); - - for (auto& file : files) - { - std::string file_cpy = file; - - while (file_cpy.find("/") != std::string::npos) - { - file_cpy.erase(0, file_cpy.find("/")); - file_cpy.erase(file_cpy.find("/"), 1); - } - - std::filesystem::copy(path, path_arg / kExecDirectory / file_cpy); - } - - return EXIT_SUCCESS; - } - - return EXIT_FAILURE; -} -- cgit v1.2.3