mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:57:46 +00:00
Kernel: Use Processor::wait_check in loops waiting for HW to respond
This gives the processor the hint that it is in a hot loop and allows us to do other work in between
This commit is contained in:
parent
cbaa3465a8
commit
a2810d3cf8
9 changed files with 31 additions and 36 deletions
|
@ -64,13 +64,13 @@ static void wait_until_we_can_write(MMIO& mmio)
|
|||
// Since nothing else writes to the mailbox, this wait is mostly cargo-culted.
|
||||
// Most baremetal tutorials on the internet query MBOX_READ_STATUS here, which I think is incorrect and only works because this wait really isn't needed.
|
||||
while (mmio.read(MBOX_WRITE_STATUS) & MBOX_FULL)
|
||||
;
|
||||
Processor::wait_check();
|
||||
}
|
||||
|
||||
static void wait_for_reply(MMIO& mmio)
|
||||
{
|
||||
while (mmio.read(MBOX_READ_STATUS) & MBOX_EMPTY)
|
||||
;
|
||||
Processor::wait_check();
|
||||
}
|
||||
|
||||
bool Mailbox::send_queue(void* queue, u32 queue_size) const
|
||||
|
|
|
@ -114,7 +114,7 @@ ErrorOr<size_t> MiniUART::write(Kernel::OpenFileDescription& description, u64, K
|
|||
void MiniUART::put_char(u8 ch)
|
||||
{
|
||||
while ((m_registers->line_status & TransmitterEmpty) == 0)
|
||||
;
|
||||
Processor::wait_check();
|
||||
|
||||
if (ch == '\n' && !m_last_put_char_was_carriage_return)
|
||||
m_registers->io_data = '\r';
|
||||
|
|
|
@ -160,13 +160,13 @@ void UART::set_baud_rate(int baud_rate, int uart_frequency_in_hz)
|
|||
void UART::wait_until_we_can_send()
|
||||
{
|
||||
while (m_registers->flag & TransmitFifoFull)
|
||||
;
|
||||
Processor::wait_check();
|
||||
}
|
||||
|
||||
void UART::wait_until_we_can_receive()
|
||||
{
|
||||
while (m_registers->flag & ReceiveFifoEmpty)
|
||||
;
|
||||
Processor::wait_check();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <Kernel/Arch/DebugOutput.h>
|
||||
#include <Kernel/Arch/x86_64/BochsDebugOutput.h>
|
||||
#include <Kernel/Arch/x86_64/IO.h>
|
||||
#include <Kernel/Arch/x86_64/Processor.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -35,7 +36,7 @@ void debug_output(char ch)
|
|||
}
|
||||
|
||||
while ((IO::in8(serial_com1_io_port + 5) & 0x20) == 0)
|
||||
;
|
||||
Processor::wait_check();
|
||||
|
||||
if (ch == '\n' && !was_cr)
|
||||
IO::out8(serial_com1_io_port, '\r');
|
||||
|
|
|
@ -91,7 +91,7 @@ UNMAP_AFTER_INIT bool APICTimer::calibrate(HardwareTimerBase& calibration_source
|
|||
sti();
|
||||
// Loop for about 100 ms
|
||||
while (state.calibration_ticks.load() <= state.ticks_in_100ms)
|
||||
;
|
||||
Processor::wait_check();
|
||||
cli();
|
||||
|
||||
// Restore timer callbacks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue