Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 90 additions & 119 deletions libplatsupport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,154 +14,130 @@ project(libplatsupport C)
# Some projects in particular that need to be fixed:
# - rumprun-sel4-demoapps
if(NOT ${PLATSUPPORT_HELPERS} STREQUAL "")
include(${PLATSUPPORT_HELPERS})
include(${PLATSUPPORT_HELPERS})
endif()

set(configure_string "")

config_choice(
LibPlatSupportX86ConsoleDevice
LIB_PLAT_SUPPORT_X86_CONSOLE_DEVICE
"X86 console device. The serial port that libplatsupport will use for communication \
LibPlatSupportX86ConsoleDevice
LIB_PLAT_SUPPORT_X86_CONSOLE_DEVICE
"X86 console device. The serial port that libplatsupport will use for communication \
com1 -> 0x3f8 \
com2 -> 0x2f8 \
com3 -> 0x3e8 \
com4 -> 0x2e8 \
ega -> 80x25 text mode ega screen"
"com1;LibPlatSupportX86ConsoleDeviceCom1;LIB_PLAT_SUPPORT_SERIAL_PORT_X86_COM1;KernelPlatPC99"
"com2;LibPlatSupportX86ConsoleDeviceCom2;LIB_PLAT_SUPPORT_SERIAL_PORT_X86_COM2;KernelPlatPC99"
"com3;LibPlatSupportX86ConsoleDeviceCom3;LIB_PLAT_SUPPORT_SERIAL_PORT_X86_COM3;KernelPlatPC99"
"com4;LibPlatSupportX86ConsoleDeviceCom4;LIB_PLAT_SUPPORT_SERIAL_PORT_X86_COM4;KernelPlatPC99"
"ega;LibPlatSupportX86ConsoleDeviceEGA;LIB_PLAT_SUPPORT_SERIAL_TEXT_EGA;KernelPlatPC99"
)
"com1;LibPlatSupportX86ConsoleDeviceCom1;LIB_PLAT_SUPPORT_SERIAL_PORT_X86_COM1;KernelPlatPC99"
"com2;LibPlatSupportX86ConsoleDeviceCom2;LIB_PLAT_SUPPORT_SERIAL_PORT_X86_COM2;KernelPlatPC99"
"com3;LibPlatSupportX86ConsoleDeviceCom3;LIB_PLAT_SUPPORT_SERIAL_PORT_X86_COM3;KernelPlatPC99"
"com4;LibPlatSupportX86ConsoleDeviceCom4;LIB_PLAT_SUPPORT_SERIAL_PORT_X86_COM4;KernelPlatPC99"
"ega;LibPlatSupportX86ConsoleDeviceEGA;LIB_PLAT_SUPPORT_SERIAL_TEXT_EGA;KernelPlatPC99")

config_choice(
LibPlatSupportLPTMRclock
LIB_PLAT_SUPPORT_LPTMR_CLOCK
"Which input clock to use for the Low Power Timer\
LibPlatSupportLPTMRclock
LIB_PLAT_SUPPORT_LPTMR_CLOCK
"Which input clock to use for the Low Power Timer\
32.768 kHz -> High accuracy, but low precision.\
24 MHz -> Higher precision, but lower accuracy. Synchronous with the scheduling clock."
"32kHz;LibPlatSupportLPTMRclock24MHz;LIB_PLAT_SUPPORT_LPTMR_CLOCK_32kHZ;KernelPlatformIMX93"
"24MHz;LibPlatSupportLPTMRclock32kHz;LIB_PLAT_SUPPORT_LPTMR_CLOCK_24MHz;KernelPlatformIMX93"
)
"32kHz;LibPlatSupportLPTMRclock24MHz;LIB_PLAT_SUPPORT_LPTMR_CLOCK_32kHZ;KernelPlatformIMX93"
"24MHz;LibPlatSupportLPTMRclock32kHz;LIB_PLAT_SUPPORT_LPTMR_CLOCK_24MHz;KernelPlatformIMX93")

mark_as_advanced(CLEAR LibPlatSupportX86ConsoleDevice LibPlatSupportLPTMRclock)

# Some platforms don't have a platform timer.
if((KernelPlatformQEMUArmVirt AND NOT (KernelArmExportPCNTUser AND KernelArmExportPTMRUser))
OR KernelPlatformRocketchip
OR KernelPlatformRocketchipZCU102
OR KernelPlatformCheshire
OR (SIMULATION AND (KernelArchRiscV OR KernelArchARM))
)
set(LibPlatSupportHaveTimer OFF)
OR KernelPlatformRocketchip OR KernelPlatformRocketchipZCU102 OR KernelPlatformCheshire
OR (SIMULATION AND (KernelArchRiscV OR KernelArchARM)))
set(LibPlatSupportHaveTimer OFF)
else()
set(LibPlatSupportHaveTimer ON)
set(LibPlatSupportHaveTimer ON)
endif()

config_option(
LibPlatSupportHaveTimer LIB_PLAT_SUPPORT_HAVE_TIMER
"Indicates that this platform has support for platform ltimers" DEFAULT ON
)
config_option(LibPlatSupportHaveTimer LIB_PLAT_SUPPORT_HAVE_TIMER
"Indicates that this platform has support for platform ltimers" DEFAULT ON)

mark_as_advanced(LibPlatSupportHaveTimer)

set(LibPlatSupportMach "")
if(KernelPlatformRpi3 OR KernelPlatformRpi4)
set(LibPlatSupportMach "bcm")
if(KernelPlatformRpi3 OR KernelPlatformRpi4 OR KernelPlatformRpi5)
set(LibPlatSupportMach "bcm")
elseif(KernelPlatformCheshire OR KernelPlatformAriane)
set(LibPlatSupportMach "cva6")
set(LibPlatSupportMach "cva6")
elseif(KernelPlatformHifiveP550)
set(LibPlatSupportMach "eswin")
set(LibPlatSupportMach "eswin")
elseif(KernelPlatformBananapiF3)
set(LibPlatSupportMach "spacemit")
set(LibPlatSupportMach "spacemit")
elseif(KernelPlatformRockpro64 OR KernelPlatformRock3b)
set(LibPlatSupportMach "rockchip")
set(LibPlatSupportMach "rockchip")
elseif(NOT ${KernelArmMach} STREQUAL "")
# falling back to kernel settings is done to keep legacy compatibility
set(LibPlatSupportMach "${KernelArmMach}")
# falling back to kernel settings is done to keep legacy compatibility
set(LibPlatSupportMach "${KernelArmMach}")
endif()

file(GLOB deps src/plat/${KernelPlatform}/*.c src/*.c src/plat/${KernelPlatform}/acpi/*.c)

if(NOT ${LibPlatSupportMach} STREQUAL "")
file(GLOB lib_deps "src/mach/${LibPlatSupportMach}/*.c")
list(APPEND deps ${lib_deps})
file(GLOB lib_deps "src/mach/${LibPlatSupportMach}/*.c")
list(APPEND deps ${lib_deps})
endif()

if(KernelArchARM)
list(APPEND deps src/arch/arm/clock.c)
list(APPEND deps src/arch/arm/delay.c)
list(APPEND deps src/arch/arm/dma330.c)
list(APPEND deps src/arch/arm/i2c.c)
list(APPEND deps src/arch/arm/i2c_bitbang.c)
list(APPEND deps src/arch/arm/generic_timer.c)
list(APPEND deps src/arch/arm/irqchip/gic.c)
list(APPEND deps src/arch/arm/irqchip/tegra.c)
list(APPEND deps src/arch/arm/irqchip/gicv3.c)
list(APPEND deps src/arch/arm/irqchip/omap3.c)
# Link the IRQ chip parser modules
list(APPEND irqchip_modules
"-Wl,--undefined=arm_gic_ptr,--undefined=tegra_ictlr_ptr,--undefined=arm_gicv3_ptr,\
--undefined=fsl_avic_ptr,--undefined=ti_omap3_ptr"
)
list(APPEND deps src/arch/arm/clock.c)
list(APPEND deps src/arch/arm/delay.c)
list(APPEND deps src/arch/arm/dma330.c)
list(APPEND deps src/arch/arm/i2c.c)
list(APPEND deps src/arch/arm/i2c_bitbang.c)
list(APPEND deps src/arch/arm/generic_timer.c)
list(APPEND deps src/arch/arm/irqchip/gic.c)
list(APPEND deps src/arch/arm/irqchip/tegra.c)
list(APPEND deps src/arch/arm/irqchip/gicv3.c)
list(APPEND deps src/arch/arm/irqchip/omap3.c)
# Link the IRQ chip parser modules
list(APPEND irqchip_modules
"-Wl,--undefined=arm_gic_ptr,--undefined=tegra_ictlr_ptr,--undefined=arm_gicv3_ptr,\
--undefined=fsl_avic_ptr,--undefined=ti_omap3_ptr")
elseif(KernelArchX86)
list(APPEND deps src/arch/x86/delay.c)
list(APPEND deps src/arch/x86/tsc.c)
list(APPEND deps src/arch/x86/delay.c)
list(APPEND deps src/arch/x86/tsc.c)
elseif(KernelArchRiscV)
list(APPEND deps src/arch/riscv/irqchip/plic.c)
list(APPEND irqchip_modules "-Wl,--undefined=riscv_plic_ptr")
list(APPEND deps src/arch/riscv/irqchip/plic.c)
list(APPEND irqchip_modules "-Wl,--undefined=riscv_plic_ptr")
else()
message(FATAL_ERROR "Unsupported KernelArch '${KernelArch}'")
message(FATAL_ERROR "Unsupported KernelArch '${KernelArch}'")
endif()

if(KernelPlatformQEMUArmVirt
OR KernelPlatformQuartz64
OR KernelPlatformIMX93
)
if(KernelArmExportPCNTUser AND KernelArmExportPTMRUser)
list(APPEND deps src/arch/arm/generic_ltimer.c)
endif()
if(KernelPlatformQEMUArmVirt OR KernelPlatformQuartz64 OR KernelPlatformIMX93)
if(KernelArmExportPCNTUser AND KernelArmExportPTMRUser)
list(APPEND deps src/arch/arm/generic_ltimer.c)
endif()
endif()

if(KernelPlatformExynos5422)
list(APPEND deps src/mach/${LibPlatSupportMach}/clock/exynos_5422_clock.c)
elseif(
KernelPlatformExynos4
OR KernelPlatformExynos5410
OR KernelPlatformExynos5250
)
list(APPEND deps src/mach/${LibPlatSupportMach}/clock/exynos_common_clock.c)
list(APPEND deps src/mach/${LibPlatSupportMach}/clock/exynos_5422_clock.c)
elseif(KernelPlatformExynos4 OR KernelPlatformExynos5410 OR KernelPlatformExynos5250)
list(APPEND deps src/mach/${LibPlatSupportMach}/clock/exynos_common_clock.c)
endif()

if(KernelPlatImx6 OR KernelPlatformImx7Sabre)
list(APPEND deps src/mach/${LibPlatSupportMach}/epit/epit.c)
list(APPEND deps src/mach/${LibPlatSupportMach}/epit/epit.c)
endif()

if(KernelPlatImx6
OR KernelPlatformImx7Sabre
OR KernelPlatformImx8mq-evk
OR KernelPlatformImx8mm-evk
OR KernelPlatformImx8mp-evk
OR KernelPlatformMaaxboard
)
list(APPEND deps src/mach/${LibPlatSupportMach}/serial/serial.c)
if(KernelPlatImx6 OR KernelPlatformImx7Sabre OR KernelPlatformImx8mq-evk OR KernelPlatformImx8mm-evk
OR KernelPlatformImx8mp-evk OR KernelPlatformMaaxboard)
list(APPEND deps src/mach/${LibPlatSupportMach}/serial/serial.c)
endif()

if(KernelPlatImx8mq
OR KernelPlatformImx8mm-evk
OR KernelPlatformImx8mp-evk
)
list(APPEND deps src/plat/imx8m/chardev.c)
# There's no clock driver at the moment, but this is to allow the
# libethdrivers to build for imx8mq
list(APPEND deps src/plat/imx8m/clock.c)
if(KernelPlatImx8mq OR KernelPlatformImx8mm-evk OR KernelPlatformImx8mp-evk)
list(APPEND deps src/plat/imx8m/chardev.c)
# There's no clock driver at the moment, but this is to allow the
# libethdrivers to build for imx8mq
list(APPEND deps src/plat/imx8m/clock.c)
endif()

if(KernelPlatPC99)
set_source_files_properties(
src/plat/pc99/keyboard_vkey.c PROPERTIES COMPILE_FLAGS -Wno-initializer-overrides
)
set_source_files_properties(src/plat/pc99/keyboard_vkey.c PROPERTIES COMPILE_FLAGS
-Wno-initializer-overrides)
endif()

list(SORT deps)
Expand All @@ -170,47 +146,42 @@ add_config_library(platsupport "${configure_string}")

add_library(platsupport EXCLUDE_FROM_ALL ${deps})

if(KernelPlatImx8mq
OR KernelPlatformImx8mm-evk
OR KernelPlatformImx8mp-evk
)
if(KernelPlatformImx8mp-evk)
# For the imx8mp, the DTS is in a different format compared to those of
# the imx8mm and imx8mq, there are some constants in the headers that
# point to the proper path
target_compile_definitions(platsupport PRIVATE USE_IMX8MP_GPT_PATH)
endif()
target_include_directories(platsupport PUBLIC plat_include/imx8m)
if(KernelPlatImx8mq OR KernelPlatformImx8mm-evk OR KernelPlatformImx8mp-evk)
if(KernelPlatformImx8mp-evk)
# For the imx8mp, the DTS is in a different format compared to those of
# the imx8mm and imx8mq, there are some constants in the headers that
# point to the proper path
target_compile_definitions(platsupport PRIVATE USE_IMX8MP_GPT_PATH)
endif()
target_include_directories(platsupport PUBLIC plat_include/imx8m)
endif()

if(KernelPlatformZynqmp)
# This still needs to be cleaned up, so there is a mach folder "zynqmp" and
# the board specific folders "zcu102" and "ultra96". Then we don't need to
# include this folder here explicitly
target_include_directories(platsupport PUBLIC plat_include/zynqmp)
# This still needs to be cleaned up, so there is a mach folder "zynqmp" and
# the board specific folders "zcu102" and "ultra96". Then we don't need to
# include this folder here explicitly
target_include_directories(platsupport PUBLIC plat_include/zynqmp)
endif()

if(NOT "${LibPlatSupportMach}" STREQUAL "")
target_include_directories(platsupport PUBLIC mach_include/${LibPlatSupportMach})
target_include_directories(platsupport PUBLIC mach_include/${LibPlatSupportMach})
endif()

# special handling for "arm_hyp", it's an add-on-hack over "aarch32"
set(_inc_folder_KernelSel4Arch "${KernelSel4Arch}")
if("${KernelSel4Arch}" STREQUAL "arm_hyp")
set(_inc_folder_KernelSel4Arch "aarch32")
set(_inc_folder_KernelSel4Arch "aarch32")
endif()

target_include_directories(
platsupport PUBLIC include plat_include/${KernelPlatform}
sel4_arch_include/${_inc_folder_KernelSel4Arch} arch_include/${KernelArch}
)
platsupport PUBLIC include plat_include/${KernelPlatform}
sel4_arch_include/${_inc_folder_KernelSel4Arch} arch_include/${KernelArch})

target_link_libraries(
platsupport
muslc
utils
fdt
sel4_autoconf
platsupport_Config
${irqchip_modules}
)
platsupport
muslc
utils
fdt
sel4_autoconf
platsupport_Config
${irqchip_modules})
4 changes: 2 additions & 2 deletions libplatsupport/include/platsupport/fdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* RISCV does have 128 bits but there are no platforms that use that bit length (yet) */
#define READ_CELL32(addr) fdt32_ld(addr)
#define READ_CELL64(addr) fdt64_ld(addr)
#define READ_CELL(size, addr, offset) (size == 2 ? READ_CELL64(addr + (offset * sizeof(uint32_t))) : \
READ_CELL32(addr + (offset * sizeof(uint32_t))))
#define READ_CELL(size, addr, offset) (size == 2 ? READ_CELL64((addr) + ((offset) * sizeof(uint32_t))) : \
READ_CELL32((addr) + ((offset) * sizeof(uint32_t))))

/*
* Type of the callback function that is called for each device register instance
Expand Down
17 changes: 17 additions & 0 deletions libplatsupport/plat_include/bcm2712/platsupport/plat/clock.h
Comment thread
Ivan-Velickovic marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2017, Data61, CSIRO (ABN 41 687 119 230)
* Copyright (C) 2021, Hensoldt Cyber GmbH
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once

enum clk_id {
CLK_MASTER,
/* ----- */
NCLOCKS,
};

enum clock_gate {
NCLKGATES
};
10 changes: 10 additions & 0 deletions libplatsupport/plat_include/bcm2712/platsupport/plat/gpio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (C) 2021, HENSOLDT Cyber GmbH
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once

#include <utils/util.h>
#include <platsupport/gpio.h>
11 changes: 11 additions & 0 deletions libplatsupport/plat_include/bcm2712/platsupport/plat/i2c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright 2017, Data61, CSIRO (ABN 41 687 119 230)
* Copyright (C) 2021, Hensoldt Cyber GmbH
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once

enum i2c_id {
NI2C
};
12 changes: 12 additions & 0 deletions libplatsupport/plat_include/bcm2712/platsupport/plat/mailbox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (C) 2021, HENSOLDT Cyber GmbH
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once

#include <platsupport/mach/mailbox.h>

#define MAILBOX_PADDR 0x107c013880
#define MAILBOX_SIZE 0x1000
34 changes: 34 additions & 0 deletions libplatsupport/plat_include/bcm2712/platsupport/plat/serial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2025, UNSW
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once

#include <autoconf.h>
#include <platsupport/gen_config.h>

/* Corresponds to the Device Tree node '/soc@107c000000/serial@7d001000' */
#define PL011_UART_BASE 0x107d001000

#define UART0_OFFSET 0x0 // UART0: PL011

#define UART0_PADDR (PL011_UART_BASE)

#define UART0_IRQ 153

#define DEFAULT_SERIAL_PADDR UART0_PADDR
#define DEFAULT_SERIAL_INTERRUPT UART0_IRQ

enum chardev_id {
BCM2xxx_UART0,

NUM_CHARDEV,

/* Aliases */
PS_SERIAL0 = BCM2xxx_UART0,

/* Defaults */
PS_SERIAL_DEFAULT = BCM2xxx_UART0
};
Loading