mirror of
https://github.com/RGBCube/serenity
synced 2025-06-27 14:02:11 +00:00
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.
This commit is contained in:
parent
3a24eb323f
commit
d0b9c7a20b
4 changed files with 54 additions and 3 deletions
26
Kernel/Prekernel/Arch/aarch64/MMIO.cpp
Normal file
26
Kernel/Prekernel/Arch/aarch64/MMIO.cpp
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
25
Kernel/Prekernel/Arch/aarch64/MMIO.h
Normal file
25
Kernel/Prekernel/Arch/aarch64/MMIO.h
Normal file
|
@ -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;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -5,15 +5,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/Types.h>
|
#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 halt();
|
||||||
|
|
||||||
extern "C" [[noreturn]] void init();
|
extern "C" [[noreturn]] void init();
|
||||||
extern "C" [[noreturn]] void init()
|
extern "C" [[noreturn]] void init()
|
||||||
{
|
{
|
||||||
Prekernel::MainIdRegister id;
|
[[maybe_unused]] auto& MMIO = Prekernel::MMIO::the();
|
||||||
[[maybe_unused]] unsigned part_num = id.part_num();
|
|
||||||
halt();
|
halt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ if ("${SERENITY_ARCH}" STREQUAL "aarch64")
|
||||||
|
|
||||||
${SOURCES}
|
${SOURCES}
|
||||||
Arch/aarch64/MainIdRegister.cpp
|
Arch/aarch64/MainIdRegister.cpp
|
||||||
|
Arch/aarch64/MMIO.cpp
|
||||||
Arch/aarch64/init.cpp
|
Arch/aarch64/init.cpp
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue