diff options
author | Hendiadyoin1 <leon2002.la@gmail.com> | 2021-07-13 17:17:12 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-07-14 11:26:34 +0430 |
commit | d761c5024b20cb09a4052b3f0aaff60ea9d03b5e (patch) | |
tree | a73bf6643363bb2d49076fe6a531640ecb4415cc /Kernel/Bus/PCI | |
parent | b98e741237d6f3335a7c86d849818a4c0ab0d3a3 (diff) | |
download | serenity-d761c5024b20cb09a4052b3f0aaff60ea9d03b5e.zip |
AK: Generalize ByteReader
Also use it instead of CPU.h's possibly_unaligned_data interface
Diffstat (limited to 'Kernel/Bus/PCI')
-rw-r--r-- | Kernel/Bus/PCI/MMIOAccess.cpp | 9 | ||||
-rw-r--r-- | Kernel/Bus/PCI/WindowedMMIOAccess.cpp | 9 |
2 files changed, 10 insertions, 8 deletions
diff --git a/Kernel/Bus/PCI/MMIOAccess.cpp b/Kernel/Bus/PCI/MMIOAccess.cpp index d807cf71fb..f8d0945a1c 100644 --- a/Kernel/Bus/PCI/MMIOAccess.cpp +++ b/Kernel/Bus/PCI/MMIOAccess.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <AK/ByteReader.h> #include <AK/Optional.h> #include <Kernel/Arch/x86/InterruptDisabler.h> #include <Kernel/Bus/PCI/MMIOAccess.h> @@ -128,7 +129,7 @@ u16 MMIOAccess::read16_field(Address address, u32 field) VERIFY(field < 0xfff); dbgln_if(PCI_DEBUG, "PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address); u16 data = 0; - read_possibly_unaligned_data<u16>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), data); + ByteReader::load<u16>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), data); return data; } @@ -138,7 +139,7 @@ u32 MMIOAccess::read32_field(Address address, u32 field) VERIFY(field <= 0xffc); dbgln_if(PCI_DEBUG, "PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address); u32 data = 0; - read_possibly_unaligned_data<u32>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), data); + ByteReader::load<u32>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), data); return data; } @@ -154,14 +155,14 @@ void MMIOAccess::write16_field(Address address, u32 field, u16 value) ScopedSpinLock lock(m_access_lock); VERIFY(field < 0xfff); dbgln_if(PCI_DEBUG, "PCI: MMIO Writing 16-bit field {:#08x}, value={:#02x} for {}", field, value, address); - write_possibly_unaligned_data<u16>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), value); + ByteReader::store<u16>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), value); } void MMIOAccess::write32_field(Address address, u32 field, u32 value) { ScopedSpinLock lock(m_access_lock); VERIFY(field <= 0xffc); dbgln_if(PCI_DEBUG, "PCI: MMIO Writing 32-bit field {:#08x}, value={:#02x} for {}", field, value, address); - write_possibly_unaligned_data<u32>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), value); + ByteReader::store<u32>(get_device_configuration_space(address).offset(field & 0xfff).as_ptr(), value); } void MMIOAccess::enumerate_hardware(Function<void(Address, ID)> callback) diff --git a/Kernel/Bus/PCI/WindowedMMIOAccess.cpp b/Kernel/Bus/PCI/WindowedMMIOAccess.cpp index 181d8e9920..ef1503553f 100644 --- a/Kernel/Bus/PCI/WindowedMMIOAccess.cpp +++ b/Kernel/Bus/PCI/WindowedMMIOAccess.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <AK/ByteReader.h> #include <AK/Optional.h> #include <AK/StringView.h> #include <Kernel/Arch/x86/InterruptDisabler.h> @@ -79,7 +80,7 @@ u16 WindowedMMIOAccess::read16_field(Address address, u32 field) VERIFY(field < 0xfff); dbgln_if(PCI_DEBUG, "PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address); u16 data = 0; - read_possibly_unaligned_data<u16>(get_device_configuration_space(address).value().offset(field & 0xfff).as_ptr(), data); + ByteReader::load<u16>(get_device_configuration_space(address).value().offset(field & 0xfff).as_ptr(), data); return data; } @@ -89,7 +90,7 @@ u32 WindowedMMIOAccess::read32_field(Address address, u32 field) VERIFY(field <= 0xffc); dbgln_if(PCI_DEBUG, "PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address); u32 data = 0; - read_possibly_unaligned_data<u32>(get_device_configuration_space(address).value().offset(field & 0xfff).as_ptr(), data); + ByteReader::load<u32>(get_device_configuration_space(address).value().offset(field & 0xfff).as_ptr(), data); return data; } @@ -105,14 +106,14 @@ void WindowedMMIOAccess::write16_field(Address address, u32 field, u16 value) InterruptDisabler disabler; VERIFY(field < 0xfff); dbgln_if(PCI_DEBUG, "PCI: MMIO Writing 16-bit field {:#08x}, value={:#02x} for {}", field, value, address); - write_possibly_unaligned_data<u16>(get_device_configuration_space(address).value().offset(field & 0xfff).as_ptr(), value); + ByteReader::store<u16>(get_device_configuration_space(address).value().offset(field & 0xfff).as_ptr(), value); } void WindowedMMIOAccess::write32_field(Address address, u32 field, u32 value) { InterruptDisabler disabler; VERIFY(field <= 0xffc); dbgln_if(PCI_DEBUG, "PCI: MMIO Writing 32-bit field {:#08x}, value={:#02x} for {}", field, value, address); - write_possibly_unaligned_data<u32>(get_device_configuration_space(address).value().offset(field & 0xfff).as_ptr(), value); + ByteReader::store<u32>(get_device_configuration_space(address).value().offset(field & 0xfff).as_ptr(), value); } } |