20 #include "pedigree/kernel/processor/MemoryMappedIo.h" 21 #include "pedigree/kernel/processor/Processor.h" 22 #include "pedigree/kernel/utilities/utility.h" 24 MemoryMappedIo::MemoryMappedIo(
25 const char *pName, uintptr_t offset, uintptr_t padding)
41 #if defined(ADDITIONAL_CHECKS) 46 return *
reinterpret_cast<volatile uint8_t *
>(
47 adjust_pointer(virtualAddress(), (offset * m_Padding) + m_Offset));
52 #if defined(ADDITIONAL_CHECKS) 53 if ((offset + 1) >= size())
57 return *
reinterpret_cast<volatile uint16_t *
>(
58 adjust_pointer(virtualAddress(), (offset * m_Padding) + m_Offset));
63 #if defined(ADDITIONAL_CHECKS) 64 if ((offset + 3) >= size())
68 return *
reinterpret_cast<volatile uint32_t *
>(
69 adjust_pointer(virtualAddress(), (offset * m_Padding) + m_Offset));
74 #if defined(ADDITIONAL_CHECKS) 75 if ((offset + 7) >= size())
79 return *
reinterpret_cast<volatile uint64_t *
>(
80 adjust_pointer(virtualAddress(), (offset * m_Padding) + m_Offset));
85 #if defined(ADDITIONAL_CHECKS) 90 *
reinterpret_cast<volatile uint8_t *
>(adjust_pointer(
91 virtualAddress(), (offset * m_Padding) + m_Offset)) = value;
96 #if defined(ADDITIONAL_CHECKS) 97 if ((offset + 1) >= size())
101 *
reinterpret_cast<volatile uint16_t *
>(adjust_pointer(
102 virtualAddress(), (offset * m_Padding) + m_Offset)) = value;
107 #if defined(ADDITIONAL_CHECKS) 108 if ((offset + 3) >= size())
112 *
reinterpret_cast<volatile uint32_t *
>(adjust_pointer(
113 virtualAddress(), (offset * m_Padding) + m_Offset)) = value;
118 #if defined(ADDITIONAL_CHECKS) 119 if ((offset + 7) >= size())
123 *
reinterpret_cast<volatile uint64_t *
>(adjust_pointer(
124 virtualAddress(), (offset * m_Padding) + m_Offset)) = value;
127 MemoryMappedIo::operator bool()
const 129 return MemoryRegion::operator bool();
virtual void write64(uint64_t value, size_t offset=0)
virtual uint64_t read64(size_t offset=0)
virtual void write16(uint16_t value, size_t offset=0)
virtual size_t size() const
Abstrace base class for hardware I/O capabilities.
virtual uint8_t read8(size_t offset=0)
virtual void write32(uint32_t value, size_t offset=0)
Special memory entity in the kernel's virtual address space.
virtual uint16_t read16(size_t offset=0)
virtual void write8(uint8_t value, size_t offset=0)
virtual ~MemoryMappedIo()
virtual uint32_t read32(size_t offset=0)