diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-14 15:02:02 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-14 15:02:02 +0200 |
commit | e78097d14028da4e5139e7187c3e52fe38cdaf99 (patch) | |
tree | 7977dbe1e5c264f18cdae917ee5b5bbfd4871e1f /Kernel/Devices/SB16.cpp | |
parent | b2e502e533173594431b53ef551bd64bbb85ae4f (diff) | |
download | serenity-e78097d14028da4e5139e7187c3e52fe38cdaf99.zip |
SB16: Set "m_interrupted" to false before enabling IRQ's.
Otherwise, we might get interrupted before entering wait_for_irq() and then
resetting the flag again.
Diffstat (limited to 'Kernel/Devices/SB16.cpp')
-rw-r--r-- | Kernel/Devices/SB16.cpp | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp index b97cf545fd..9742bfe828 100644 --- a/Kernel/Devices/SB16.cpp +++ b/Kernel/Devices/SB16.cpp @@ -63,18 +63,6 @@ SB16& SB16::the() return *s_the; } -void SB16::handle_irq() -{ - // Stop sound output ready for the next block. - dsp_write(0xd5); - - IO::in8(DSP_STATUS); // 8 bit interrupt - if (m_major_version >= 4) - IO::in8(DSP_R_ACK); // 16 bit interrupt - - m_interrupted = true; -} - void SB16::initialize() { IO::out8(0x226, 1); @@ -137,26 +125,29 @@ void SB16::dma_start(uint32_t length) IO::out8(0xd4, (channel % 4)); } +void SB16::handle_irq() +{ + // Stop sound output ready for the next block. + dsp_write(0xd5); + + IO::in8(DSP_STATUS); // 8 bit interrupt + if (m_major_version >= 4) + IO::in8(DSP_R_ACK); // 16 bit interrupt + + m_interrupted = true; +} + void SB16::wait_for_irq() { - m_interrupted = false; -#ifdef SB16_DEBUG - kprintf("SB16: waiting for interrupt...\n"); -#endif - current->block_until([this] { return m_interrupted; }); -#ifdef SB16_DEBUG - kprintf("SB16: got interrupt!\n"); -#endif + current->block_until([this] { + return m_interrupted; + }); } ssize_t SB16::write(FileDescription&, const u8* data, ssize_t length) { - if (!m_dma_buffer_page) { -#ifdef SB16_DEBUG - kprintf("SB16: Allocating page\n"); -#endif + if (!m_dma_buffer_page) m_dma_buffer_page = MM.allocate_supervisor_physical_page(); - } #ifdef SB16_DEBUG kprintf("SB16: Writing buffer of %d bytes\n", length); @@ -190,6 +181,7 @@ ssize_t SB16::write(FileDescription&, const u8* data, ssize_t length) dsp_write((u8)sample_count); dsp_write((u8)(sample_count >> 8)); + m_interrupted = false; enable_irq(); wait_for_irq(); return length; |