aarch64: add rk3399_rockpro64 BSP

This adds a basic BSP for RockPro64, which includes a UART,
an ARM timer, and GICv3 support, and utilizes all available
memory as defined by the upstream U-Boot configuration.

Closes #5414
This commit is contained in:
Ning Yang
2026-01-25 15:15:37 +08:00
committed by Joel Sherrill
parent 76614d5200
commit 33950b4418
21 changed files with 911 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup RTEMSBSPsAArch64RK3399
*
* @brief Console Configuration
*/
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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 <bsp.h>
#include <bsp/console-termios.h>
#include <bsp/rk3399.h>
#include <rtems/bspIo.h>
#include <rtems/console.h>
#include <libchip/ns16550.h>
uint32_t rk3399_uart_reg_shift = 2;
static uint8_t get_register(uintptr_t addr, uint8_t i)
{
volatile uint8_t *reg = (uint8_t *) addr;
i <<= rk3399_uart_reg_shift;
return reg [i];
}
static void set_register(uintptr_t addr, uint8_t i, uint8_t val)
{
volatile uint8_t *reg = (uint8_t *) addr;
i <<= rk3399_uart_reg_shift;
reg [i] = val;
}
static ns16550_context rk3399_uart_instances[5] = {
{
.base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("RK3399 UART 0"),
.get_reg = get_register,
.set_reg = set_register,
.initial_baud = RK3399_UART_DEFAULT_BAUD,
.port = RK3399_UART0_BASE
}, {
.base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("RK3399 UART 1"),
.get_reg = get_register,
.set_reg = set_register,
.initial_baud = RK3399_UART_DEFAULT_BAUD,
.port = RK3399_UART1_BASE
}, {
.base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("RK3399 UART 2"),
.get_reg = get_register,
.set_reg = set_register,
.initial_baud = RK3399_UART_DEFAULT_BAUD,
.port = RK3399_UART2_BASE
}, {
.base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("RK3399 UART 3"),
.get_reg = get_register,
.set_reg = set_register,
.initial_baud = RK3399_UART_DEFAULT_BAUD,
.port = RK3399_UART3_BASE
}, {
.base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("RK3399 UART 4"),
.get_reg = get_register,
.set_reg = set_register,
.initial_baud = RK3399_UART_DEFAULT_BAUD,
.port = RK3399_UART4_BASE
}
};
rtems_status_code console_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
)
{
(void) major;
(void) minor;
(void) arg;
size_t i;
rtems_termios_initialize();
for (i = 0; i < RTEMS_ARRAY_SIZE(rk3399_uart_instances); ++i) {
ns16550_context *ctx = &rk3399_uart_instances[i];
char uart[] = "/dev/ttySX";
uart[sizeof(uart) - 2] = (char) ('0' + i);
rtems_termios_device_install(
&uart[0],
&ns16550_handler_polled,
NULL,
&ctx->base
);
if (i == BSP_CONSOLE_MINOR) {
link(&uart[0], CONSOLE_DEVICE_NAME);
}
}
return RTEMS_SUCCESSFUL;
}
static void output_char(char c)
{
rtems_termios_device_context *ctx = &rk3399_uart_instances[BSP_CONSOLE_MINOR].base;
ns16550_polled_putchar(ctx, c);
}
BSP_output_char_function_type BSP_output_char = output_char;
BSP_polling_getchar_function_type BSP_poll_char = NULL;

View File

@@ -0,0 +1,72 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup RTEMSBSPsAArch64RK3399
*
* @brief Core BSP definitions
*/
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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 LIBBSP_AARCH64_RK3399_BSP_H
#define LIBBSP_AARCH64_RK3399_BSP_H
/**
* @addtogroup RTEMSBSPsAArch64
*
* @{
*/
#include <bspopts.h>
#ifndef ASM
#include <bsp/default-initial-extension.h>
#include <bsp/start.h>
#include <rtems.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define BSP_ARM_GIC_CPUIF_BASE 0xfff00000
#define BSP_ARM_GIC_DIST_BASE 0xfee00000
#define BSP_ARM_GIC_REDIST_BASE 0xfef00000
BSP_START_TEXT_SECTION void rk3399_setup_mmu_and_cache( void );
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ASM */
/** @} */
#endif /* LIBBSP_AARCH64_RK3399_BSP_H */

View File

@@ -0,0 +1,64 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup RTEMSBSPsAArch64RK3399
*
* @brief BSP IRQ definitions
*/
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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 LIBBSP_AARCH64_RK3399_IRQ_H
#define LIBBSP_AARCH64_RK3399_IRQ_H
#ifndef ASM
#include <rtems/irq.h>
#include <rtems/irq-extension.h>
#include <dev/irq/arm-gic-irq.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define BSP_INTERRUPT_VECTOR_COUNT 1020
/* Interrupts vectors */
#define BSP_TIMER_VIRT_PPI 27
#define BSP_TIMER_PHYS_NS_PPI 30
/** @} */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ASM */
#endif /* LIBBSP_AARCH64_RK3399_IRQ_H */

View File

@@ -0,0 +1,74 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup RTEMSBSPsAArch64RK3399
*
* @brief Register definitions.
*/
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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 LIBBSP_AARCH64_RK3399_RK3399_H
#define LIBBSP_AARCH64_RK3399_RK3399_H
#include <bsp/utility.h>
#include <bspopts.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name RK3399 UARTs
*
* @{
*/
#define RK3399_UART_BASE 0xff180000
#define RK3399_UART_DEVICE_SIZE 0x10000
#define RK3399_UART0_BASE (RK3399_UART_BASE + 0x00000)
#define RK3399_UART0_SIZE RK3399_UART_DEVICE_SIZE
#define RK3399_UART1_BASE (RK3399_UART_BASE + 0x10000)
#define RK3399_UART1_SIZE RK3399_UART_DEVICE_SIZE
#define RK3399_UART2_BASE (RK3399_UART_BASE + 0x20000)
#define RK3399_UART2_SIZE RK3399_UART_DEVICE_SIZE
#define RK3399_UART3_BASE (RK3399_UART_BASE + 0x30000)
#define RK3399_UART3_SIZE RK3399_UART_DEVICE_SIZE
#define RK3399_UART4_BASE 0xff370000
#define RK3399_UART4_SIZE RK3399_UART_DEVICE_SIZE
#define RK3399_UART_DEFAULT_BAUD 1500000
/** @} */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LIBBSP_AARCH64_RK3399_RK3399_H */

View File

@@ -0,0 +1,45 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup RTEMSBSPsAArch64RK3399
*
* @brief BSP tm27 header
*/
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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 _RTEMS_TMTEST27
#error "This is an RTEMS internal file you must not include directly."
#endif
#ifndef __tm27_h
#define __tm27_h
#include <dev/irq/arm-gic-tm27.h>
#endif /* __tm27_h */

View File

@@ -0,0 +1,48 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup RTEMSBSPsAArch64RK3399
*
* @brief This source file contains the implementation of bsp_start().
*/
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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 <bsp.h>
#include <bsp/bootcard.h>
#include <bsp/irq-generic.h>
#include <bsp/linker-symbols.h>
void bsp_start( void )
{
bsp_interrupt_initialize();
rtems_cache_coherent_add_area(
bsp_section_nocacheheap_begin,
(uintptr_t) bsp_section_nocacheheap_size
);
}

View File

@@ -0,0 +1,58 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup RTEMSBSPsAArch64RK3399
*
* @brief BSP Startup Hooks
*/
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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 <bsp.h>
#include <bsp/start.h>
BSP_START_TEXT_SECTION void rk3399_setup_mmu_and_cache(void);
#ifdef BSP_START_ENABLE_EL3_START_SUPPORT
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
/* Do nothing */
}
#endif
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{
_AARCH64_Data_synchronization_barrier();
_AARCH64_Instruction_synchronization_barrier();
AArch64_start_set_vector_base();
bsp_start_copy_sections();
rk3399_setup_mmu_and_cache();
bsp_start_clear_bss();
}

View File

@@ -0,0 +1,53 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup RTEMSBSPsAArch64RK3399
*
* @brief This source file contains the default MMU tables and setup.
*/
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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 <bsp.h>
#include <bsp/aarch64-mmu.h>
#include <libcpu/mmu-vmsav8-64.h>
BSP_START_TEXT_SECTION void rk3399_setup_mmu_and_cache( void )
{
aarch64_mmu_control *control = &aarch64_mmu_instance;
aarch64_mmu_setup();
aarch64_mmu_setup_translation_table(
control,
&aarch64_mmu_config_table[ 0 ],
aarch64_mmu_config_table_size
);
aarch64_mmu_enable( control );
}

View File

@@ -0,0 +1,64 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/**
* @file
*
* @ingroup RTEMSBSPsAArch64RK3399
*
* @brief This source file contains the definition of ::aarch64_mmu_config_table
* and ::aarch64_mmu_config_table_size.
*/
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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 <bsp.h>
#include <bsp/start.h>
#include <bsp/rk3399.h>
#include <bsp/aarch64-mmu.h>
#include <libcpu/mmu-vmsav8-64.h>
BSP_START_DATA_SECTION const aarch64_mmu_config_entry
aarch64_mmu_config_table[] = {
AARCH64_MMU_DEFAULT_SECTIONS,
{ /* GIC500 */
.begin = 0xFEE00000ULL,
.end = 0xFF000000ULL,
.flags = AARCH64_MMU_DEVICE
},
{ /* NS16550 UART0-UART3 */
.begin = RK3399_UART_BASE,
.end = RK3399_UART_BASE + RK3399_UART_DEVICE_SIZE * 4,
.flags = AARCH64_MMU_DEVICE
},
{ /* NS16550 UART4 */
.begin = RK3399_UART4_BASE,
.end = RK3399_UART4_BASE + RK3399_UART_DEVICE_SIZE,
.flags = AARCH64_MMU_DEVICE
}
};
BSP_START_DATA_SECTION const size_t aarch64_mmu_config_table_size =
RTEMS_ARRAY_SIZE(aarch64_mmu_config_table);

View File

@@ -0,0 +1,18 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-string: null
- split: null
- env-append: null
build-type: option
copyrights:
- Copyright (C) 2026 Ning Yang <yangn0@qq.com>
default:
- enabled-by: true
value:
- -mcpu=cortex-a72
description: |
ABI flags
enabled-by: true
links: []
name: ABI_FLAGS
type: build

View File

@@ -0,0 +1,19 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
arch: aarch64
bsp: rk3399_rockpro64
build-type: bsp
cflags: []
copyrights:
- Copyright (C) 2026 Ning Yang <yangn0@qq.com>
cppflags: []
enabled-by: true
family: rk3399
includes: []
install: []
links:
- role: build-dependency
uid: grp
- role: build-dependency
uid: linkcmds
source: []
type: build

View File

@@ -0,0 +1,51 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
build-type: group
cflags: []
copyrights:
- Copyright (C) 2026 Ning Yang <yangn0@qq.com>
cppflags: []
cxxflags: []
enabled-by: true
includes: []
install: []
ldflags: []
links:
- role: build-dependency
uid: ../grp
- role: build-dependency
uid: ../start
- role: build-dependency
uid: abi
- role: build-dependency
uid: obj
- role: build-dependency
uid: optconminor
- role: build-dependency
uid: optloadoff
- role: build-dependency
uid: optnocachelen
- role: build-dependency
uid: optramlen
- role: build-dependency
uid: optramori
- role: build-dependency
uid: ../objclockarmgenerictimer
- role: build-dependency
uid: ../../obj
- role: build-dependency
uid: ../../objirq
- role: build-dependency
uid: ../../dev/irq/objarmgicv3
- role: build-dependency
uid: ../../objmem
- role: build-dependency
uid: ../../optcachedata
- role: build-dependency
uid: ../../optcacheinst
- role: build-dependency
uid: ../../opto2
- role: build-dependency
uid: ../../bspopts
type: build
use-after: []
use-before: []

View File

@@ -0,0 +1,73 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
build-type: config-file
content: |
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (C) 2026 Ning Yang <yangn0@qq.com>
*
* 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 OWNER 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.
*/
MEMORY {
RAM : ORIGIN = ${BSP_RK3399_RAM_BASE} + ${BSP_RK3399_LOAD_OFFSET}, LENGTH = ${BSP_RK3399_RAM_LENGTH} - ${BSP_RK3399_LOAD_OFFSET} - ${BSP_RK3399_NOCACHE_LENGTH} - 0x1000 * ${AARCH64_MMU_TRANSLATION_TABLE_PAGES}
RAM_MMU : ORIGIN = ${BSP_RK3399_RAM_BASE} + ${BSP_RK3399_RAM_LENGTH} - (0x1000 * ${AARCH64_MMU_TRANSLATION_TABLE_PAGES}) - ${BSP_RK3399_NOCACHE_LENGTH}, LENGTH = 0x1000 * ${AARCH64_MMU_TRANSLATION_TABLE_PAGES}
NOCACHE : ORIGIN = ${BSP_RK3399_RAM_BASE} + ${BSP_RK3399_RAM_LENGTH} - ${BSP_RK3399_NOCACHE_LENGTH}, LENGTH = ${BSP_RK3399_NOCACHE_LENGTH}
}
REGION_ALIAS ("REGION_START", RAM);
REGION_ALIAS ("REGION_VECTOR", RAM);
REGION_ALIAS ("REGION_TEXT", RAM);
REGION_ALIAS ("REGION_TEXT_LOAD", RAM);
REGION_ALIAS ("REGION_RODATA", RAM);
REGION_ALIAS ("REGION_RODATA_LOAD", RAM);
REGION_ALIAS ("REGION_DATA", RAM);
REGION_ALIAS ("REGION_DATA_LOAD", RAM);
REGION_ALIAS ("REGION_FAST_TEXT", RAM);
REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM);
REGION_ALIAS ("REGION_FAST_DATA", RAM);
REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
REGION_ALIAS ("REGION_BSS", RAM);
REGION_ALIAS ("REGION_WORK", RAM);
REGION_ALIAS ("REGION_STACK", RAM);
REGION_ALIAS ("REGION_NOCACHE", NOCACHE);
REGION_ALIAS ("REGION_NOCACHE_LOAD", NOCACHE);
bsp_stack_exception_size = DEFINED (bsp_stack_exception_size) ? bsp_stack_exception_size : 1024;
bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1M;
bsp_vector_table_in_start_section = 1;
bsp_translation_table_base = ORIGIN (RAM_MMU);
bsp_translation_table_end = ORIGIN (RAM_MMU) + LENGTH (RAM_MMU);
OUTPUT_FORMAT ("elf64-littleaarch64")
OUTPUT_ARCH (aarch64)
INCLUDE linkcmds.base
copyrights:
- Copyright (C) 2026 Ning Yang
enabled-by: true
install-path: ${BSP_LIBDIR}
links: []
target: linkcmds
type: build

View File

@@ -0,0 +1,38 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
build-type: objects
cflags: []
copyrights:
- Copyright (C) 2026 Ning Yang <yangn0@qq.com>
cppflags: []
cxxflags: []
enabled-by: true
includes: []
install:
- destination: ${BSP_INCLUDEDIR}
source:
- bsps/aarch64/rk3399/include/bsp.h
- destination: ${BSP_INCLUDEDIR}/bsp
source:
- bsps/aarch64/rk3399/include/bsp/irq.h
links:
- role: build-dependency
uid: ../optmmupages
source:
- bsps/aarch64/rk3399/console/console.c
- bsps/aarch64/rk3399/start/bspstart.c
- bsps/aarch64/rk3399/start/bspstarthooks.c
- bsps/aarch64/rk3399/start/bspstartmmu.c
- bsps/aarch64/rk3399/start/mmu-config.c
- bsps/aarch64/shared/cache/cache.c
- bsps/aarch64/shared/mmu/mmu-setup.c
- bsps/aarch64/shared/mmu/vmsav8-64.c
- bsps/aarch64/shared/start/start-cpu-mpidr.S
- bsps/shared/dev/btimer/btimer-cpucounter.c
- bsps/shared/dev/getentropy/getentropy-cpucounter.c
- bsps/shared/dev/serial/console-termios-init.c
- bsps/shared/dev/serial/console-termios.c
- bsps/shared/irq/irq-default-handler.c
- bsps/shared/start/bspreset-arm-psci.S
- bsps/shared/start/gettargethash-default.c
- bsps/shared/start/sbrk.c
type: build

View File

@@ -0,0 +1,17 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-integer: null
- define: null
build-type: option
copyrights:
- Copyright (C) 2026 Ning Yang <yangn0@qq.com>
default:
- enabled-by: true
value: 2
description: |
minor number of console device
enabled-by: true
format: '{}'
links: []
name: BSP_CONSOLE_MINOR
type: build

View File

@@ -0,0 +1,19 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-integer: null
- assert-uint32: null
- env-assign: null
- format-and-define: null
build-type: option
copyrights:
- Copyright (C) 2026 Ning Yang <yangn0@qq.com>
default:
- enabled-by: true
value: 0x00200000
description: |
offset of RAM region from memory area base
enabled-by: true
format: '{:#010x}'
links: []
name: BSP_RK3399_LOAD_OFFSET
type: build

View File

@@ -0,0 +1,19 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-integer: null
- assert-uint32: null
- env-assign: null
- format-and-define: null
build-type: option
copyrights:
- Copyright (C) 2026 Ning Yang <yangn0@qq.com>
default:
- enabled-by: true
value: 0x00100000
description: |
length of nocache RAM region
enabled-by: true
format: '{:#010x}'
links: []
name: BSP_RK3399_NOCACHE_LENGTH
type: build

View File

@@ -0,0 +1,19 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-integer: null
- assert-uint32: null
- env-assign: null
- format-and-define: null
build-type: option
copyrights:
- Copyright (C) 2026 Ning Yang <yangn0@qq.com>
default:
- enabled-by: true
value: 0xf0efe000
description: |
length of memory area available to the BSP
enabled-by: true
format: '{:#010x}'
links: []
name: BSP_RK3399_RAM_LENGTH
type: build

View File

@@ -0,0 +1,19 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-integer: null
- assert-uint32: null
- env-assign: null
- format-and-define: null
build-type: option
copyrights:
- Copyright (C) 2026 Ning Yang <yangn0@qq.com>
default:
- enabled-by: true
value: 0
description: |
base address of memory area available to the BSP
enabled-by: true
format: '{:#010x}'
links: []
name: BSP_RK3399_RAM_BASE
type: build

View File

@@ -12,6 +12,7 @@ default:
- aarch64/a72_ilp32_qemu
- aarch64/a72_lp64_qemu
- aarch64/raspberrypi4b
- aarch64/rk3399_rockpro64
- aarch64/versal_aiedge
- aarch64/versal_qemu
- aarch64/versal_vck190

View File

@@ -12,6 +12,7 @@ default:
- aarch64/a72_ilp32_qemu
- aarch64/a72_lp64_qemu
- aarch64/raspberrypi4b
- aarch64/rk3399_rockpro64
- aarch64/versal_aiedge
- aarch64/versal_qemu
- aarch64/versal_vck190