34 lines
1.2 KiB
C++
34 lines
1.2 KiB
C++
/*
|
|
* CpuIdle.hpp
|
|
* ACPI-guided CPU idle-state selection
|
|
* Copyright (c) 2026 Daniel Hammer
|
|
*/
|
|
|
|
#pragma once
|
|
#include <cstdint>
|
|
#include <ACPI/ACPI.hpp>
|
|
|
|
namespace Hal {
|
|
namespace CpuIdle {
|
|
|
|
// Initialize ACPI idle-state policy from the AML namespace and FADT.
|
|
void Initialize(ACPI::CommonSDTHeader* xsdt);
|
|
|
|
// Enter an idle state chosen for the predicted idle duration.
|
|
// Falls back to MWAIT/HLT when ACPI data is unavailable.
|
|
void Wait(uint32_t predictedIdleMs, bool hasMwait,
|
|
volatile uint64_t* monitorAddr = nullptr);
|
|
|
|
// Same as Wait(), but called with interrupts disabled and returns with
|
|
// interrupts disabled. Used by tickless idle paths that need atomic
|
|
// STI+HLT/MWAIT semantics.
|
|
void WaitWithInterruptsDisabled(uint32_t predictedIdleMs, bool hasMwait,
|
|
volatile uint64_t* monitorAddr = nullptr);
|
|
|
|
// Shallow atomic idle for latency-sensitive interactive bursts.
|
|
void WaitShallowWithInterruptsDisabled(bool hasMwait,
|
|
volatile uint64_t* monitorAddr = nullptr);
|
|
|
|
};
|
|
};
|