diff options
Diffstat (limited to 'Kernel/Devices')
-rw-r--r-- | Kernel/Devices/BlockDevice.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/CharacterDevice.h | 2 | ||||
-rw-r--r-- | Kernel/Devices/Device.cpp | 34 | ||||
-rw-r--r-- | Kernel/Devices/Device.h | 12 | ||||
-rw-r--r-- | Kernel/Devices/FloppyDiskDevice.cpp | 14 | ||||
-rw-r--r-- | Kernel/Devices/FloppyDiskDevice.h | 6 | ||||
-rw-r--r-- | Kernel/Devices/HardwareEventsManager.cpp | 65 | ||||
-rw-r--r-- | Kernel/Devices/HardwareEventsManager.h | 44 | ||||
-rw-r--r-- | Kernel/Devices/KeyboardDevice.cpp | 6 | ||||
-rw-r--r-- | Kernel/Devices/KeyboardDevice.h | 6 | ||||
-rw-r--r-- | Kernel/Devices/PATAChannel.cpp | 34 | ||||
-rw-r--r-- | Kernel/Devices/PATAChannel.h | 12 | ||||
-rw-r--r-- | Kernel/Devices/PATADiskDevice.h | 2 | ||||
-rw-r--r-- | Kernel/Devices/PS2MouseDevice.cpp | 6 | ||||
-rw-r--r-- | Kernel/Devices/PS2MouseDevice.h | 6 | ||||
-rw-r--r-- | Kernel/Devices/SB16.cpp | 9 | ||||
-rw-r--r-- | Kernel/Devices/SB16.h | 6 |
17 files changed, 85 insertions, 182 deletions
diff --git a/Kernel/Devices/BlockDevice.h b/Kernel/Devices/BlockDevice.h index 483ca90fd9..fd8c2fb495 100644 --- a/Kernel/Devices/BlockDevice.h +++ b/Kernel/Devices/BlockDevice.h @@ -34,9 +34,10 @@ public: size_t block_size() const { return m_block_size; } virtual bool is_seekable() const override { return true; } + protected: BlockDevice(unsigned major, unsigned minor, size_t block_size = PAGE_SIZE) - : Device(major, minor, (u8)DEVICE_TYPE::BLOCK_DEVICE) + : Device(major, minor) , m_block_size(block_size) { } diff --git a/Kernel/Devices/CharacterDevice.h b/Kernel/Devices/CharacterDevice.h index 09fd7f92e8..6d52eed55e 100644 --- a/Kernel/Devices/CharacterDevice.h +++ b/Kernel/Devices/CharacterDevice.h @@ -34,7 +34,7 @@ public: protected: CharacterDevice(unsigned major, unsigned minor) - : Device(major, minor, (u8)DEVICE_TYPE::CHAR_DEVICE) + : Device(major, minor) { } diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp index 09b1419d1c..833e9da0f3 100644 --- a/Kernel/Devices/Device.cpp +++ b/Kernel/Devices/Device.cpp @@ -25,32 +25,48 @@ */ #include <Kernel/Devices/Device.h> -#include <Kernel/Devices/HardwareEventsManager.h> +#include <Kernel/FileSystem/InodeMetadata.h> #include <LibC/errno_numbers.h> +static HashMap<u32, Device*>* s_all_devices; + +HashMap<u32, Device*>& Device::all_devices() +{ + if (s_all_devices == nullptr) + s_all_devices = new HashMap<u32, Device*>; + return *s_all_devices; +} + void Device::for_each(Function<void(Device&)> callback) { - for (auto* entry : HardwareEventsManager::the().get_devices_list()) { - ASSERT(entry != nullptr); - callback(*entry); - } + for (auto& entry : all_devices()) + callback(*entry.value); } Device* Device::get_device(unsigned major, unsigned minor) { - return HardwareEventsManager::the().get_device(major, minor); + auto it = all_devices().find(encoded_device(major, minor)); + if (it == all_devices().end()) + return nullptr; + return it->value; } -Device::Device(unsigned major, unsigned minor, u8 device_type) +Device::Device(unsigned major, unsigned minor) : m_major(major) , m_minor(minor) { - HardwareEventsManager::the().register_device(*this, device_type); + u32 device_id = encoded_device(major, minor); + auto it = all_devices().find(device_id); + if (it != all_devices().end()) { + dbg() << "Already registered " << major << "," << minor << ": " << it->value->class_name(); + } + ASSERT(!all_devices().contains(device_id)); + all_devices().set(device_id, this); } Device::~Device() { - HardwareEventsManager::the().unregister_device(*this); + all_devices().remove(encoded_device(m_major, m_minor)); } String Device::absolute_path() const diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index 4aadf49a9a..2ddd7720c8 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -39,11 +39,6 @@ #include <Kernel/FileSystem/File.h> #include <Kernel/UnixTypes.h> -enum class DEVICE_TYPE { - BLOCK_DEVICE = 1, - CHAR_DEVICE = 2 -}; - class Device : public File { public: virtual ~Device() override; @@ -60,17 +55,16 @@ public: virtual bool is_device() const override { return true; } virtual bool is_disk_device() const { return false; } - virtual bool is_block_device() const override { return false; } - virtual bool is_character_device() const override { return true; } - static void for_each(Function<void(Device&)>); static Device* get_device(unsigned major, unsigned minor); protected: - Device(unsigned major, unsigned minor, u8 device_type); + Device(unsigned major, unsigned minor); void set_uid(uid_t uid) { m_uid = uid; } void set_gid(gid_t gid) { m_gid = gid; } + static HashMap<u32, Device*>& all_devices(); + private: unsigned m_major { 0 }; unsigned m_minor { 0 }; diff --git a/Kernel/Devices/FloppyDiskDevice.cpp b/Kernel/Devices/FloppyDiskDevice.cpp index 8ad1ecf7d3..d0486f925c 100644 --- a/Kernel/Devices/FloppyDiskDevice.cpp +++ b/Kernel/Devices/FloppyDiskDevice.cpp @@ -109,7 +109,7 @@ const char* FloppyDiskDevice::class_name() const } FloppyDiskDevice::FloppyDiskDevice(FloppyDiskDevice::DriveType type) - : InterruptHandler(IRQ_FLOPPY_DRIVE) + : IRQHandler(IRQ_FLOPPY_DRIVE) , DiskDevice(89, (type == FloppyDiskDevice::DriveType::Master) ? 0 : 1, BYTES_PER_SECTOR) , m_io_base_addr((type == FloppyDiskDevice::DriveType::Master) ? 0x3F0 : 0x370) { @@ -167,7 +167,7 @@ bool FloppyDiskDevice::read_sectors_with_dma(u16 lba, u16 count, u8* outbuf) //while(start < PIT::seconds_since_boot() + 1) // ; - disable_interrupts(); + disable_irq(); IO::out8(0xA, FLOPPY_DMA_CHANNEL | 0x4); // Channel 2 SEL, MASK_ON = 1 IO::out8(0x0B, 0x56); // Begin DMA, Single Transfer, Increment, Auto, FDC -> RAM, Channel 2 @@ -195,7 +195,7 @@ bool FloppyDiskDevice::read_sectors_with_dma(u16 lba, u16 count, u8* outbuf) send_byte(0x1b); // GPL3 value. The Datasheet doesn't really specify the values for this properly... send_byte(0xff); - enable_interrupts(); + enable_irq(); wait_for_irq(); // TODO: See if there was a lockup here via some "timeout counter" m_interrupted = false; @@ -269,7 +269,7 @@ bool FloppyDiskDevice::write_sectors_with_dma(u16 lba, u16 count, const u8* inbu //while(start < PIT::seconds_since_boot() + 1) // ; - disable_interrupts(); + disable_irq(); IO::out8(0xA, FLOPPY_DMA_CHANNEL | 0x4); // Channel 2 SEL, MASK_ON = 1 IO::out8(0x0B, 0x5A); // Begin DMA, Single Transfer, Increment, Auto, RAM -> FDC, Channel 2 @@ -295,7 +295,7 @@ bool FloppyDiskDevice::write_sectors_with_dma(u16 lba, u16 count, const u8* inbu send_byte(0x1b); // GPL3 value. The Datasheet doesn't really specify the values for this properly... send_byte(0xff); - enable_interrupts(); + enable_irq(); wait_for_irq(); // TODO: See if there was a lockup here via some "timeout counter" m_interrupted = false; @@ -358,7 +358,7 @@ bool FloppyDiskDevice::wait_for_irq() return true; } -void FloppyDiskDevice::handle_interrupt() +void FloppyDiskDevice::handle_irq() { // The only thing we need to do is acknowledge the IRQ happened m_interrupted = true; @@ -512,7 +512,7 @@ void FloppyDiskDevice::initialize() kprintf("fdc: m_io_base = 0x%x IRQn = %d\n", m_io_base_addr, IRQ_FLOPPY_DRIVE); #endif - enable_interrupts(); + enable_irq(); // Get the version of the Floppy Disk Controller send_byte(FloppyCommand::Version); diff --git a/Kernel/Devices/FloppyDiskDevice.h b/Kernel/Devices/FloppyDiskDevice.h index b52c4b0b2d..2942f94227 100644 --- a/Kernel/Devices/FloppyDiskDevice.h +++ b/Kernel/Devices/FloppyDiskDevice.h @@ -99,7 +99,7 @@ #include <AK/RefPtr.h> #include <Kernel/Devices/DiskDevice.h> -#include <Kernel/InterruptHandler.h> +#include <Kernel/IRQHandler.h> #include <Kernel/Lock.h> #include <Kernel/VM/PhysicalAddress.h> #include <Kernel/VM/PhysicalPage.h> @@ -120,7 +120,7 @@ struct FloppyControllerCommand { // uses the Intel 82077A controller. More about this controller can // be found here: http://www.buchty.net/casio/files/82077.pdf // -class FloppyDiskDevice final : public InterruptHandler +class FloppyDiskDevice final : public IRQHandler , public DiskDevice { AK_MAKE_ETERNAL @@ -176,7 +176,7 @@ protected: private: // ^IRQHandler - void handle_interrupt(); + void handle_irq(); // ^DiskDevice virtual const char* class_name() const override; diff --git a/Kernel/Devices/HardwareEventsManager.cpp b/Kernel/Devices/HardwareEventsManager.cpp deleted file mode 100644 index f586ee0322..0000000000 --- a/Kernel/Devices/HardwareEventsManager.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <Kernel/Devices/HardwareEventsManager.h> - -static HardwareEventsManager* s_hardware_events_manager; - -HardwareEventsManager& HardwareEventsManager::the() -{ - if (s_hardware_events_manager == nullptr) { - s_hardware_events_manager = new HardwareEventsManager(); - } - return *s_hardware_events_manager; -} - -HashTable<Device*>& HardwareEventsManager::get_devices_list() -{ - return m_devices; -} - -void HardwareEventsManager::unregister_device(Device& device) -{ - get_devices_list().remove(&device); -} - -HardwareEventsManager::HardwareEventsManager() -{ -} - -Device* HardwareEventsManager::get_device(unsigned major, unsigned minor) -{ - for (auto* entry : HardwareEventsManager::get_devices_list()) { - ASSERT(entry != nullptr); - if (entry->major() == major && entry->minor() == minor) - return entry; - } - return nullptr; -} -void HardwareEventsManager::register_device(Device& device, u8) -{ - get_devices_list().set(&device); -} diff --git a/Kernel/Devices/HardwareEventsManager.h b/Kernel/Devices/HardwareEventsManager.h deleted file mode 100644 index b8b6c1f112..0000000000 --- a/Kernel/Devices/HardwareEventsManager.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include <AK/Types.h> -#include <Kernel/Devices/Device.h> - -class HardwareEventsManager { -public: - static HardwareEventsManager& the(); - void register_device(Device&, u8); - void unregister_device(Device&); - void register_device_event(); - Device* get_device(unsigned, unsigned); - HashTable<Device*>& get_devices_list(); - -private: - HashTable<Device*> m_devices; - HardwareEventsManager(); -}; diff --git a/Kernel/Devices/KeyboardDevice.cpp b/Kernel/Devices/KeyboardDevice.cpp index 5996e87566..86c862057e 100644 --- a/Kernel/Devices/KeyboardDevice.cpp +++ b/Kernel/Devices/KeyboardDevice.cpp @@ -483,7 +483,7 @@ void KeyboardDevice::key_state_changed(u8 raw, bool pressed) m_has_e0_prefix = false; } -void KeyboardDevice::handle_interrupt() +void KeyboardDevice::handle_irq() { for (;;) { u8 status = IO::in8(I8042_STATUS); @@ -551,7 +551,7 @@ KeyboardDevice& KeyboardDevice::the() } KeyboardDevice::KeyboardDevice() - : InterruptHandler(IRQ_KEYBOARD) + : IRQHandler(IRQ_KEYBOARD) , CharacterDevice(85, 1) { s_the = this; @@ -563,7 +563,7 @@ KeyboardDevice::KeyboardDevice() while (IO::in8(I8042_STATUS) & I8042_BUFFER_FULL) IO::in8(I8042_BUFFER); - enable_interrupts(); + enable_irq(); } KeyboardDevice::~KeyboardDevice() diff --git a/Kernel/Devices/KeyboardDevice.h b/Kernel/Devices/KeyboardDevice.h index a5b24b7b2d..a2c9b4e3a3 100644 --- a/Kernel/Devices/KeyboardDevice.h +++ b/Kernel/Devices/KeyboardDevice.h @@ -26,16 +26,16 @@ #pragma once +#include "IRQHandler.h" #include "KeyCode.h" #include <AK/CircularQueue.h> #include <AK/DoublyLinkedList.h> #include <AK/Types.h> #include <Kernel/Devices/CharacterDevice.h> -#include <Kernel/InterruptHandler.h> class KeyboardClient; -class KeyboardDevice final : public InterruptHandler +class KeyboardDevice final : public IRQHandler , public CharacterDevice { AK_MAKE_ETERNAL public: @@ -57,7 +57,7 @@ public: private: // ^IRQHandler - virtual void handle_interrupt() override; + virtual void handle_irq() override; // ^CharacterDevice virtual const char* class_name() const override { return "KeyboardDevice"; } diff --git a/Kernel/Devices/PATAChannel.cpp b/Kernel/Devices/PATAChannel.cpp index ee67eb7ff7..b57fe42c1c 100644 --- a/Kernel/Devices/PATAChannel.cpp +++ b/Kernel/Devices/PATAChannel.cpp @@ -112,25 +112,18 @@ static Lock& s_lock() return *lock; }; -OwnPtr<PATAChannel> PATAChannel::autodetect(ChannelType type, bool force_pio) +OwnPtr<PATAChannel> PATAChannel::create(ChannelType type, bool force_pio) { - PCI::Address found_address; - PCI::enumerate_all([&](const PCI::Address& address, PCI::ID id) { - if (PCI::get_class(address) == PCI_Mass_Storage_Class && PCI::get_subclass(address) == PCI_IDE_Controller_Subclass) { - found_address = address; - kprintf("PATAChannel: PATA Controller found! id=%w:%w\n", id.vendor_id, id.device_id); - } - }); - return make<PATAChannel>(found_address, type, force_pio); + return make<PATAChannel>(type, force_pio); } -PATAChannel::PATAChannel(PCI::Address pci_address, ChannelType type, bool force_pio) - : PCI::Device(pci_address, (type == ChannelType::Primary ? PATA_PRIMARY_IRQ : PATA_SECONDARY_IRQ)) +PATAChannel::PATAChannel(ChannelType type, bool force_pio) + : IRQHandler((type == ChannelType::Primary ? PATA_PRIMARY_IRQ : PATA_SECONDARY_IRQ)) , m_channel_number((type == ChannelType::Primary ? 0 : 1)) , m_io_base((type == ChannelType::Primary ? 0x1F0 : 0x170)) , m_control_base((type == ChannelType::Primary ? 0x3f6 : 0x376)) { - disable_interrupts(); + disable_irq(); m_dma_enabled.resource() = true; ProcFS::add_sys_bool("ide_dma", m_dma_enabled); @@ -147,8 +140,14 @@ PATAChannel::~PATAChannel() void PATAChannel::initialize(bool force_pio) { + PCI::enumerate_all([this](const PCI::Address& address, PCI::ID id) { + if (PCI::get_class(address) == PCI_Mass_Storage_Class && PCI::get_subclass(address) == PCI_IDE_Controller_Subclass) { + m_pci_address = address; + kprintf("PATAChannel: PATA Controller found! id=%w:%w\n", id.vendor_id, id.device_id); + } + }); - if (get_pci_address().is_null()) { + if (m_pci_address.is_null()) { kprintf("PATAChannel: PCI address was null; can not set up DMA\n"); return; } @@ -159,9 +158,9 @@ void PATAChannel::initialize(bool force_pio) } // Let's try to set up DMA transfers. - PCI::enable_bus_mastering(get_pci_address()); + PCI::enable_bus_mastering(m_pci_address); prdt().end_of_table = 0x8000; - m_bus_master_base = PCI::get_BAR4(get_pci_address()) & 0xfffc; + m_bus_master_base = PCI::get_BAR4(m_pci_address) & 0xfffc; m_dma_buffer_page = MM.allocate_supervisor_physical_page(); kprintf("PATAChannel: Bus master IDE: I/O @ %x\n", m_bus_master_base); } @@ -182,11 +181,12 @@ static void print_ide_status(u8 status) void PATAChannel::wait_for_irq() { cli(); - InterruptHandler::Enabler enabler(*this); + enable_irq(); current->wait_on(m_irq_queue); + disable_irq(); } -void PATAChannel::handle_interrupt() +void PATAChannel::handle_irq() { u8 status = IO::in8(m_io_base + ATA_REG_STATUS); if (status & ATA_SR_ERR) { diff --git a/Kernel/Devices/PATAChannel.h b/Kernel/Devices/PATAChannel.h index cee50d3928..829def7558 100644 --- a/Kernel/Devices/PATAChannel.h +++ b/Kernel/Devices/PATAChannel.h @@ -38,10 +38,9 @@ #include <AK/OwnPtr.h> #include <AK/RefPtr.h> -#include <Kernel/InterruptHandler.h> +#include <Kernel/IRQHandler.h> #include <Kernel/Lock.h> #include <Kernel/PCI/Access.h> -#include <Kernel/PCI/Device.h> #include <Kernel/VM/PhysicalAddress.h> #include <Kernel/VM/PhysicalPage.h> #include <Kernel/WaitQueue.h> @@ -53,7 +52,7 @@ struct PhysicalRegionDescriptor { }; class PATADiskDevice; -class PATAChannel final : public PCI::Device { +class PATAChannel final : public IRQHandler { friend class PATADiskDevice; AK_MAKE_ETERNAL public: @@ -63,8 +62,8 @@ public: }; public: - static OwnPtr<PATAChannel> autodetect(ChannelType type, bool force_pio); - PATAChannel(PCI::Address pci_address, ChannelType type, bool force_pio); + static OwnPtr<PATAChannel> create(ChannelType type, bool force_pio); + PATAChannel(ChannelType type, bool force_pio); virtual ~PATAChannel() override; RefPtr<PATADiskDevice> master_device() { return m_master; }; @@ -72,7 +71,7 @@ public: private: //^ IRQHandler - virtual void handle_interrupt() override; + virtual void handle_irq() override; void initialize(bool force_pio); void detect_disks(); @@ -91,6 +90,7 @@ private: WaitQueue m_irq_queue; + PCI::Address m_pci_address; PhysicalRegionDescriptor& prdt() { return *reinterpret_cast<PhysicalRegionDescriptor*>(m_prdt_page->paddr().offset(0xc0000000).as_ptr()); } RefPtr<PhysicalPage> m_prdt_page; RefPtr<PhysicalPage> m_dma_buffer_page; diff --git a/Kernel/Devices/PATADiskDevice.h b/Kernel/Devices/PATADiskDevice.h index d99de6518f..086c6d8467 100644 --- a/Kernel/Devices/PATADiskDevice.h +++ b/Kernel/Devices/PATADiskDevice.h @@ -31,7 +31,7 @@ #pragma once #include <Kernel/Devices/DiskDevice.h> -#include <Kernel/InterruptHandler.h> +#include <Kernel/IRQHandler.h> #include <Kernel/Lock.h> class PATAChannel; diff --git a/Kernel/Devices/PS2MouseDevice.cpp b/Kernel/Devices/PS2MouseDevice.cpp index fca9320412..6a1e178560 100644 --- a/Kernel/Devices/PS2MouseDevice.cpp +++ b/Kernel/Devices/PS2MouseDevice.cpp @@ -54,7 +54,7 @@ static PS2MouseDevice* s_the; PS2MouseDevice::PS2MouseDevice() - : InterruptHandler(IRQ_MOUSE) + : IRQHandler(IRQ_MOUSE) , CharacterDevice(10, 1) { s_the = this; @@ -70,7 +70,7 @@ PS2MouseDevice& PS2MouseDevice::the() return *s_the; } -void PS2MouseDevice::handle_interrupt() +void PS2MouseDevice::handle_irq() { for (;;) { u8 status = IO::in8(I8042_STATUS); @@ -242,7 +242,7 @@ void PS2MouseDevice::initialize_device() kprintf("PS2MouseDevice: No mouse wheel detected!\n"); } - enable_interrupts(); + enable_irq(); } void PS2MouseDevice::expect_ack() diff --git a/Kernel/Devices/PS2MouseDevice.h b/Kernel/Devices/PS2MouseDevice.h index e806b7fa83..6010bb6cef 100644 --- a/Kernel/Devices/PS2MouseDevice.h +++ b/Kernel/Devices/PS2MouseDevice.h @@ -28,10 +28,10 @@ #include <AK/CircularQueue.h> #include <Kernel/Devices/CharacterDevice.h> -#include <Kernel/InterruptHandler.h> +#include <Kernel/IRQHandler.h> #include <Kernel/MousePacket.h> -class PS2MouseDevice final : public InterruptHandler +class PS2MouseDevice final : public IRQHandler , public CharacterDevice { public: PS2MouseDevice(); @@ -47,7 +47,7 @@ public: private: // ^IRQHandler - virtual void handle_interrupt() override; + virtual void handle_irq() override; // ^CharacterDevice virtual const char* class_name() const override { return "PS2MouseDevice"; } diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp index 8150aaacda..f015adcc10 100644 --- a/Kernel/Devices/SB16.cpp +++ b/Kernel/Devices/SB16.cpp @@ -74,7 +74,7 @@ void SB16::set_sample_rate(uint16_t hz) static SB16* s_the; SB16::SB16() - : InterruptHandler(5) + : IRQHandler(5) , CharacterDevice(42, 42) // ### ? { s_the = this; @@ -92,7 +92,7 @@ SB16& SB16::the() void SB16::initialize() { - disable_interrupts(); + disable_irq(); IO::out8(0x226, 1); IO::delay(); @@ -153,7 +153,7 @@ void SB16::dma_start(uint32_t length) IO::out8(0xd4, (channel % 4)); } -void SB16::handle_interrupt() +void SB16::handle_irq() { // Stop sound output ready for the next block. dsp_write(0xd5); @@ -168,8 +168,9 @@ void SB16::handle_interrupt() void SB16::wait_for_irq() { cli(); - InterruptHandler::Enabler enabler(*this); + enable_irq(); current->wait_on(m_irq_queue); + disable_irq(); } ssize_t SB16::write(FileDescription&, const u8* data, ssize_t length) diff --git a/Kernel/Devices/SB16.h b/Kernel/Devices/SB16.h index 25c91cf59f..21df353222 100644 --- a/Kernel/Devices/SB16.h +++ b/Kernel/Devices/SB16.h @@ -28,14 +28,14 @@ #include <AK/CircularQueue.h> #include <Kernel/Devices/CharacterDevice.h> -#include <Kernel/InterruptHandler.h> +#include <Kernel/IRQHandler.h> #include <Kernel/VM/PhysicalAddress.h> #include <Kernel/VM/PhysicalPage.h> #include <Kernel/WaitQueue.h> class SB16; -class SB16 final : public InterruptHandler +class SB16 final : public IRQHandler , public CharacterDevice { public: SB16(); @@ -51,7 +51,7 @@ public: private: // ^IRQHandler - virtual void handle_interrupt() override; + virtual void handle_irq() override; // ^CharacterDevice virtual const char* class_name() const override { return "SB16"; } |