Kernel: Make ATABus use BAN::Atomic<> instead of gcc builtin atomics

This commit is contained in:
Bananymous 2024-07-21 17:39:26 +03:00
parent ffe73165f9
commit 77b5e6d44a
2 changed files with 8 additions and 4 deletions

View File

@ -53,7 +53,7 @@ namespace Kernel
const uint16_t m_ctrl;
Mutex m_mutex;
volatile bool m_has_got_irq { false };
BAN::Atomic<bool> m_has_got_irq { false };
// Non-owning pointers
BAN::Vector<ATADevice*> m_devices;

View File

@ -149,13 +149,17 @@ namespace Kernel
ASSERT(!m_has_got_irq);
if (io_read(ATA_PORT_STATUS) & ATA_STATUS_ERR)
dprintln("ATA Error: {}", error());
m_has_got_irq = true;
m_has_got_irq.store(true);
}
void ATABus::block_until_irq()
{
while (!__sync_bool_compare_and_swap(&m_has_got_irq, true, false))
__builtin_ia32_pause();
bool expected { true };
while (!m_has_got_irq.compare_exchange(expected, false))
{
Processor::pause();
expected = true;
}
}
uint8_t ATABus::io_read(uint16_t port)