summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/HALKit/ARM64
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-30 18:46:00 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-30 19:56:02 +0200
commita9d87cbd143b05cc3de711d84401f8ef514f3aa3 (patch)
treecfc703f1dc02f6894b4d6d173d18d84be5757c5f /dev/ZKA/HALKit/ARM64
parent5229ca8ae190c0cb3db8d381a44be4113e81d5dc (diff)
[IMP] Updated the ARM64 release of ZKA.
[IMP] Shall use the timer on AMD64 by default, a SMP driver will be written if needed. Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/HALKit/ARM64')
-rw-r--r--dev/ZKA/HALKit/ARM64/HalHart.cxx2
-rw-r--r--dev/ZKA/HALKit/ARM64/HalKernelMain.cxx159
-rw-r--r--dev/ZKA/HALKit/ARM64/HalScheduler.cxx2
-rw-r--r--dev/ZKA/HALKit/ARM64/HalTimer.cxx2
-rw-r--r--dev/ZKA/HALKit/ARM64/Processor.hxx10
-rw-r--r--dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx8
6 files changed, 108 insertions, 75 deletions
diff --git a/dev/ZKA/HALKit/ARM64/HalHart.cxx b/dev/ZKA/HALKit/ARM64/HalHart.cxx
index d2a91bf3..68672595 100644
--- a/dev/ZKA/HALKit/ARM64/HalHart.cxx
+++ b/dev/ZKA/HALKit/ARM64/HalHart.cxx
@@ -14,7 +14,7 @@ namespace Kernel
/// wakes up thread from hang.
void mp_wakeup_thread(HAL::StackFrame* stack)
{
- rt_do_context_switch(stack);
+ mp_do_context_switch(stack);
}
/// @brief makes the thread sleep on a loop.
diff --git a/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx b/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx
index 129170f7..c2886b31 100644
--- a/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx
+++ b/dev/ZKA/HALKit/ARM64/HalKernelMain.cxx
@@ -18,22 +18,27 @@
#include <KernelKit/CodeManager.hxx>
#include <Modules/ACPI/ACPIFactoryInterface.hxx>
#include <NetworkKit/IPC.hxx>
+#include <CFKit/Property.hxx>
+#include <Modules/CoreCG/TextRenderer.hxx>
-EXTERN_C Kernel::VoidPtr kInterruptVectorTable[];
+Kernel::Property cKernelVersion;
+Kernel::User cUserSuper{Kernel::RingKind::kRingSuperUser, kSuperUser};
-struct PACKED HeapAllocInfo final
+EXTERN Kernel::Boolean kAllocationInProgress;
+
+struct HEAP_ALLOC_INFO final
{
Kernel::VoidPtr fThe;
Kernel::Size fTheSz;
};
-struct PACKED ProcessBlockInfo final
+struct PROCESS_BLOCK_INFO final
{
THREAD_INFORMATION_BLOCK* fTIB;
- THREAD_INFORMATION_BLOCK* fPIB;
+ THREAD_INFORMATION_BLOCK* fGIB;
};
-struct PACKED ProcessExitInfo final
+struct PROCESS_EXIT_INFO final
{
STATIC constexpr auto cReasonLen = 512;
@@ -41,6 +46,16 @@ struct PACKED ProcessExitInfo final
Kernel::Char fReason[cReasonLen];
};
+namespace Kernel::HAL
+{
+ /// @brief Gets the system cores using the MADT.
+ /// @param rsdPtr The 'RSD PTR' data structure.
+ EXTERN void hal_system_get_cores(Kernel::voidPtr rsdPtr);
+} // namespace Kernel::HAL
+
+Kernel::Void hal_real_init(Kernel::Void) noexcept;
+EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void);
+
EXTERN_C void hal_init_platform(
Kernel::HEL::HandoverInformationHeader* HandoverHeader)
{
@@ -54,38 +69,46 @@ EXTERN_C void hal_init_platform(
return;
}
- kKernelVirtualSize = HandoverHeader->f_VirtualSize;
+ hal_real_init();
+}
+
+Kernel::Void hal_real_init(Kernel::Void) noexcept
+{
+ // reset kAllocationInProgress field to zero.
+ kAllocationInProgress = false;
+
+ kKernelVMHStart = kHandoverHeader->f_HeapStart;
+
+ // get page size.
+ kKernelVirtualSize = kHandoverHeader->f_VirtualSize;
+
+ // get virtual address start (for the heap)
kKernelVirtualStart = reinterpret_cast<Kernel::VoidPtr>(
- reinterpret_cast<Kernel::UIntPtr>(HandoverHeader->f_VirtualStart) + cHeapStartOffset);
-
- kKernelPhysicalStart = HandoverHeader->f_PhysicalStart;
-
- // Register the basic SCI functions.
-
- constexpr auto cSerialAlertInterrupt = 0x10;
- constexpr auto cTlsInterrupt = 0x11;
- constexpr auto cTlsInstallInterrupt = 0x12;
- constexpr auto cNewInterrupt = 0x13;
- constexpr auto cDeleteInterrupt = 0x14;
- constexpr auto cExitInterrupt = 0x15;
- constexpr auto cLastExitInterrupt = 0x16;
- constexpr auto cCatalogOpen = 0x17;
- constexpr auto cForkRead = 0x18;
- constexpr auto cForkWrite = 0x19;
- constexpr auto cCatalogClose = 0x20;
- constexpr auto cCatalogRemove = 0x21;
- constexpr auto cCatalogCreate = 0x22;
- constexpr auto cRebootInterrupt = 0x23;
- constexpr auto cShutdownInterrupt = 0x24;
- constexpr auto cLPCSendMsg = 0x25;
- constexpr auto cLPCOpenMsg = 0x26;
- constexpr auto cLPCCloseMsg = 0x27;
- constexpr auto cLPCSanitizeMsg = 0x28;
-
- kSyscalls[cSerialAlertInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- const Kernel::Char* msg = (const Kernel::Char*)rdx;
- Kernel::kcout << "Kernel: " << msg << "\r";
- };
+ reinterpret_cast<Kernel::UIntPtr>(kHandoverHeader->f_VirtualStart));
+
+ // get physical address start.
+ kKernelPhysicalStart = reinterpret_cast<Kernel::VoidPtr>(
+ reinterpret_cast<Kernel::UIntPtr>(kHandoverHeader->f_PhysicalStart));
+
+ // Register the basic system calls.
+
+ constexpr auto cTlsInterrupt = 0x11;
+ constexpr auto cTlsInstallInterrupt = 0x12;
+ constexpr auto cNewInterrupt = 0x13;
+ constexpr auto cDeleteInterrupt = 0x14;
+ constexpr auto cExitInterrupt = 0x15;
+ constexpr auto cLastExitInterrupt = 0x16;
+ constexpr auto cCatalogOpen = 0x17;
+ constexpr auto cForkRead = 0x18;
+ constexpr auto cForkWrite = 0x19;
+ constexpr auto cCatalogClose = 0x20;
+ constexpr auto cCatalogRemove = 0x21;
+ constexpr auto cCatalogCreate = 0x22;
+ constexpr auto cRebootInterrupt = 0x23;
+ constexpr auto cShutdownInterrupt = 0x24;
+ constexpr auto cLPCSendMsg = 0x25;
+ constexpr auto cLPCOpenMsg = 0x26;
+ constexpr auto cLPCCloseMsg = 0x27;
kSyscalls[cTlsInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
if (tls_check_syscall_impl(rdx) == false)
@@ -94,13 +117,9 @@ EXTERN_C void hal_init_platform(
}
};
- kSyscalls[cLPCSanitizeMsg].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- Kernel::ipc_sanitize_packet(reinterpret_cast<Kernel::IPC_MESSAGE_STRUCT*>(rdx));
- };
-
kSyscalls[cNewInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
// get HAC struct.
- HeapAllocInfo* rdxInf = reinterpret_cast<HeapAllocInfo*>(rdx);
+ HEAP_ALLOC_INFO* rdxInf = reinterpret_cast<HEAP_ALLOC_INFO*>(rdx);
if (!rdxInf)
return;
@@ -111,7 +130,7 @@ EXTERN_C void hal_init_platform(
kSyscalls[cDeleteInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
// get HAC struct.
- HeapAllocInfo* rdxInf = reinterpret_cast<HeapAllocInfo*>(rdx);
+ HEAP_ALLOC_INFO* rdxInf = reinterpret_cast<HEAP_ALLOC_INFO*>(rdx);
if (!rdxInf)
return;
@@ -121,17 +140,17 @@ EXTERN_C void hal_init_platform(
};
kSyscalls[cTlsInstallInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- ProcessBlockInfo* rdxPb = reinterpret_cast<ProcessBlockInfo*>(rdx);
+ PROCESS_BLOCK_INFO* rdxPb = reinterpret_cast<PROCESS_BLOCK_INFO*>(rdx);
if (!rdxPb)
return;
- // install the fTIB and fPIB.
- rt_install_tib(rdxPb->fTIB, rdxPb->fPIB);
+ // install the fTIB and fGIB.
+ rt_install_tib(rdxPb->fTIB, rdxPb->fGIB);
};
kSyscalls[cExitInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- ProcessExitInfo* rdxEi = reinterpret_cast<ProcessExitInfo*>(rdx);
+ PROCESS_EXIT_INFO* rdxEi = reinterpret_cast<PROCESS_EXIT_INFO*>(rdx);
if (!rdxEi)
return;
@@ -141,7 +160,7 @@ EXTERN_C void hal_init_platform(
};
kSyscalls[cLastExitInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- ProcessExitInfo* rdxEi = reinterpret_cast<ProcessExitInfo*>(rdx);
+ PROCESS_EXIT_INFO* rdxEi = reinterpret_cast<PROCESS_EXIT_INFO*>(rdx);
if (!rdxEi)
return;
@@ -150,23 +169,41 @@ EXTERN_C void hal_init_platform(
};
kSyscalls[cRebootInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- Kernel::ACPIFactoryInterface acpi(kHandoverHeader->f_HardwareTables.f_VendorPtr);
- acpi.Reboot();
+ Kernel::PowerFactoryInterface pow(kHandoverHeader->f_HardwareTables.f_VendorPtr);
+ pow.Reboot();
};
kSyscalls[cShutdownInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void {
- Kernel::ACPIFactoryInterface acpi(kHandoverHeader->f_HardwareTables.f_VendorPtr);
- acpi.Shutdown();
+ Kernel::PowerFactoryInterface pow(kHandoverHeader->f_HardwareTables.f_VendorPtr);
+ pow.Shutdown();
};
- kSyscalls[cSerialAlertInterrupt].Leak().Leak()->fHooked = true;
- kSyscalls[cTlsInterrupt].Leak().Leak()->fHooked = true;
- kSyscalls[cTlsInstallInterrupt].Leak().Leak()->fHooked = true;
- kSyscalls[cDeleteInterrupt].Leak().Leak()->fHooked = true;
- kSyscalls[cNewInterrupt].Leak().Leak()->fHooked = true;
- kSyscalls[cExitInterrupt].Leak().Leak()->fHooked = true;
- kSyscalls[cLastExitInterrupt].Leak().Leak()->fHooked = true;
- kSyscalls[cShutdownInterrupt].Leak().Leak()->fHooked = true;
- kSyscalls[cRebootInterrupt].Leak().Leak()->fHooked = true;
- kSyscalls[cLPCSanitizeMsg].Leak().Leak()->fHooked = true;
+ kSyscalls[cTlsInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cTlsInstallInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cDeleteInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cNewInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cExitInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cLastExitInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cShutdownInterrupt].Leak().Leak()->fHooked = true;
+ kSyscalls[cRebootInterrupt].Leak().Leak()->fHooked = true;
+
+ if (kHandoverHeader->f_MultiProcessingEnabled)
+ Kernel::HAL::hal_system_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
+
+ Kernel::kcout << "newoskrnl: Creating filesystem and such.\r";
+
+ auto fs = new Kernel::NewFilesystemManager();
+
+ MUST_PASS(fs);
+ MUST_PASS(fs->GetParser());
+
+ Kernel::NewFilesystemManager::Mount(fs);
+
+ const auto cPassword = "ZKA_KERNEL_AUTHORITY";
+
+ cUserSuper.TrySave(cPassword);
+
+ ke_dll_entrypoint();
+
+ Kernel::ke_stop(RUNTIME_CHECK_FAILED);
}
diff --git a/dev/ZKA/HALKit/ARM64/HalScheduler.cxx b/dev/ZKA/HALKit/ARM64/HalScheduler.cxx
index 51cbfe4b..072c09be 100644
--- a/dev/ZKA/HALKit/ARM64/HalScheduler.cxx
+++ b/dev/ZKA/HALKit/ARM64/HalScheduler.cxx
@@ -19,7 +19,7 @@ Void PROCESS_HEADER_BLOCK::SetEntrypoint(UIntPtr& imageStart) noexcept
namespace Kernel
{
- bool rt_check_stack(HAL::StackFramePtr stackPtr)
+ bool hal_check_stack(HAL::StackFramePtr stackPtr)
{
if (!stackPtr)
return false;
diff --git a/dev/ZKA/HALKit/ARM64/HalTimer.cxx b/dev/ZKA/HALKit/ARM64/HalTimer.cxx
index ef907e4f..4ef87227 100644
--- a/dev/ZKA/HALKit/ARM64/HalTimer.cxx
+++ b/dev/ZKA/HALKit/ARM64/HalTimer.cxx
@@ -13,4 +13,4 @@
#include <ArchKit/ArchKit.hxx>
-struct TimerInfoStruct;
+struct TIMER_INFO;
diff --git a/dev/ZKA/HALKit/ARM64/Processor.hxx b/dev/ZKA/HALKit/ARM64/Processor.hxx
index 16e9ec8c..985dfe64 100644
--- a/dev/ZKA/HALKit/ARM64/Processor.hxx
+++ b/dev/ZKA/HALKit/ARM64/Processor.hxx
@@ -19,12 +19,6 @@
#define kCPUBackendName "ARMv8"
-#ifdef __ZETA_MACHINE__
-#define cHeapStartOffset (0x10000000)
-#else
-#error !!! please provide that macro. !!!
-#endif
-
namespace Kernel::HAL
{
struct PACKED Register64 final
@@ -48,7 +42,9 @@ namespace Kernel::HAL
typedef StackFrame* StackFramePtr;
} // namespace Kernel::HAL
-inline Kernel::VoidPtr kKernelVirtualStart = (Kernel::VoidPtr)cHeapStartOffset;
+
+inline Kernel::VoidPtr kKernelVMHStart = nullptr;
+inline Kernel::VoidPtr kKernelVirtualStart = nullptr;
inline Kernel::UIntPtr kKernelVirtualSize = 0UL;
inline Kernel::VoidPtr kKernelPhysicalStart = nullptr;
diff --git a/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx b/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx
index cc7802cb..ac17d658 100644
--- a/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx
+++ b/dev/ZKA/HALKit/ARM64/Storage/HalFlash.cxx
@@ -10,7 +10,7 @@
/// @file Flash.cxx
/// @brief Flash memory builtin.
-#ifdef __FLASH_MEM__
+#ifdef __USE_MBCI_FLASH__
#define cMaxFlash (4U)
@@ -53,14 +53,14 @@ namespace Kernel
/// @brief Enable flash memory at slot.
STATIC Void drv_enable_flash(Int32 arg)
{
- kcout << "newoskrnl: enabled hardware.\r";
+ kcout << "newoskrnl: Enabled FLSH hardware.\r";
}
/// @brief Disable flash memory at slot.
STATIC Void drv_disable_flash(Int32 arg)
{
- kcout << "newoskrnl: disabled hardware.\r";
+ kcout << "newoskrnl: Disabled FLSH hardware.\r";
}
} // namespace Kernel
-#endif // if __FLASH_MEM__ (Bridge)
+#endif // if __USE_MBCI_FLASH__ (Bridge)