mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-02 00:13:02 +00:00
Kernel: Use generic functions to change interrupt state of Processor
This allows these files to be built for aarch64.
This commit is contained in:
parent
acfeffc9ca
commit
f9ab02429b
Notes:
sideshowbarker
2024-07-17 07:11:12 +09:00
Author: https://github.com/FireFox317
Commit: f9ab02429b
Pull-request: https://github.com/SerenityOS/serenity/pull/15794
Reviewed-by: https://github.com/nico ✅
2 changed files with 27 additions and 26 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include <Kernel/Arch/Delay.h>
|
#include <Kernel/Arch/Delay.h>
|
||||||
#include <Kernel/Devices/Audio/AC97.h>
|
#include <Kernel/Devices/Audio/AC97.h>
|
||||||
#include <Kernel/Devices/DeviceManagement.h>
|
#include <Kernel/Devices/DeviceManagement.h>
|
||||||
|
#include <Kernel/InterruptDisabler.h>
|
||||||
#include <Kernel/Memory/AnonymousVMObject.h>
|
#include <Kernel/Memory/AnonymousVMObject.h>
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
@ -226,34 +227,34 @@ ErrorOr<void> AC97::write_single_buffer(UserOrKernelBuffer const& data, size_t o
|
||||||
{
|
{
|
||||||
VERIFY(length <= PAGE_SIZE);
|
VERIFY(length <= PAGE_SIZE);
|
||||||
|
|
||||||
// Block until we can write into an unused buffer
|
{
|
||||||
cli();
|
// Block until we can write into an unused buffer
|
||||||
do {
|
InterruptDisabler disabler;
|
||||||
auto pcm_out_status = m_pcm_out_channel->io_window().read16(AC97Channel::Register::Status);
|
do {
|
||||||
auto current_index = m_pcm_out_channel->io_window().read8(AC97Channel::Register::CurrentIndexValue);
|
auto pcm_out_status = m_pcm_out_channel->io_window().read16(AC97Channel::Register::Status);
|
||||||
int last_valid_index = m_pcm_out_channel->io_window().read8(AC97Channel::Register::LastValidIndex);
|
auto current_index = m_pcm_out_channel->io_window().read8(AC97Channel::Register::CurrentIndexValue);
|
||||||
|
int last_valid_index = m_pcm_out_channel->io_window().read8(AC97Channel::Register::LastValidIndex);
|
||||||
|
|
||||||
auto head_distance = last_valid_index - current_index;
|
auto head_distance = last_valid_index - current_index;
|
||||||
if (head_distance < 0)
|
if (head_distance < 0)
|
||||||
head_distance += buffer_descriptor_list_max_entries;
|
head_distance += buffer_descriptor_list_max_entries;
|
||||||
if (m_pcm_out_channel->dma_running())
|
if (m_pcm_out_channel->dma_running())
|
||||||
++head_distance;
|
++head_distance;
|
||||||
|
|
||||||
// Current index has _passed_ last valid index - move our list index up
|
// Current index has _passed_ last valid index - move our list index up
|
||||||
if (head_distance > m_output_buffer_page_count) {
|
if (head_distance > m_output_buffer_page_count) {
|
||||||
m_buffer_descriptor_list_index = current_index + 1;
|
m_buffer_descriptor_list_index = current_index + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is room for our data
|
// There is room for our data
|
||||||
if (head_distance < m_output_buffer_page_count)
|
if (head_distance < m_output_buffer_page_count)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
dbgln_if(AC97_DEBUG, "AC97 @ {}: waiting on interrupt - status: {:#05b} CI: {} LVI: {}", pci_address(), pcm_out_status, current_index, last_valid_index);
|
|
||||||
m_irq_queue.wait_forever("AC97"sv);
|
|
||||||
} while (m_pcm_out_channel->dma_running());
|
|
||||||
sti();
|
|
||||||
|
|
||||||
|
dbgln_if(AC97_DEBUG, "AC97 @ {}: waiting on interrupt - status: {:#05b} CI: {} LVI: {}", pci_address(), pcm_out_status, current_index, last_valid_index);
|
||||||
|
m_irq_queue.wait_forever("AC97"sv);
|
||||||
|
} while (m_pcm_out_channel->dma_running());
|
||||||
|
}
|
||||||
// Copy data from userspace into one of our buffers
|
// Copy data from userspace into one of our buffers
|
||||||
TRY(data.read(m_output_buffer->vaddr_from_page_index(m_output_buffer_page_index).as_ptr(), offset, length));
|
TRY(data.read(m_output_buffer->vaddr_from_page_index(m_output_buffer_page_index).as_ptr(), offset, length));
|
||||||
|
|
||||||
|
|
|
@ -408,12 +408,12 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload)
|
||||||
descriptor.cmd = CMD_EOP | CMD_IFCS | CMD_RS;
|
descriptor.cmd = CMD_EOP | CMD_IFCS | CMD_RS;
|
||||||
dbgln_if(E1000_DEBUG, "E1000: Using tx descriptor {} (head is at {})", tx_current, in32(REG_TXDESCHEAD));
|
dbgln_if(E1000_DEBUG, "E1000: Using tx descriptor {} (head is at {})", tx_current, in32(REG_TXDESCHEAD));
|
||||||
tx_current = (tx_current + 1) % number_of_tx_descriptors;
|
tx_current = (tx_current + 1) % number_of_tx_descriptors;
|
||||||
cli();
|
Processor::disable_interrupts();
|
||||||
enable_irq();
|
enable_irq();
|
||||||
out32(REG_TXDESCTAIL, tx_current);
|
out32(REG_TXDESCTAIL, tx_current);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (descriptor.status) {
|
if (descriptor.status) {
|
||||||
sti();
|
Processor::enable_interrupts();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_wait_queue.wait_forever("E1000NetworkAdapter"sv);
|
m_wait_queue.wait_forever("E1000NetworkAdapter"sv);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue