summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2021-09-17 11:00:46 -0400
committerLinus Groh <mail@linusgroh.de>2021-09-19 17:45:59 +0200
commitd0b9c7a20b2518f268c055c86427404bdae3a12c (patch)
tree8b88c0c3ccc856bf90a88c9bae7792e236175015 /Kernel
parent3a24eb323f5065371516cf154fc152329b9998e1 (diff)
downloadserenity-d0b9c7a20b2518f268c055c86427404bdae3a12c.zip
Kernel: Add a MMIO class for aarch64
It doesn't do anything yet except figure out the peripheral base address. Very likely belongs in Kernel, not Prekernel, eventually.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Prekernel/Arch/aarch64/MMIO.cpp26
-rw-r--r--Kernel/Prekernel/Arch/aarch64/MMIO.h25
-rw-r--r--Kernel/Prekernel/Arch/aarch64/init.cpp5
-rw-r--r--Kernel/Prekernel/CMakeLists.txt1
4 files changed, 54 insertions, 3 deletions
diff --git a/Kernel/Prekernel/Arch/aarch64/MMIO.cpp b/Kernel/Prekernel/Arch/aarch64/MMIO.cpp
new file mode 100644
index 0000000000..2cfdec17fc
--- /dev/null
+++ b/Kernel/Prekernel/Arch/aarch64/MMIO.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2021, Nico Weber <thakis@chromium.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <Kernel/Prekernel/Arch/aarch64/MMIO.h>
+#include <Kernel/Prekernel/Arch/aarch64/MainIdRegister.h>
+
+namespace Prekernel {
+
+MMIO::MMIO()
+ : m_base_address(0xFE00'0000)
+{
+ MainIdRegister id;
+ if (id.part_num() <= MainIdRegister::RaspberryPi3)
+ m_base_address = 0x3F00'0000;
+}
+
+MMIO& MMIO::the()
+{
+ static MMIO instance;
+ return instance;
+}
+
+}
diff --git a/Kernel/Prekernel/Arch/aarch64/MMIO.h b/Kernel/Prekernel/Arch/aarch64/MMIO.h
new file mode 100644
index 0000000000..39f662641f
--- /dev/null
+++ b/Kernel/Prekernel/Arch/aarch64/MMIO.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2021, Nico Weber <thakis@chromium.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+namespace Prekernel {
+
+// Knows about memory-mapped IO addresses on the Broadcom family of SOCs used in Raspberry Pis.
+// RPi3 is the first Raspberry Pi that supports aarch64.
+// https://datasheets.raspberrypi.org/bcm2836/bcm2836-peripherals.pdf (RPi3)
+// https://datasheets.raspberrypi.org/bcm2711/bcm2711-peripherals.pdf (RPi4 Model B)
+class MMIO {
+public:
+ static MMIO& the();
+
+private:
+ MMIO();
+
+ unsigned int m_base_address;
+};
+
+}
diff --git a/Kernel/Prekernel/Arch/aarch64/init.cpp b/Kernel/Prekernel/Arch/aarch64/init.cpp
index 70b5e42ef6..4a61464d60 100644
--- a/Kernel/Prekernel/Arch/aarch64/init.cpp
+++ b/Kernel/Prekernel/Arch/aarch64/init.cpp
@@ -5,15 +5,14 @@
*/
#include <AK/Types.h>
-#include <Kernel/Prekernel/Arch/aarch64/MainIdRegister.h>
+#include <Kernel/Prekernel/Arch/aarch64/MMIO.h>
extern "C" [[noreturn]] void halt();
extern "C" [[noreturn]] void init();
extern "C" [[noreturn]] void init()
{
- Prekernel::MainIdRegister id;
- [[maybe_unused]] unsigned part_num = id.part_num();
+ [[maybe_unused]] auto& MMIO = Prekernel::MMIO::the();
halt();
}
diff --git a/Kernel/Prekernel/CMakeLists.txt b/Kernel/Prekernel/CMakeLists.txt
index 4a3e031795..a13ee09f0d 100644
--- a/Kernel/Prekernel/CMakeLists.txt
+++ b/Kernel/Prekernel/CMakeLists.txt
@@ -13,6 +13,7 @@ if ("${SERENITY_ARCH}" STREQUAL "aarch64")
${SOURCES}
Arch/aarch64/MainIdRegister.cpp
+ Arch/aarch64/MMIO.cpp
Arch/aarch64/init.cpp
)
else()