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:
Nico Weber 2021-09-17 11:00:46 -04:00 committed by Linus Groh
parent 3a24eb323f
commit d0b9c7a20b
Notes: sideshowbarker 2024-07-18 03:40:29 +09:00
4 changed files with 54 additions and 3 deletions

View 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;
}
}

View 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;
};
}

View file

@ -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();
}

View file

@ -13,6 +13,7 @@ if ("${SERENITY_ARCH}" STREQUAL "aarch64")
${SOURCES}
Arch/aarch64/MainIdRegister.cpp
Arch/aarch64/MMIO.cpp
Arch/aarch64/init.cpp
)
else()