replace nob with ms' build, move disk creation to build.bat, major comment cleanup, remove old and stupid tests, overhaul interrupt management with per-CPU vector allocation, affinity migration and safe teardown, add proper IOAPIC routing and PCI MSI/MSI-X/INTx support, migrate drivers to the new interrupt API, integrate ACPICA with a proper OS services layer, move ACPI firmware events, power button handling and S5 shutdown into acpi.sys, add parallel driver startup and atomic publication, replace PnP arrays with dynamic lists, redesign service startup again to be asynchronous, add delayed startup mode for services, allow omitting keys in services.ini, fix acpi ec deferred work handling, fix kernel threads having garbage exit code.
This commit is contained in:
1 parent
d36f19509c
commit
36eef8f58d
696 files changed
+147281
-7530
No files matched your search
@@ -6,13 +6,14 @@
|
||||
#include <kernel/hal/hal_timer.h>
|
||||
#include <kernel/hal/hal_internal.h>
|
||||
#include <kernel/hal/hal_debug.h>
|
||||
#include <kernel/ke_vectors.h>
|
||||
|
||||
#define LAPIC_TIMER_LVT 0x320
|
||||
#define LAPIC_TIMER_INIT 0x380
|
||||
#define LAPIC_TIMER_CUR 0x390
|
||||
#define LAPIC_TIMER_DIV 0x3E0
|
||||
|
||||
#define TIMER_VECTOR 0x20 // vector 0x20 = IRQ 0 slot in IDT
|
||||
#define TIMER_VECTOR KE_VECTOR_CPU_TIMER
|
||||
#define TIMER_PERIODIC (1 << 17)
|
||||
#define TIMER_MASKED (1 << 16)
|
||||
#define TIMER_DIV16 0x3
|
||||
@@ -30,9 +31,7 @@ static volatile uint64_t* gHpet = NULL;
|
||||
|
||||
static volatile uint64_t gTicks = 0;
|
||||
|
||||
// Implements the outb operation.
|
||||
static inline void outb(uint16_t port, uint8_t val) { __outbyte(port, val); }
|
||||
// Implements the inb operation.
|
||||
static inline uint8_t inb(uint16_t port) { return __inbyte(port); }
|
||||
|
||||
// Records one local timer interrupt for HAL timekeeping fallback.
|
||||
@@ -87,7 +86,6 @@ static uint64_t QueryTickFrequency(void) {
|
||||
return 1000000ull;
|
||||
}
|
||||
|
||||
// Implements the stall operation.
|
||||
void HalTimerStall(uint32_t us) {
|
||||
// Priority 1: Use HPET (Highest Precision).
|
||||
if (gHpet && gHpetTicksPerUs > 0) {
|
||||
@@ -187,7 +185,6 @@ static uint32_t CalibrateApicTimerViaHpet(uintptr_t hpetPhys) {
|
||||
return elapsed / 10; // APIC ticks per ms
|
||||
}
|
||||
|
||||
// Implements the timer Configure Current Cpu operation.
|
||||
void HalTimerConfigureCurrentProcessor(void) {
|
||||
if (!gLapic || !gApicTicksPerQuantum) return;
|
||||
LAPIC_REG(LAPIC_TIMER_DIV) = TIMER_DIV16;
|
||||
@@ -195,14 +192,12 @@ void HalTimerConfigureCurrentProcessor(void) {
|
||||
LAPIC_REG(LAPIC_TIMER_INIT) = gApicTicksPerQuantum;
|
||||
}
|
||||
|
||||
// Implements the timer Initialize operation.
|
||||
KSTATUS HalTimerInitialize(uintptr_t lapicPhys, uintptr_t hpetPhys, HAL_TIMER* out) {
|
||||
gLapic = (volatile uint32_t*)HalPhysicalToVirtual(lapicPhys);
|
||||
HalDbgPrint("HAL: lapicPhys=0x%016llX, lapicVirt=0x%016llX, hpetPhys=0x%016llX\n", lapicPhys, (uintptr_t)gLapic, hpetPhys);
|
||||
|
||||
uint32_t ticksPerMs = 0;
|
||||
if (hpetPhys) {
|
||||
HalDbgPrint("HAL: Attempting to calibrate APIC timer via HPET...\n");
|
||||
ticksPerMs = CalibrateApicTimerViaHpet(hpetPhys);
|
||||
}
|
||||
if (!ticksPerMs) {
|
||||
@@ -210,7 +205,7 @@ KSTATUS HalTimerInitialize(uintptr_t lapicPhys, uintptr_t hpetPhys, HAL_TIMER* o
|
||||
ticksPerMs = CalibrateApicTimerViaPit();
|
||||
}
|
||||
if (!ticksPerMs) {
|
||||
HalDbgPrint("HAL: APIC calibration failed. How?\n");
|
||||
HalDbgPrint("hal: APIC timer calibration failed\n");
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@@ -226,14 +221,13 @@ KSTATUS HalTimerInitialize(uintptr_t lapicPhys, uintptr_t hpetPhys, HAL_TIMER* o
|
||||
|
||||
HalDbgPrint("HAL: APIC timer: %u ticks/ms\n", ticksPerMs);
|
||||
|
||||
// Leave the BSP timer masked until the kernel registers its scheduler
|
||||
// callback and IRQ route. APs arm their local timer after per-CPU setup.
|
||||
// Leave the BSP timer masked until the kernel installs its timer handlers.
|
||||
// APs arm their local timer after per-CPU setup.
|
||||
|
||||
out->QueryTicks = HalTimerQueryTicks;
|
||||
out->QueryTickFrequency = QueryTickFrequency;
|
||||
out->Stall = HalTimerStall;
|
||||
out->HandleInterrupt = TimerInterrupt;
|
||||
out->ConfigureCurrentProcessor = HalTimerConfigureCurrentProcessor;
|
||||
out->IrqNumber = 0;
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
Reference in new issue
Block a user