feat: further kernel power and power optimizations
This commit is contained in:
@@ -14,6 +14,8 @@ using namespace Kt;
|
||||
namespace Hal {
|
||||
namespace LocalApic {
|
||||
static volatile uint32_t* g_apicBase = nullptr;
|
||||
static constexpr uint32_t ICR_DELIVERY_STATUS = (1 << 12);
|
||||
static constexpr uint32_t ICR_LEVEL_ASSERT = (1 << 14);
|
||||
|
||||
static inline uint64_t ReadMSR(uint32_t msr) {
|
||||
uint32_t lo, hi;
|
||||
@@ -113,6 +115,21 @@ namespace Hal {
|
||||
WriteRegister(REG_EOI, 0);
|
||||
}
|
||||
|
||||
void SendFixedIpi(uint32_t apicId, uint8_t vector) {
|
||||
if (g_apicBase == nullptr) return;
|
||||
|
||||
while (ReadRegister(REG_ICR_LOW) & ICR_DELIVERY_STATUS) {
|
||||
asm volatile("pause");
|
||||
}
|
||||
|
||||
WriteRegister(REG_ICR_HIGH, apicId << 24);
|
||||
WriteRegister(REG_ICR_LOW, (uint32_t)vector | ICR_LEVEL_ASSERT);
|
||||
|
||||
while (ReadRegister(REG_ICR_LOW) & ICR_DELIVERY_STATUS) {
|
||||
asm volatile("pause");
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t GetId() {
|
||||
return (ReadRegister(REG_ID) >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user