From b81fa1e379db91597e00407faf331cf11f72eb04 Mon Sep 17 00:00:00 2001 From: Ben Levinsky Date: Fri, 1 Dec 2023 13:41:05 -0800 Subject: [PATCH] lib: generic: xlnx: Enable CMake handling for System Device Tree Flow For AMD-Xilinx tooling, there is a new System Device Tree (SDT) BSP with different symbols for GIC than the classic BSP. This causes issues when linking Libmetal against the SDT Flow BSP. Note that there is a planned deprecation of the classic BSP. For AMD-Xilinx System Device Tree (SDT) Flow, one of the files provided by BSP is bspconfig.h. This file provides reference to the symbols that describe GIC Device ID and GIC distributor Base Address. AMD-Xilinx tools that use the SDT Flow BSP will provide symbol 'SDT' to signal that the SDT Flow BSP is present. If SDT symbol is present then the Libmetal build will include the new header "lib/system/generic/xlnx/sdt.h" to preserve library build. Signed-off-by: Ben Levinsky --- lib/system/generic/xlnx/CMakeLists.txt | 6 ++++++ lib/system/generic/xlnx/sdt.h | 27 ++++++++++++++++++++++++++ lib/system/generic/xlnx/sys.h | 5 +++++ 3 files changed, 38 insertions(+) create mode 100644 lib/system/generic/xlnx/sdt.h diff --git a/lib/system/generic/xlnx/CMakeLists.txt b/lib/system/generic/xlnx/CMakeLists.txt index 4f595bdd..1f7716f8 100644 --- a/lib/system/generic/xlnx/CMakeLists.txt +++ b/lib/system/generic/xlnx/CMakeLists.txt @@ -8,4 +8,10 @@ collect (PROJECT_LIB_HEADERS sys.h) collect (PROJECT_LIB_SOURCES irq.c) +include(CheckSymbolExists) +check_symbol_exists(SDT "bspconfig.h" HAS_SDT) +if (HAS_SDT) + collect (PROJECT_LIB_HEADERS sdt.h) +endif() + # vim: expandtab:ts=2:sw=2:smartindent diff --git a/lib/system/generic/xlnx/sdt.h b/lib/system/generic/xlnx/sdt.h new file mode 100644 index 00000000..e473b473 --- /dev/null +++ b/lib/system/generic/xlnx/sdt.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * @file generic/xlnx/sdt.h + * @brief Xilinx-AMD Specific symbols for System Device Tree Flow + */ + +#ifndef __METAL_GENERIC_SYS_XLNX_SDT_H__ +#define __METAL_GENERIC_SYS_XLNX_SDT_H__ + +/* The Xilinx-AMD System Device Tree (SDT) Flow BSP provides this file. */ +#ifdef SDT +#include "bspconfig.h" +#endif + +#ifdef XPAR_SCUGIC_SINGLE_DEVICE_ID +#define XPAR_SCUGIC_0_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID +#endif + +#ifdef XPAR_SCUGIC_DIST_BASEADDR +#define XPAR_SCUGIC_0_DIST_BASEADDR XPAR_SCUGIC_DIST_BASEADDR +#endif +#endif /* __METAL_GENERIC_SYS_XLNX_SDT_H__ */ diff --git a/lib/system/generic/xlnx/sys.h b/lib/system/generic/xlnx/sys.h index c144c3ee..8a06d02f 100644 --- a/lib/system/generic/xlnx/sys.h +++ b/lib/system/generic/xlnx/sys.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved. + * Copyright (C) 2023, Advanced Micro Devices, Inc. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -28,6 +29,10 @@ #include #include +#ifdef SDT +#include +#endif + #ifndef __METAL_GENERIC_XLNX_SYS__H__ #define __METAL_GENERIC_XLNX_SYS__H__