summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Private/EFIKit/Api.hxx40
-rw-r--r--Private/FSKit/NewFS.hxx8
-rw-r--r--Private/NetworkKit/IP.hpp84
-rw-r--r--Private/NetworkKit/NetworkDevice.hpp57
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx5
-rw-r--r--Private/NewBoot/Source/Entrypoint.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/AMD64-Main.cxx)7
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx74
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/AMD64-CoreSync-ATA.asm24
-rw-r--r--Private/NewBoot/Source/ImageReader.cxx70
-rw-r--r--Private/NewBoot/Source/String.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx)56
-rw-r--r--Private/NewBoot/Source/Utils.cxx162
-rw-r--r--Private/NewBoot/Source/makefile5
-rw-r--r--Private/NewKit/RuntimeCheck.hpp64
-rw-r--r--Private/Servers/.gitkeep0
-rw-r--r--Private/Source/ProcessManager.cxx2
-rw-r--r--Private/Source/RuntimeCheck.cxx9
-rw-r--r--Private/Source/Utils.cxx2
17 files changed, 284 insertions, 385 deletions
diff --git a/Private/EFIKit/Api.hxx b/Private/EFIKit/Api.hxx
index 927d2f6f..c747b777 100644
--- a/Private/EFIKit/Api.hxx
+++ b/Private/EFIKit/Api.hxx
@@ -33,22 +33,22 @@ Bascially frees everything we have in the EFI side.
inline void ExitBootServices(UInt64 MapKey, EfiHandlePtr ImageHandle) noexcept {
if (!ST) return;
+ ST->ConOut->OutputString(ST->ConOut, L"EFI: Exit Boot services...\r\n");
ST->BootServices->ExitBootServices(ImageHandle, MapKey);
}
-} // namespace EFI
-inline void InitEFI(EfiSystemTable *SystemTable) noexcept {
- if (!SystemTable) return;
-
- ST = SystemTable;
- BS = ST->BootServices;
-
- ST->ConOut->ClearScreen(SystemTable->ConOut);
- ST->ConOut->SetAttribute(SystemTable->ConOut, kEFIYellow);
-}
+enum {
+ kPartEPM,
+ kPartGPT,
+ kPartMBR,
+ kPartCnt,
+};
-inline void KeRuntimeStop(const EfiCharType *ErrorCode,
- const EfiCharType *Reason) noexcept {
+/***
+ * @brief Raise Hard kernel error.
+ */
+inline void RaiseHardError(const EfiCharType *ErrorCode,
+ const EfiCharType *Reason) noexcept {
ST->ConOut->OutputString(ST->ConOut, L"*** STOP ***\r\n");
ST->ConOut->OutputString(ST->ConOut, L"*** Error: ");
@@ -59,13 +59,17 @@ inline void KeRuntimeStop(const EfiCharType *ErrorCode,
EFI::Stop();
}
+} // namespace EFI
-enum {
- kPartEPM,
- kPartGPT,
- kPartMBR,
- kPartCnt,
-};
+inline void InitEFI(EfiSystemTable *SystemTable) noexcept {
+ if (!SystemTable) return;
+
+ ST = SystemTable;
+ BS = ST->BootServices;
+
+ ST->ConOut->ClearScreen(SystemTable->ConOut);
+ ST->ConOut->SetAttribute(SystemTable->ConOut, kEFIYellow);
+}
#ifdef __BOOTLOADER__
diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx
index bfb6f7c5..28187b09 100644
--- a/Private/FSKit/NewFS.hxx
+++ b/Private/FSKit/NewFS.hxx
@@ -17,8 +17,8 @@
#define kInvalidCatalog -1
#define kNameLen 256
-#define kIdentLen 6
-#define kIdent "NewFS"
+#define kNewFSIdentLen 6
+#define kNewFSIdent "NewFS"
#define kPadLen 16
#define kNewFSVersion 1
@@ -32,7 +32,7 @@ enum {
};
struct PACKED NewBootBlock final {
- HCore::WideChar Ident[kIdentLen];
+ HCore::WideChar Ident[kNewFSIdentLen];
HCore::WideChar Shell[kNameLen];
HCore::Int64 NumParts;
@@ -93,7 +93,7 @@ struct PACKED NewFork final {
#define kPartLen 32
struct PACKED NewPartitionBlock final {
- HCore::WideChar Ident[kIdentLen];
+ HCore::WideChar Ident[kNewFSIdentLen];
HCore::WideChar PartitionName[kPartLen];
HCore::Int32 Flags;
diff --git a/Private/NetworkKit/IP.hpp b/Private/NetworkKit/IP.hpp
index de9d6e74..8761b65d 100644
--- a/Private/NetworkKit/IP.hpp
+++ b/Private/NetworkKit/IP.hpp
@@ -9,79 +9,71 @@
#pragma once
-#include <NewKit/Defines.hpp>
#include <KernelKit/DebugOutput.hpp>
-#include <NewKit/String.hpp>
+#include <NewKit/Defines.hpp>
#include <NewKit/Ref.hpp>
+#include <NewKit/String.hpp>
-namespace HCore
-{
+namespace HCore {
class RawIPAddress6;
class RawIPAddress;
class IPFactory;
-class RawIPAddress final
-{
- private:
- explicit RawIPAddress(char bytes[4]);
- ~RawIPAddress() = default;
+class RawIPAddress final {
+ private:
+ explicit RawIPAddress(char bytes[4]);
+ ~RawIPAddress() = default;
- RawIPAddress &operator=(const RawIPAddress &) = delete;
- RawIPAddress(const RawIPAddress &) = default;
+ RawIPAddress &operator=(const RawIPAddress &) = delete;
+ RawIPAddress(const RawIPAddress &) = default;
- public:
- char *Address();
+ public:
+ char *Address();
- char &operator[](const Size &index);
+ char &operator[](const Size &index);
- bool operator==(const RawIPAddress &ipv6);
- bool operator!=(const RawIPAddress &ipv6);
+ bool operator==(const RawIPAddress &ipv6);
+ bool operator!=(const RawIPAddress &ipv6);
- private:
- char m_Addr[4];
+ private:
+ char m_Addr[4];
- friend IPFactory; // it is the one creating these addresses, thus this
- // is why the constructors are private.
+ friend IPFactory; // it is the one creating these addresses, thus this
+ // is why the constructors are private.
};
/**
* @brief IPv6 address.
*/
-class RawIPAddress6 final
-{
- private:
- explicit RawIPAddress6(char Bytes[8]);
- ~RawIPAddress6() = default;
+class RawIPAddress6 final {
+ private:
+ explicit RawIPAddress6(char Bytes[8]);
+ ~RawIPAddress6() = default;
- RawIPAddress6 &operator=(const RawIPAddress6 &) = delete;
- RawIPAddress6(const RawIPAddress6 &) = default;
+ RawIPAddress6 &operator=(const RawIPAddress6 &) = delete;
+ RawIPAddress6(const RawIPAddress6 &) = default;
- public:
- char *Address()
- {
- return m_Addr;
- }
+ public:
+ char *Address() { return m_Addr; }
- char &operator[](const Size &index);
+ char &operator[](const Size &index);
- bool operator==(const RawIPAddress6 &ipv6);
- bool operator!=(const RawIPAddress6 &ipv6);
+ bool operator==(const RawIPAddress6 &ipv6);
+ bool operator!=(const RawIPAddress6 &ipv6);
- private:
- char m_Addr[8];
+ private:
+ char m_Addr[8];
- friend IPFactory;
+ friend IPFactory;
};
/**
* @brief IP Creation helpers
*/
-class IPFactory final
-{
- public:
- static ErrorOr<StringView> ToStringView(Ref<RawIPAddress6> ipv6);
- static ErrorOr<StringView> ToStringView(Ref<RawIPAddress> ipv4);
- static bool IpCheckVersion4(const char *ip);
-
+class IPFactory final {
+ public:
+ static ErrorOr<StringView> ToStringView(Ref<RawIPAddress6> ipv6);
+ static ErrorOr<StringView> ToStringView(Ref<RawIPAddress> ipv4);
+ static bool IpCheckVersion4(const char *ip);
};
-} // namespace HCore
+} // namespace HCore
diff --git a/Private/NetworkKit/NetworkDevice.hpp b/Private/NetworkKit/NetworkDevice.hpp
index 31a304cf..a9edb09c 100644
--- a/Private/NetworkKit/NetworkDevice.hpp
+++ b/Private/NetworkKit/NetworkDevice.hpp
@@ -13,41 +13,38 @@
#include <KernelKit/Device.hpp>
#include <NetworkKit/IP.hpp>
-namespace HCore
-{
- struct NetworkDeviceCommand;
+namespace HCore {
+struct NetworkDeviceCommand;
- class NetworkDevice final : public DeviceInterface<NetworkDeviceCommand>
- {
- public:
- NetworkDevice(void(*out)(NetworkDeviceCommand), void(*in)(NetworkDeviceCommand),
- void(*on_cleanup)(void) = nullptr);
+class NetworkDevice final : public DeviceInterface<NetworkDeviceCommand> {
+ public:
+ NetworkDevice(void (*out)(NetworkDeviceCommand),
+ void (*in)(NetworkDeviceCommand),
+ void (*on_cleanup)(void) = nullptr);
- ~NetworkDevice() override;
+ ~NetworkDevice() override;
- public:
- NetworkDevice &operator=(const NetworkDevice &) = default;
- NetworkDevice(const NetworkDevice &) = default;
+ public:
+ NetworkDevice &operator=(const NetworkDevice &) = default;
+ NetworkDevice(const NetworkDevice &) = default;
- public:
- const char* Name() const override { return ("NetworkDevice"); }
+ public:
+ const char *Name() const override { return ("NetworkDevice"); }
- private:
- void(*fCleanup)(void);
+ private:
+ void (*fCleanup)(void);
+};
- };
+struct NetworkDeviceCommand {
+ UInt32 Command;
+ UInt32 VLan;
+ UInt32 DmaLow;
+ UInt32 DmaHigh;
+};
- struct NetworkDeviceCommand
- {
- UInt32 Command;
- UInt32 VLan;
- UInt32 DmaLow;
- UInt32 DmaHigh;
- };
+using TCPNetworkDevice = NetworkDevice;
+using UDPNetworkDevice = NetworkDevice;
+using PPPNetworkDevice = NetworkDevice;
+} // namespace HCore
- using TCPNetworkDevice = NetworkDevice;
- using UDPNetworkDevice = NetworkDevice;
- using PPPNetworkDevice = NetworkDevice;
-} // namespace HCore
-
-#endif // !_INC_NETWORKDEVICE_HPP__
+#endif // !_INC_NETWORKDEVICE_HPP__
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index 0cbddfab..766749bd 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -84,7 +84,8 @@ class BImageReader final {
private:
Int32 mErrorCode{kOperationOkay};
CharacterType mPath[kPathLen];
- VoidPtr mHandle{nullptr};
+ BTextWriter mWriter;
+ BATADevice mDevice;
};
/***********************************************************************************/
@@ -121,7 +122,7 @@ inline UInt8 In8(UInt16 port) {
inline UInt16 In16(UInt16 port) {
UInt16 value = 0UL;
- asm volatile("inw %1, %%ax" : "=a"(value) : "Nd"(port) : "memory");
+ asm volatile("in %%dx, %%ax" : "=a"(value) : "d"(port));
return value;
}
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-Main.cxx b/Private/NewBoot/Source/Entrypoint.cxx
index c2631a6f..6a778143 100644
--- a/Private/NewBoot/Source/HEL/AMD64/AMD64-Main.cxx
+++ b/Private/NewBoot/Source/Entrypoint.cxx
@@ -12,6 +12,7 @@
#include <BootKit/BootKit.hxx>
#include <EFIKit/Api.hxx>
#include <KernelKit/PE.hpp>
+#include <NewKit/Ref.hpp>
// don't remove EfiGUID, it will call initializer_list!
@@ -33,7 +34,8 @@ EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle,
PEImagePtr blob = (PEImagePtr)img.Fetch(sz);
if (!blob || sz < 1)
- KeRuntimeStop(L"HCoreLdr_NoSuchKernel", L"Couldn't find HCoreKrnl.exe!");
+ EFI::RaiseHardError(L"HCoreLdr_NoSuchKernel",
+ L"Couldn't find HCoreKrnl.exe!");
ExecHeaderPtr headerPtr = (ExecHeaderPtr)blob;
@@ -41,10 +43,11 @@ EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle,
writer.WriteString(L"HCoreLdr: Running HCoreKrnl.exe...\r\n");
/// Load Image here
} else {
- KeRuntimeStop(L"HCoreLdr_NotPE", L"Not a PE file! Aborting...");
+ EFI::RaiseHardError(L"HCoreLdr_NotPE", L"Not a PE file! Aborting...");
}
EFI::Stop();
+ EFI::ExitBootServices(mapKey, ImageHandle);
return kEfiOk;
}
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx
index c289bcf5..d6b6e0a9 100644
--- a/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-ATA.cxx
@@ -23,6 +23,8 @@
/// bugs: 0
+extern "C" Void ATAWaitForIO(Void);
+
static Boolean kATADetected = false;
static Int32 kATADeviceType = kATADeviceCount;
@@ -67,19 +69,19 @@ Boolean ATAInitDriver(UInt8 Bus, UInt8 Drive, UInt16& OutBus,
/* differentiate ATA, ATAPI, SATA and SATAPI */
if (cl == 0x14 && ch == 0xEB) {
- writer.WriteString(L"HCoreLdr: PATAPI drive detected.\r\n");
+ writer.WriteString(L"HCoreLdr: PATAPI: drive detected.\r\n");
kATADeviceType = kATADevicePATA_PI;
}
if (cl == 0x69 && ch == 0x96) {
- writer.WriteString(L"HCoreLdr: SATAPI drive detected.\r\n");
+ writer.WriteString(L"HCoreLdr: SATAPI: drive detected.\r\n");
kATADeviceType = kATADeviceSATA_PI;
}
if (cl == 0 && ch == 0) {
- writer.WriteString(L"HCoreLdr: PATA drive detected.\r\n");
+ writer.WriteString(L"HCoreLdr: PATA: drive detected.\r\n");
kATADeviceType = kATADevicePATA;
}
if (cl == 0x3c && ch == 0xc3) {
- writer.WriteString(L"HCoreLdr: SATA drive detected.\r\n");
+ writer.WriteString(L"HCoreLdr: SATA: drive detected.\r\n");
kATADeviceType = kATADeviceSATA;
}
@@ -95,52 +97,50 @@ void ATAWait(UInt16 IO) {
void ATAPoll(UInt16 IO) { ATAWait(IO); }
-Void ATAReadLba(UInt32 Lba, UInt8 Bus, Boolean Master, CharacterType* Buf,
+Void ATAReadLba(UInt32 Lba, UInt8 IO, Boolean Master, CharacterType* Buf,
SizeT Offset) {
- UInt16 IO = Bus;
+ rt_cli();
+ ATAWaitForIO();
- ATASelect(IO + ATA_REG_HDDEVSEL,
- (Master ? ATA_MASTER : ATA_SLAVE) | Lba >> 24 & 0xF);
+ Lba &= 0x00FFFFFF;
- ATASelect(IO + 1, 0);
+ UInt8 Command = (Master ? 0xE0 : 0xF0);
- Out8(IO + ATA_REG_SEC_COUNT0, 1);
+ Out8(IO + ATA_REG_HDDEVSEL, Command | ((Lba >> 24)));
+ Out8(IO + ATA_REG_SEC_COUNT0, 0x1);
Out8(IO + ATA_REG_LBA0, (UInt8)Lba);
- Out8(IO + ATA_REG_LBA1, (UInt8)(Lba >> 8));
- Out8(IO + ATA_REG_LBA2, (UInt8)(Lba >> 16));
+ Out8(IO + ATA_REG_LBA1, (UInt8)Lba >> 8);
+ Out8(IO + ATA_REG_LBA2, (UInt8)Lba >> 16);
Out8(IO + ATA_REG_COMMAND, ATA_CMD_READ_PIO);
- ATAPoll(IO);
-
- Buf[Offset] = In16(IO + ATA_REG_DATA);
+ Buf[Offset] = In16(IO);
- ATAWait(IO);
+ ATAWaitForIO();
+ rt_sti();
}
-Void ATAWriteLba(UInt32 Lba, UInt8 Bus, Boolean Master, wchar_t* Buf,
+Void ATAWriteLba(UInt32 Lba, UInt8 IO, Boolean Master, wchar_t* Buf,
SizeT Offset) {
- UInt16 IO = Bus;
-
- ATASelect(IO + ATA_REG_HDDEVSEL,
- (Master ? ATA_MASTER : ATA_SLAVE) | Lba >> 24 & 0xF);
+ rt_cli();
+ ATAWaitForIO();
+ Lba &= 0x00FFFFFF;
- ATASelect(IO + 1, 0);
+ UInt8 Command = (Master ? 0xE0 : 0xF0);
- Out8(IO + ATA_REG_SEC_COUNT0, 1);
+ Out8(IO + ATA_REG_HDDEVSEL, Command | ((Lba >> 24)));
+ Out8(IO + ATA_REG_SEC_COUNT0, 0x1);
Out8(IO + ATA_REG_LBA0, (UInt8)Lba);
- Out8(IO + ATA_REG_LBA1, (UInt8)(Lba >> 8));
- Out8(IO + ATA_REG_LBA2, (UInt8)(Lba >> 16));
+ Out8(IO + ATA_REG_LBA1, (UInt8)Lba >> 8);
+ Out8(IO + ATA_REG_LBA2, (UInt8)Lba >> 16);
Out8(IO + ATA_REG_COMMAND, ATA_CMD_WRITE_PIO);
- ATAPoll(IO);
-
- Out16(IO + ATA_REG_DATA, Buf[Offset]);
-
- ATAWait(IO);
+ Out16(IO, Buf[Offset]);
+ ATAWaitForIO();
+ rt_sti();
}
Boolean ATAIsDetected(Void) { return kATADetected; }
@@ -171,7 +171,7 @@ BATADevice::BATADevice() noexcept {
kATADetected = true;
BTextWriter writer;
- writer.WriteString(L"BATADevice::BATADevice: OnLine\r\n");
+ writer.WriteString(L"HCoreLdr: Driver: OnLine.\r\n");
}
}
@@ -180,12 +180,12 @@ BATADevice::BATADevice() noexcept {
@param Sz Sector size
@param Buf buffer
*/
-BATADevice& BATADevice::Read(CharacterType* Buf, const SizeT& Sz) {
+BATADevice& BATADevice::Read(CharacterType* Buf, const SizeT& SectorSz) {
if (!ATAIsDetected()) return *this;
- if (!Buf || Sz < 1) return *this;
+ if (!Buf || SectorSz > kATASectorSz || SectorSz < 1) return *this;
- for (SizeT i = 0UL; i < Sz; ++i) {
+ for (SizeT i = 0UL; i < SectorSz; ++i) {
ATAReadLba(this->Leak().mBase + i, this->Leak().mBus, this->Leak().mMaster,
Buf, i);
}
@@ -198,14 +198,14 @@ BATADevice& BATADevice::Read(CharacterType* Buf, const SizeT& Sz) {
@param Sz Sector size
@param Buf buffer
*/
-BATADevice& BATADevice::Write(CharacterType* Buf, const SizeT& Sz) {
+BATADevice& BATADevice::Write(CharacterType* Buf, const SizeT& SectorSz) {
if (!ATAIsDetected()) return *this;
- if (!Buf || Sz < 1) return *this;
+ if (!Buf || SectorSz > kATASectorSz || SectorSz < 1) return *this;
SizeT Off = 0UL;
- for (SizeT i = 0UL; i < Sz; ++i) {
+ for (SizeT i = 0UL; i < SectorSz; ++i) {
ATAWriteLba(this->Leak().mBase + i, this->Leak().mBus, this->Leak().mMaster,
Buf, Off);
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-CoreSync-ATA.asm b/Private/NewBoot/Source/HEL/AMD64/AMD64-CoreSync-ATA.asm
new file mode 100644
index 00000000..6ad07a59
--- /dev/null
+++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-CoreSync-ATA.asm
@@ -0,0 +1,24 @@
+[bits 64]
+
+
+section .text
+global ATAWaitForIO
+
+ATAWaitForIO:
+ push ax
+ push dx
+
+ xor ax, ax
+ mov dx, 01F7h
+
+ATAWaitForIO_Loop:
+ in al, dx
+ and al, 0C0h
+ cmp al, 040h
+ jne ATAWaitForIO_Loop
+
+ATAWaitForIO_End:
+ pop dx
+ pop ax
+
+ ret
diff --git a/Private/NewBoot/Source/ImageReader.cxx b/Private/NewBoot/Source/ImageReader.cxx
new file mode 100644
index 00000000..b714c21f
--- /dev/null
+++ b/Private/NewBoot/Source/ImageReader.cxx
@@ -0,0 +1,70 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+ File: String.cxx
+ Purpose: NewBoot string library
+
+ Revision History:
+
+
+
+------------------------------------------- */
+
+#include <BootKit/BootKit.hxx>
+#include <EFIKit/Api.hxx>
+#include <FSKit/NewFS.hxx>
+
+#include "NewKit/Defines.hpp"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+//
+// @brief BImageReader class
+//
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/***
+ @brief File Reader constructor.
+*/
+BImageReader::BImageReader(const CharacterType *path) {
+ if (path != nullptr) {
+ SizeT index = 0UL;
+ for (; path[index] != L'\0'; ++index) {
+ mPath[index] = path[index];
+ }
+
+ mPath[index] = 0;
+ }
+}
+
+/**
+ @brief this reads all of the buffer.
+ @param size, new buffer size.
+*/
+HCore::VoidPtr BImageReader::Fetch(SizeT &size) {
+ mWriter.WriteString(L"HCoreLdr: Fetch-Image: ")
+ .WriteString(mPath)
+ .WriteString(L"\r\n");
+
+ CharacterType bootBlockBytes[kATASectorSz] = {0};
+
+ mDevice.Leak().mBase = kNewFSAddressAsLba;
+ mDevice.Leak().mMaster = true;
+
+ mDevice.Read(bootBlockBytes, kATASectorSz);
+
+ NewBootBlock *bootBlock = (NewBootBlock *)bootBlockBytes;
+
+ for (SizeT index = 0UL; index < kNewFSIdentLen; ++index) {
+ if (bootBlock->Ident[index] != kNewFSIdent[index]) {
+ mWriter.WriteString(L"HCoreLdr: NewFS: Not found.\r\n");
+ return nullptr;
+ }
+ }
+
+ /// get file catalog with mPath inside it.
+
+ return nullptr;
+}
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx b/Private/NewBoot/Source/String.cxx
index 8db6ae16..a2d19f1f 100644
--- a/Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx
+++ b/Private/NewBoot/Source/String.cxx
@@ -1,11 +1,15 @@
-/*
- * ========================================================
- *
- * NewBoot
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+ File: String.cxx
+ Purpose: NewBoot string library
+
+ Revision History:
+
+
+
+------------------------------------------- */
#include <BootKit/BootKit.hxx>
#include <EFIKit/Api.hxx>
@@ -82,39 +86,3 @@ BTextWriter &BTextWriter::WriteCharacter(CharacterType c) {
return *this;
}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-/***
- @brief File Reader constructor.
-*/
-BImageReader::BImageReader(const CharacterType *path) {
- if (path != nullptr) {
- SizeT index = 0UL;
- for (; path[index] != L'\0'; ++index) {
- mPath[index] = path[index];
- }
-
- mPath[index] = 0;
- }
-}
-
-/**
-@brief this reads all of the buffer.
-@param size, new buffer size.
-*/
-HCore::VoidPtr BImageReader::Fetch(SizeT &size) {
- BTextWriter writer;
- writer.WriteString(L"*** BImageReader::Fetch: Fetching... ")
- .WriteString(mPath)
- .WriteString(L" *** \r\n");
-
- EfiLoadImageProtocol *proto = nullptr;
- EfiGUID guidImg = EfiGUID(EFI_LOADED_IMAGE_PROTOCOL_GUID);
-
- if (BS->LocateProtocol(&guidImg, nullptr, (VoidPtr *)&proto) == kEfiOk) {
- }
-
- return nullptr;
-}
diff --git a/Private/NewBoot/Source/Utils.cxx b/Private/NewBoot/Source/Utils.cxx
index c51a87d6..8d2242cd 100644
--- a/Private/NewBoot/Source/Utils.cxx
+++ b/Private/NewBoot/Source/Utils.cxx
@@ -11,164 +11,4 @@
#include <EFIKit/Api.hxx>
#include <EFIKit/EFI.hxx>
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// @brief External EFI code for completeness.
-//
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-namespace Detail {
-const EfiDevicePathProtocol mUefiDevicePathLibEndDevicePath = {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {sizeof(EfiDevicePathProtocol), 0}};
-
-EfiDevicePathProtocol *UefiDevicePathLibAppendDevicePath(
- const EfiDevicePathProtocol *FirstDevicePath,
- const EfiDevicePathProtocol *SecondDevicePath) {
- SizeT Size;
- SizeT Size1;
- SizeT Size2;
- EfiDevicePathProtocol *NewDevicePath;
- EfiDevicePathProtocol *DevicePath2;
-
- //
- // If there's only 1 path, just duplicate it.
- //
- if (FirstDevicePath == nullptr) {
- return DuplicateDevicePath((SecondDevicePath != nullptr)
- ? SecondDevicePath
- : &mUefiDevicePathLibEndDevicePath);
- }
-
- if (SecondDevicePath == nullptr) {
- return DuplicateDevicePath(FirstDevicePath);
- }
-
- if (!IsDevicePathValid(FirstDevicePath, 0) ||
- !IsDevicePathValid(SecondDevicePath, 0)) {
- return nullptr;
- }
-
- //
- // Allocate space for the combined device path. It only has one end node of
- // length EFI_DEVICE_PATH_PROTOCOL.
- //
- Size1 = GetDevicePathSize(FirstDevicePath);
- Size2 = GetDevicePathSize(SecondDevicePath);
- Size = Size1 + Size2 - sizeof(EfiDevicePathProtocol);
-
- BS->AllocatePool(EfiLoaderData, Size, (VoidPtr *)&NewDevicePath);
-
- if (NewDevicePath != NULL) {
- BCopyMem((CharacterType *)NewDevicePath, (CharacterType *)FirstDevicePath,
- Size1);
- //
- // Over write FirstDevicePath EndNode and do the copy
- //
- DevicePath2 =
- (EfiDevicePathProtocol *)((Char *)NewDevicePath +
- (Size1 - sizeof(EfiDevicePathProtocol)));
- BCopyMem((CharacterType *)DevicePath2, (CharacterType *)SecondDevicePath,
- Size2);
- }
-
- return NewDevicePath;
-}
-
-EfiDevicePathProtocol *AppendDevicePath(
- EfiDevicePathProtocol *FirstDevicePath,
- EfiDevicePathProtocol *SecondDevicePath) {
- return UefiDevicePathLibAppendDevicePath(FirstDevicePath, SecondDevicePath);
-}
-
-EfiDevicePathProtocol *EFI_API DevicePathFromHandle(EfiHandlePtr Handle) {
- EfiDevicePathProtocol *DevicePath;
- UInt64 Status;
-
- EfiGUID guid = EfiGUID(EFI_DEVICE_PATH_PROTOCOL_GUID);
-
- Status = BS->HandleProtocol(Handle, &guid, (VoidPtr *)&DevicePath);
- if (Status != kEfiOk) {
- DevicePath = nullptr;
- }
-
- return DevicePath;
-}
-
-UInt16 ReadUnaligned16(UInt16 *Buffer) {
- // ASSERT (Buffer != NULL);
- return *Buffer;
-}
-
-UInt16 WriteUnaligned16(UInt16 *Buffer, UInt16 Value) {
- // ASSERT (Buffer != NULL);
-
- return *Buffer = Value;
-}
-
-UInt16 EFI_API SetDevicePathNodeLength(Void *Node, UInt32 Length) {
- // ASSERT(Node != nullptr);
- // ASSERT((Length >= sizeof(EfiDevicePathProtocol)) && (Length < KIB(64)));
- return WriteUnaligned16(
- (UInt16 *)&((EfiDevicePathProtocol *)(Node))->Length[0],
- (UInt16)(Length));
-}
-
-Void EFI_API SetDevicePathEndNode(Void *Node) {
- // ASSERT(Node != NULL);
- BCopyMem((CharacterType *)Node,
- (CharacterType *)&mUefiDevicePathLibEndDevicePath,
- sizeof(mUefiDevicePathLibEndDevicePath));
-}
-
-UInt32 EFI_API DevicePathNodeLength(const Void *Node) {
- // ASSERT(Node != NULL);
- return ReadUnaligned16(
- (UInt16 *)&((EfiDevicePathProtocol *)(Node))->Length[0]);
-}
-
-EfiDevicePathProtocol *EFI_API NextDevicePathNode(Void *Node) {
- // ASSERT (Node != NULL);
- return (EfiDevicePathProtocol *)((UInt8 *)(Node) +
- DevicePathNodeLength(Node));
-}
-
-EfiDevicePathProtocol *EFI_API FileDevicePath(EfiHandlePtr Device,
- CharacterType *FileName) {
- SizeT Size;
- EfiFileDevicePathProtocol *FilePath;
- EfiDevicePathProtocol *DevicePath;
- EfiDevicePathProtocol *FileDevicePath;
-
- DevicePath = nullptr;
-
- Size = BStrLen(FileName);
- BS->AllocatePool(
- EfiLoaderData,
- Size + sizeof(EfiFileDevicePathProtocol) + sizeof(EfiDevicePathProtocol),
- (VoidPtr *)&FileDevicePath);
-
- if (FileDevicePath != nullptr) {
- FilePath = (EfiFileDevicePathProtocol *)FileDevicePath;
- FilePath->Proto.Type = kEFIMediaDevicePath;
- FilePath->Proto.SubType = kEFIMediaDevicePath;
-
- BCopyMem(FilePath->Path, FileName, Size);
-
- SetDevicePathNodeLength(&FilePath->Proto,
- Size + sizeof(EfiFileDevicePathProtocol));
-
- SetDevicePathEndNode(NextDevicePathNode(&FilePath->Proto));
-
- if (Device != nullptr) {
- DevicePath = DevicePathFromHandle(Device);
- }
-
- DevicePath = AppendDevicePath(DevicePath, FileDevicePath);
- BS->FreePool(FileDevicePath);
- }
-
- return DevicePath;
-}
-} // namespace Detail
+/// @brief EFI API
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 04b39516..eb836632 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -5,7 +5,9 @@
CC_GNU=x86_64-w64-mingw32-g++
LD_GNU=x86_64-w64-mingw32-ld
+ASM=nasm
+FLAG_ASM=-f win64
FLAG_GNU=-fshort-wchar -fPIC -D__DEBUG__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I../../efiSDK/inc -I./ -c -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -D__HAVE_HCORE_APIS__ -D__HCORE__ -I./ -I$(HOME)/
.PHONY: invalid-recipe
@@ -14,8 +16,9 @@ invalid-recipe:
.PHONY: bootloader-amd64
bootloader-amd64:
+ $(ASM) $(FLAG_ASM) HEL/AMD64/AMD64-CoreSync-ATA.asm
$(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx *.cxx
- $(LD_GNU) *.o -e efi_main -filealign:16 -shared --subsystem=10 -ffreestanding -o HCoreLdr.exe
+ $(LD_GNU) *.o HEL/AMD64/*.obj -e efi_main -filealign:16 -shared --subsystem=10 -ffreestanding -o HCoreLdr.exe
cp HCoreLdr.exe CDROM/EFI/BOOT/BOOTX64.EFI
cp ../../HCoreKrnl.exe CDROM/EFI/BOOT/HCoreKrnl.exe
diff --git a/Private/NewKit/RuntimeCheck.hpp b/Private/NewKit/RuntimeCheck.hpp
index c5978aad..4a10d31c 100644
--- a/Private/NewKit/RuntimeCheck.hpp
+++ b/Private/NewKit/RuntimeCheck.hpp
@@ -12,46 +12,41 @@
#include <NewKit/Defines.hpp>
-namespace HCore
-{
-void runtime_check(bool bExpression, const char *file, const char *line);
+namespace HCore {
+void ke_runtime_check(bool bExpression, const char *file, const char *line);
}
#define MUST_PASS_COMPILER(EXPR, MSG) static_assert(EXPR, MSG)
-#define MUST_PASS(EXPR) HCore::runtime_check(EXPR, __FILE__, " %d -> ")
+#define MUST_PASS(EXPR) HCore::ke_runtime_check(EXPR, __FILE__, " %d -> ")
#define assert(EXPR) MUST_PASS(EXPR, RUNTIME_CHECK_EXPRESSION)
-enum RUNTIME_CHECK
-{
- RUNTIME_CHECK_FAILED = -1,
- RUNTIME_CHECK_POINTER = 0,
- RUNTIME_CHECK_EXPRESSION,
- RUNTIME_CHECK_FILE,
- RUNTIME_CHECK_IPC,
- RUNTIME_CHECK_TLS,
- RUNTIME_CHECK_LD,
- RUNTIME_CHECK_HANDSHAKE,
- RUNTIME_CHECK_ACPI,
- RUNTIME_CHECK_INVALID_PRIVILEGE,
- RUNTIME_CHECK_PROCESS,
- RUNTIME_CHECK_BAD_BEHAVIOR,
- RUNTIME_CHECK_COUNT,
- RUNTIME_CHECK_BOOTSTRAP,
+enum RUNTIME_CHECK {
+ RUNTIME_CHECK_FAILED = -1,
+ RUNTIME_CHECK_POINTER = 0,
+ RUNTIME_CHECK_EXPRESSION,
+ RUNTIME_CHECK_FILE,
+ RUNTIME_CHECK_IPC,
+ RUNTIME_CHECK_TLS,
+ RUNTIME_CHECK_LD,
+ RUNTIME_CHECK_HANDSHAKE,
+ RUNTIME_CHECK_ACPI,
+ RUNTIME_CHECK_INVALID_PRIVILEGE,
+ RUNTIME_CHECK_PROCESS,
+ RUNTIME_CHECK_BAD_BEHAVIOR,
+ RUNTIME_CHECK_COUNT,
+ RUNTIME_CHECK_BOOTSTRAP,
};
-namespace HCore
-{
-class DumpManager final
-{
- public:
- static void Dump(void)
- {
- // TODO:
- }
+namespace HCore {
+class DumpManager final {
+ public:
+ static void Dump(void) {
+ // TODO:
+ }
};
void ke_stop(const Int &id);
-} // namespace HCore
+} // namespace HCore
#ifdef TRY
#undef TRY
@@ -59,8 +54,7 @@ void ke_stop(const Int &id);
#define INIT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__)
-#define TRY(FN) \
- if (!FN()) \
- { \
- MUST_PASS(false); \
- }
+#define TRY(FN) \
+ if (!FN()) { \
+ MUST_PASS(false); \
+ }
diff --git a/Private/Servers/.gitkeep b/Private/Servers/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/Servers/.gitkeep
diff --git a/Private/Source/ProcessManager.cxx b/Private/Source/ProcessManager.cxx
index 1bba7f7e..0c552b7f 100644
--- a/Private/Source/ProcessManager.cxx
+++ b/Private/Source/ProcessManager.cxx
@@ -202,7 +202,7 @@ SizeT ProcessManager::Run() noexcept {
ProcessHelper::Switch(m_CurrentProcess.Leak().StackFrame,
m_CurrentProcess.Leak().ProcessId);
} else {
- // otherwise increment the micro-time.
+ // otherwise increment the P-time.
++m_CurrentProcess.Leak().PTime;
}
}
diff --git a/Private/Source/RuntimeCheck.cxx b/Private/Source/RuntimeCheck.cxx
index a84a0b7a..664e3d75 100644
--- a/Private/Source/RuntimeCheck.cxx
+++ b/Private/Source/RuntimeCheck.cxx
@@ -12,7 +12,7 @@
#include <NewKit/RuntimeCheck.hpp>
#include <NewKit/String.hpp>
-extern "C" [[noreturn]] void wait_for_debugger() {
+extern "C" [[noreturn]] void ke_wait_for_debugger() {
while (true) {
HCore::HAL::rt_cli();
HCore::HAL::rt_halt();
@@ -63,10 +63,13 @@ void ke_stop(const HCore::Int &id) {
};
DumpManager::Dump();
- wait_for_debugger();
+
+#ifdef __DEBUG__
+ ke_wait_for_debugger();
+#endif // ifdef __DEBUG__
}
-void runtime_check(bool expr, const char *file, const char *line) {
+void ke_runtime_check(bool expr, const char *file, const char *line) {
if (!expr) {
#ifdef __DEBUG__
kcout << "[KERNEL] Check Failed!\n";
diff --git a/Private/Source/Utils.cxx b/Private/Source/Utils.cxx
index f843abba..6072ccd3 100644
--- a/Private/Source/Utils.cxx
+++ b/Private/Source/Utils.cxx
@@ -21,7 +21,7 @@ Int string_compare(const Char *src, const Char *cmp, Size size) {
}
void rt_zero_memory(voidPtr pointer, Size len) {
- rt_set_memory((voidPtr)pointer, 0, len);
+ rt_set_memory(pointer, 0, len);
}
Size string_length(const Char *str, SizeT _len) {