summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-16 10:39:06 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-16 10:55:54 +0200
commit03eb0e5638b2b4f6cb1a57a3c9e77db990e07db0 (patch)
tree2039b51ec55b61e5e9a3789eca0522d146ca2a3e
parent85aafe492d40a106b90238f2a231f540e8d00eba (diff)
downloadserenity-03eb0e5638b2b4f6cb1a57a3c9e77db990e07db0.zip
Kernel: Let's say that IO::delay(N) delays for N microseconds
Supposedly that's how much delay you get when doing I/O on port 0x80.
-rw-r--r--Kernel/Devices/SB16.cpp2
-rw-r--r--Kernel/Interrupts/APIC.cpp8
-rw-r--r--Libraries/LibBareMetal/IO.h6
3 files changed, 5 insertions, 11 deletions
diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp
index e65d87605f..53964c4cc0 100644
--- a/Kernel/Devices/SB16.cpp
+++ b/Kernel/Devices/SB16.cpp
@@ -100,7 +100,7 @@ void SB16::initialize()
disable_irq();
IO::out8(0x226, 1);
- IO::delay();
+ IO::delay(32);
IO::out8(0x226, 0);
auto data = dsp_read();
diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp
index 6eaac95583..6400e24bc4 100644
--- a/Kernel/Interrupts/APIC.cpp
+++ b/Kernel/Interrupts/APIC.cpp
@@ -215,20 +215,16 @@ void enable(u32 cpu)
write_register(APIC_REG_TPR, 0);
if (cpu != 0) {
- static volatile u32 foo = 0;
-
// INIT
write_icr(ICRReg(0, ICRReg::INIT, ICRReg::Physical, ICRReg::Assert, ICRReg::TriggerMode::Edge, ICRReg::AllExcludingSelf));
- for (foo = 0; foo < 0x800000; foo++)
- ; // TODO: 10 millisecond delay
+ IO::delay(10 * 1000);
for (int i = 0; i < 2; i++) {
// SIPI
write_icr(ICRReg(0x08, ICRReg::StartUp, ICRReg::Physical, ICRReg::Assert, ICRReg::TriggerMode::Edge, ICRReg::AllExcludingSelf)); // start execution at P8000
- for (foo = 0; foo < 0x80000; foo++)
- ; // TODO: 200 microsecond delay
+ IO::delay(200);
}
}
}
diff --git a/Libraries/LibBareMetal/IO.h b/Libraries/LibBareMetal/IO.h
index 6e30562b42..d287801a0d 100644
--- a/Libraries/LibBareMetal/IO.h
+++ b/Libraries/LibBareMetal/IO.h
@@ -94,12 +94,10 @@ inline void repeated_out16(u16 port, const u16* data, int data_size)
: "d"(port));
}
-inline void delay()
+inline void delay(size_t microseconds)
{
- // ~3 microsecs
- for (auto i = 0; i < 32; i++) {
+ for (size_t i = 0; i < microseconds; ++i)
IO::in8(0x80);
- }
}
}