summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.vscode/c_cpp_properties.json15
-rw-r--r--Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx1
-rw-r--r--Private/HALKit/AMD64/HalInterruptRouting.asm2
-rw-r--r--Private/KernelKit/CodeManager.hpp15
-rw-r--r--Private/KernelKit/PEFCodeManager.hxx10
-rw-r--r--Private/KernelKit/ProcessManager.hpp22
-rw-r--r--Private/KernelKit/ProcessTeam.hpp28
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx2
-rw-r--r--Private/NewBoot/Source/FileReader.cxx7
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/AMD64-VirtualMemory.asm8
-rw-r--r--Private/NewBoot/Source/makefile11
-rw-r--r--Private/NewBoot/Source/run-qemu.ps11
-rw-r--r--Private/Source/ProcessManager.cxx10
-rw-r--r--Private/makefile12
14 files changed, 81 insertions, 63 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index 412858d6..a6a60a86 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -5,13 +5,26 @@
"includePath": [
"${workspaceFolder}/Private/**",
"${workspaceFolder}/Private/NewBoot/**",
- "${workspaceFolder}/Public/Kits/**",
+ "${workspaceFolder}/Public/Kits/**"
],
"defines": ["__HCORE__", "__HAVE_HCORE_APIS__", "__FSKIT_NEWFS__", "kBootKrnlSections"],
"cStandard": "c17",
"cppStandard": "c++20",
"compilerPath": "/opt/homebrew/bin/x86_64-w64-mingw32-gcc",
"intelliSenseMode": "gcc-x64"
+ },
+ {
+ "name": "HCore (Win)",
+ "includePath": [
+ "${workspaceFolder}/Private/**",
+ "${workspaceFolder}/Private/NewBoot/**",
+ "${workspaceFolder}/Public/Kits/**"
+ ],
+ "defines": ["__HCORE__", "__HAVE_HCORE_APIS__", "__FSKIT_NEWFS__", "kBootKrnlSections"],
+ "cStandard": "c17",
+ "cppStandard": "c++20",
+ "compilerPath": "C:/cygwin64/bin/x86_64-w64-mingw32-gcc.exe",
+ "intelliSenseMode": "gcc-x64"
},
{
"name": "HCore Tools (Mac)",
diff --git a/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx
index 0f89d208..be0932bd 100644
--- a/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx
+++ b/Private/HALKit/AMD64/HalInterruptHandlerAMD64.cxx
@@ -18,7 +18,6 @@
EXTERN_C ATTRIBUTE(naked) HCore::UIntPtr rt_handle_interrupts(HCore::UIntPtr rsp)
{
HCore::HAL::StackFramePtr stackPtr = reinterpret_cast<HCore::HAL::StackFramePtr>(rsp);
- HCORE_UNUSED(stackPtr);
if (stackPtr->IntNum == kInterruptId ||
stackPtr->IntNum == kInterruptIdAlt) {
diff --git a/Private/HALKit/AMD64/HalInterruptRouting.asm b/Private/HALKit/AMD64/HalInterruptRouting.asm
index 84429482..a835d031 100644
--- a/Private/HALKit/AMD64/HalInterruptRouting.asm
+++ b/Private/HALKit/AMD64/HalInterruptRouting.asm
@@ -12,7 +12,6 @@
[bits 64]
%macro IntExp 1
-align 4
global __HCR_INT_%1
__HCR_INT_%1:
cld
@@ -21,7 +20,6 @@ __HCR_INT_%1:
%endmacro
%macro IntNormal 1
-align 4
global __HCR_INT_%1
__HCR_INT_%1:
cld
diff --git a/Private/KernelKit/CodeManager.hpp b/Private/KernelKit/CodeManager.hpp
index 4bbbc350..ed42517a 100644
--- a/Private/KernelKit/CodeManager.hpp
+++ b/Private/KernelKit/CodeManager.hpp
@@ -8,6 +8,7 @@
Revision History:
30/01/24: Added file (amlel)
+ 3/8/24: Add UPP struct.
------------------------------------------- */
@@ -16,3 +17,17 @@
#include <KernelKit/PECodeManager.hxx>
#include <KernelKit/PEFCodeManager.hxx>
#include <KernelKit/PEFSharedObject.hxx>
+
+#define kUPPNameLen 64
+
+namespace HCore {
+/// \brief Much like Mac OS's UPP.
+/// This is read-only by design.
+/// It handles different kind of code.
+/// ARM <-> AMD64 for example.
+typedef struct UniversalProcedureTable final {
+ const Char NAME[kUPPNameLen];
+ const VoidPtr TRAP;
+ const SizeT ARCH;
+} PACKED UniversalProcedureTableType;
+} // namespace HCore \ No newline at end of file
diff --git a/Private/KernelKit/PEFCodeManager.hxx b/Private/KernelKit/PEFCodeManager.hxx
index a4bc08eb..73bc8ea3 100644
--- a/Private/KernelKit/PEFCodeManager.hxx
+++ b/Private/KernelKit/PEFCodeManager.hxx
@@ -52,16 +52,6 @@ class PEFLoader : public Loader {
};
namespace Utils {
-/// \brief Much like Mac OS's UPP.
-/// This is read-only by design.
-/// It handles different kind of code.
-/// ARM <-> AMD64 for example.
-typedef struct UniversalProcedureTable final {
- const Char NAME[kPefNameLen];
- const VoidPtr TRAP;
- const SizeT ARCH;
-} PACKED UniversalProcedureTableType;
-
bool execute_from_image(PEFLoader &exec) noexcept;
} // namespace Utils
} // namespace HCore
diff --git a/Private/KernelKit/ProcessManager.hpp b/Private/KernelKit/ProcessManager.hpp
index d7a3d39e..0eb3f80e 100644
--- a/Private/KernelKit/ProcessManager.hpp
+++ b/Private/KernelKit/ProcessManager.hpp
@@ -24,6 +24,10 @@
////////////////////////////////////////////////////
namespace HCore {
+class Process;
+class ProcessTeam;
+class ProcessManager;
+
//! @brief Process identifier.
typedef Int64 ProcessID;
@@ -180,6 +184,24 @@ class Process final {
friend ProcessHelper;
};
+/// \brief Processs Team (contains multiple processes inside it.)
+/// Equivalent to a process batch
+class ProcessTeam final {
+public:
+ explicit ProcessTeam() = default;
+ ~ProcessTeam() = default;
+
+ HCORE_COPY_DEFAULT(ProcessTeam);
+
+ MutableArray<Ref<Process>>& AsArray() { return mProcessList; }
+ Ref<Process>& AsRef() { return mCurrentProcess; }
+
+public:
+ MutableArray<Ref<Process>> mProcessList;
+ Ref<Process> mCurrentProcess;
+
+};
+
using ProcessPtr = Process *;
//! @brief Kernel scheduler..
diff --git a/Private/KernelKit/ProcessTeam.hpp b/Private/KernelKit/ProcessTeam.hpp
index 1fb78d1d..31759ff6 100644
--- a/Private/KernelKit/ProcessTeam.hpp
+++ b/Private/KernelKit/ProcessTeam.hpp
@@ -6,30 +6,4 @@
#pragma once
-#include <ArchKit/ArchKit.hpp>
-#include <KernelKit/FileManager.hpp>
-#include <KernelKit/PermissionSelector.hxx>
-#include <NewKit/LockDelegate.hpp>
-#include <NewKit/MutableArray.hpp>
-#include <NewKit/UserHeap.hpp>
-
-/// kernel namespace
-namespace HCore {
-/// \brief Processs Team (contains multiple processes inside it.)
-/// Equivalent to a process batch
-class ProcessTeam final {
-public:
- explicit ProcessTeam() = default;
- ~ProcessTeam() = default;
-
- HCORE_COPY_DEFAULT(ProcessTeam);
-
- MutableArray<Ref<Process>>& AsArray() { return mProcessList; }
- Ref<Process>& AsRef() { return mCurrentProcess; }
-
-public:
- MutableArray<Ref<Process>> mProcessList;
- Ref<Process> mCurrentProcess;
-
-};
-} // namespace HCore \ No newline at end of file
+#include <KernelKit/ProcessManager.hpp> \ No newline at end of file
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index fa173f25..25a29ea1 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -157,8 +157,6 @@ inline UInt32 In32(UInt16 port) {
return value;
}
-extern "C" VoidPtr __cr3();
-
#endif // __EFI_x86_64__
/***********************************************************************************/
diff --git a/Private/NewBoot/Source/FileReader.cxx b/Private/NewBoot/Source/FileReader.cxx
index 158f9ab4..f24329e8 100644
--- a/Private/NewBoot/Source/FileReader.cxx
+++ b/Private/NewBoot/Source/FileReader.cxx
@@ -8,7 +8,7 @@
Revision History:
-
+ Fix stupid implementation for a more smarter one.
------------------------------------------- */
@@ -92,11 +92,12 @@ BFileReader::~BFileReader() {
this->mFile = nullptr;
}
+ if (this->mBlob)
+ BS->FreePool(mBlob);
+
BSetMem(this->mPath, 0, kPathLen);
}
-#define hTransferBufferAddress 0xffffffff10000000
-
/**
@brief this reads all of the buffer.
@param ImageHandle used internally.
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-VirtualMemory.asm b/Private/NewBoot/Source/HEL/AMD64/AMD64-VirtualMemory.asm
deleted file mode 100644
index 46928cf7..00000000
--- a/Private/NewBoot/Source/HEL/AMD64/AMD64-VirtualMemory.asm
+++ /dev/null
@@ -1,8 +0,0 @@
-bits 64
-global __cr3
-
-section .text
-
-__cr3:
- mov rax, cr3
- ret
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index c3b02fc6..057a5d44 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -5,8 +5,14 @@
CC_GNU=x86_64-w64-mingw32-g++
LD_GNU=x86_64-w64-mingw32-ld
+
+ifeq ($(shell uname), Darwin)
+EMU=qemu-system-x86_64
+else
+EMU=qemu-system-x86_64w.exe
+endif
+
LD_FLAGS=-e efi_main --subsystem=10
-ASM=nasm
OBJ=$(wildcard *.o) $(wildcard ../../Obj/*.obj) $(wildcard HEL/AMD64/*.obj)
REM=rm
@@ -22,7 +28,6 @@ invalid-recipe:
.PHONY: bootloader-amd64
bootloader-amd64:
$(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx *.cxx
- $(ASM) $(FLAG_ASM) HEL/AMD64/AMD64-VirtualMemory.asm
$(LD_GNU) $(OBJ) $(LD_FLAGS) -o HCoreLdr.exe
cp HCoreLdr.exe CDROM/EFI/BOOT/BOOTX64.EFI
cp HCoreLdr.exe CDROM/EFI/BOOT/HCORELDR.EFI
@@ -30,7 +35,7 @@ bootloader-amd64:
.PHONY: run-efi-amd64
run-efi-amd64:
- qemu-system-x86_64 -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -d int
+ $(EMU) -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -d int
.PHONY: download-edk
download-edk:
diff --git a/Private/NewBoot/Source/run-qemu.ps1 b/Private/NewBoot/Source/run-qemu.ps1
new file mode 100644
index 00000000..d84c9327
--- /dev/null
+++ b/Private/NewBoot/Source/run-qemu.ps1
@@ -0,0 +1 @@
+qemu-system-x86_64w.exe -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -d int \ No newline at end of file
diff --git a/Private/Source/ProcessManager.cxx b/Private/Source/ProcessManager.cxx
index bb952186..056eac5c 100644
--- a/Private/Source/ProcessManager.cxx
+++ b/Private/Source/ProcessManager.cxx
@@ -206,14 +206,14 @@ SizeT ProcessManager::Run() noexcept {
unwrapped_process.PTime = 0;
// set the current process.
- m_CurrentProcess = unwrapped_process;
+ mTeam.AsRef() = unwrapped_process;
// tell helper to find a core to schedule on.
- ProcessHelper::Switch(m_CurrentProcess.Leak().StackFrame,
- m_CurrentProcess.Leak().ProcessId);
+ ProcessHelper::Switch(mTeam.AsRef().Leak().StackFrame,
+ mTeam.AsRef().Leak().ProcessId);
} else {
// otherwise increment the P-time.
- ++m_CurrentProcess.Leak().PTime;
+ ++mTeam.AsRef().Leak().PTime;
}
}
@@ -225,7 +225,7 @@ Ref<ProcessManager> ProcessManager::Shared() {
return {ref};
}
-Ref<Process> &ProcessManager::GetCurrent() { return m_CurrentProcess; }
+Ref<Process> &ProcessManager::GetCurrent() { return mTeam.AsRef(); }
PID &ProcessHelper::GetCurrentPID() {
kcout << "ProcessHelper::GetCurrentPID: Leaking ProcessId...\r\n";
diff --git a/Private/makefile b/Private/makefile
index e9c116ae..9b5d1595 100644
--- a/Private/makefile
+++ b/Private/makefile
@@ -6,7 +6,17 @@
CC = x86_64-w64-mingw32-gcc
LD = x86_64-w64-mingw32-ld
CCFLAGS = -c -ffreestanding -mgeneral-regs-only -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__FSKIT_NEWFS__ -D__HAVE_HCORE_APIS__ -D__HCORE__ -I../ -I./
-ASM = nasm
+
+UNAME := $(shell uname)
+
+ifeq ($(UNAME), Darwin)
+ASM = nasm
+else
+# Otherwise Windows NT.
+ASM = $(WINASM)
+endif
+
+# Add assembler, linker, and object files variables.
ASMFLAGS = -f win64
LDFLAGS = -e Main --subsystem=17
LDOBJ = $(wildcard Obj/*.obj)