From 2bd2e28868d50a2f3ced8b1bfea68216ed35622a Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 25 Feb 2024 16:12:36 +0100 Subject: WiP: See below. - Reworking bootloader to adapt if kernel and programs are already here or not for HCoreLdr. - Working on IDT support for HCoreKrnl. - Add Award and Mahrouss Logic logo in recovery-mode for HCoreKrnl. - Working on reading .NewBoot section in HCoreLdr. Signed-off-by: Amlal El Mahrouss --- Private/Source/KernelMain.cxx | 15 +++-- Private/Source/Network/IP.cpp | 97 -------------------------------- Private/Source/Network/IP.cxx | 97 ++++++++++++++++++++++++++++++++ Private/Source/Network/NetworkDevice.cpp | 32 ----------- Private/Source/Network/NetworkDevice.cxx | 32 +++++++++++ 5 files changed, 140 insertions(+), 133 deletions(-) delete mode 100644 Private/Source/Network/IP.cpp create mode 100644 Private/Source/Network/IP.cxx delete mode 100644 Private/Source/Network/NetworkDevice.cpp create mode 100644 Private/Source/Network/NetworkDevice.cxx (limited to 'Private/Source') diff --git a/Private/Source/KernelMain.cxx b/Private/Source/KernelMain.cxx index b4ea817a..10a5d761 100644 --- a/Private/Source/KernelMain.cxx +++ b/Private/Source/KernelMain.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -31,9 +32,6 @@ EXTERN_C void RuntimeMain( kKernelPhysicalSize = HandoverHeader->f_VirtualSize; kKernelPhysicalStart = HandoverHeader->f_VirtualStart; - /// Init the HAL. - MUST_PASS(HCore::ke_init_hal()); - if (HandoverHeader->f_Bootloader == 0xDD) { /// Mount a New partition. HCore::IFilesystemManager::Mount(new HCore::NewFilesystemManager()); @@ -50,9 +48,16 @@ EXTERN_C void RuntimeMain( ** This draws the background. */ - DrawResource(HCoreLogo, HandoverHeader, HCORELOGO_WIDTH, HCORELOGO_HEIGHT, + ResourceInit(); + + DrawResource(HCoreLogo, HandoverHeader, HCORELOGO_HEIGHT, HCORELOGO_WIDTH, 10, 10); + ResourceClear(); + + DrawResource(PoweredByAward, HandoverHeader, POWEREDBYAWARD_HEIGHT, + POWEREDBYAWARD_WIDTH, POWEREDBYAWARD_WIDTH + 20, 10); + /** ** This draws the HCore resource icon.. */ @@ -60,5 +65,7 @@ EXTERN_C void RuntimeMain( /** This mounts the NewFS drive. */ + + HCore::ke_stop(RUNTIME_CHECK_BOOTSTRAP); } } diff --git a/Private/Source/Network/IP.cpp b/Private/Source/Network/IP.cpp deleted file mode 100644 index b1b45521..00000000 --- a/Private/Source/Network/IP.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include -#include - -namespace HCore { -char* RawIPAddress::Address() { return m_Addr; } - -RawIPAddress::RawIPAddress(char bytes[4]) { rt_copy_memory(bytes, m_Addr, 4); } - -bool RawIPAddress::operator==(const RawIPAddress& ipv4) { - for (Size index = 0; index < 4; ++index) { - if (ipv4.m_Addr[index] != m_Addr[index]) return false; - } - - return true; -} - -bool RawIPAddress::operator!=(const RawIPAddress& ipv4) { - for (Size index = 0; index < 4; ++index) { - if (ipv4.m_Addr[index] == m_Addr[index]) return false; - } - - return true; -} - -char& RawIPAddress::operator[](const Size& index) { - kcout << "[RawIPAddress::operator[]] Fetching Index...\r\n"; - - static char IP_PLACEHOLDER = '0'; - if (index > 4) return IP_PLACEHOLDER; - - return m_Addr[index]; -} - -RawIPAddress6::RawIPAddress6(char bytes[8]) { - rt_copy_memory(bytes, m_Addr, 8); -} - -char& RawIPAddress6::operator[](const Size& index) { - kcout << "[RawIPAddress6::operator[]] Fetching Index...\r\n"; - - static char IP_PLACEHOLDER = '0'; - if (index > 8) return IP_PLACEHOLDER; - - return m_Addr[index]; -} - -bool RawIPAddress6::operator==(const RawIPAddress6& ipv6) { - for (SizeT index = 0; index < 8; ++index) { - if (ipv6.m_Addr[index] != m_Addr[index]) return false; - } - - return true; -} - -bool RawIPAddress6::operator!=(const RawIPAddress6& ipv6) { - for (SizeT index = 0; index < 8; ++index) { - if (ipv6.m_Addr[index] == m_Addr[index]) return false; - } - - return true; -} - -ErrorOr IPFactory::ToStringView(Ref ipv6) { - auto str = StringBuilder::Construct(ipv6.Leak().Address()); - return str; -} - -ErrorOr IPFactory::ToStringView(Ref ipv4) { - auto str = StringBuilder::Construct(ipv4.Leak().Address()); - return str; -} - -bool IPFactory::IpCheckVersion4(const char* ip) { - int cnter = 0; - - for (Size base = 0; base < rt_string_len(ip); ++base) { - if (ip[base] == '.') { - cnter = 0; - } else { - if (cnter == 3) return false; - - ++cnter; - } - } - - return true; -} -} // namespace HCore diff --git a/Private/Source/Network/IP.cxx b/Private/Source/Network/IP.cxx new file mode 100644 index 00000000..b1b45521 --- /dev/null +++ b/Private/Source/Network/IP.cxx @@ -0,0 +1,97 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include +#include + +namespace HCore { +char* RawIPAddress::Address() { return m_Addr; } + +RawIPAddress::RawIPAddress(char bytes[4]) { rt_copy_memory(bytes, m_Addr, 4); } + +bool RawIPAddress::operator==(const RawIPAddress& ipv4) { + for (Size index = 0; index < 4; ++index) { + if (ipv4.m_Addr[index] != m_Addr[index]) return false; + } + + return true; +} + +bool RawIPAddress::operator!=(const RawIPAddress& ipv4) { + for (Size index = 0; index < 4; ++index) { + if (ipv4.m_Addr[index] == m_Addr[index]) return false; + } + + return true; +} + +char& RawIPAddress::operator[](const Size& index) { + kcout << "[RawIPAddress::operator[]] Fetching Index...\r\n"; + + static char IP_PLACEHOLDER = '0'; + if (index > 4) return IP_PLACEHOLDER; + + return m_Addr[index]; +} + +RawIPAddress6::RawIPAddress6(char bytes[8]) { + rt_copy_memory(bytes, m_Addr, 8); +} + +char& RawIPAddress6::operator[](const Size& index) { + kcout << "[RawIPAddress6::operator[]] Fetching Index...\r\n"; + + static char IP_PLACEHOLDER = '0'; + if (index > 8) return IP_PLACEHOLDER; + + return m_Addr[index]; +} + +bool RawIPAddress6::operator==(const RawIPAddress6& ipv6) { + for (SizeT index = 0; index < 8; ++index) { + if (ipv6.m_Addr[index] != m_Addr[index]) return false; + } + + return true; +} + +bool RawIPAddress6::operator!=(const RawIPAddress6& ipv6) { + for (SizeT index = 0; index < 8; ++index) { + if (ipv6.m_Addr[index] == m_Addr[index]) return false; + } + + return true; +} + +ErrorOr IPFactory::ToStringView(Ref ipv6) { + auto str = StringBuilder::Construct(ipv6.Leak().Address()); + return str; +} + +ErrorOr IPFactory::ToStringView(Ref ipv4) { + auto str = StringBuilder::Construct(ipv4.Leak().Address()); + return str; +} + +bool IPFactory::IpCheckVersion4(const char* ip) { + int cnter = 0; + + for (Size base = 0; base < rt_string_len(ip); ++base) { + if (ip[base] == '.') { + cnter = 0; + } else { + if (cnter == 3) return false; + + ++cnter; + } + } + + return true; +} +} // namespace HCore diff --git a/Private/Source/Network/NetworkDevice.cpp b/Private/Source/Network/NetworkDevice.cpp deleted file mode 100644 index 8443467c..00000000 --- a/Private/Source/Network/NetworkDevice.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include - -// network devices implementation. -// PPPNetworkService, TCPNetworkDevice, UDPNetworkService - -namespace HCore { -NetworkDevice::NetworkDevice(void (*out)(NetworkDeviceCommand), - void (*in)(NetworkDeviceCommand), - void (*on_cleanup)(void)) - : DeviceInterface(out, in), fCleanup(on_cleanup) { -#ifdef __DEBUG__ - kcout << "NetworkDevice init.\r\n"; -#endif -} - -NetworkDevice::~NetworkDevice() { -#ifdef __DEBUG__ - kcout << "NetworkDevice cleanup.\r\n"; -#endif - - if (fCleanup) fCleanup(); -} -} // namespace HCore diff --git a/Private/Source/Network/NetworkDevice.cxx b/Private/Source/Network/NetworkDevice.cxx new file mode 100644 index 00000000..8443467c --- /dev/null +++ b/Private/Source/Network/NetworkDevice.cxx @@ -0,0 +1,32 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include + +// network devices implementation. +// PPPNetworkService, TCPNetworkDevice, UDPNetworkService + +namespace HCore { +NetworkDevice::NetworkDevice(void (*out)(NetworkDeviceCommand), + void (*in)(NetworkDeviceCommand), + void (*on_cleanup)(void)) + : DeviceInterface(out, in), fCleanup(on_cleanup) { +#ifdef __DEBUG__ + kcout << "NetworkDevice init.\r\n"; +#endif +} + +NetworkDevice::~NetworkDevice() { +#ifdef __DEBUG__ + kcout << "NetworkDevice cleanup.\r\n"; +#endif + + if (fCleanup) fCleanup(); +} +} // namespace HCore -- cgit v1.2.3