Skip to content

Commit

Permalink
WIP: Add support for RPI5 platform
Browse files Browse the repository at this point in the history
This is early development variant. You will need hacked TF-A to use this.

Signed-off-by: Volodymyr Babchuk <[email protected]>
  • Loading branch information
lorc committed May 20, 2024
1 parent 9b1d1cf commit 725e39e
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
38 changes: 38 additions & 0 deletions core/arch/arm/plat-rpi5/conf.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
include core/arch/arm/cpu/cortex-armv8-0.mk

$(call force,CFG_TEE_CORE_NB_CORE,4)
$(call force,CFG_ARM64_core,y)
$(call force,CFG_WITH_LPAE,y)
$(call force,CFG_AUTO_MAX_PA_BITS,y)
$(call force,CFG_LPAE_ADDR_SPACE_BITS,40)

CFG_SHMEM_START ?= 0x08000000
CFG_SHMEM_SIZE ?= 0x00400000
CFG_TZDRAM_START ?= 0x1FE000000
CFG_TZDRAM_SIZE ?= 0x002000000
CFG_TEE_RAM_VA_SIZE ?= 0x00700000
CFG_DT ?= y
CFG_DTB_MAX_SIZE ?= 0x20000

# TODO: support arm32
supported-ta-targets = ta_arm64

$(call force,CFG_PL011,y)
$(call force,CFG_SECURE_TIME_SOURCE_CNTPCT,y)
$(call force,CFG_WITH_ARM_TRUSTED_FW,y)

CFG_NUM_THREADS ?= 4
CFG_CRYPTO_WITH_CE ?= n

CFG_TEE_CORE_EMBED_INTERNAL_TESTS ?= y
CFG_WITH_STACK_CANARIES ?= y
CFG_WITH_STATS ?= y

arm32-platform-cflags += -Wno-error=cast-align
arm64-platform-cflags += -Wno-error=cast-align

$(call force,CFG_CRYPTO_SHA256_ARM32_CE,n)
$(call force,CFG_CRYPTO_SHA256_ARM64_CE,n)
$(call force,CFG_CRYPTO_SHA1_ARM32_CE,n)
$(call force,CFG_CRYPTO_SHA1_ARM64_CE,n)
$(call force,CFG_CRYPTO_AES_ARM64_CE,n)
46 changes: 46 additions & 0 deletions core/arch/arm/plat-rpi5/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright (c) 2016, Sequitur Labs Inc. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#include <console.h>
#include <drivers/pl011.h>
#include <kernel/panic.h>
#include <mm/core_memprot.h>
#include <mm/tee_pager.h>
#include <platform_config.h>

register_phys_mem_pgdir(MEM_AREA_IO_NSEC,
CONSOLE_UART_BASE, PL011_REG_SIZE);

static struct pl011_data console_data;

void plat_console_init(void)
{
pl011_init(&console_data, CONSOLE_UART_BASE,
CONSOLE_UART_CLK_IN_HZ, CONSOLE_BAUDRATE);
register_serial_console(&console_data.chip);
}
72 changes: 72 additions & 0 deletions core/arch/arm/plat-rpi5/platform_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2016, Sequitur Labs Inc. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef PLATFORM_CONFIG_H
#define PLATFORM_CONFIG_H

#include <mm/generic_ram_layout.h>

/* Make stacks aligned to data cache line length */
#define STACK_ALIGNMENT 64

#ifdef ARM64
#ifdef CFG_WITH_PAGER
#error "Pager not supported for ARM64"
#endif
#endif /* ARM64 */

/* PL011 UART */
#define CONSOLE_UART_BASE 0x107d001000ULL /* UART0 */
#define CONSOLE_BAUDRATE 0 /* VPU will set UART for us */
#define CONSOLE_UART_CLK_IN_HZ 0

/* TODO: This is invalid now */
/*
* RPi memory map
*
* No secure memory on RPi...
*
*
* Available to Linux <above>
* 0x0a00_0000
* TA RAM: 16 MiB |
* 0x0842_0000 | TZDRAM
* TEE RAM: 4 MiB (TEE_RAM_VA_SIZE) |
* 0x0840_0000 [ARM Trusted Firmware ] -
* 0x0840_0000 [TZDRAM_BASE, BL32_LOAD_ADDR] -
* Shared memory: 4 MiB |
* 0x0800_0000 | DRAM0
* Available to Linux |
* 0x0000_0000 [DRAM0_BASE] -
*
*/

#define DRAM0_BASE 0x00000000
#define DRAM0_SIZE 0x200000000

#endif /* PLATFORM_CONFIG_H */
2 changes: 2 additions & 0 deletions core/arch/arm/plat-rpi5/sub.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global-incdirs-y += .
srcs-y += main.c

0 comments on commit 725e39e

Please sign in to comment.