summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Doxyfile5
-rw-r--r--Private/Docs/SPECIFICATION.md (renamed from Private/Documentation/Spec.md)0
-rw-r--r--Private/Docs/TODO-LIST.md (renamed from Private/Documentation/Todo.md)18
-rw-r--r--Private/Documentation/kernel-design.drawio70
-rw-r--r--Private/FirmwareKit/EFI/API.hxx18
-rw-r--r--Private/NewBoot/BootKit/Vendor/Qr.hxx36
-rw-r--r--Private/NewBoot/BootKit/Vendor/QrVendor/base.h25
-rw-r--r--Private/NewBoot/BootKit/Vendor/QrVendor/bit.h245
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx6
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx10
-rw-r--r--Private/NewLoader/Source/.gitkeep (renamed from Private/Documentation/.gitkeep)0
-rw-r--r--Private/makefile5
12 files changed, 318 insertions, 120 deletions
diff --git a/Doxyfile b/Doxyfile
index a52de5be..7fd58842 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -943,7 +943,8 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
-INPUT = ./Private/ \
+INPUT = ./ \
+ ./Private/ \
./Public/ \
# This tag can be used to specify the character encoding of the source files
@@ -1159,7 +1160,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.
-USE_MDFILE_AS_MAINPAGE =
+USE_MDFILE_AS_MAINPAGE = ./ReadMe.md
# The Fortran standard specifies that for fixed formatted Fortran code all
# characters from position 72 are to be considered as comment. A common
diff --git a/Private/Documentation/Spec.md b/Private/Docs/SPECIFICATION.md
index e218947e..e218947e 100644
--- a/Private/Documentation/Spec.md
+++ b/Private/Docs/SPECIFICATION.md
diff --git a/Private/Documentation/Todo.md b/Private/Docs/TODO-LIST.md
index 2c4af6e5..c997ce10 100644
--- a/Private/Documentation/Todo.md
+++ b/Private/Docs/TODO-LIST.md
@@ -1,14 +1,16 @@
+# TODO list.
+
- We need preemptive multi-threading. [ X ]
- We then need sync primitives. [ X ]
- We also need a system library for the OS. [ X ]
- We need a bootloader for AMD64 [ X ]
- - Implement Boot Services [ X ]
- - Design Handover [ X ]
- - Load kernel into memory [ X ]
- - Fix bug in kernel loader, which causes a 06 #UD. [ X ]
- - Load Kernel [ X ]
- - Add IDT [ X ]
- - AHCI driver [ WiP ]
+ - Implement Boot Services [ X ]
+ - Design Handover [ X ]
+ - Load kernel into memory [ X ]
+ - Fix bug in kernel loader, which causes a 06 #UD. [ X ]
+ - Load Kernel [ X ]
+ - Add IDT [ X ]
+ - AHCI driver [ WiP ]
- Context switch x87/SSE/AVX registers [ X ]
- Framebuffer [ X ]
- AHCI support [ ]
@@ -17,5 +19,5 @@
Status:
NewBoot: Need to boot from EPM partition.
+<br>
NewKernel: New Filesystem in progress.
-
diff --git a/Private/Documentation/kernel-design.drawio b/Private/Documentation/kernel-design.drawio
deleted file mode 100644
index d78ac170..00000000
--- a/Private/Documentation/kernel-design.drawio
+++ /dev/null
@@ -1,70 +0,0 @@
-<mxfile host="app.diagrams.net" modified="2024-03-20T02:51:52.841Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" etag="oPkzCtvrIkHoFdXP1Jzt" version="24.0.7" type="gitlab">
- <diagram name="Page-1" id="mxOE_IV8GVOi3fDmlM2_">
- <mxGraphModel dx="1002" dy="569" 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="dpAw-ApGermXuwIBdtFA-1" value="&lt;h1 style=&quot;margin-top: 0px;&quot;&gt;NewKernel.exe&lt;/h1&gt;&lt;p&gt;The kernel is a C++ app, designed to be scalable, reliable and object oriented.&lt;/p&gt;&lt;p&gt;We&#39;re actually working on the AHCI support for it is scheduled to be done by the end of april.&lt;/p&gt;" style="text;html=1;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
- <mxGeometry x="40" y="40" width="400" height="120" as="geometry" />
- </mxCell>
- <mxCell id="dpAw-ApGermXuwIBdtFA-2" value="MicroKernel" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="286" y="450" width="256" height="60" as="geometry" />
- </mxCell>
- <mxCell id="dpAw-ApGermXuwIBdtFA-3" value="System Call Interface" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="286" y="420" width="256" height="30" as="geometry" />
- </mxCell>
- <mxCell id="dpAw-ApGermXuwIBdtFA-4" value="System Object" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="286" y="330" width="254" height="70" as="geometry" />
- </mxCell>
- <mxCell id="dpAw-ApGermXuwIBdtFA-5" value="User Defined Object #1" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="288" y="280" width="92" height="40" as="geometry" />
- </mxCell>
- <mxCell id="dpAw-ApGermXuwIBdtFA-6" value="User Defined Object #2" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="390" y="280" width="70" height="40" as="geometry" />
- </mxCell>
- <mxCell id="dpAw-ApGermXuwIBdtFA-7" value="User Defined Object #3" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="470" y="280" width="70" height="40" as="geometry" />
- </mxCell>
- <mxCell id="NTNQYUPq4CuizRvDkpOI-1" value="&lt;h1 style=&quot;margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: initial;&quot;&gt;SystemLib.lib&lt;/span&gt;&lt;/h1&gt;&lt;h1 style=&quot;margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: initial; font-size: 12px; font-weight: normal;&quot;&gt;The System API is written in C/C++ and assembly, meant to interface with the SCI, it provides everything you need to make a NewOS application, properties, objects, threading, heap allocation.&lt;/span&gt;&lt;br&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;background-color: initial; font-size: 12px; font-weight: normal;&quot;&gt;You can also register you own user objects.&lt;/span&gt;&lt;/div&gt;" style="text;html=1;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
- <mxGeometry x="40" y="560" width="360" height="190" as="geometry" />
- </mxCell>
- <mxCell id="NTNQYUPq4CuizRvDkpOI-2" value="System Object" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="281" y="820" width="254" height="70" as="geometry" />
- </mxCell>
- <mxCell id="NTNQYUPq4CuizRvDkpOI-3" value="User Defined Object #1" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="286" y="730" width="92" height="40" as="geometry" />
- </mxCell>
- <mxCell id="NTNQYUPq4CuizRvDkpOI-4" value="User Defined Object #2" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="388" y="730" width="70" height="40" as="geometry" />
- </mxCell>
- <mxCell id="NTNQYUPq4CuizRvDkpOI-5" value="User Defined Object #3" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
- <mxGeometry x="468" y="730" width="70" height="40" as="geometry" />
- </mxCell>
- <mxCell id="NTNQYUPq4CuizRvDkpOI-6" value="" style="endArrow=classic;html=1;rounded=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" parent="1" source="NTNQYUPq4CuizRvDkpOI-5" edge="1">
- <mxGeometry width="50" height="50" relative="1" as="geometry">
- <mxPoint x="390" y="770" as="sourcePoint" />
- <mxPoint x="560" y="690" as="targetPoint" />
- </mxGeometry>
- </mxCell>
- <mxCell id="NTNQYUPq4CuizRvDkpOI-7" value="/Manifest.xml&lt;div&gt;/NewOS/&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;&#x9;&lt;/span&gt;- Library.lib/Dll.dll (Subsystem 17)&lt;/div&gt;&lt;div&gt;/Resources/&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
- <mxGeometry x="570" y="650" width="210" height="110" as="geometry" />
- </mxCell>
- <mxCell id="vm68-OaV5PJmx3jSNiIi-1" value="&lt;h1 style=&quot;margin-top: 0px;&quot;&gt;GraphicsLib.lib (merged with SystemLib)&lt;/h1&gt;&lt;p&gt;Handles input, graphics and sound.&lt;/p&gt;&lt;p&gt;Uses the ODF format to display graphics and sound is handled by XIFF.&lt;/p&gt;" style="text;html=1;whiteSpace=wrap;overflow=hidden;rounded=0;" vertex="1" parent="1">
- <mxGeometry x="31" y="980" width="250" height="120" as="geometry" />
- </mxCell>
- <mxCell id="vm68-OaV5PJmx3jSNiIi-3" value="GraphicsLib.lib" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
- <mxGeometry x="286" y="780" width="114" height="30" as="geometry" />
- </mxCell>
- <mxCell id="vm68-OaV5PJmx3jSNiIi-4" value="System Object" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
- <mxGeometry x="298" y="1150" width="254" height="70" as="geometry" />
- </mxCell>
- <mxCell id="vm68-OaV5PJmx3jSNiIi-5" value="GraphicsLib.lib" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
- <mxGeometry x="300" y="1110" width="114" height="30" as="geometry" />
- </mxCell>
- <mxCell id="vm68-OaV5PJmx3jSNiIi-6" value="SystemLib.lib" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
- <mxGeometry x="406" y="780" width="124" height="30" as="geometry" />
- </mxCell>
- </root>
- </mxGraphModel>
- </diagram>
-</mxfile>
diff --git a/Private/FirmwareKit/EFI/API.hxx b/Private/FirmwareKit/EFI/API.hxx
index 212f3686..0e2ef200 100644
--- a/Private/FirmwareKit/EFI/API.hxx
+++ b/Private/FirmwareKit/EFI/API.hxx
@@ -61,9 +61,11 @@ enum {
inline UInt32 Platform() noexcept { return kPEMachineAMD64; }
/***
- * @brief Raise Hard kernel error.
+ * @brief Throw an error, stop execution as well.
+ * @param ErrorCode error code to be print.
+ * @param Reason reason to be print.
*/
-inline void RaiseHardError(const EfiCharType *ErrorCode,
+inline void ThrowError(const EfiCharType *ErrorCode,
const EfiCharType *Reason) noexcept {
#ifdef __DEBUG__
ST->ConOut->OutputString(ST->ConOut, L"\r\n*** STOP ***\r\n");
@@ -88,19 +90,19 @@ inline void RaiseHardError(const EfiCharType *ErrorCode,
/// Show the QR code now.
- constexpr auto ver = 7;
+ constexpr auto ver = 4;
auto ecc = qr::Ecc::H;
- auto str = "https://www.mahrouss-logic.com/help";
- auto len = BStrLen(L"https://www.mahrouss-logic.com/help");
+ auto str = "https://el-mahrouss-logic.com/";
+ auto len = BStrLen(L"https://el-mahrouss-logic.com/");
qr::Qr<ver> encoder;
qr::QrDelegate encoderDelegate;
- encoder.encode(str, len, ecc, -1); // Automatic mask.
+ encoder.encode(str, len, ecc, 0); // Manual mask 0
/// tell delegate to draw encoded QR.
- encoderDelegate.draw<ver>(encoder, (kHandoverHeader->f_GOP.f_Width - encoder.side_size()) / 2,
- (kHandoverHeader->f_GOP.f_Height - encoder.side_size()) - 20);
+ encoderDelegate.draw<ver>(encoder, (kHandoverHeader->f_GOP.f_Width - encoder.side_size()) - 20,
+ (kHandoverHeader->f_GOP.f_Height - encoder.side_size()) / 2);
#endif // ifdef __NEWBOOT__
diff --git a/Private/NewBoot/BootKit/Vendor/Qr.hxx b/Private/NewBoot/BootKit/Vendor/Qr.hxx
index 7fec429e..ca5eb566 100644
--- a/Private/NewBoot/BootKit/Vendor/Qr.hxx
+++ b/Private/NewBoot/BootKit/Vendor/Qr.hxx
@@ -5,6 +5,9 @@
#include <stddef.h>
#include <stdint.h>
+#include <BootKit/Vendor/QrVendor/base.h>
+#include <BootKit/Vendor/QrVendor/bit.h>
+
#include <BootKit/Vendor/QrPrelude.hxx>
#include <BootKit/Vendor/Support.hxx>
#include <Builtins/Toolbox/Toolbox.hxx>
@@ -276,7 +279,7 @@ public:
void apply_mask(int mask, uint8_t *patterns);
private:
- static_assert(V <= 40, "invalid version");
+ static_assert(V >= 1 && V <= 40, "invalid version");
static constexpr int SIDE = 17 + V * 4;
static constexpr int N_BITS = SIDE * SIDE;
static constexpr int N_ALIGN = V == 1 ? 0 : V / 7 + 2;
@@ -286,42 +289,29 @@ public:
static constexpr int N_VER_BITS = V > 6 ? 36 : 0;
static constexpr int N_DAT_BITS =
N_BITS - (192 + N_ALIGN_BITS + N_TIMING_BITS + 31 + N_VER_BITS);
- static constexpr int N_BYTES = N_BITS; // Actual number of bytes_in_bits
+ static constexpr int N_BYTES = utl::bytes_in_bits(N_BITS); // Actual number of bytes_in_bits
// required to store whole Qr code
- static constexpr int N_DAT_BYTES =
- N_DAT_BITS; // Actual number of bytes_in_bits required to store
+ static constexpr int N_DAT_BYTES = utl::bytes_in_bits(N_DAT_BITS); // Actual number of bytes_in_bits required to store
// [data + ecc]
static constexpr int N_DAT_CAPACITY =
N_DAT_BITS >> 3; // Capacity of [data + ecc] without remainder bits
private:
/// @brief internal function to retrieve bit from a bitset.
- uint8_t get_arr_bit(uint8_t *arr, uint64_t bit) const {
- return ((volatile uint8_t *)arr)[bit];
+ uint8_t get_arr_bit(uint8_t *arr, unsigned bit) const {
+ return utl::get_arr_bit(arr, bit);
}
/// @brief internal function to set bit from a bitset.
- bool set_arr_bit(uint8_t *arr, uint64_t bit) {
- if (((volatile uint8_t *)arr)[bit] == 0) {
- ((volatile uint8_t *)arr)[bit] = 1;
-
- return true;
- }
-
- return false;
+ void set_arr_bit(uint8_t *arr, unsigned bit) {
+ utl::set_arr_bit(arr, bit);
}
/// @brief internal function to clear bit from a bitset.
- bool clr_arr_bit(uint8_t *arr, uint64_t bit) {
- if (((volatile uint8_t *)arr)[bit] == 1) {
- ((volatile uint8_t *)arr)[bit] = 0;
-
- return true;
- }
-
- return false;
+ void clr_arr_bit(uint8_t *arr, unsigned bit) {
+ utl::clr_arr_bit(arr, bit);
}
- uint8_t code[N_BITS] = {0};
+ uint8_t code[N_BYTES] = {};
bool status = false;
};
diff --git a/Private/NewBoot/BootKit/Vendor/QrVendor/base.h b/Private/NewBoot/BootKit/Vendor/QrVendor/base.h
new file mode 100644
index 00000000..d8261d1e
--- /dev/null
+++ b/Private/NewBoot/BootKit/Vendor/QrVendor/base.h
@@ -0,0 +1,25 @@
+#ifndef UTL_BASE_H
+#define UTL_BASE_H
+
+#include <cstdint>
+#include <cstddef>
+#include <cassert>
+
+namespace utl {
+
+/**
+ * @brief Helper to get number of elements in array.
+ *
+ * @tparam T Auto-deduced element type
+ * @tparam N Auto-deduced number of elements
+ * @return Array size
+ */
+template<class T, size_t N>
+constexpr size_t countof(T(&)[N])
+{
+ return N;
+}
+
+}
+
+#endif \ No newline at end of file
diff --git a/Private/NewBoot/BootKit/Vendor/QrVendor/bit.h b/Private/NewBoot/BootKit/Vendor/QrVendor/bit.h
new file mode 100644
index 00000000..646151b6
--- /dev/null
+++ b/Private/NewBoot/BootKit/Vendor/QrVendor/bit.h
@@ -0,0 +1,245 @@
+#ifndef UTL_BIT_H
+#define UTL_BIT_H
+
+#include <bit>
+
+namespace utl {
+
+/**
+ * @brief Size of object in terms of bits.
+ *
+ * @tparam T Object type
+ * @return Number of bits
+ */
+template<class T>
+constexpr auto bit_size()
+{
+ return sizeof(T) * 8;
+}
+
+/**
+ * @brief Integer with all bits set to 1.
+ *
+ * @tparam T Integer type
+ * @return All set integer
+ */
+template<class T>
+constexpr T bit_full()
+{
+ return T(-1);
+}
+
+/**
+ * @brief Wrap around mask for power of two number of bits
+ * within given integer type. For example:
+ * [ bit_wrap<uint8_t> = 8 - 1 = 0b111 ]
+ * [ bit_wrap<uint16_t> = 16 - 1 = 0b1111 ]
+ * [ bit_wrap<uint32_t> = 32 - 1 = 0b11111 ]
+ *
+ * @tparam T Integer type
+ * @return Wrap around mask for number of bits
+ */
+template<class T>
+constexpr T bit_wrap()
+{
+ return bit_size<T>() - 1;
+}
+
+/**
+ * @brief Number of bits to fit bit_wrap<T> result, in other words
+ * bit width of (sizeof(T) * 8 - 1). For example:
+ * [ bit_shft<uint8_t> = bit_width(0b111) = 3 ]
+ * [ bit_shft<uint16_t> = bit_width(0b1111) = 4 ]
+ * [ bit_shft<uint32_t> = bit_width(0b11111) = 5 ]
+ *
+ * @tparam T Integer type
+ * @return Number of bits to shift to divide by sizeof(T) * 8
+ */
+template<class T>
+constexpr auto bit_shft()
+{
+ return std::bit_width(bit_wrap<T>());
+}
+
+/**
+ * @brief Round up division by number of bits within given integer type,
+ * which sizeof(T) * 8 is power of two.
+ *
+ * @tparam T Inetegr type
+ * @param x Dividend
+ * @return Quotient
+ */
+template<class T>
+constexpr auto bit_ceil(auto x)
+{
+ return (x + bit_wrap<T>()) >> bit_shft<T>();
+}
+
+/**
+ * @brief Count leading zeros.
+ *
+ * @param x Unsigned integer argument
+ * @return Number of leading zeros
+ */
+constexpr unsigned cntlz(auto x)
+{
+ if constexpr (std::is_same_v<decltype(x), int>)
+ return std::countl_zero(unsigned(x));
+ else
+ return std::countl_zero(x);
+}
+
+/**
+ * @brief Count trailing zeros.
+ *
+ * @param x Unsigned integer argument
+ * @return Number of trailing zeros
+ */
+constexpr unsigned cnttz(auto x)
+{
+ if constexpr (std::is_same_v<decltype(x), int>)
+ return std::countr_zero(unsigned(x));
+ else
+ return std::countr_zero(x);
+}
+
+/**
+ * @brief Get number of words (integers) required to store N bits.
+ *
+ * @tparam T Word integer type
+ * @param n Number of bits to store
+ * @return Number of words
+ */
+template<class T>
+constexpr size_t words_in_bits(size_t n)
+{
+ return (n >> bit_shft<T>()) + !!(n & bit_wrap<T>());
+}
+
+/**
+ * @brief Get number of bytes required to store N bits.
+ *
+ * @param n Number of bits to store
+ * @return Number of bytes
+ */
+constexpr size_t bytes_in_bits(size_t n)
+{
+ return words_in_bits<uint8_t>(n);
+}
+
+/**
+ * @brief Make integer with bit at given position.
+ *
+ * @tparam T Inetegr type
+ * @param n Bit position
+ * @return Integer with set bit
+ */
+template<class T = unsigned>
+constexpr T bit(int n)
+{
+ return T(1) << n;
+}
+
+/**
+ * @brief Get n-th bit of an integer.
+ *
+ * @tparam T Integer type
+ * @param x Integer
+ * @param n Bit position from LSB
+ * @return true if set
+ */
+template<class T>
+constexpr bool get_bit(T x, int n)
+{
+ return (x >> n) & 1;
+}
+
+/**
+ * @brief Set n-th bit of an integer.
+ *
+ * @tparam T Integer type
+ * @param x Integer
+ * @param n Bit position from LSB
+ */
+template<class T>
+constexpr void set_bit(T& x, int n)
+{
+ x |= 1 << n;
+}
+
+/**
+ * @brief Clear n-th bit of an integer.
+ *
+ * @tparam T Integer type
+ * @param x Integer
+ * @param n Bit position from LSB
+ */
+template<class T>
+constexpr void clr_bit(T& x, int n)
+{
+ x &= ~(1 << n);
+}
+
+/**
+ * @brief Get n-th bit in array of words (starting from LSB).
+ *
+ * @tparam T Word type
+ * @param p Array of words
+ * @param n Index of bit to get
+ * @return true if set
+ */
+template<class T>
+constexpr bool get_arr_bit(const T* p, unsigned n)
+{
+ return get_bit(p[n >> bit_shft<T>()], n & bit_wrap<T>());
+}
+
+/**
+ * @brief Set n-th bit in array of words (starting from LSB).
+ *
+ * @tparam T Word type
+ * @param p Array of words
+ * @param n Index of bit to set
+ */
+template<class T>
+constexpr void set_arr_bit(T* p, unsigned n)
+{
+ set_bit(p[n >> bit_shft<T>()], n & bit_wrap<T>());
+}
+
+/**
+ * @brief Clear n-th bit in array of words (starting from LSB).
+ *
+ * @tparam T Word type
+ * @param p Array of words
+ * @param n Index of bit to clear
+ */
+template<class T>
+constexpr void clr_arr_bit(T* p, unsigned n)
+{
+ clr_bit(p[n >> bit_shft<T>()], n & bit_wrap<T>());
+}
+
+/**
+ * @brief Shift bits left in array of integer elements from least significant bit
+ * and considering 0-th byte as the right most.
+ * uint16_t example: 0b10000000'11100001 ==> 0b00000001'11000010.
+ *
+ * @tparam T Integer type
+ * @tparam L Length of array
+ * @param x Array of integers, nullptr not acceptable!
+ * @param len Number of elements
+ */
+template<class T, size_t L>
+constexpr void shift_left(T (&x)[L])
+{
+ for (int i = L - 1; i > 0; --i) {
+ x[i] <<= 1;
+ x[i] |= x[i - 1] >> bit_wrap<T>();
+ }
+ x[0] <<= 1;
+}
+
+}
+
+#endif
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
index aab5db1f..0e126ada 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
@@ -66,7 +66,7 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
if (efp->OpenVolume(efp, &rootFs) != kEfiOk) {
mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Volume").Write(L"\r\n");
- EFI::RaiseHardError(L"NoSuchVolume", L"No Such volume.");
+ EFI::ThrowError(L"NoSuchVolume", L"No Such volume.");
this->mErrorCode = kNotSupported;
return;
}
@@ -78,7 +78,7 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
mWriter.Write(L"New Boot: Fetch-Protocol: No-Such-Path: ")
.Write(mPath)
.Write(L"\r\n");
- EFI::RaiseHardError(L"NoSuchPath", L"No Such file on filesystem.");
+ EFI::ThrowError(L"NoSuchPath", L"No Such file on filesystem.");
this->mErrorCode = kNotSupported;
return;
}
@@ -110,7 +110,7 @@ Void BFileReader::ReadAll(SizeT until, SizeT chunk) {
if (auto err = BS->AllocatePool(EfiLoaderCode, until, (VoidPtr*)&mBlob) !=
kEfiOk) {
mWriter.Write(L"*** EFI-Code: ").Write(err).Write(L" ***\r\n");
- EFI::RaiseHardError(L"NewBoot_PageError", L"Allocation error.");
+ EFI::ThrowError(L"NewBoot_PageError", L"Allocation error.");
}
}
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
index d314c949..7120bcd9 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -67,7 +67,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (BS->AllocatePool(EfiLoaderData, sizeof(UInt32), (VoidPtr*)&SizePtr) !=
kEfiOk) {
- EFI::RaiseHardError(L"Bad-Alloc", L"New Boot ran out of memory!");
+ EFI::ThrowError(L"Bad-Alloc", L"New Boot ran out of memory!");
}
/****
@@ -80,7 +80,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
if (BS->AllocatePool(EfiLoaderData, sizeof(EfiMemoryDescriptor),
(VoidPtr*)&Descriptor) != kEfiOk) {
- EFI::RaiseHardError(L"Bad-Alloc", L"New Boot ran out of memory!");
+ EFI::ThrowError(L"Bad-Alloc", L"New Boot ran out of memory!");
}
HEL::HandoverInformationHeader* handoverHdrPtr = nullptr;
@@ -179,14 +179,14 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
headerKind->Magic[3] == kPefMagic[3] &&
headerKind->Magic[4] == kPefMagic[4]) {
if (headerKind->Abi != kPefAbi || headerKind->Cpu != kPefArchAMD64) {
- EFI::RaiseHardError(L"Bad-Architecture",
+ EFI::ThrowError(L"Bad-Architecture",
L"New Boot can't run this architecture.");
}
NewOS::HEL::BootMainKind main = (NewOS::HEL::BootMainKind) nullptr;
if (!main) {
- EFI::RaiseHardError(L"Bad-Exec",
+ EFI::ThrowError(L"Bad-Exec",
L"New Boot can't recognize this executable.");
}
@@ -200,7 +200,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
}
}
- EFI::RaiseHardError(L"Invalid-PEF-Executable", L"PEF executable expected. Got something else.");
+ EFI::ThrowError(L"Invalid-PEF-Executable", L"PEF executable expected. Got something else.");
return kEfiFail;
}
diff --git a/Private/Documentation/.gitkeep b/Private/NewLoader/Source/.gitkeep
index e69de29b..e69de29b 100644
--- a/Private/Documentation/.gitkeep
+++ b/Private/NewLoader/Source/.gitkeep
diff --git a/Private/makefile b/Private/makefile
index 41f70c81..673a4b56 100644
--- a/Private/makefile
+++ b/Private/makefile
@@ -28,10 +28,12 @@ COPY = cp
# Add assembler, linker, and object files variables.
ASMFLAGS = -f win64
+
+# NewOS subsystem is 17.
LDFLAGS = -e Main --subsystem=17
LDOBJ = Objects/*.obj
-# This file is the kernel, responsible of task management, memory, drivers and more.
+# This file is the kernel, responsible of task management and memory.
KERNEL = NewKernel.exe
# The kernel entrypoint
@@ -39,6 +41,7 @@ SCRIPT = --script=Linker/Platforms/PC.lds
.PHONY: error
error:
+ @echo "=== ERROR ==="
@echo "=> Use a specific target."
MOVEALL=./MoveAll.sh