forked from Bananymous/banan-os
Kernel: Make disk IO blocking thread safe
This was causing a lot of deadlocks on vms without kvm accel
This commit is contained in:
parent
bf617036c7
commit
32e1473c94
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <BAN/Errors.h>
|
||||
#include <kernel/Semaphore.h>
|
||||
#include <kernel/SpinLock.h>
|
||||
#include <kernel/Storage/ATAController.h>
|
||||
|
||||
|
@ -56,7 +55,6 @@ namespace Kernel
|
|||
const uint16_t m_base;
|
||||
const uint16_t m_ctrl;
|
||||
SpinLock m_lock;
|
||||
Semaphore m_semaphore;
|
||||
|
||||
bool m_has_got_irq { false };
|
||||
|
||||
|
|
|
@ -151,14 +151,12 @@ namespace Kernel
|
|||
if (io_read(ATA_PORT_STATUS) & ATA_STATUS_ERR)
|
||||
dprintln("ATA Error: {}", error());
|
||||
m_has_got_irq = true;
|
||||
m_semaphore.unblock();
|
||||
}
|
||||
|
||||
void ATABus::block_until_irq()
|
||||
{
|
||||
if (!m_has_got_irq)
|
||||
m_semaphore.block();
|
||||
m_has_got_irq = false;
|
||||
while (!__sync_bool_compare_and_swap(&m_has_got_irq, true, false))
|
||||
__builtin_ia32_pause();
|
||||
}
|
||||
|
||||
uint8_t ATABus::io_read(uint16_t port)
|
||||
|
|
Loading…
Reference in New Issue