summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-08 19:50:36 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-08 19:51:18 +0100
commitd0252ab0b32c55b08749e94545e17d389b1081c9 (patch)
tree20af91e0b6ac2d7f4f61c3547d3bf97e49a747c2
parentfe44d10437a3508f62ac21e03cd712aba0c1683b (diff)
HCR-15: See below.
Boot: Fixed dependance on old os.epm file. Kernel: Will get it running this weekend. Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
-rw-r--r--Private/HALKit/64x0/APM/.hgkeep0
-rw-r--r--Private/HALKit/AMD64/HalPageAlloc.hpp37
-rw-r--r--Private/HALKit/ARM64/ACPI/.gitkeep0
-rw-r--r--Private/HALKit/RISCV/APM/.gitkeep0
-rw-r--r--Private/NewBoot/Source/makefile2
-rw-r--r--Private/NewKit/PageAllocator.hpp48
-rw-r--r--Private/Source/NewFS+FileManager.cxx (renamed from Private/Source/NewFS.cxx)0
-rw-r--r--Private/Source/NewFS+IO.cxx6
-rw-r--r--Private/Source/PageManager.cxx13
-rw-r--r--Private/Source/SMPManager.cxx17
-rw-r--r--Public/Kits/GKit/Core.hpp11
-rw-r--r--Public/Kits/GKit/Dim2d.hpp4
-rw-r--r--Public/Kits/GKit/GFrame.hpp2
-rw-r--r--Public/Kits/GKit/Stylesheet.hxx16
-rw-r--r--Public/Kits/SystemKit/SystemKit.hxx6
15 files changed, 99 insertions, 63 deletions
diff --git a/Private/HALKit/64x0/APM/.hgkeep b/Private/HALKit/64x0/APM/.hgkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/HALKit/64x0/APM/.hgkeep
diff --git a/Private/HALKit/AMD64/HalPageAlloc.hpp b/Private/HALKit/AMD64/HalPageAlloc.hpp
index 367cc26e..d6912318 100644
--- a/Private/HALKit/AMD64/HalPageAlloc.hpp
+++ b/Private/HALKit/AMD64/HalPageAlloc.hpp
@@ -9,6 +9,12 @@
#pragma once
+/** ---------------------------------------------------
+
+ * THIS FILE CONTAINS CODE FOR X86_64 PAGING.
+
+------------------------------------------------------- */
+
#include <NewKit/Defines.hpp>
#ifndef PTE_MAX
@@ -23,9 +29,9 @@ extern "C" void flush_tlb(HCore::UIntPtr VirtualAddr);
extern "C" void write_cr3(HCore::UIntPtr pde);
extern "C" void write_cr0(HCore::UIntPtr bit);
-extern "C" HCore::UIntPtr read_cr0();
-extern "C" HCore::UIntPtr read_cr2();
-extern "C" HCore::UIntPtr read_cr3();
+extern "C" HCore::UIntPtr read_cr0(); // @brief CPU control register.
+extern "C" HCore::UIntPtr read_cr2(); // @brief Fault address.
+extern "C" HCore::UIntPtr read_cr3(); // @brief Page table.
namespace HCore::HAL {
struct PageTable64 {
@@ -41,6 +47,26 @@ struct PageTable64 {
bool ExecDisable : 1;
};
+namespace Detail {
+enum class ControlRegisterBits {
+ ProtectedModeEnable = 0,
+ MonitorCoProcessor = 1,
+ Emulation = 2,
+ TaskSwitched = 3,
+ ExtensionType = 4,
+ NumericError = 5,
+ WriteProtect = 16,
+ AlignementMask = 18,
+ NotWriteThrough = 29,
+ CacheDisable = 30,
+ Paging = 31,
+};
+
+inline UInt8 control_register_cast(ControlRegisterBits reg) {
+ return static_cast<UInt8>(reg);
+}
+} // namespace Detail
+
struct PageDirectory64 final {
PageTable64 ALIGN(PTE_ALIGN) Pte[PTE_MAX];
};
@@ -50,3 +76,8 @@ UIntPtr& hal_page_base() noexcept;
void hal_page_base(const UIntPtr& newPagePtr) noexcept;
UIntPtr hal_create_page(Boolean rw, Boolean user);
} // namespace HCore::HAL
+
+namespace HCore {
+typedef HAL::PageTable64 PTE;
+typedef HAL::PageDirectory64 PDE;
+} // namespace HCore
diff --git a/Private/HALKit/ARM64/ACPI/.gitkeep b/Private/HALKit/ARM64/ACPI/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/HALKit/ARM64/ACPI/.gitkeep
diff --git a/Private/HALKit/RISCV/APM/.gitkeep b/Private/HALKit/RISCV/APM/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/HALKit/RISCV/APM/.gitkeep
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 62a48abf..23678e9d 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -27,7 +27,7 @@ bootloader-amd64:
.PHONY: run-efi-amd64
run-efi-amd64:
wget https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd
- qemu-system-x86_64 -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=os.epm,index=0,if=ide,format=qcow2 -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio
+ qemu-system-x86_64 -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio
.PHONY: clean
clean:
diff --git a/Private/NewKit/PageAllocator.hpp b/Private/NewKit/PageAllocator.hpp
index 612ca5c0..9f49a51a 100644
--- a/Private/NewKit/PageAllocator.hpp
+++ b/Private/NewKit/PageAllocator.hpp
@@ -13,52 +13,12 @@
#include <NewKit/Defines.hpp>
#include <NewKit/PageManager.hpp>
-namespace HCore
-{
-namespace Detail
-{
-enum PAGE_BIT
-{
- ProtectedModeEnable = 0,
- MonitorCoProcessor = 1,
- Emulation = 2,
- TaskSwitched = 3,
- ExtensionType = 4,
- NumericError = 5,
- WriteProtect = 16,
- AlignementMask = 18,
- NotWriteThrough = 29,
- CacheDisable = 30,
- Paging = 31,
-};
-} // namespace Detail
-
-class ATTRIBUTE(packed) PTE final
-{
- public:
- Boolean Present : 1;
- Boolean Rw : 1;
- Boolean User : 1;
- Boolean Wt : 1;
- Boolean Cache : 1;
- Boolean Accessed : 1;
- Boolean Shared : 1;
- Boolean ExecDisable : 1;
- UIntPtr PhysAddr : 32;
-};
-
-class ATTRIBUTE(packed) PDE final
-{
- public:
- ATTRIBUTE(aligned(PTE_ALIGN)) PTE Entries[PTE_MAX];
-};
-
-namespace Detail
-{
+namespace HCore {
+namespace Detail {
UIntPtr create_page_wrapper(Boolean rw, Boolean user);
void exec_disable(UIntPtr addr);
bool page_disable(UIntPtr addr);
-} // namespace Detail
+} // namespace Detail
// TODO: SwapVirtualMemoryDevice class!
-} // namespace HCore
+} // namespace HCore
diff --git a/Private/Source/NewFS.cxx b/Private/Source/NewFS+FileManager.cxx
index b0ba37c6..b0ba37c6 100644
--- a/Private/Source/NewFS.cxx
+++ b/Private/Source/NewFS+FileManager.cxx
diff --git a/Private/Source/NewFS+IO.cxx b/Private/Source/NewFS+IO.cxx
index e90ed1a4..1a9ac1ad 100644
--- a/Private/Source/NewFS+IO.cxx
+++ b/Private/Source/NewFS+IO.cxx
@@ -10,6 +10,12 @@
#include <KernelKit/DriveManager.hpp>
#include <KernelKit/FileManager.hpp>
+/** ---------------------------------------------------
+
+ * THIS FILE CONTAINS CODE FOR THE HCFS I/O DEVICES.
+
+------------------------------------------------------- */
+
#ifdef __USE_NEWFS__
/// @brief This implements NewFS with Device Abstraction in mind.
diff --git a/Private/Source/PageManager.cxx b/Private/Source/PageManager.cxx
index 7dec0343..b4d9ed8e 100644
--- a/Private/Source/PageManager.cxx
+++ b/Private/Source/PageManager.cxx
@@ -10,6 +10,10 @@
#include <KernelKit/DebugOutput.hpp>
#include <NewKit/PageManager.hpp>
+#ifdef __x86_64__
+#include <HALKit/AMD64/HalPageAlloc.hpp>
+#endif // ifdef __x86_64__
+
//! null deref will throw (Page Zero detected, aborting program!)
#define kProtectedRegionEnd 512
@@ -37,9 +41,7 @@ PTEWrapper::PTEWrapper(Boolean Rw, Boolean User, Boolean ExecDisable,
PTEWrapper::~PTEWrapper() {
PTE *raw = reinterpret_cast<PTE *>(m_VirtAddr);
-
MUST_PASS(raw);
- MUST_PASS(!raw->Accessed);
if (raw->Present) raw->Present = false;
}
@@ -107,10 +109,13 @@ bool PTEWrapper::Shareable() {
auto raw = reinterpret_cast<PTE *>(m_VirtAddr);
if (raw->Present) {
- m_Shareable = raw->Shared;
+ m_Shareable = raw->Rw;
+ kcout << m_Shareable ? "[PTEWrapper::Shareable] page is sharable!\n"
+ : "[PTEWrapper::Shareable] page is not sharable!\n";
+
return m_Shareable;
} else {
- kcout << "[PTEWrapper::Shareable] page is not present!";
+ kcout << "[PTEWrapper::Shareable] page is not present!\n";
return false;
}
}
diff --git a/Private/Source/SMPManager.cxx b/Private/Source/SMPManager.cxx
index 487eda51..0b3e1550 100644
--- a/Private/Source/SMPManager.cxx
+++ b/Private/Source/SMPManager.cxx
@@ -109,13 +109,24 @@ bool SMPManager::Switch(HAL::StackFrame* stack) {
m_ThreadList[idx].Leak().Leak().IsBusy())
continue;
+ // to avoid any null deref.
+ if (!stack, m_ThreadList[idx].Leak().Leak().m_Stack) continue;
+
+ m_ThreadList[idx].Leak().Leak().Busy(true);
+
m_ThreadList[idx].Leak().Leak().m_ID = idx;
- m_ThreadList[idx].Leak().Leak().m_Stack = stack;
- m_ThreadList[idx].Leak().Leak().m_PID = ProcessHelper::GetCurrentPID();
m_ThreadList[idx].Leak().Leak().Busy(true);
- rt_do_context_switch(stack);
+ /// I figured out this:
+ /// Allocate stack
+ /// Set APIC base to stack
+ /// Do stuff and relocate stack based on this code.
+ /// - Amlel
+ rt_copy_memory(stack, m_ThreadList[idx].Leak().Leak().m_Stack,
+ sizeof(HAL::StackFrame));
+
+ m_ThreadList[idx].Leak().Leak().m_PID = ProcessHelper::GetCurrentPID();
m_ThreadList[idx].Leak().Leak().Busy(false);
diff --git a/Public/Kits/GKit/Core.hpp b/Public/Kits/GKit/Core.hpp
index 5fcf6546..7059eb5e 100644
--- a/Public/Kits/GKit/Core.hpp
+++ b/Public/Kits/GKit/Core.hpp
@@ -8,6 +8,7 @@
Revision History:
31/01/24: Added file (amlel)
+ 08/02/24: Update Form to GForm. (amlel)
------------------------------------------- */
@@ -33,7 +34,7 @@ class GBoolean {
HCore::Boolean m_Value;
- friend class Form;
+ friend class GForm;
public:
static const GBoolean Construct(HCore::StringView& sw, HCore::Boolean value) {
@@ -51,7 +52,7 @@ class GAction {
HCore::StringView m_Name;
void (*m_Action)(T&&... args);
- friend class Form;
+ friend class GForm;
public:
static const GAction Construct(HCore::StringView& sw,
@@ -68,7 +69,7 @@ class GVector2 {
HCore::Array<HCore::Int, 3> m_Vec2;
- friend class Form;
+ friend class GForm;
public:
static const GVector2 Construct(HCore::StringView& sw,
@@ -82,7 +83,7 @@ class GVector2 {
class GNumber {
HCore::Int m_Number{0};
- friend class Form;
+ friend class GForm;
public:
static const GNumber Construct(HCore::Int& number) {
@@ -101,7 +102,7 @@ class GString {
HCore::StringView* m_Content;
- friend class Form;
+ friend class GForm;
public:
static const GString Construct(HCore::StringView& value) {
diff --git a/Public/Kits/GKit/Dim2d.hpp b/Public/Kits/GKit/Dim2d.hpp
index 39d441d4..9ae01aa0 100644
--- a/Public/Kits/GKit/Dim2d.hpp
+++ b/Public/Kits/GKit/Dim2d.hpp
@@ -19,8 +19,8 @@
namespace HCore {
class Dim2d final {
public:
- Dim2d() = delete;
- Dim2d(const HCore::UInt& x, const HCore::UInt& y) : m_X(x), m_Y(y) {}
+ explicit Dim2d() = delete;
+ explicit Dim2d(const HCore::UInt& x, const HCore::UInt& y) : m_X(x), m_Y(y) {}
Dim2d& operator=(const Dim2d&) = default;
Dim2d(const Dim2d&) = default;
diff --git a/Public/Kits/GKit/GFrame.hpp b/Public/Kits/GKit/GFrame.hpp
index e1262e3f..f70f8f8e 100644
--- a/Public/Kits/GKit/GFrame.hpp
+++ b/Public/Kits/GKit/GFrame.hpp
@@ -54,6 +54,6 @@ class GFrame {
private:
HCore::MutableArray<GFrame*> m_Frames;
- GFrame* m_ParentFrame;
+ GFrame* m_ParentFrame{nullptr};
};
} // namespace HCore
diff --git a/Public/Kits/GKit/Stylesheet.hxx b/Public/Kits/GKit/Stylesheet.hxx
new file mode 100644
index 00000000..bd764fcb
--- /dev/null
+++ b/Public/Kits/GKit/Stylesheet.hxx
@@ -0,0 +1,16 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+ File: Stylesheet.hpp
+ Purpose:
+
+ Revision History:
+
+ 08/02/24: Added file (amlel)
+
+------------------------------------------- */
+
+#pragma once
+
+/// TODO: Stylesheets for GUI.
diff --git a/Public/Kits/SystemKit/SystemKit.hxx b/Public/Kits/SystemKit/SystemKit.hxx
index eca53757..a4462f1c 100644
--- a/Public/Kits/SystemKit/SystemKit.hxx
+++ b/Public/Kits/SystemKit/SystemKit.hxx
@@ -4,6 +4,12 @@
#pragma once
+/** ---------------------------------------------------
+
+ * THIS FILE CONTAINS CODE FOR THE STANDARD HCORE API.
+
+------------------------------------------------------- */
+
#include <SystemKit/CoreAPI.hxx>
#include <SystemKit/FileAPI.hxx>
#include <SystemKit/HeapAPI.hxx>