1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-29 20:17:46 +00:00

Kernel/aarch64: Access MMIO using mapping in high virtual memory

This ensures that we can unmap the identity mapping of the kernel in
physical memory.
This commit is contained in:
Timon Kruiper 2023-01-07 11:40:23 +01:00 committed by Linus Groh
parent 91d0451999
commit 5db32ecbe1
3 changed files with 12 additions and 7 deletions

View file

@ -14,7 +14,7 @@ MMIO::MMIO()
{
MainIdRegister id;
if (id.part_num() <= MainIdRegister::RaspberryPi3)
m_base_address = 0x3F00'0000;
m_base_address = PhysicalAddress(0x3F00'0000);
}
MMIO& MMIO::the()

View file

@ -7,6 +7,8 @@
#pragma once
#include <AK/Types.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/Sections.h>
namespace Kernel::RPi {
@ -21,17 +23,20 @@ public:
u32 read(FlatPtr offset) { return *peripheral_address(offset); }
void write(FlatPtr offset, u32 value) { *peripheral_address(offset) = value; }
u32 volatile* peripheral_address(FlatPtr offset) { return (u32 volatile*)(m_base_address + offset); }
// FIXME: The MMIO region is currently mapped at kernel_mapping_base + peripheral_base_address(),
// but the code should be changed to use the MemoryManager to map the physical memory instead
// of pre-mapping the whole MMIO region.
u32 volatile* peripheral_address(FlatPtr offset) { return (u32 volatile*)(kernel_mapping_base + m_base_address.get() + offset); }
template<class T>
T volatile* peripheral(FlatPtr offset) { return (T volatile*)peripheral_address(offset); }
FlatPtr peripheral_base_address() const { return m_base_address; }
FlatPtr peripheral_end_address() const { return m_base_address + 0x00FFFFFF; }
PhysicalAddress peripheral_base_address() const { return m_base_address; }
PhysicalAddress peripheral_end_address() const { return m_base_address.offset(0x00FFFFFF); }
private:
MMIO();
unsigned int m_base_address;
PhysicalAddress m_base_address;
};
}