feat: make kernel architecture-agnostic; primitive work on arm port

This commit is contained in:
daniel committed 2026-10-24 21:25:18 +02:00
1 parent dab7d5427b
commit 1bae77ec84
164 files changed
+3664 -1641

No files matched your search

+12 -11
View File
@@ -5,6 +5,7 @@
*/
#include "A2dp.hpp"
#include <Arch/Cpu.hpp>
#include "Sbc.hpp"
#include "L2cap.hpp"
#include "Hci.hpp"
@@ -12,7 +13,7 @@
#include <Terminal/Terminal.hpp>
#include <CppLib/Stream.hpp>
#include <Libraries/Memory.hpp>
#include <Timekeeping/ApicTimer.hpp>
#include <Timekeeping/Timer.hpp>
#include <atomic>
using namespace Kt;
@@ -232,7 +233,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
return true;
}
for (int j = 0; j < 100; j++) {
asm volatile("" ::: "memory");
Arch::CompilerBarrier();
}
}
g_expectLabel.store(0xFF, std::memory_order_release);
@@ -1166,7 +1167,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
answered = true;
break;
}
for (int j = 0; j < 100; j++) asm volatile("" ::: "memory");
for (int j = 0; j < 100; j++) Arch::CompilerBarrier();
}
// Transaction over: CLOSE the client channel (FreeChannel sends the
@@ -1200,7 +1201,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
Hci::ProcessPendingCommands();
auto* c = Hci::GetConnection(g_aclHandle.load(std::memory_order_acquire));
if (c && c->Encrypted) return true;
for (int j = 0; j < 100; j++) asm volatile("" ::: "memory");
for (int j = 0; j < 100; j++) Arch::CompilerBarrier();
}
return false;
}
@@ -1236,7 +1237,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
&& Timekeeping::GetMilliseconds() - waitStart < timeoutMs) {
Xhci::PollEvents();
Hci::DrainEvents();
for (int j = 0; j < 100; j++) asm volatile("pause" ::: "memory");
for (int j = 0; j < 100; j++) Arch::Pause();
}
return IsReady();
}
@@ -1268,7 +1269,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
Hci::DrainEvents();
Hci::ProcessPendingCommands();
if (g_sigCid.load(std::memory_order_acquire) != 0) break;
for (int j = 0; j < 100; j++) asm volatile("" ::: "memory");
for (int j = 0; j < 100; j++) Arch::CompilerBarrier();
}
}
if (g_sigCid.load(std::memory_order_acquire) != 0) {
@@ -1327,7 +1328,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
// timer.
if (L2cap::ConnRspResult(sig) == L2cap::CONN_PENDING)
waitBudgetMs = timeoutMs;
for (int j = 0; j < 100; j++) asm volatile("" ::: "memory");
for (int j = 0; j < 100; j++) Arch::CompilerBarrier();
}
uint16_t readySig = g_sigCid.load(std::memory_order_acquire);
if (readySig != 0) {
@@ -1364,7 +1365,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
while (Timekeeping::GetMilliseconds() - st < 400) {
Xhci::PollEvents();
Hci::DrainEvents();
for (int j = 0; j < 200; j++) asm volatile("pause" ::: "memory");
for (int j = 0; j < 200; j++) Arch::Pause();
}
}
@@ -1387,7 +1388,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
Hci::DrainEvents();
State s = g_state.load(std::memory_order_acquire);
if (s == State::Open || s == State::Streaming) break;
for (int j = 0; j < 100; j++) asm volatile("" ::: "memory");
for (int j = 0; j < 100; j++) Arch::CompilerBarrier();
}
State s = g_state.load(std::memory_order_acquire);
if (s != State::Open && s != State::Streaming) {
@@ -1495,7 +1496,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
g_mediaCid.store(other, std::memory_order_release);
break;
}
for (int j = 0; j < 100; j++) asm volatile("" ::: "memory");
for (int j = 0; j < 100; j++) Arch::CompilerBarrier();
}
if (g_mediaCid.load(std::memory_order_acquire) == 0) {
@@ -1879,7 +1880,7 @@ namespace Drivers::USB::Bluetooth::A2dp {
if (g_serviceActive.compare_exchange_weak(expected, true,
std::memory_order_acquire))
return true;
asm volatile("pause" ::: "memory");
Arch::Pause();
}
return false;
}