1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

Revert "Kernel: Replace IRQHandler with the new InterruptHandler class"

This reverts commit 6c72736b26.

I am unable to boot on my home machine with this change in the tree.
This commit is contained in:
Andreas Kling 2020-01-22 22:23:50 +01:00
parent 8e21e31b3a
commit e64c335e5a
29 changed files with 169 additions and 193 deletions

View file

@ -135,23 +135,24 @@ OwnPtr<E1000NetworkAdapter> E1000NetworkAdapter::autodetect()
return make<E1000NetworkAdapter>(found_address, irq);
}
E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address pci_address, u8 interrupt_vector)
: PCI::Device(pci_address, interrupt_vector)
E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address pci_address, u8 irq)
: IRQHandler(irq)
, m_pci_address(pci_address)
{
set_interface_name("e1k");
kprintf("E1000: Found at PCI address @ %w:%b:%b.%b\n", pci_address.seg(), pci_address.bus(), pci_address.slot(), pci_address.function());
enable_bus_mastering(get_pci_address());
enable_bus_mastering(m_pci_address);
size_t mmio_base_size = PCI::get_BAR_Space_Size(pci_address, 0);
m_mmio_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(get_pci_address()))), PAGE_ROUND_UP(mmio_base_size), "E1000 MMIO", Region::Access::Read | Region::Access::Write, false, false);
m_mmio_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(m_pci_address))), PAGE_ROUND_UP(mmio_base_size), "E1000 MMIO", Region::Access::Read | Region::Access::Write, false, false);
m_mmio_base = m_mmio_region->vaddr();
m_use_mmio = true;
m_io_base = PCI::get_BAR1(get_pci_address()) & ~1;
m_interrupt_line = PCI::get_interrupt_line(get_pci_address());
m_io_base = PCI::get_BAR1(m_pci_address) & ~1;
m_interrupt_line = PCI::get_interrupt_line(m_pci_address);
kprintf("E1000: IO port base: %w\n", m_io_base);
kprintf("E1000: MMIO base: P%x\n", PCI::get_BAR0(get_pci_address()) & 0xfffffffc);
kprintf("E1000: MMIO base: P%x\n", PCI::get_BAR0(pci_address) & 0xfffffffc);
kprintf("E1000: MMIO base size: %u bytes\n", mmio_base_size);
kprintf("E1000: Interrupt line: %u\n", m_interrupt_line);
detect_eeprom();
@ -170,14 +171,14 @@ E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address pci_address, u8 interrupt_
out32(REG_IMASK, 0xff & ~4);
in32(0xc0);
enable_interrupts();
enable_irq();
}
E1000NetworkAdapter::~E1000NetworkAdapter()
{
}
void E1000NetworkAdapter::handle_interrupt()
void E1000NetworkAdapter::handle_irq()
{
out32(REG_IMASK, 0x1);
@ -372,14 +373,14 @@ u32 E1000NetworkAdapter::in32(u16 address)
void E1000NetworkAdapter::send_raw(const u8* data, int length)
{
disable_interrupts();
disable_irq();
u32 tx_current = in32(REG_TXDESCTAIL);
#ifdef E1000_DEBUG
kprintf("E1000: Sending packet (%d bytes)\n", length);
#endif
auto& descriptor = m_tx_descriptors[tx_current];
ASSERT(length <= 8192);
auto* vptr = (void*)(descriptor.addr + 0xc0000000);
auto *vptr = (void*)(descriptor.addr + 0xc0000000);
memcpy(vptr, data, length);
descriptor.length = length;
descriptor.status = 0;
@ -390,7 +391,7 @@ void E1000NetworkAdapter::send_raw(const u8* data, int length)
tx_current = (tx_current + 1) % number_of_tx_descriptors;
out32(REG_TXDESCTAIL, tx_current);
cli();
enable_interrupts();
enable_irq();
for (;;) {
if (descriptor.status) {
sti();

View file

@ -27,23 +27,23 @@
#pragma once
#include <AK/OwnPtr.h>
#include <Kernel/IRQHandler.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/PCI/Device.h>
class E1000NetworkAdapter final : public NetworkAdapter
, public PCI::Device {
, public IRQHandler {
public:
static OwnPtr<E1000NetworkAdapter> autodetect();
E1000NetworkAdapter(PCI::Address, u8 interrupt_vector);
E1000NetworkAdapter(PCI::Address, u8 irq);
virtual ~E1000NetworkAdapter() override;
virtual void send_raw(const u8*, int) override;
virtual bool link_up() override;
private:
virtual void handle_interrupt() override;
virtual void handle_irq() override;
virtual const char* class_name() const override { return "E1000NetworkAdapter"; }
struct [[gnu::packed]] e1000_rx_desc
@ -86,6 +86,7 @@ private:
void receive();
PCI::Address m_pci_address;
u16 m_io_base { 0 };
VirtualAddress m_mmio_base;
OwnPtr<Region> m_mmio_region;

View file

@ -139,17 +139,18 @@ OwnPtr<RTL8139NetworkAdapter> RTL8139NetworkAdapter::autodetect()
return make<RTL8139NetworkAdapter>(found_address, irq);
}
RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address pci_address, u8 interrupt_vector)
: PCI::Device(pci_address, interrupt_vector)
RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address pci_address, u8 irq)
: IRQHandler(irq)
, m_pci_address(pci_address)
{
set_interface_name("rtl8139");
kprintf("RTL8139: Found at PCI address %b:%b:%b\n", pci_address.bus(), pci_address.slot(), pci_address.function());
enable_bus_mastering(get_pci_address());
enable_bus_mastering(m_pci_address);
m_io_base = PCI::get_BAR0(get_pci_address()) & ~1;
m_interrupt_line = PCI::get_interrupt_line(get_pci_address());
m_io_base = PCI::get_BAR0(m_pci_address) & ~1;
m_interrupt_line = PCI::get_interrupt_line(m_pci_address);
kprintf("RTL8139: IO port base: %w\n", m_io_base);
kprintf("RTL8139: Interrupt line: %u\n", m_interrupt_line);
@ -173,14 +174,14 @@ RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address pci_address, u8 interr
const auto& mac = mac_address();
kprintf("RTL8139: MAC address: %s\n", mac.to_string().characters());
enable_interrupts();
enable_irq();
}
RTL8139NetworkAdapter::~RTL8139NetworkAdapter()
{
}
void RTL8139NetworkAdapter::handle_interrupt()
void RTL8139NetworkAdapter::handle_irq()
{
for (;;) {
int status = in16(REG_ISR);

View file

@ -27,25 +27,25 @@
#pragma once
#include <AK/OwnPtr.h>
#include <Kernel/IRQHandler.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/PCI/Device.h>
#define RTL8139_TX_BUFFER_COUNT 4
class RTL8139NetworkAdapter final : public NetworkAdapter
, public PCI::Device {
, public IRQHandler {
public:
static OwnPtr<RTL8139NetworkAdapter> autodetect();
RTL8139NetworkAdapter(PCI::Address, u8 interrupt_vector);
RTL8139NetworkAdapter(PCI::Address, u8 irq);
virtual ~RTL8139NetworkAdapter() override;
virtual void send_raw(const u8*, int) override;
virtual bool link_up() override { return m_link_up; }
private:
virtual void handle_interrupt() override;
virtual void handle_irq() override;
virtual const char* class_name() const override { return "RTL8139NetworkAdapter"; }
void reset();
@ -60,6 +60,7 @@ private:
u16 in16(u16 address);
u32 in32(u16 address);
PCI::Address m_pci_address;
u16 m_io_base { 0 };
u8 m_interrupt_line { 0 };
u32 m_rx_buffer_addr { 0 };