42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
/*
|
|
* GsiRouting.cpp
|
|
* Platform interrupt lines for ACPI global system interrupts
|
|
* Copyright (c) 2026 Daniel Hammer
|
|
*/
|
|
|
|
#include "GsiRouting.hpp"
|
|
#include <Arch/Interrupts.hpp>
|
|
#include <CppLib/Spinlock.hpp>
|
|
|
|
namespace Hal::GsiRouting {
|
|
|
|
static constexpr uint8_t FirstLine = 1;
|
|
static constexpr uint8_t LineCount = 24;
|
|
|
|
static uint32_t g_lineGsi[LineCount] = {};
|
|
static uint8_t g_nextLine = FirstLine;
|
|
static kcp::Mutex g_lock;
|
|
|
|
uint8_t LineForGsi(uint32_t gsi, bool levelTriggered, bool activeLow) {
|
|
if (Arch::PlatformLinesAreFixed()) return 0;
|
|
|
|
g_lock.Acquire();
|
|
for (uint8_t line = FirstLine; line < g_nextLine; line++) {
|
|
if (g_lineGsi[line] == gsi) {
|
|
g_lock.Release();
|
|
return line;
|
|
}
|
|
}
|
|
|
|
uint8_t line = 0;
|
|
if (g_nextLine < LineCount &&
|
|
Arch::AssignPlatformLine(g_nextLine, gsi, levelTriggered, activeLow)) {
|
|
line = g_nextLine++;
|
|
g_lineGsi[line] = gsi;
|
|
}
|
|
g_lock.Release();
|
|
return line;
|
|
}
|
|
|
|
}
|