summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-09-07 23:29:48 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-09-07 23:29:48 +0200
commitd3f87b1b84d355ad72366ced5d7e5a43207226c0 (patch)
treeae1f85714d2fc4deb77edfbb391344118180a715 /dev
parent12d192e44e4269b8398021adbf524e0e7c8cf308 (diff)
feat: kernel: startup sequence fix, and new mgmt.hefs manual.
wip: LaunchKit for the `ne_launch` program. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev')
-rw-r--r--dev/boot/amd64-desktop.make6
-rw-r--r--dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc13
-rw-r--r--dev/kernel/HALKit/AMD64/HalKernelMain.cc31
-rw-r--r--dev/kernel/HALKit/ARM64/HalKernelMain.cc14
-rw-r--r--dev/kernel/src/UserProcessScheduler.cc2
-rw-r--r--dev/launch/LaunchKit/LaunchKit.h9
-rw-r--r--dev/launch/src/LaunchSrv.cc15
-rw-r--r--dev/libDDK/src/ddk_kernel_call.c4
8 files changed, 45 insertions, 49 deletions
diff --git a/dev/boot/amd64-desktop.make b/dev/boot/amd64-desktop.make
index 443e5677..d8c3fd86 100644
--- a/dev/boot/amd64-desktop.make
+++ b/dev/boot/amd64-desktop.make
@@ -117,15 +117,15 @@ compile-amd64:
.PHONY: run-efi-amd64-ahci
run-efi-amd64-ahci:
- $(EMU) $(EMU_FLAGS) -monitor stdio -hda $(IMG) -s -S -boot menu=on
+ $(EMU) $(EMU_FLAGS) -monitor stdio -hda $(IMG) -s -boot menu=on
.PHONY: run-efi-amd64-ata-pio
run-efi-amd64-ata-pio:
- $(EMU) $(EMU_FLAGS) -device piix3-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -s -S -d int -boot menu=on
+ $(EMU) $(EMU_FLAGS) -device piix3-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -s -d int -boot menu=on
.PHONY: run-efi-amd64-ata-dma
run-efi-amd64-ata-dma:
- $(EMU) $(EMU_FLAGS) -device piix4-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -s -S -boot menu=on
+ $(EMU) $(EMU_FLAGS) -device piix4-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -s -boot menu=on
.PHONY: run-efi-amd64-ata
run-efi-amd64-ata: run-efi-amd64-ata-pio
diff --git a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc
index df5386e4..e3e08830 100644
--- a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc
+++ b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc
@@ -88,7 +88,7 @@ struct LAPIC final {
/// @param target
/// @return
/***********************************************************************************/
-Void hal_send_ipi_msg(UInt32 target, UInt32 apic_id, UInt8 vector) {
+EXTERN_C Void hal_send_ipi_msg(UInt32 target, UInt32 apic_id, UInt8 vector) {
Kernel::ke_dma_write<UInt32>(target, APIC_ICR_HIGH, apic_id << 24);
Kernel::ke_dma_write<UInt32>(target, APIC_ICR_LOW, 0x00000600 | 0x00004000 | 0x00000000 | vector);
@@ -200,10 +200,7 @@ Void mp_init_cores(VoidPtr vendor_ptr) noexcept {
UInt8 type = *entry_ptr;
UInt8 length = *(entry_ptr + 1);
- // Avoid infinite loop on bad APIC tables.
- if (length < 2) break;
-
- if (type == 0) {
+ if (type == 0 && length == sizeof(struct LAPIC)) {
volatile LAPIC* entry_struct = (volatile LAPIC*) entry_ptr;
if (entry_struct->Flags & 0x1) {
@@ -212,15 +209,15 @@ Void mp_init_cores(VoidPtr vendor_ptr) noexcept {
++kSMPCount;
- kout << "Kind: LAPIC: ON\r";
+ kout << "AP: kind: LAPIC: ON.\r";
// 0x7c00, as recommended by the Intel SDM.
hal_send_ipi_msg(kApicBaseAddress, entry_struct->ProcessorID, 0x7c);
} else {
- kout << "Kind: LAPIC: OFF\r";
+ kout << "AP: kind: LAPIC: OFF.\r";
}
} else {
- kout << "Kind: UNKNOWN: OFF\r";
+ kout << "AP: kind: UNKNOWN: OFF.\r";
}
entry_ptr += length;
diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc
index cb5d4af8..95214353 100644
--- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc
+++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc
@@ -32,8 +32,6 @@ EXTERN_C Int32 hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) {
HAL::rt_sti();
- kHandoverHeader = handover_hdr;
-
FB::fb_clear_video();
fw_init_efi((EfiSystemTable*) handover_hdr->f_FirmwareCustomTables[1]);
@@ -41,8 +39,9 @@ EXTERN_C Int32 hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) {
Boot::ExitBootServices(handover_hdr->f_HardwareTables.f_ImageKey,
handover_hdr->f_HardwareTables.f_ImageHandle);
- kBitMapCursor = 0UL;
- kKernelVM = kHandoverHeader->f_PageStart;
+ kHandoverHeader = handover_hdr;
+
+ kKernelVM = kHandoverHeader->f_PageStart;
if (!kKernelVM) {
MUST_PASS(kKernelVM);
@@ -55,6 +54,7 @@ EXTERN_C Int32 hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) {
/* INITIALIZE BIT MAP. */
/************************************** */
+ kBitMapCursor = 0UL;
kKernelBitMpSize = kHandoverHeader->f_BitMapSize;
kKernelBitMpStart =
reinterpret_cast<VoidPtr>(reinterpret_cast<UIntPtr>(kHandoverHeader->f_BitMapStart));
@@ -133,20 +133,14 @@ EXTERN_C Int32 hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) {
return kEfiFail;
}
-EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept {
+EXTERN_C Kernel::Void hal_real_init(Kernel::Void) {
using namespace Kernel;
- for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Capacity(); ++index) {
- HardwareThreadScheduler::The()[index].Leak()->Kind() = ThreadKind::kAPStandard;
- HardwareThreadScheduler::The()[index].Leak()->ID() = index;
- HardwareThreadScheduler::The()[index].Leak()->Busy(NO);
- }
+ HAL::Register64 idt_reg;
+ idt_reg.Base = reinterpret_cast<UIntPtr>(kInterruptVectorTable);
- for (SizeT index = 0UL; index < UserProcessScheduler::The().TheCurrentTeam().AsArray().Count();
- ++index) {
- UserProcessScheduler::The().TheCurrentTeam().AsArray()[index].Status =
- ProcessStatusKind::kInvalid;
- }
+ HAL::IDTLoader idt_loader;
+ idt_loader.Load(idt_reg);
HAL::mp_init_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
@@ -158,13 +152,6 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept {
NeFS::fs_init_nefs();
#endif
- HAL::Register64 idt_reg;
- idt_reg.Base = reinterpret_cast<UIntPtr>(kInterruptVectorTable);
-
- HAL::IDTLoader idt_loader;
-
- idt_loader.Load(idt_reg);
-
while (YES)
;
}
diff --git a/dev/kernel/HALKit/ARM64/HalKernelMain.cc b/dev/kernel/HALKit/ARM64/HalKernelMain.cc
index 096df49e..29541d48 100644
--- a/dev/kernel/HALKit/ARM64/HalKernelMain.cc
+++ b/dev/kernel/HALKit/ARM64/HalKernelMain.cc
@@ -37,8 +37,6 @@ EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) {
FB::fb_clear_video();
- kBitMapCursor = 0UL;
-
#ifdef __NE_ARM64_EFI__
fw_init_efi((EfiSystemTable*) handover_hdr->f_FirmwareCustomTables[1]);
@@ -50,23 +48,13 @@ EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) {
/* INITIALIZE BIT MAP. */
/************************************** */
+ kBitMapCursor = 0UL;
kKernelBitMpSize = kHandoverHeader->f_BitMapSize;
kKernelBitMpStart = reinterpret_cast<Kernel::VoidPtr>(
reinterpret_cast<Kernel::UIntPtr>(kHandoverHeader->f_BitMapStart));
/// @note do initialize the interrupts after it.
- for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Capacity(); ++index) {
- HardwareThreadScheduler::The()[index].Leak()->Kind() = ThreadKind::kAPStandard;
- HardwareThreadScheduler::The()[index].Leak()->Busy(NO);
- }
-
- for (SizeT index = 0UL; index < UserProcessScheduler::The().TheCurrentTeam().AsArray().Count();
- ++index) {
- UserProcessScheduler::The().TheCurrentTeam().AsArray()[index].Status =
- ProcessStatusKind::kInvalid;
- }
-
Kernel::mp_init_cores();
while (YES)
diff --git a/dev/kernel/src/UserProcessScheduler.cc b/dev/kernel/src/UserProcessScheduler.cc
index 174862a4..07c4a572 100644
--- a/dev/kernel/src/UserProcessScheduler.cc
+++ b/dev/kernel/src/UserProcessScheduler.cc
@@ -438,7 +438,7 @@ ProcessID UserProcessScheduler::Spawn(const Char* name, VoidPtr code, VoidPtr im
}
(Void)(kout << "ProcessID: " << number(process.ProcessId) << kendl);
- (Void)(kout << "Name: " << process.Name << kendl);
+ (Void)(kout << "ProcesName: " << process.Name << kendl);
return pid;
}
diff --git a/dev/launch/LaunchKit/LaunchKit.h b/dev/launch/LaunchKit/LaunchKit.h
new file mode 100644
index 00000000..95d91e09
--- /dev/null
+++ b/dev/launch/LaunchKit/LaunchKit.h
@@ -0,0 +1,9 @@
+/* -------------------------------------------
+
+ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved.
+
+ ------------------------------------------- */
+
+#pragma once
+
+#include <libSystem/SystemKit/System.h>
diff --git a/dev/launch/src/LaunchSrv.cc b/dev/launch/src/LaunchSrv.cc
new file mode 100644
index 00000000..8c302c6d
--- /dev/null
+++ b/dev/launch/src/LaunchSrv.cc
@@ -0,0 +1,15 @@
+/* -------------------------------------------
+
+ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved.
+
+ ------------------------------------------- */
+
+#include <LaunchKit/LaunchKit.h>
+
+SInt32 _NeMain(Void) {
+ PrintOut(nullptr, "%s", "NeKernel Launcher\n");
+
+ /// @todo Start LaunchServices.fwrk, make the launcher manageable too (via mgmt.launch)
+
+ return kErrorSuccess;
+}
diff --git a/dev/libDDK/src/ddk_kernel_call.c b/dev/libDDK/src/ddk_kernel_call.c
index 61742b7b..5976665b 100644
--- a/dev/libDDK/src/ddk_kernel_call.c
+++ b/dev/libDDK/src/ddk_kernel_call.c
@@ -12,8 +12,8 @@
#include <stdarg.h>
/// @brief this is an internal call, do not use it.
-DDK_EXTERN ATTRIBUTE(naked) ptr_t __ke_call_dispatch(const int32_t name, int32_t cnt, void* data,
- size_t sz);
+DDK_EXTERN ATTRIBUTE(naked) ptr_t
+ __ke_call_dispatch(const int32_t name, int32_t cnt, void* data, size_t sz);
/// @brief This function hashes the path into a FNV symbol.
/// @param path the path to hash.
/// @retval 0 symbol wasn't hashed.