From 621abd9043dcbc813697f3bab7d2595f0f3c446f Mon Sep 17 00:00:00 2001 From: Srikar Josyula Date: Tue, 26 Mar 2024 14:55:19 +0530 Subject: [PATCH 1/2] Introducing common VAL PAL for linux-acs - Removing bsa-acs-drv and introducing acs-drv that is common for BSA and SBSA. - APIs used by both BSA and SBSA are moved to common path in pal_linux/files folder. Signed-off-by: Srikar Josyula Co-authored-by: Chetan Rathore --- {bsa-acs-drv => acs-drv}/files/COPYING | 0 .../Makefile => acs-drv/files/MakefileBSA | 2 +- {bsa-acs-drv => acs-drv}/files/bsa_acs_drv.c | 50 +-- {bsa-acs-drv => acs-drv}/files/bsa_acs_drv.h | 0 .../setup.sh => acs-drv/files/bsa_setup.sh | 2 +- acs-drv/files/linux_bsa_acs.sh | 53 +++ .../files/platform/pal_linux/files/COPYING | 0 .../platform/pal_linux/files/MakefileBSA | 52 +++ .../platform/pal_linux/files/bsa/COPYING | 340 ++++++++++++++++++ .../platform/pal_linux/files/bsa}/Makefile | 0 .../pal_linux/files/bsa/include/bsa_pal_dt.h | 0 .../files/bsa/include/bsa_pal_exerciser.h | 41 +++ .../pal_linux/files/bsa/src/bsa_pal_acpi.c | 37 ++ .../pal_linux/files/bsa/src/bsa_pal_dt.c | 4 +- .../files/bsa/src/bsa_pal_exerciser.c | 38 ++ .../platform/pal_linux/files/common/COPYING | 340 ++++++++++++++++++ .../platform/pal_linux/files/common/Makefile | 50 +++ .../files/common}/include/pal_exerciser.h | 17 +- .../files/common}/include/pal_linux.h | 9 +- .../files/common/include/pal_pcie_enum.h | 4 +- .../pal_linux/files/common}/src/pal_acpi.c | 31 +- .../pal_linux/files/common}/src/pal_dma.c | 20 +- .../files/common}/src/pal_exerciser.c | 24 +- .../pal_linux/files/common}/src/pal_gic.c | 16 +- .../pal_linux/files/common}/src/pal_iovirt.c | 103 ++++-- .../pal_linux/files/common}/src/pal_misc.c | 8 +- .../pal_linux/files/common}/src/pal_pcie.c | 15 +- .../files/common}/src/pal_pcie_enumeration.c | 8 +- .../pal_linux/files/common}/src/pal_pe.c | 24 +- .../files/common}/src/pal_peripherals.c | 13 +- .../pal_linux/files/common}/src/pal_smmu.c | 21 +- bsa-acs-drv/files/linux_bsa_acs.sh | 33 -- 32 files changed, 1135 insertions(+), 220 deletions(-) rename {bsa-acs-drv => acs-drv}/files/COPYING (100%) rename bsa-acs-drv/files/Makefile => acs-drv/files/MakefileBSA (96%) mode change 100644 => 100755 rename {bsa-acs-drv => acs-drv}/files/bsa_acs_drv.c (82%) mode change 100644 => 100755 rename {bsa-acs-drv => acs-drv}/files/bsa_acs_drv.h (100%) rename bsa-acs-drv/files/setup.sh => acs-drv/files/bsa_setup.sh (87%) create mode 100755 acs-drv/files/linux_bsa_acs.sh rename {bsa-acs-drv => acs-drv}/files/platform/pal_linux/files/COPYING (100%) create mode 100644 acs-drv/files/platform/pal_linux/files/MakefileBSA create mode 100644 acs-drv/files/platform/pal_linux/files/bsa/COPYING rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/bsa}/Makefile (100%) rename bsa-acs-drv/files/platform/pal_linux/files/include/pal_dt.h => acs-drv/files/platform/pal_linux/files/bsa/include/bsa_pal_dt.h (100%) create mode 100644 acs-drv/files/platform/pal_linux/files/bsa/include/bsa_pal_exerciser.h create mode 100644 acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_acpi.c rename bsa-acs-drv/files/platform/pal_linux/files/src/pal_dt.c => acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_dt.c (98%) create mode 100644 acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_exerciser.c create mode 100644 acs-drv/files/platform/pal_linux/files/common/COPYING create mode 100644 acs-drv/files/platform/pal_linux/files/common/Makefile rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/include/pal_exerciser.h (86%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/include/pal_linux.h (91%) rename bsa-acs-drv/files/platform/pal_linux/files/include/bsa_pcie_enum.h => acs-drv/files/platform/pal_linux/files/common/include/pal_pcie_enum.h (95%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_acpi.c (89%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_dma.c (93%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_exerciser.c (89%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_gic.c (87%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_iovirt.c (83%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_misc.c (98%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_pcie.c (98%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_pcie_enumeration.c (96%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_pe.c (96%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_peripherals.c (93%) rename {bsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/common}/src/pal_smmu.c (85%) delete mode 100755 bsa-acs-drv/files/linux_bsa_acs.sh diff --git a/bsa-acs-drv/files/COPYING b/acs-drv/files/COPYING similarity index 100% rename from bsa-acs-drv/files/COPYING rename to acs-drv/files/COPYING diff --git a/bsa-acs-drv/files/Makefile b/acs-drv/files/MakefileBSA old mode 100644 new mode 100755 similarity index 96% rename from bsa-acs-drv/files/Makefile rename to acs-drv/files/MakefileBSA index eecbcec..0abf5ac --- a/bsa-acs-drv/files/Makefile +++ b/acs-drv/files/MakefileBSA @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - # Copyright (C) 2016-2018,2021 Arm Limited + # Copyright (C) 2016-2018,2021, 2024, Arm Limited # ## diff --git a/bsa-acs-drv/files/bsa_acs_drv.c b/acs-drv/files/bsa_acs_drv.c old mode 100644 new mode 100755 similarity index 82% rename from bsa-acs-drv/files/bsa_acs_drv.c rename to acs-drv/files/bsa_acs_drv.c index 5200a14..8235617 --- a/bsa-acs-drv/files/bsa_acs_drv.c +++ b/acs-drv/files/bsa_acs_drv.c @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2023 Arm Limited + * Copyright (C) 2016-2024 Arm Limited * * Author: Prasanth Pulla * @@ -22,11 +22,12 @@ #include #include "bsa_acs_drv.h" -#include "val/include/val_interface.h" -#include "val/include/bsa_acs_common.h" -#include "val/include/bsa_acs_val.h" -#include "val/include/bsa_acs_pcie.h" -#include "val/include/bsa_acs_exerciser.h" +#include "val/common/include/val_interface.h" +#include "val/bsa/include/bsa_val_interface.h" +#include "val/common/include/acs_common.h" +#include "val/common/include/acs_val.h" +#include "val/common/include/acs_pcie.h" +#include "val/bsa/include/bsa_acs_pcie.h" test_params_t params; test_msg_parms_t msg_params; @@ -39,9 +40,9 @@ unsigned int *g_skip_test_num; unsigned int g_num_skip = 3; unsigned int *g_execute_tests; unsigned int *g_execute_modules; -unsigned int g_bsa_tests_total; -unsigned int g_bsa_tests_pass; -unsigned int g_bsa_tests_fail; +unsigned int g_acs_tests_total; +unsigned int g_acs_tests_pass; +unsigned int g_acs_tests_fail; uint64_t g_exception_ret_addr; uint64_t g_stack_pointer; uint64_t g_ret_addr; @@ -79,9 +80,9 @@ val_glue_execute_command(void) if (params.api_num == BSA_CREATE_INFO_TABLES) { - g_bsa_tests_total = 0; - g_bsa_tests_pass = 0; - g_bsa_tests_fail = 0; + g_acs_tests_total = 0; + g_acs_tests_pass = 0; + g_acs_tests_fail = 0; tail_msg = 0; g_msg_buf = (char*) kmalloc(num_msg * sizeof(test_msg_parms_t), GFP_KERNEL); @@ -125,28 +126,15 @@ val_glue_execute_command(void) } - if (params.api_num == BSA_EXERCISER_EXECUTE_TEST) - { - params.arg0 = DRV_STATUS_PENDING; - //val_exerciser_execute_tests(params.level); - val_print(ACS_PRINT_TEST, "\n ------------------------------------------------------------", 0); - val_print(ACS_PRINT_TEST, "\n Total Tests Run = %2d, ", g_bsa_tests_total); - val_print(ACS_PRINT_TEST, "Tests Passed = %2d, ", g_bsa_tests_pass); - val_print(ACS_PRINT_TEST, "Tests Failed = %2d ", g_bsa_tests_fail); - val_print(ACS_PRINT_TEST, "\n ------------------------------------------------------------\n", 0); - params.arg0 = DRV_STATUS_AVAILABLE; - params.arg1 = val_get_status(0); - } - if (params.api_num == BSA_PCIE_EXECUTE_TEST) { params.arg0 = DRV_STATUS_PENDING; - val_pcie_execute_tests(params.num_pe, g_sw_view); + val_bsa_pcie_execute_tests(params.num_pe, g_sw_view); val_print(ACS_PRINT_TEST, "\n ------------------------------------------------------------", 0); - val_print(ACS_PRINT_TEST, "\n Total Tests Run = %2d, ", g_bsa_tests_total); - val_print(ACS_PRINT_TEST, "Tests Passed = %2d, ", g_bsa_tests_pass); - val_print(ACS_PRINT_TEST, "Tests Failed = %2d ", g_bsa_tests_fail); + val_print(ACS_PRINT_TEST, "\n Total Tests Run = %2d, ", g_acs_tests_total); + val_print(ACS_PRINT_TEST, "Tests Passed = %2d, ", g_acs_tests_pass); + val_print(ACS_PRINT_TEST, "Tests Failed = %2d ", g_acs_tests_fail); val_print(ACS_PRINT_TEST, "\n ------------------------------------------------------------\n", 0); params.arg0 = DRV_STATUS_AVAILABLE; params.arg1 = val_get_status(0); @@ -155,7 +143,7 @@ val_glue_execute_command(void) if (params.api_num == BSA_PER_EXECUTE_TEST) { params.arg0 = DRV_STATUS_PENDING; - val_peripheral_execute_tests(params.num_pe, g_sw_view); + val_bsa_peripheral_execute_tests(params.num_pe, g_sw_view); params.arg0 = DRV_STATUS_AVAILABLE; params.arg1 = val_get_status(0); } @@ -163,7 +151,7 @@ val_glue_execute_command(void) if (params.api_num == BSA_MEM_EXECUTE_TEST) { params.arg0 = DRV_STATUS_PENDING; - val_memory_execute_tests(params.num_pe, g_sw_view); + val_bsa_memory_execute_tests(params.num_pe, g_sw_view); params.arg0 = DRV_STATUS_AVAILABLE; params.arg1 = val_get_status(0); } diff --git a/bsa-acs-drv/files/bsa_acs_drv.h b/acs-drv/files/bsa_acs_drv.h similarity index 100% rename from bsa-acs-drv/files/bsa_acs_drv.h rename to acs-drv/files/bsa_acs_drv.h diff --git a/bsa-acs-drv/files/setup.sh b/acs-drv/files/bsa_setup.sh similarity index 87% rename from bsa-acs-drv/files/setup.sh rename to acs-drv/files/bsa_setup.sh index 219b3fd..2e39cfd 100755 --- a/bsa-acs-drv/files/setup.sh +++ b/acs-drv/files/bsa_setup.sh @@ -6,7 +6,7 @@ echo "==================================================================" if [ $# -ne 1 ]; then - echo "Give ACS_PATH as the arguments to the script" + echo "Give BSA-ACS PATH as the arguments to the script" return 0 fi diff --git a/acs-drv/files/linux_bsa_acs.sh b/acs-drv/files/linux_bsa_acs.sh new file mode 100755 index 0000000..ea05eef --- /dev/null +++ b/acs-drv/files/linux_bsa_acs.sh @@ -0,0 +1,53 @@ +# /** @file +# * Copyright (c) 2018-2024, Arm Limited or its affiliates. All rights reserved. +# * SPDX-License-Identifier : Apache-2.0 +# +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# **/ + +#!/bin/bash + +echo "==================================================================" +echo "This script will compile the Linux BSA Kernel module " +echo "==================================================================" + +BSA_ACS_PATH=`pwd` +if [ -z $KERNEL_SRC ] +then + echo "Error: set KERNEL_SRC path" + exit 0 +fi + +if [ $(uname -m) != "aarch64" ] && [ -z $CROSS_COMPILE ] +then + echo "Error: set CROSS_COMPILE path for cross compile" + exit 0 +fi + +cd $BSA_ACS_PATH/platform/pal_linux/files +cp MakefileBSA Makefile +make +cp bsa_acs_pal.o $BSA_ACS_PATH/ + +cd $BSA_ACS_PATH/val/ +cp MakefileBSA Makefile +make +cp bsa_acs_val.o $BSA_ACS_PATH/ + +cd $BSA_ACS_PATH/test_pool/ +make +cp bsa_acs_test.o $BSA_ACS_PATH/ + +cd $BSA_ACS_PATH/ +cp MakefileBSA Makefile +make diff --git a/bsa-acs-drv/files/platform/pal_linux/files/COPYING b/acs-drv/files/platform/pal_linux/files/COPYING similarity index 100% rename from bsa-acs-drv/files/platform/pal_linux/files/COPYING rename to acs-drv/files/platform/pal_linux/files/COPYING diff --git a/acs-drv/files/platform/pal_linux/files/MakefileBSA b/acs-drv/files/platform/pal_linux/files/MakefileBSA new file mode 100644 index 0000000..59fc068 --- /dev/null +++ b/acs-drv/files/platform/pal_linux/files/MakefileBSA @@ -0,0 +1,52 @@ +## @file + # + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License version 2 as + # published by the Free Software Foundation. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + # + # Copyright (C) 2016-2018, 2021 Arm Limited + # +## + +export CROSS_COMPILE ?= aarch64-linux-gnu- +export ARCH ?= arm64 + +#since we have copied the files locally +ACS_DIR ?= . + +COMMON_PAL_SRC = $(ACS_DIR)/common/src +BSA_PAL_SRC = $(ACS_DIR)/bsa/src + +obj-m += bsa_acs_pal.o +bsa_acs_pal-objs += $(COMMON_PAL_SRC)/pal_misc.o \ + $(COMMON_PAL_SRC)/pal_pe.o $(COMMON_PAL_SRC)/pal_pcie.o $(COMMON_PAL_SRC)/pal_pcie_enumeration.o \ + $(COMMON_PAL_SRC)/pal_smmu.o $(COMMON_PAL_SRC)/pal_iovirt.o $(COMMON_PAL_SRC)/pal_peripherals.o \ + $(COMMON_PAL_SRC)/pal_dma.o $(COMMON_PAL_SRC)/pal_acpi.o $(COMMON_PAL_SRC)/pal_gic.o \ + $(BSA_PAL_SRC)/bsa_pal_dt.o $(BSA_PAL_SRC)/bsa_pal_acpi.o $(BSA_PAL_SRC)/bsa_pal_exerciser.o \ + $(COMMON_PAL_SRC)/pal_exerciser.o + +ccflags-y=-I$(PWD)/$(ACS_DIR)/val/common/include -I$(PWD)/$(ACS_DIR)/val/bsa/include -I$(PWD)/$(ACS_DIR)/common/include -I$(PWD)/$(ACS_DIR)/bsa/include -I$(PWD) -I$(PWD)/../../ -I$(PWD)/../../../ -DTARGET_LINUX -Wall -Werror + +all: +ifeq ($(KERNEL_SRC),) + echo " KERNEL_SRC variable should be set to kernel path " + exit 1 +else + echo "Kernel source is set to $(KERNEL_SRC)" +endif + + make -C $(KERNEL_SRC) M=$(PWD) modules + +modules_install: + $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install + +clean: + make -C $(KERNEL_SRC) M=$(PWD) clean diff --git a/acs-drv/files/platform/pal_linux/files/bsa/COPYING b/acs-drv/files/platform/pal_linux/files/bsa/COPYING new file mode 100644 index 0000000..6d45519 --- /dev/null +++ b/acs-drv/files/platform/pal_linux/files/bsa/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/bsa-acs-drv/files/platform/pal_linux/files/Makefile b/acs-drv/files/platform/pal_linux/files/bsa/Makefile similarity index 100% rename from bsa-acs-drv/files/platform/pal_linux/files/Makefile rename to acs-drv/files/platform/pal_linux/files/bsa/Makefile diff --git a/bsa-acs-drv/files/platform/pal_linux/files/include/pal_dt.h b/acs-drv/files/platform/pal_linux/files/bsa/include/bsa_pal_dt.h similarity index 100% rename from bsa-acs-drv/files/platform/pal_linux/files/include/pal_dt.h rename to acs-drv/files/platform/pal_linux/files/bsa/include/bsa_pal_dt.h diff --git a/acs-drv/files/platform/pal_linux/files/bsa/include/bsa_pal_exerciser.h b/acs-drv/files/platform/pal_linux/files/bsa/include/bsa_pal_exerciser.h new file mode 100644 index 0000000..e19efdd --- /dev/null +++ b/acs-drv/files/platform/pal_linux/files/bsa/include/bsa_pal_exerciser.h @@ -0,0 +1,41 @@ +/* + * BSA SBSA ACS Platform module. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Copyright (C) 2016-2021, 2023-2024, Arm Limited + * + */ + +#ifndef __BSA_PAL_EXERCISER_H__ +#define __BSA_PAL_EXERCISER_H__ + +#include + + +#define LEGACY_PCI_IRQ_CNT 4 +#define MAX_IRQ_CNT 0xFFFF // This value is arbitrary and may have to be adjusted + +typedef struct { + uint32_t irq_list[MAX_IRQ_CNT]; + uint32_t irq_count; +} PERIFERAL_IRQ_LIST; + +typedef struct { + PERIFERAL_IRQ_LIST legacy_irq_map[LEGACY_PCI_IRQ_CNT]; +} PERIPHERAL_IRQ_MAP; + +uint32_t pal_exerciser_get_legacy_irq_map(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn, + PERIPHERAL_IRQ_MAP *irq_map); + +#endif diff --git a/acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_acpi.c b/acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_acpi.c new file mode 100644 index 0000000..7390fba --- /dev/null +++ b/acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_acpi.c @@ -0,0 +1,37 @@ +/* + * BSA SBSA ACS Platform module. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Copyright (C) 2016-2018, 2021, 2024, Arm Limited + * + * Author: Prasanth Pulla + * + */ + +#include "common/include/pal_linux.h" + +#include +#include +#include +#include + + + + +void +pal_dump_dtb() +{ + return; +} + diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_dt.c b/acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_dt.c similarity index 98% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_dt.c rename to acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_dt.c index a6c13f0..29287a6 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_dt.c +++ b/acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_dt.c @@ -19,8 +19,8 @@ * */ -#include "include/pal_linux.h" -#include "include/pal_dt.h" +#include "common/include/pal_linux.h" +#include "bsa/include/bsa_pal_dt.h" #include #include diff --git a/acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_exerciser.c b/acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_exerciser.c new file mode 100644 index 0000000..09cbc42 --- /dev/null +++ b/acs-drv/files/platform/pal_linux/files/bsa/src/bsa_pal_exerciser.c @@ -0,0 +1,38 @@ +/* + * BSA SBSA ACS Platform module. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Copyright (C) 2016-2021, 2023, 2024 Arm Limited + * + */ + +#include "bsa/include/bsa_pal_exerciser.h" + +/** + @brief Get legacy IRQ routing for a PCI device + + @param bus PCI bus address + @param dev PCI device address + @param fn PCI function number + @param irq_map pointer to IRQ map structure + + @return irq_map IRQ routing map + @return status code +**/ +uint32_t +pal_exerciser_get_legacy_irq_map(uint32_t Seg, uint32_t Bus, uint32_t Dev, uint32_t Fn, PERIPHERAL_IRQ_MAP *IrqMap) +{ + return 0; +} + diff --git a/acs-drv/files/platform/pal_linux/files/common/COPYING b/acs-drv/files/platform/pal_linux/files/common/COPYING new file mode 100644 index 0000000..6d45519 --- /dev/null +++ b/acs-drv/files/platform/pal_linux/files/common/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/acs-drv/files/platform/pal_linux/files/common/Makefile b/acs-drv/files/platform/pal_linux/files/common/Makefile new file mode 100644 index 0000000..74105f5 --- /dev/null +++ b/acs-drv/files/platform/pal_linux/files/common/Makefile @@ -0,0 +1,50 @@ +## @file + # + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License version 2 as + # published by the Free Software Foundation. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + # + # Copyright (C) 2016-2018, 2021 Arm Limited + # +## + +export CROSS_COMPILE ?= aarch64-linux-gnu- +export ARCH ?= arm64 + +#since we have copied the files locally +ACS_DIR ?= . + +PAL_SRC = $(ACS_DIR)/src + +obj-m += bsa_acs_pal.o +bsa_acs_pal-objs += $(PAL_SRC)/pal_misc.o \ + $(PAL_SRC)/pal_pe.o $(PAL_SRC)/pal_pcie.o $(PAL_SRC)/pal_pcie_enumeration.o \ + $(PAL_SRC)/pal_smmu.o $(PAL_SRC)/pal_iovirt.o $(PAL_SRC)/pal_peripherals.o \ + $(PAL_SRC)/pal_dma.o $(PAL_SRC)/pal_acpi.o $(PAL_SRC)/pal_gic.o $(PAL_SRC)/pal_exerciser.o \ + $(PAL_SRC)/pal_dt.o + +ccflags-y=-I$(PWD)/$(ACS_DIR)/val/include -I$(PWD)/$(ACS_DIR)/include -I$(PWD) -I$(PWD)/../../ -I$(PWD)/../../../ -DTARGET_LINUX -Wall -Werror + +all: +ifeq ($(KERNEL_SRC),) + echo " KERNEL_SRC variable should be set to kernel path " + exit 1 +else + echo "Kernel source is set to $(KERNEL_SRC)" +endif + + make -C $(KERNEL_SRC) M=$(PWD) modules + +modules_install: + $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install + +clean: + make -C $(KERNEL_SRC) M=$(PWD) clean diff --git a/bsa-acs-drv/files/platform/pal_linux/files/include/pal_exerciser.h b/acs-drv/files/platform/pal_linux/files/common/include/pal_exerciser.h similarity index 86% rename from bsa-acs-drv/files/platform/pal_linux/files/include/pal_exerciser.h rename to acs-drv/files/platform/pal_linux/files/common/include/pal_exerciser.h index d95e645..b342aed 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/include/pal_exerciser.h +++ b/acs-drv/files/platform/pal_linux/files/common/include/pal_exerciser.h @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2021, 2023 Arm Limited + * Copyright (C) 2016-2021, 2023-2024, Arm Limited * */ @@ -125,17 +125,6 @@ typedef enum { EXERCISER_DATA_BAR0_SPACE = 0x2, } EXERCISER_DATA_TYPE; -#define LEGACY_PCI_IRQ_CNT 4 -#define MAX_IRQ_CNT 0xFFFF // This value is arbitrary and may have to be adjusted - -typedef struct { - uint32_t irq_list[MAX_IRQ_CNT]; - uint32_t irq_count; -} PERIFERAL_IRQ_LIST; - -typedef struct { - PERIFERAL_IRQ_LIST legacy_irq_map[LEGACY_PCI_IRQ_CNT]; -} PERIPHERAL_IRQ_MAP; void pal_exerciser_create_info_table(EXERCISER_INFO_TABLE *exerciser_info_table); uint32_t pal_exerciser_get_info(EXERCISER_INFO_TYPE type, uint32_t instance); @@ -145,7 +134,5 @@ uint32_t pal_exerciser_set_state(EXERCISER_STATE state, uint64_t *value, uint32_ uint32_t pal_exerciser_get_state(EXERCISER_STATE *state, uint32_t bdf); uint32_t pal_exerciser_ops(EXERCISER_OPS ops, uint64_t param, uint32_t instance); uint32_t pal_exerciser_get_data(EXERCISER_DATA_TYPE type, exerciser_data_t *data, uint32_t instance); -uint32_t pal_exerciser_get_legacy_irq_map(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn, - PERIPHERAL_IRQ_MAP *irq_map); #endif diff --git a/bsa-acs-drv/files/platform/pal_linux/files/include/pal_linux.h b/acs-drv/files/platform/pal_linux/files/common/include/pal_linux.h similarity index 91% rename from bsa-acs-drv/files/platform/pal_linux/files/include/pal_linux.h rename to acs-drv/files/platform/pal_linux/files/common/include/pal_linux.h index 09f5112..a2df0a0 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/include/pal_linux.h +++ b/acs-drv/files/platform/pal_linux/files/common/include/pal_linux.h @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2018,2021 Arm Limited + * Copyright (C) 2016-2018, 2021, 2024, Arm Limited * * Author: Prasanth Pulla * @@ -29,7 +29,8 @@ #include #include -#include "val/include/pal_interface.h" +#include "val/common/include/pal_interface.h" +#include "val/bsa/include/bsa_pal_interface.h" #define PAL_LINUX_SUCCESS 0x0 #define PAL_LINUX_ERR 0xEDCB1234 //some impropable value? @@ -79,7 +80,7 @@ int pal_smmu_check_dev_attach(struct device *dev); #define ACS_PRINT_DEBUG 2 /* For Debug statements. contains register dumps etc */ #define ACS_PRINT_INFO 1 /* Print all statements. Do not use unless really needed */ -#define bsa_print(verbosity, string, data) \ +#define acs_print(verbosity, string, data) \ if(verbosity >= g_print_level) { \ pal_print(string, data); \ } diff --git a/bsa-acs-drv/files/platform/pal_linux/files/include/bsa_pcie_enum.h b/acs-drv/files/platform/pal_linux/files/common/include/pal_pcie_enum.h similarity index 95% rename from bsa-acs-drv/files/platform/pal_linux/files/include/bsa_pcie_enum.h rename to acs-drv/files/platform/pal_linux/files/common/include/pal_pcie_enum.h index 4f10560..da7d0a5 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/include/bsa_pcie_enum.h +++ b/acs-drv/files/platform/pal_linux/files/common/include/pal_pcie_enum.h @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2018, 2021-2022 Arm Limited + * Copyright (C) 2016-2018, 2021-2022, 2024, Arm Limited * * Author: Prasanth Pulla * diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_acpi.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_acpi.c similarity index 89% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_acpi.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_acpi.c index 52a2944..0101cf8 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_acpi.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_acpi.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,32 +13,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2018,2021 Arm Limited + * Copyright (C) 2016-2018, 2021, 2024, Arm Limited * * Author: Prasanth Pulla * */ -#include "include/pal_linux.h" +#include "common/include/pal_linux.h" #include #include #include #include - -uint32_t -pal_target_is_dt() -{ - return 0; -} - -void -pal_dump_dtb() -{ - return; -} - uint64_t pal_get_madt_ptr(void) { @@ -72,3 +59,15 @@ pal_get_iort_ptr(void) return (uint64_t)iort_table; } + +uint32_t +pal_target_is_bm() +{ + return 0; +} + +uint32_t +pal_target_is_dt() +{ + return 0; +} diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_dma.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_dma.c similarity index 93% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_dma.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_dma.c index 383e9a6..dca9179 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_dma.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_dma.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2018,2021,2023-2024 Arm Limited + * Copyright (C) 2016-2018,2021,2023-2024, Arm Limited * * Author: Prasanth Pulla * @@ -39,8 +39,8 @@ #include -#include "include/pal_linux.h" -#include "include/bsa_pcie_enum.h" +#include "common/include/pal_linux.h" +#include "common/include/pal_pcie_enum.h" #include #include @@ -56,14 +56,14 @@ pal_dma_mem_alloc(void **buffer, unsigned int length, void *port, unsigned int f if (flags == DMA_COHERENT) { *buffer = dmam_alloc_coherent(((struct ata_port *)port)->dev, length, &mem_dma, GFP_KERNEL); if (!(*buffer)) { - pr_err ("BSA-DRV - Alloc failure %s \n", __func__); + pr_err("ACS-DRV - Alloc failure %s \n", __func__); return -ENOMEM; } } else { *buffer = kmalloc(length, GFP_KERNEL); mem_dma = dma_map_single(((struct ata_port *)port)->dev, *buffer, length, DMA_BIDIRECTIONAL); if (dma_mapping_error(((struct ata_port *)port)->dev, mem_dma)) { - pr_err("BSA_DRV : DMA Map single page failed.\n"); + pr_err("ACS_DRV : DMA Map single page failed.\n"); kfree(*buffer); return -1; } @@ -242,12 +242,12 @@ pal_dma_mem_get_attrs(void *buf, uint32_t *attr, uint32_t *sh) pgd = pgd_offset_k((uint64_t)buf); if(!pgd) return -1; - bsa_print(ACS_PRINT_DEBUG, "DEBUG : pgd from pgd_offset_k: 0x%llx\n", (uint64_t)(pgd->pgd)); + acs_print(ACS_PRINT_DEBUG, "DEBUG : pgd from pgd_offset_k: 0x%llx\n", (uint64_t)(pgd->pgd)); pud = pud_offset((p4d_t *) pgd, (uint64_t)buf); if(!pud) return -1; - bsa_print(ACS_PRINT_DEBUG, "DEBUG : pud from pud_offset: 0x%llx\n", (uint64_t)(pud_val(*pud))); + acs_print(ACS_PRINT_DEBUG, "DEBUG : pud from pud_offset: 0x%llx\n", (uint64_t)(pud_val(*pud))); if(!(pud_val(*pud) & 0x2)) { decode_mem_attr_sh(pud_val(*pud), attr, sh); @@ -257,7 +257,7 @@ pal_dma_mem_get_attrs(void *buf, uint32_t *attr, uint32_t *sh) pmd = pmd_offset(pud, (uint64_t)buf); if(!pmd) return -1; - bsa_print(ACS_PRINT_DEBUG, "DEBUG : pmd from pmd_offset: 0x%llx\n", (uint64_t)(pmd_val(*pmd))); + acs_print(ACS_PRINT_DEBUG, "DEBUG : pmd from pmd_offset: 0x%llx\n", (uint64_t)(pmd_val(*pmd))); if(!(pmd_val(*pmd) & 0x2)) { decode_mem_attr_sh(pmd_val(*pmd), attr, sh); @@ -267,7 +267,7 @@ pal_dma_mem_get_attrs(void *buf, uint32_t *attr, uint32_t *sh) pte = pte_offset_kernel(pmd, (uint64_t)buf); if(!pte) return -1; - bsa_print(ACS_PRINT_DEBUG, "DEBUG : pte from pte_offset_kernel: 0x%llx\n", (uint64_t)(pte_val(*pte))); + acs_print(ACS_PRINT_DEBUG, "DEBUG : pte from pte_offset_kernel: 0x%llx\n", (uint64_t)(pte_val(*pte))); if(is_pte(pte_val(*pte))) { decode_mem_attr_sh(pte_val(*pte), attr, sh); diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_exerciser.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_exerciser.c similarity index 89% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_exerciser.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_exerciser.c index 86028d4..c9514b5 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_exerciser.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_exerciser.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,11 +13,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2021,2023 Arm Limited + * Copyright (C) 2016-2021, 2023, 2024 Arm Limited * */ -#include "include/pal_exerciser.h" +#include "common/include/pal_exerciser.h" /** @brief This API popultaes information from all the PCIe stimulus generation IP available @@ -119,21 +119,3 @@ uint32_t pal_exerciser_get_data(EXERCISER_DATA_TYPE type, exerciser_data_t *data { return 0; } - -/** - @brief Get legacy IRQ routing for a PCI device - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - @param irq_map pointer to IRQ map structure - - @return irq_map IRQ routing map - @return status code -**/ -uint32_t -pal_exerciser_get_legacy_irq_map(uint32_t Seg, uint32_t Bus, uint32_t Dev, uint32_t Fn, PERIPHERAL_IRQ_MAP *IrqMap) -{ - return 0; -} - diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_gic.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_gic.c similarity index 87% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_gic.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_gic.c index 7bff2c1..3ba5b30 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_gic.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_gic.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -17,7 +17,7 @@ * */ -#include "include/pal_linux.h" +#include "common/include/pal_linux.h" #include #include #include @@ -31,15 +31,15 @@ unsigned int pal_gic_install_isr(unsigned int int_id, void (*isr)(void)) struct irq_domain *domain = NULL; struct irq_fwspec *fwspec; - domain = acs_get_irq_domain(); + domain = acs_get_irq_domain(); if (!domain) { - bsa_print(ACS_PRINT_ERR, "\n Domain is null", 0); + acs_print(ACS_PRINT_ERR, "\n Domain is null", 0); return 1; } fwspec = kmalloc(sizeof(struct irq_fwspec), GFP_KERNEL); if (!fwspec) { - bsa_print(ACS_PRINT_ERR, "\n Kmalloc failed", 0); + acs_print(ACS_PRINT_ERR, "\n Kmalloc failed", 0); return 1; } @@ -68,10 +68,10 @@ unsigned int pal_gic_install_isr(unsigned int int_id, void (*isr)(void)) } } - ret = request_irq(virq, (irq_handler_t)isr, flags, "BSA", NULL); + ret = request_irq(virq, (irq_handler_t)isr, flags, "ACS", NULL); if (ret != 0) { - bsa_print(ACS_PRINT_ERR, "\n IRQ registration failure %x", int_id); - bsa_print(ACS_PRINT_ERR, " \n err %d", ret); + acs_print(ACS_PRINT_ERR, "\n IRQ registration failure %x", int_id); + acs_print(ACS_PRINT_ERR, " \n err %d", ret); ret = 1; goto error; } diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_iovirt.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_iovirt.c similarity index 83% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_iovirt.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_iovirt.c index 3a50385..404d8ab 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_iovirt.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_iovirt.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2019, 2021, 2023 Arm Limited + * Copyright (C) 2016-2019, 2021, 2023, 2024, Arm Limited * * Author: Sakar Arora * @@ -24,9 +24,9 @@ #include #include -#include "include/pal_linux.h" -#include "include/bsa_pcie_enum.h" -#include "include/pal_dt.h" +#include "common/include/pal_linux.h" +#include "common/include/pal_pcie_enum.h" +#include "bsa/include/bsa_pal_dt.h" #if LINUX_VERSION_CODE < KERNEL_VERSION(4,18,0) struct acpi_iort_pmcg { @@ -46,17 +46,18 @@ dump_block(IOVIRT_BLOCK *block) NODE_DATA_MAP *map = &block->data_map[0]; switch(block->type) { case ACPI_IORT_NODE_ITS_GROUP: - bsa_print(ACS_PRINT_INFO, "\nITS Group:\n Num ITS:%d\n", (*map).id[0]); + acs_print(ACS_PRINT_INFO, "\nITS Group:\n Num ITS:%d\n", (*map).id[0]); for(i = 0; i < block->data.its_count; i++) - bsa_print(ACS_PRINT_INFO, "%d ", (*map).id[i]); + acs_print(ACS_PRINT_INFO, "%d ", (*map).id[i]); - bsa_print(ACS_PRINT_INFO, "\n", 0); + acs_print(ACS_PRINT_INFO, "\n", 0); return; case ACPI_IORT_NODE_NAMED_COMPONENT: - pr_info("\nNamed Component:\n Device Name:%s\n", block->data.name); + pr_info("\nNamed Component:\n Device Name:%s\n", block->data.named_comp.name); + pr_info(" CCA Attribute: 0x%x\n", block->data.named_comp.cca); break; case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: - bsa_print(ACS_PRINT_INFO, "\nRoot Complex:\n PCI segment number:%d\n", block->data.rc.segment); + acs_print(ACS_PRINT_INFO, "\nRoot Complex:\n PCI segment number:%d\n", block->data.rc.segment); break; case ACPI_IORT_NODE_SMMU: case ACPI_IORT_NODE_SMMU_V3: @@ -69,13 +70,13 @@ dump_block(IOVIRT_BLOCK *block) break; } - bsa_print(ACS_PRINT_INFO, "Number of ID Mappings:%d\n", block->num_data_map); + acs_print(ACS_PRINT_INFO, "Number of ID Mappings:%d\n", block->num_data_map); for(i = 0; i < block->num_data_map; i++, map++) { pr_info("\n input_base:0x%x\n id_count:0x%x\n output_base:0x%x\n output ref:0x%x\n", (*map).map.input_base, (*map).map.id_count, (*map).map.output_base, (*map).map.output_ref); } - bsa_print(ACS_PRINT_INFO, "\n", 0); + acs_print(ACS_PRINT_INFO, "\n", 0); } static void @@ -83,7 +84,7 @@ dump_iovirt_table(IOVIRT_INFO_TABLE *iort) { uint32_t i; IOVIRT_BLOCK *block = &iort->blocks[0]; - bsa_print(ACS_PRINT_INFO, "Number of IOVIRT blocks = %d\n", iort->num_blocks); + acs_print(ACS_PRINT_INFO, "Number of IOVIRT blocks = %d\n", iort->num_blocks); for(i = 0; i < iort->num_blocks; i++, block = IOVIRT_NEXT_BLOCK(block)) dump_block(block); } @@ -223,6 +224,7 @@ iovirt_add_block(struct acpi_table_iort *iort, struct acpi_iort_node *iort_node, NODE_DATA_MAP *data_map = &((*block)->data_map[0]); NODE_DATA *data = &((*block)->data); void *node_data = &(iort_node->node_data[0]); + struct acpi_iort_node *node_ref_block; pr_info("IORT node offset:%lx, type: %d\n", (uint8_t*)iort_node - (uint8_t*)iort, iort_node->type); @@ -245,13 +247,15 @@ iovirt_add_block(struct acpi_table_iort *iort, struct acpi_iort_node *iort_node, count = &iovirt_table->num_its_groups; break; case ACPI_IORT_NODE_NAMED_COMPONENT: - strncpy((char*)(*data).name, (char*)&((struct acpi_iort_named_component*)node_data)->device_name[0], 16); + strncpy((char*)(*data).named_comp.name, (char*)&((struct acpi_iort_named_component*)node_data)->device_name[0], 16); + (*data).named_comp.cca = (uint32_t)(((struct acpi_iort_named_component*)node_data)->memory_properties & IOVIRT_CCA_MASK); count = &iovirt_table->num_named_components; break; case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: (*data).rc.segment = ((struct acpi_iort_root_complex*)node_data)->pci_segment_number; (*data).rc.cca = (uint32_t)(((struct acpi_iort_root_complex*)node_data)->memory_properties & IOVIRT_CCA_MASK); (*data).rc.ats_attr = ((struct acpi_iort_root_complex*)node_data)->ats_attribute; + (*data).rc.smmu_base = 0; /* initialize smmu_base info for root complex */ count = &iovirt_table->num_pci_rcs; break; case ACPI_IORT_NODE_SMMU: @@ -271,11 +275,19 @@ iovirt_add_block(struct acpi_table_iort *iort, struct acpi_iort_node *iort_node, next_block = ACPI_ADD_PTR(IOVIRT_BLOCK, data_map, (*block)->num_data_map * sizeof(NODE_DATA_MAP)); offset = iovirt_add_block(iort, ACPI_ADD_PTR(struct acpi_iort_node, iort, (*data).pmcg.node_ref), iovirt_table, &next_block); - (*data).pmcg.node_ref = offset; + /* if the PMCG node is associated with a SMMU, store SMMU base */ + node_ref_block = ACPI_ADD_PTR(struct acpi_iort_node, iort, (*data).pmcg.node_ref); + if (node_ref_block->type == ACPI_IORT_NODE_SMMU + || node_ref_block->type == ACPI_IORT_NODE_SMMU_V3) { + (*data).pmcg.smmu_base = ((struct acpi_iort_smmu *)node_ref_block->node_data)->base_address; + } + else { + (*data).pmcg.smmu_base = 0; + } count = &iovirt_table->num_pmcgs; break; default: - bsa_print(ACS_PRINT_ERR, "Invalid IORT node type\n", 0); + acs_print(ACS_PRINT_ERR, "Invalid IORT node type\n", 0); return (uint32_t) -1; } @@ -331,6 +343,18 @@ iovirt_add_block(struct acpi_table_iort *iort, struct acpi_iort_node *iort_node, (*data).rc.smmu_base = (*temp_data).smmu.base; } + /* If this node is a named component, Check whether it is behind a SMMU + * store the SMMU base in named component info structure if true, else + * save NULL pointer. + */ + temp_block = ACPI_ADD_PTR(IOVIRT_BLOCK, iovirt_table, offset); + if (((*block)->type == ACPI_IORT_NODE_NAMED_COMPONENT) && + ((temp_block->type == ACPI_IORT_NODE_SMMU) || + (temp_block->type == ACPI_IORT_NODE_SMMU_V3))) { + temp_data = &(temp_block->data); + (*data).named_comp.smmu_base = (*temp_data).smmu.base; + } + } } /* So we successfully added a new block. Calculate its offset */ @@ -367,28 +391,31 @@ pal_iovirt_create_info_table(IOVIRT_INFO_TABLE *iovirt_table) iort = (struct acpi_table_iort *)pal_get_iort_ptr(); - if (iort == NULL) { + if (iort) { + /* Point to the first Iovirt table block */ + next_block = &(iovirt_table->blocks[0]); + + /* Point to the first IORT node */ + iort_node = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->node_offset); + iort_end = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->header.length); + /* Create iovirt block for each IORT node*/ + for (i = 0; i < iort->node_count; i++) { + if (iort_node >= iort_end) { + acs_print(ACS_PRINT_ERR, "Bad IORT table \n", 0); + return; + } + iovirt_add_block(iort, iort_node, iovirt_table, &next_block); + iort_node = ACPI_ADD_PTR(struct acpi_iort_node, iort_node, iort_node->length); + } + dump_iovirt_table(iovirt_table); + check_mapping_overlap(iovirt_table); + } +#ifndef BUILD_SBSA + else { pal_iovirt_create_info_table_dt(iovirt_table); return; } - - /* Point to the first Iovirt table block */ - next_block = &(iovirt_table->blocks[0]); - - /* Point to the first IORT node */ - iort_node = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->node_offset); - iort_end = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->header.length); - /* Create iovirt block for each IORT node*/ - for (i = 0; i < iort->node_count; i++) { - if (iort_node >= iort_end) { - bsa_print(ACS_PRINT_ERR, "Bad IORT table \n", 0); - return; - } - iovirt_add_block(iort, iort_node, iovirt_table, &next_block); - iort_node = ACPI_ADD_PTR(struct acpi_iort_node, iort_node, iort_node->length); - } - dump_iovirt_table(iovirt_table); - check_mapping_overlap(iovirt_table); +#endif } /** @@ -460,7 +487,7 @@ pal_iovirt_get_rc_smmu_base(IOVIRT_INFO_TABLE *iovirt, uint32_t rc_seg_num, uint } if (!mapping_found) { - bsa_print(ACS_PRINT_ERR, + acs_print(ACS_PRINT_ERR, "GET_DEVICE_ID: Requestor ID to Stream ID/Device ID mapping not found\n", 0); return 0xFFFFFFFF; } @@ -475,7 +502,7 @@ pal_iovirt_get_rc_smmu_base(IOVIRT_INFO_TABLE *iovirt, uint32_t rc_seg_num, uint if (sid >= (*map).map.input_base && sid <= ((*map).map.input_base + (*map).map.id_count)) { - bsa_print(ACS_PRINT_DEBUG, "RC block->data.smmu.base: %llx", block->data.smmu.base); + acs_print(ACS_PRINT_DEBUG, "RC block->data.smmu.base: %llx", block->data.smmu.base); return block->data.smmu.base; } } @@ -484,6 +511,6 @@ pal_iovirt_get_rc_smmu_base(IOVIRT_INFO_TABLE *iovirt, uint32_t rc_seg_num, uint /* The Root Complex represented by rc_seg_num * is not behind any SMMU. Return NULL pointer */ - bsa_print(ACS_PRINT_DEBUG, "No SMMU found behind the RootComplex with seg :%x", rc_seg_num); + acs_print(ACS_PRINT_DEBUG, "No SMMU found behind the RootComplex with seg :%x", rc_seg_num); return 0; } diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_misc.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_misc.c similarity index 98% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_misc.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_misc.c index 37aaec6..5bc0b16 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_misc.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_misc.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -25,7 +25,7 @@ #include #include #include -#include "include/pal_linux.h" +#include "common/include/pal_linux.h" unsigned int *gSharedMemory; @@ -115,7 +115,7 @@ uint32_t pal_mmio_read(uint64_t addr) void __iomem *p; if (addr & 0x3) { - bsa_print(ACS_PRINT_INFO, "\n Error-Input address is not aligned." + acs_print(ACS_PRINT_INFO, "\n Error-Input address is not aligned." " Masking the last 2 bits \n", 0); addr = addr & ~(0x3); //make sure addr is aligned to 4 bytes } @@ -348,7 +348,7 @@ void *pal_mem_virt_to_phys(void *va) **/ void pal_mem_allocate_shared(unsigned int num_pe, unsigned int sizeofentry) { - gSharedMemory = 0; + gSharedMemory = 0; gSharedMemory = kmalloc((num_pe * sizeofentry), GFP_KERNEL); diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_pcie.c similarity index 98% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_pcie.c index 3693676..5f26ac9 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_pcie.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -20,8 +20,8 @@ * */ -#include "include/pal_linux.h" -#include "include/pal_dt.h" +#include "common/include/pal_linux.h" +#include "bsa/include/bsa_pal_dt.h" #include #include @@ -212,9 +212,10 @@ pal_pcie_create_info_table(PCIE_INFO_TABLE *PcieTable) i++; PcieTable->num_entries++; } while((length < mcfg->header.length) && (entry)); - +#ifndef BUILD_SBSA } else { pal_pcie_create_info_table_dt(PcieTable); +#endif } return; @@ -335,7 +336,7 @@ pal_pcie_is_devicedma_64bit(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t f pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); if (pdev) { - bsa_print(ACS_PRINT_INFO,"dma mask is %llx \n", *pdev->dev.dma_mask); + acs_print(ACS_PRINT_INFO,"dma mask is %llx \n", *pdev->dev.dma_mask); if (*pdev->dev.dma_mask == DMA_BIT_MASK(64)) return 1; else @@ -364,7 +365,7 @@ pal_pcie_device_driver_present(uint32_t seg, uint32_t bus, uint32_t dev, uint32_ if (pdev) { driver = (*pdev).driver; if (driver && driver->name) { - bsa_print(ACS_PRINT_INFO,"driver name is %s \n", *driver->name); + acs_print(ACS_PRINT_INFO,"driver name is %s \n", *driver->name); return 1; } else @@ -631,7 +632,7 @@ uint32_t pal_bsa_pcie_enumerate(void) uint32_t pal_pcie_is_cache_present(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) { - return 1; + return 1; /* SBSA has it return 0 TODO */ } /** diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie_enumeration.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_pcie_enumeration.c similarity index 96% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie_enumeration.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_pcie_enumeration.c index 72691bf..582a070 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie_enumeration.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_pcie_enumeration.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2018, 2021-2022 Arm Limited + * Copyright (C) 2016-2018, 2021-2022, 2024, Arm Limited * * Author: Prasanth Pulla * @@ -22,8 +22,8 @@ #include #include -#include "include/bsa_pcie_enum.h" -#include "include/pal_linux.h" +#include "common/include/pal_pcie_enum.h" +#include "common/include/pal_linux.h" /** diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_pe.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_pe.c similarity index 96% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_pe.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_pe.c index 6e8ee94..c47aa3f 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_pe.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_pe.c @@ -19,13 +19,13 @@ * */ -#include "include/pal_linux.h" +#include "common/include/pal_linux.h" #include #include #include #include #include -#include "include/pal_dt.h" +#include "bsa/include/bsa_pal_dt.h" /** @brief This API fills in the PE_INFO Table with information about the PEs in the @@ -48,13 +48,8 @@ pal_pe_create_info_table(PE_INFO_TABLE *PeTable) madt = (struct acpi_table_madt *)pal_get_madt_ptr(); - if (!madt) { - // Get from DT - // - pal_pe_create_info_table_dt(PeTable); - return; - } - + if (madt) { + table_length = madt->header.length; length = sizeof(struct acpi_table_madt); entry = (struct acpi_madt_generic_interrupt *) &madt[1]; @@ -73,8 +68,17 @@ pal_pe_create_info_table(PE_INFO_TABLE *PeTable) entry = (struct acpi_madt_generic_interrupt *) ((u8 *)entry + (entry->header.length)); } while(length < table_length); +#ifndef BUILD_SBSA + } else { + // Get from DT + // + pal_pe_create_info_table_dt(PeTable); + return; +#endif + } } + /** @brief Install Exception Handler using UEFI CPU Architecture protocol's Register Interrupt Handler API @@ -88,7 +92,7 @@ unsigned int pal_pe_install_esr(unsigned int ExceptionType, void (*esr)(unsigned long long, void *)) { - return 0; + return 0; /* IN SBSA it is 1 TODO */ } void diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_peripherals.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_peripherals.c similarity index 93% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_peripherals.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_peripherals.c index 9c104d2..6ec8802 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_peripherals.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_peripherals.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2018, 2020-2023 Arm Limited + * Copyright (C) 2016-2018, 2020-2023, 2024, Arm Limited * * Author: Prasanth Pulla * @@ -24,9 +24,8 @@ #include #include -#include "include/pal_linux.h" -#include "include/bsa_pcie_enum.h" -//#include "include/platform_override.h" +#include "common/include/pal_linux.h" +#include "common/include/pal_pcie_enum.h" #define USB_CLASSCODE 0x0C0330 #define SATA_CLASSCODE 0x010601 @@ -76,13 +75,13 @@ pal_peripheral_create_info_table(PERIPHERAL_INFO_TABLE *peripheralInfoTable) /* check for any XHCI - USB Controllers */ case USB_CLASSCODE: per_info->type = PERIPHERAL_TYPE_USB; - bsa_print(ACS_PRINT_INFO, "Found a USB controller %4x \n", per_info->bdf); + acs_print(ACS_PRINT_INFO, "Found a USB controller %4x \n", per_info->bdf); peripheralInfoTable->header.num_usb++; break; /* check for any AHCI - SATA Controllers */ case SATA_CLASSCODE: per_info->type = PERIPHERAL_TYPE_SATA; - bsa_print(ACS_PRINT_INFO, "Found a SATA controller %4x \n", per_info->bdf); + acs_print(ACS_PRINT_INFO, "Found a SATA controller %4x \n", per_info->bdf); per_info->base1 = pal_pcie_get_base (pdev, BAR5); peripheralInfoTable->header.num_sata++; break; diff --git a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_smmu.c b/acs-drv/files/platform/pal_linux/files/common/src/pal_smmu.c similarity index 85% rename from bsa-acs-drv/files/platform/pal_linux/files/src/pal_smmu.c rename to acs-drv/files/platform/pal_linux/files/common/src/pal_smmu.c index e8ce6a3..a7cedd3 100644 --- a/bsa-acs-drv/files/platform/pal_linux/files/src/pal_smmu.c +++ b/acs-drv/files/platform/pal_linux/files/common/src/pal_smmu.c @@ -1,5 +1,5 @@ /* - * BSA ACS Platform module. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2019, 2021, 2023, Arm Limited + * Copyright (C) 2016-2019, 2021, 2023-2024, Arm Limited * * Author: Prasanth Pulla * @@ -25,7 +25,7 @@ #include #include -#include "include/pal_linux.h" +#include "common/include/pal_linux.h" #define SMMU_V3_IDR1 0x4 #define SMMU_V3_IDR1_PASID_SHIFT 6 @@ -43,7 +43,7 @@ void pal_smmu_device_start_monitor_iova(void *port) { if (!pal_smmu_check_dev_attach(((struct ata_port *)port)->dev)) { - bsa_print(ACS_PRINT_WARN, "\n This device is not behind an SMMU ", 0); + acs_print(ACS_PRINT_WARN, "\n This device is not behind an SMMU ", 0); return; } @@ -54,7 +54,7 @@ void pal_smmu_device_stop_monitor_iova(void *port) { if (!pal_smmu_check_dev_attach(((struct ata_port *)port)->dev)) { - bsa_print(ACS_PRINT_WARN, "\n This device is not behind an SMMU ", 0); + acs_print(ACS_PRINT_WARN, "\n This device is not behind an SMMU ", 0); return; } @@ -79,7 +79,7 @@ pal_smmu_check_device_iova(void *port, unsigned long long dma_addr) phys_addr_t phys; if (!pal_smmu_check_dev_attach(((struct ata_port *)port)->dev)) { - bsa_print(ACS_PRINT_WARN, "\n This device is not behind an SMMU ", 0); + acs_print(ACS_PRINT_WARN, "\n This device is not behind an SMMU ", 0); return PAL_LINUX_SKIP; } @@ -111,6 +111,15 @@ pal_smmu_check_device_iova(void *port, unsigned long long dma_addr) return PAL_LINUX_ERR; } +uint32_t +pal_smmu_max_pasids(uint64_t smmu_base) +{ + uint32_t reg = pal_mmio_read(smmu_base + SMMU_V3_IDR1); + uint32_t pasid_bits = reg >> SMMU_V3_IDR1_PASID_SHIFT & SMMU_V3_IDR1_PASID_MASK; + if(pasid_bits == 0) + return 0; + return (1 << pasid_bits); +} uint32_t pal_smmu_create_pasid_entry(uint64_t smmu_base, uint32_t pasid) { diff --git a/bsa-acs-drv/files/linux_bsa_acs.sh b/bsa-acs-drv/files/linux_bsa_acs.sh deleted file mode 100755 index 46fe86a..0000000 --- a/bsa-acs-drv/files/linux_bsa_acs.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -echo "==================================================================" -echo "This script will compile the Linux BSA Kernel module " -echo "==================================================================" - -BSA_ACS_PATH=`pwd` -if [ -z $KERNEL_SRC ] -then - echo "Error: set KERNEL_SRC path" - exit 0 -fi - -if [ $(uname -m) != "aarch64" ] && [ -z $CROSS_COMPILE ] -then - echo "Error: set CROSS_COMPILE path for cross compile" - exit 0 -fi - -cd $BSA_ACS_PATH/platform/pal_linux/files -make -cp bsa_acs_pal.o $BSA_ACS_PATH/ - -cd $BSA_ACS_PATH/val/ -make -cp bsa_acs_val.o $BSA_ACS_PATH/ - -cd $BSA_ACS_PATH/test_pool/ -make -cp bsa_acs_test.o $BSA_ACS_PATH/ - -cd $BSA_ACS_PATH/ -make -- GitLab From 00c239849747aeb60dcdc530fc52a9eff98eef79 Mon Sep 17 00:00:00 2001 From: Srikar Josyula Date: Tue, 26 Mar 2024 15:07:00 +0530 Subject: [PATCH 2/2] Common VAL PAL for linux-acs - SBSA changes - Removed sbsa-acs-drv and moved SBSA specific APIs to pal_linux/files/sbsa folder. Signed-off-by: Srikar Josyula Co-authored-by: Chetan Rathore --- .../Makefile => acs-drv/files/MakefileSBSA | 0 .../files/linux_sbsa_acs.sh | 3 + .../platform/pal_linux/files/MakefileSBSA | 51 ++ .../platform/pal_linux/files/sbsa}/COPYING | 0 .../platform/pal_linux/files/sbsa}/Makefile | 0 .../files/sbsa/include/sbsa_pal_linux.h | 36 +- .../files/sbsa/src/sbsa_pal_iovirt.c | 84 +++ .../files/sbsa_acs_drv.c | 56 +- .../files/sbsa_acs_drv.h | 1 - acs-drv/files/sbsa_setup.sh | 19 + ffa-acs-drv/Makefile | 73 -- ffa-acs-drv/README.md | 65 -- ffa-acs-drv/ffa_acs.c | 84 --- .../kernel/0001-FFA-ACS-Linux-v5.0.patch | 127 ---- ffa-acs-drv/linux_ffa_acs.sh | 53 -- ffa-acs-drv/pal_linux/Makefile | 77 -- ffa-acs-drv/pal_linux/inc/pal_arch_helpers.h | 53 -- ffa-acs-drv/pal_linux/inc/pal_config_def.h | 110 --- .../pal_linux/inc/pal_smmuv3_testengine.h | 115 --- ffa-acs-drv/pal_linux/src/pal_driver.c | 144 ---- ffa-acs-drv/pal_linux/src/pal_irq.c | 129 ---- ffa-acs-drv/pal_linux/src/pal_misc.c | 84 --- ffa-acs-drv/pal_linux/src/pal_mmio.c | 192 ----- .../pal_linux/src/pal_smmuv3_testengine.c | 106 --- ffa-acs-drv/pal_linux/src/pal_vcpu_setup.c | 55 -- ffa-acs-drv/setup.sh | 36 - sbsa-acs-drv/files/COPYING | 340 --------- .../files/platform/pal_linux/files/COPYING | 340 --------- .../pal_linux/files/include/pal_exerciser.h | 138 ---- .../pal_linux/files/include/pal_linux.h | 92 --- .../pal_linux/files/include/sbsa_pcie_enum.h | 64 -- .../platform/pal_linux/files/src/pal_acpi.c | 67 -- .../platform/pal_linux/files/src/pal_dma.c | 281 ------- .../pal_linux/files/src/pal_exerciser.c | 127 ---- .../platform/pal_linux/files/src/pal_gic.c | 124 ---- .../platform/pal_linux/files/src/pal_iovirt.c | 563 -------------- .../platform/pal_linux/files/src/pal_misc.c | 478 ------------ .../platform/pal_linux/files/src/pal_pcie.c | 685 ------------------ .../files/src/pal_pcie_enumeration.c | 187 ----- .../platform/pal_linux/files/src/pal_pe.c | 148 ---- .../pal_linux/files/src/pal_peripherals.c | 170 ----- .../platform/pal_linux/files/src/pal_smmu.c | 137 ---- .../files/platform/pal_linux/sbsa-acs-pal.bb | 20 - sbsa-acs-drv/files/setup.sh | 17 - sbsa-acs-drv/sbsa-acs-drv.bb | 31 - 45 files changed, 199 insertions(+), 5563 deletions(-) rename sbsa-acs-drv/files/Makefile => acs-drv/files/MakefileSBSA (100%) rename {sbsa-acs-drv => acs-drv}/files/linux_sbsa_acs.sh (90%) create mode 100644 acs-drv/files/platform/pal_linux/files/MakefileSBSA rename {ffa-acs-drv => acs-drv/files/platform/pal_linux/files/sbsa}/COPYING (100%) rename {sbsa-acs-drv/files/platform/pal_linux/files => acs-drv/files/platform/pal_linux/files/sbsa}/Makefile (100%) rename ffa-acs-drv/ffa_acs.h => acs-drv/files/platform/pal_linux/files/sbsa/include/sbsa_pal_linux.h (50%) create mode 100644 acs-drv/files/platform/pal_linux/files/sbsa/src/sbsa_pal_iovirt.c rename {sbsa-acs-drv => acs-drv}/files/sbsa_acs_drv.c (76%) mode change 100644 => 100755 rename {sbsa-acs-drv => acs-drv}/files/sbsa_acs_drv.h (97%) create mode 100755 acs-drv/files/sbsa_setup.sh delete mode 100644 ffa-acs-drv/Makefile delete mode 100644 ffa-acs-drv/README.md delete mode 100644 ffa-acs-drv/ffa_acs.c delete mode 100644 ffa-acs-drv/kernel/0001-FFA-ACS-Linux-v5.0.patch delete mode 100755 ffa-acs-drv/linux_ffa_acs.sh delete mode 100644 ffa-acs-drv/pal_linux/Makefile delete mode 100644 ffa-acs-drv/pal_linux/inc/pal_arch_helpers.h delete mode 100644 ffa-acs-drv/pal_linux/inc/pal_config_def.h delete mode 100644 ffa-acs-drv/pal_linux/inc/pal_smmuv3_testengine.h delete mode 100644 ffa-acs-drv/pal_linux/src/pal_driver.c delete mode 100644 ffa-acs-drv/pal_linux/src/pal_irq.c delete mode 100644 ffa-acs-drv/pal_linux/src/pal_misc.c delete mode 100644 ffa-acs-drv/pal_linux/src/pal_mmio.c delete mode 100644 ffa-acs-drv/pal_linux/src/pal_smmuv3_testengine.c delete mode 100644 ffa-acs-drv/pal_linux/src/pal_vcpu_setup.c delete mode 100755 ffa-acs-drv/setup.sh delete mode 100644 sbsa-acs-drv/files/COPYING delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/COPYING delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/include/pal_exerciser.h delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/include/pal_linux.h delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/include/sbsa_pcie_enum.h delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_acpi.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_dma.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_exerciser.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_gic.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_iovirt.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_misc.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie_enumeration.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pe.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_peripherals.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/files/src/pal_smmu.c delete mode 100644 sbsa-acs-drv/files/platform/pal_linux/sbsa-acs-pal.bb delete mode 100755 sbsa-acs-drv/files/setup.sh delete mode 100644 sbsa-acs-drv/sbsa-acs-drv.bb diff --git a/sbsa-acs-drv/files/Makefile b/acs-drv/files/MakefileSBSA similarity index 100% rename from sbsa-acs-drv/files/Makefile rename to acs-drv/files/MakefileSBSA diff --git a/sbsa-acs-drv/files/linux_sbsa_acs.sh b/acs-drv/files/linux_sbsa_acs.sh similarity index 90% rename from sbsa-acs-drv/files/linux_sbsa_acs.sh rename to acs-drv/files/linux_sbsa_acs.sh index ea49b0c..9bca76b 100755 --- a/sbsa-acs-drv/files/linux_sbsa_acs.sh +++ b/acs-drv/files/linux_sbsa_acs.sh @@ -18,10 +18,12 @@ then fi cd $SBSA_ACS_PATH/platform/pal_linux/files +cp MakefileSBSA Makefile make cp sbsa_acs_pal.o $SBSA_ACS_PATH/ cd $SBSA_ACS_PATH/val/ +cp MakefileSBSA Makefile make cp sbsa_acs_val.o $SBSA_ACS_PATH/ @@ -30,4 +32,5 @@ make cp sbsa_acs_test.o $SBSA_ACS_PATH/ cd $SBSA_ACS_PATH/ +cp MakefileSBSA Makefile make diff --git a/acs-drv/files/platform/pal_linux/files/MakefileSBSA b/acs-drv/files/platform/pal_linux/files/MakefileSBSA new file mode 100644 index 0000000..c686f5e --- /dev/null +++ b/acs-drv/files/platform/pal_linux/files/MakefileSBSA @@ -0,0 +1,51 @@ +## @file + # + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License version 2 as + # published by the Free Software Foundation. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . + # + # Copyright (C) 2016-2018 Arm Limited + # +## + +export CROSS_COMPILE ?= aarch64-linux-gnu- +export ARCH ?= arm64 + +#since we have copied the files locally +ACS_DIR ?= . + +COMMON_PAL_SRC = $(ACS_DIR)/common/src +SBSA_PAL_SRC = $(ACS_DIR)/sbsa/src + +obj-m += sbsa_acs_pal.o +sbsa_acs_pal-objs += $(COMMON_PAL_SRC)/pal_misc.o \ + $(COMMON_PAL_SRC)/pal_pe.o $(COMMON_PAL_SRC)/pal_pcie.o $(COMMON_PAL_SRC)/pal_pcie_enumeration.o \ + $(COMMON_PAL_SRC)/pal_smmu.o $(COMMON_PAL_SRC)/pal_iovirt.o $(COMMON_PAL_SRC)/pal_peripherals.o \ + $(COMMON_PAL_SRC)/pal_dma.o $(COMMON_PAL_SRC)/pal_acpi.o $(COMMON_PAL_SRC)/pal_gic.o \ + $(SBSA_PAL_SRC)/sbsa_pal_iovirt.o $(COMMON_PAL_SRC)/pal_exerciser.o + +ccflags-y=-I$(PWD)/$(ACS_DIR)/val/include -I$(PWD)/$(ACS_DIR)/include -I$(PWD) -I$(PWD)/../../ -I$(PWD)/../../../ -DTARGET_LINUX -DBUILD_SBSA -Wall -Werror + +all: +ifeq ($(KERNEL_SRC),) + echo " KERNEL_SRC variable should be set to kernel path " + exit 1 +else + echo "Kernel source is set to $(KERNEL_SRC)" +endif + + make -C $(KERNEL_SRC) M=$(PWD) modules + +modules_install: + $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install + +clean: + make -C $(KERNEL_SRC) M=$(PWD) clean diff --git a/ffa-acs-drv/COPYING b/acs-drv/files/platform/pal_linux/files/sbsa/COPYING similarity index 100% rename from ffa-acs-drv/COPYING rename to acs-drv/files/platform/pal_linux/files/sbsa/COPYING diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/Makefile b/acs-drv/files/platform/pal_linux/files/sbsa/Makefile similarity index 100% rename from sbsa-acs-drv/files/platform/pal_linux/files/Makefile rename to acs-drv/files/platform/pal_linux/files/sbsa/Makefile diff --git a/ffa-acs-drv/ffa_acs.h b/acs-drv/files/platform/pal_linux/files/sbsa/include/sbsa_pal_linux.h similarity index 50% rename from ffa-acs-drv/ffa_acs.h rename to acs-drv/files/platform/pal_linux/files/sbsa/include/sbsa_pal_linux.h index 5a6b544..bc40b26 100644 --- a/ffa-acs-drv/ffa_acs.h +++ b/acs-drv/files/platform/pal_linux/files/sbsa/include/sbsa_pal_linux.h @@ -1,5 +1,5 @@ /* - * FFA ACS Kernel module header file. + * BSA SBSA ACS Platform module. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -13,21 +13,31 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2021 Arm Limited + * Copyright (C) 2016-2018, 2021, 2024, Arm Limited + * + * Author: Prasanth Pulla * */ -#include -#include -#include -#include +#ifndef __PAL_LINUX_H__ +#define __PAL_LINUX_H__ + #include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include "val/include/pal_interface.h" + + + +acpi_status user_function (acpi_handle handle, uint32_t level, void *context, void **return_value); + +uint32_t pal_get_device_path(const char *hid, char hid_path[][MAX_NAMED_COMP_LENGTH]); + +uint32_t pal_smmu_is_etr_behind_catu(char *etr_path); -#include "val_framework.h" -#include "val_memory.h" -#include "val_test_dispatch.h" +#endif diff --git a/acs-drv/files/platform/pal_linux/files/sbsa/src/sbsa_pal_iovirt.c b/acs-drv/files/platform/pal_linux/files/sbsa/src/sbsa_pal_iovirt.c new file mode 100644 index 0000000..e1c6df5 --- /dev/null +++ b/acs-drv/files/platform/pal_linux/files/sbsa/src/sbsa_pal_iovirt.c @@ -0,0 +1,84 @@ +/* + * BSA SBSA ACS Platform module. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Copyright (C) 2016-2019, 2021, 2023, 2024, Arm Limited + * + * Author: Sakar Arora + * + */ + +#include +#include +#include +#include + +#include "common/include/pal_linux.h" +#include "sbsa/include/sbsa_pal_linux.h" + +#define NOT_IMPLEMENTED 0x4B1D + +/** + @brief This function is called by the val function pal_get_device_path + when the hid type is found + + @param handle device handle + @param level nesting level + @param context data to be passed from caller function + @param return_value return value passed to caller function pal_get_device_path + + @return 1 if test fails, 0 if test passes +**/ +acpi_status user_function(acpi_handle handle, uint32_t level, + void *context, void **return_value) +{ + acpi_status status; + static uint32_t count; + struct acpi_buffer buffer; + char (*path_buffer)[MAX_NAMED_COMP_LENGTH] = context; + + buffer.length = ACPI_ALLOCATE_BUFFER; + status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); + strncpy((char *)path_buffer[count++], (char *)(buffer.pointer), 16); + return status; +} + +/** + @brief Check the hid in ACPI and copy te full path of hid + + @param hid hardware ID to get the path for + @param hid_path 2D array in which the path is copied + + @return 1 if test fails, 0 if test passes +**/ +uint32_t +pal_get_device_path(const char *hid, char hid_path[][MAX_NAMED_COMP_LENGTH]) +{ + acpi_status status; + status = acpi_get_devices(hid, user_function, (void *)hid_path, NULL); + return status; +} + +/** + @brief Platform defined method to check if CATU is behind an ETR device + + @param etr_path full path of ETR device + + @return 0 - Success, NOT_IMPLEMENTED - API not implemented, Other values - Failure +**/ +uint32_t +pal_smmu_is_etr_behind_catu(char *etr_path) +{ + return NOT_IMPLEMENTED; +} diff --git a/sbsa-acs-drv/files/sbsa_acs_drv.c b/acs-drv/files/sbsa_acs_drv.c old mode 100644 new mode 100755 similarity index 76% rename from sbsa-acs-drv/files/sbsa_acs_drv.c rename to acs-drv/files/sbsa_acs_drv.c index 380612c..e4bd60b --- a/sbsa-acs-drv/files/sbsa_acs_drv.c +++ b/acs-drv/files/sbsa_acs_drv.c @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2016-2020, 2023 Arm Limited + * Copyright (C) 2016-2020, 2023, 2024, Arm Limited * * Author: Prasanth Pulla * @@ -22,11 +22,11 @@ #include #include "sbsa_acs_drv.h" -#include "val/include/val_interface.h" -#include "val/include/sbsa_avs_common.h" -#include "val/include/sbsa_avs_val.h" -#include "val/include/sbsa_avs_pcie.h" -#include "val/include/sbsa_avs_exerciser.h" +#include "val/common/include/val_interface.h" +#include "val/common/include/acs_val.h" +#include "val/common/include/acs_common.h" +#include "val/sbsa/include/sbsa_acs_pcie.h" +#include "val/sbsa/include/sbsa_val_interface.h" test_params_t params; test_msg_parms_t msg_params; @@ -39,9 +39,9 @@ unsigned int *g_skip_test_num; unsigned int g_num_skip = 3; unsigned int *g_execute_tests; unsigned int *g_execute_modules; -unsigned int g_sbsa_tests_total; -unsigned int g_sbsa_tests_pass; -unsigned int g_sbsa_tests_fail; +unsigned int g_acs_tests_total; +unsigned int g_acs_tests_pass; +unsigned int g_acs_tests_fail; uint64_t g_exception_ret_addr; uint64_t g_stack_pointer; uint64_t g_ret_addr; @@ -59,7 +59,6 @@ uint32_t g_num_modules = sizeof(g_specific_modules)/sizeof(unsigned int); uint64_t *g_pe_info_ptr; uint64_t *g_pcie_info_ptr; uint64_t *g_per_info_ptr; -uint64_t *g_dma_info_ptr; uint64_t *g_iovirt_info_ptr; char *g_msg_buf; @@ -81,9 +80,9 @@ val_glue_execute_command(void) if (params.api_num == SBSA_CREATE_INFO_TABLES) { - g_sbsa_tests_total = 0; - g_sbsa_tests_pass = 0; - g_sbsa_tests_fail = 0; + g_acs_tests_total = 0; + g_acs_tests_pass = 0; + g_acs_tests_fail = 0; tail_msg = 0; g_msg_buf = (char*) kmalloc(num_msg * sizeof(test_msg_parms_t), GFP_KERNEL); @@ -101,9 +100,6 @@ val_glue_execute_command(void) g_per_info_ptr = kmalloc(PERIPHERAL_INFO_TBL_SZ, GFP_KERNEL); val_peripheral_create_info_table(g_per_info_ptr); - g_dma_info_ptr = kmalloc(DMA_INFO_TBL_SZ, GFP_KERNEL); - val_dma_create_info_table(g_dma_info_ptr); - g_iovirt_info_ptr = kmalloc(IOVIRT_INFO_TBL_SZ, GFP_KERNEL); val_iovirt_create_info_table(g_iovirt_info_ptr); @@ -119,30 +115,16 @@ val_glue_execute_command(void) kfree(g_pe_info_ptr); kfree(g_pcie_info_ptr); kfree(g_per_info_ptr); - kfree(g_dma_info_ptr); kfree(g_iovirt_info_ptr); kfree(g_msg_buf); kfree(g_skip_test_num); } - if (params.api_num == SBSA_EXERCISER_EXECUTE_TEST) - { - params.arg0 = DRV_STATUS_PENDING; - //val_exerciser_execute_tests(params.level); - val_print(AVS_PRINT_TEST, "\n ------------------------------------------------------------", 0); - val_print(AVS_PRINT_TEST, "\n Total Tests Run = %2d, ", g_sbsa_tests_total); - val_print(AVS_PRINT_TEST, "Tests Passed = %2d, ", g_sbsa_tests_pass); - val_print(AVS_PRINT_TEST, "Tests Failed = %2d ", g_sbsa_tests_fail); - val_print(AVS_PRINT_TEST, "\n ------------------------------------------------------------", 0); - params.arg0 = DRV_STATUS_AVAILABLE; - params.arg1 = val_get_status(0); - } - if (params.api_num == SBSA_SMMU_EXECUTE_TEST) { params.arg0 = DRV_STATUS_PENDING; - val_smmu_execute_tests(params.level, params.num_pe); + val_sbsa_smmu_execute_tests(params.level, params.num_pe); params.arg0 = DRV_STATUS_AVAILABLE; params.arg1 = val_get_status(0); } @@ -150,12 +132,12 @@ val_glue_execute_command(void) if (params.api_num == SBSA_PCIE_EXECUTE_TEST) { params.arg0 = DRV_STATUS_PENDING; - val_pcie_execute_tests(params.level, params.num_pe); - val_print(AVS_PRINT_TEST, "\n ------------------------------------------------------------", 0); - val_print(AVS_PRINT_TEST, "\n Total Tests Run = %2d, ", g_sbsa_tests_total); - val_print(AVS_PRINT_TEST, "Tests Passed = %2d, ", g_sbsa_tests_pass); - val_print(AVS_PRINT_TEST, "Tests Failed = %2d ", g_sbsa_tests_fail); - val_print(AVS_PRINT_TEST, "\n ------------------------------------------------------------", 0); + val_sbsa_pcie_execute_tests(params.level, params.num_pe); + val_print(ACS_PRINT_TEST, "\n ------------------------------------------------------------", 0); + val_print(ACS_PRINT_TEST, "\n Total Tests Run = %2d, ", g_acs_tests_total); + val_print(ACS_PRINT_TEST, "Tests Passed = %2d, ", g_acs_tests_pass); + val_print(ACS_PRINT_TEST, "Tests Failed = %2d ", g_acs_tests_fail); + val_print(ACS_PRINT_TEST, "\n ------------------------------------------------------------\n", 0); params.arg0 = DRV_STATUS_AVAILABLE; params.arg1 = val_get_status(0); } diff --git a/sbsa-acs-drv/files/sbsa_acs_drv.h b/acs-drv/files/sbsa_acs_drv.h similarity index 97% rename from sbsa-acs-drv/files/sbsa_acs_drv.h rename to acs-drv/files/sbsa_acs_drv.h index 2564621..83cd26d 100644 --- a/sbsa-acs-drv/files/sbsa_acs_drv.h +++ b/acs-drv/files/sbsa_acs_drv.h @@ -29,7 +29,6 @@ #define SBSA_CREATE_INFO_TABLES 0x1000 #define SBSA_PCIE_EXECUTE_TEST 0x2000 #define SBSA_UPDATE_SKIP_LIST 0x3000 -#define SBSA_EXERCISER_EXECUTE_TEST 0x4000 #define SBSA_SMMU_EXECUTE_TEST 0x5000 #define SBSA_FREE_INFO_TABLES 0x9000 diff --git a/acs-drv/files/sbsa_setup.sh b/acs-drv/files/sbsa_setup.sh new file mode 100755 index 0000000..22ceede --- /dev/null +++ b/acs-drv/files/sbsa_setup.sh @@ -0,0 +1,19 @@ + +echo "==================================================================" +echo "This script will copy the necessary files for Kernel module build " +echo "to the present directory" +echo "==================================================================" + +if [ $# -ne 2 ]; +then + echo "Give both BSA_ACS (1st argument) and SBSA_ACS PATH (2nd argument) as the arguments to the script" + return 0 +fi + +export BSA_ACS_PATH=$1 +export SBSA_ACS_PATH=$2 +echo -e "BSA ACS_PATH is set to -> \e[93m $BSA_ACS_PATH\e[0m" +echo -e "SBSA ACS_PATH is set to -> \e[93m $SBSA_ACS_PATH\e[0m" + +cp -r $BSA_ACS_PATH/val . +cp -r $SBSA_ACS_PATH/test_pool . diff --git a/ffa-acs-drv/Makefile b/ffa-acs-drv/Makefile deleted file mode 100644 index c343bcb..0000000 --- a/ffa-acs-drv/Makefile +++ /dev/null @@ -1,73 +0,0 @@ -## @file - # FFA ACS Kernel module Makefile - # - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License version 2 as - # published by the Free Software Foundation. - # - # This program is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this program. If not, see . - # - # Copyright (C) 2021 Arm Limited - # - # -## - -export CROSS_COMPILE ?= aarch64-linux-gnu- -export ARCH ?= arm64 - -# ACS Make commandline arguments -VERBOSITY ?= 3 -PLATFORM_NS_HYPERVISOR_PRESENT ?= 0 -PLATFORM_SPMC_EL ?= 2 -PLATFORM_SP_EL ?= 1 -SUITE ?= all -PLATFORM_FFA_V_1_0 ?= 0 -PLATFORM_FFA_V_1_1 ?= 0 -PLATFORM_FFA_V_ALL ?= 1 - -ACS_MACROS += -DVM1_COMPILE -DTARGET_LINUX -ACS_MACROS += -DVERBOSITY=$(VERBOSITY) -ACS_MACROS += -DPLATFORM_NS_HYPERVISOR_PRESENT=$(PLATFORM_NS_HYPERVISOR_PRESENT) -ACS_MACROS += -DPLATFORM_SPMC_EL=$(PLATFORM_SPMC_EL) -ACS_MACROS += -DPLATFORM_SP_EL=$(PLATFORM_SP_EL) -ACS_MACROS += -DSUITE=$(SUITE) -ACS_MACROS += -DPLATFORM_FFA_V_1_0=$(PLATFORM_FFA_V_1_0) -ACS_MACROS += -DPLATFORM_FFA_V_1_1=$(PLATFORM_FFA_V_1_1) -ACS_MACROS += -DPLATFORM_FFA_V_ALL=$(PLATFORM_FFA_V_ALL) - -#since we have copied the files locally -ACS_DIR ?= ./ -ACS_INCLUDE = -I$(PWD)/$(ACS_DIR)/val/inc -I$(PWD)/$(ACS_DIR)/common/inc -I$(PWD)/$(ACS_DIR)/pal_linux/inc -I$(PWD)/$(ACS_DIR)/test/common - -obj-m += ffa-acs.o -ffa-acs-objs += ffa_acs.o \ - ffa_acs_test.o \ - ffa_acs_val.o \ - ffa_acs_pal.o - -ccflags-y=$(ACS_MACROS) $(ACS_INCLUDE) -Wall -Werror - -all: -ifeq ($(KERNEL_SRC),) - echo " KERNEL_SRC variable should be set to kernel path " - exit 1 -else - echo "Kernel source is set to $(KERNEL_SRC)" -endif - - make -C $(KERNEL_SRC) M=$(PWD) modules - -modules_install: - $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install - -clean: - make -C $(KERNEL_SRC) M=$(PWD) clean - rm -rf build - find $(ACS_DIR) -type f -name "*.o" -delete - find $(ACS_DIR) -type f -name "*.o.cmd" -delete diff --git a/ffa-acs-drv/README.md b/ffa-acs-drv/README.md deleted file mode 100644 index a03e987..0000000 --- a/ffa-acs-drv/README.md +++ /dev/null @@ -1,65 +0,0 @@ - -# FF-A ACS - Linux Kernel Module - -This document provides information on executing [ff-a-acs tests](https://github.com/ARM-software/ff-a-acs.git) from the Linux application. This needs Linux kernel module files to load FF-A ACS Test VM1 endpoint code at kernel level and run as part of Linux kernel. These files are hosted under ffa-acs-drv directory. The procedure to build and run FF-A tests with Linux is described here. - -## This release -- Release Version - v0.8 -- Maintained by [ff-a-acs](https://github.com/ARM-software/ff-a-acs.git) manitainers - -## Prerequisites -- Linux kernel source version 5.0 -- Linaro GCC tool chain 5.3 or above -- Build environment for AArch64 Linux kernel - -## Building the kernel module -Follow the below steps to create kernel module for VM1 endpoint code: - -* Checkout the sources: -1. mkdir ; cd -2. git clone https://git.gitlab.arm.com/linux-arm/linux-acs.git -3. git clone https://github.com/ARM-software/ff-a-acs.git - -* Porting steps for Linux kernel -1. Apply the /linux-acs/ffa-acs-drv/kernel/0001-FFA-ACS-Linux-v5.0.patch to your kernel-v5.0 source tree. -2. Build the kernel. - -* Build steps for FFA ACS kernel module -1. cd /linux-acs/ffa-acs-drv -2. Set CROSS_COMPILE to the ARM64 toolchain path. You may want to set additional env flags mentioned in **Option Information** to change the default values of the ACS Make variables. -3. Set KERNEL_SRC to the -4. ./setup.sh -5. ./linux_ffa_acs.sh - -* ffa-acs.ko file is generated for VM1 endpoint code.
- -**Options information**:
- 1. SUITE= is the sub test suite name specified in **test/** directory. The default value is -DSUITE=all
- 2. VERBOSE=. Print verbosity level. Supported print levels are 1(INFO & above), 2(DEBUG & above), 3(TEST & above), 4(WARN & ERROR) and 5(ERROR). Default value is 3.
- 3. PLATFORM_SPMC_EL=: EL number where the target SPMC component runs. Supported values are 1 and 2. The default value is 2.
- 4. PLATFORM_SP_EL=: EL number where the test secure endpoints are expected to run. Supported values are 0 and 1. The default value is 1.
- 5. PLATFORM_NS_HYPERVISOR_PRESENT=<0|1>: Does the system support the non-secure hypervisor component? 1 for yes, 0 for no. The default vaule is 0. System is expected to intergrate and load all the three of nonsecure test endpoints if the value is set to 1. Otherwise needs to use single non-secure test endpoint(vm1) which would act as NS OS kernel.
- 6. PLATFORM_FFA_V_1_0=<0|1>: It runs only tests that are supported by the Arm FF-A v1.0 specification. The default value is 0.
- 7. PLATFORM_FFA_V_1_1=<0|1>: It only tests the Arm FF-A v1.1 specifications as updates to Arm FF-A v1.0. The default value is 0.
- 8. PLATFORM_FFA_V_ALL=<0|1>: It runs all tests that are supported by the Arm FF-A v1.1 specification. The default value is 1.
- - -## Build the Linux Application -Perform below steps to generate ffa_acs executable file:
-1. cd /ffa-a-acs/linux_app/ -2. Export CROSS_COMPILE with the ARM64 toolchain path. -3. make - - -## Loading the kernel module -Before the FF-A ACS Linux application can run, load the FFA ACS kernel module using the -insmod command.
- ``` - shell> insmod ffa-acs.ko - ``` -## Run the Linux application - -Run the FF-A ACS Linux application as below:
-``` - shell> ./ffa_acs -``` diff --git a/ffa-acs-drv/ffa_acs.c b/ffa-acs-drv/ffa_acs.c deleted file mode 100644 index 4f72e12..0000000 --- a/ffa-acs-drv/ffa_acs.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * FFA ACS Kernel module Main file. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - */ - -#include "ffa_acs.h" - -static int ffa_proc_open(struct inode *sp_inode, struct file *sp_file) -{ - return 0; -} - -static int ffa_proc_release(struct inode *sp_indoe, struct file *sp_file) -{ - return 0; -} - -static ssize_t ffa_proc_read(struct file *sp_file, char __user *buf, size_t size, loff_t *offset) -{ - return 0; -} - -static ssize_t ffa_proc_write(struct file *sp_file, const char __user *buf, - size_t size, loff_t *offset) -{ - val_main(); - - return size; -} -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0) -struct file_operations ffa_fops = { - .open = ffa_proc_open, - .read = ffa_proc_read, - .write = ffa_proc_write, - .release = ffa_proc_release -}; -#else -static const struct proc_ops ffa_fops = { - .proc_open = ffa_proc_open, - .proc_read = ffa_proc_read, - .proc_write = ffa_proc_write, - .proc_release = ffa_proc_release -}; -#endif - -/* Create proc entry for communication between user and kernel levels */ -static int __init init_ffa_acs(void) -{ - printk(KERN_INFO "\tInit FFA ACS driver \n"); - - if (!proc_create("ffa_acs", 0, NULL, &ffa_fops)) { - printk(KERN_ERR "ERROR! proc_create\n"); - remove_proc_entry("ffa_acs", NULL); - return -1; - } - - return 0; -} - -/* Remove the proc entry while unloading the driver */ -static void __exit exit_ffa_acs(void) -{ - remove_proc_entry("ffa_acs", NULL); - printk(KERN_INFO "Exit FFA ACS driver \n"); -} - -MODULE_INFO(intree, "Y"); -MODULE_LICENSE("GPL"); -module_init(init_ffa_acs); -module_exit(exit_ffa_acs); diff --git a/ffa-acs-drv/kernel/0001-FFA-ACS-Linux-v5.0.patch b/ffa-acs-drv/kernel/0001-FFA-ACS-Linux-v5.0.patch deleted file mode 100644 index de4eeef..0000000 --- a/ffa-acs-drv/kernel/0001-FFA-ACS-Linux-v5.0.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 15344cc288ace34d29e4b3a82a3e4c29ebbf3720 Mon Sep 17 00:00:00 2001 -From: Mahesh Bireddy -Date: Fri, 29 Jul 2022 17:37:31 +0800 -Subject: [PATCH] FFA ACS Linux v5.0 - -Signed-off-by: Mahesh Bireddy ---- - arch/arm64/kernel/smp.c | 13 ++++++++++++- - drivers/irqchip/irq-gic-v3.c | 17 +++++++++++++++++ - include/linux/irqdomain.h | 3 +++ - kernel/irq/irqdomain.c | 1 + - 4 files changed, 33 insertions(+), 1 deletion(-) - -diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c -index 1598d6f72..40aff3581 100644 ---- a/arch/arm64/kernel/smp.c -+++ b/arch/arm64/kernel/smp.c -@@ -63,6 +63,7 @@ - #define CREATE_TRACE_POINTS - #include - -+#define FFA_ACS_SRI_INTERRUPT 8 - DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); - EXPORT_PER_CPU_SYMBOL(cpu_number); - -@@ -82,7 +83,8 @@ enum ipi_msg_type { - IPI_CPU_CRASH_STOP, - IPI_TIMER, - IPI_IRQ_WORK, -- IPI_WAKEUP -+ IPI_WAKEUP, -+ IPI_FFA_SRI = FFA_ACS_SRI_INTERRUPT - }; - - #ifdef CONFIG_HOTPLUG_CPU -@@ -94,6 +96,11 @@ static inline int op_cpu_kill(unsigned int cpu) - } - #endif - -+/* ACS FFA patch */ -+static void acs_ffa_sri_handler(void) -+{ -+ return; -+} - - /* - * Boot a secondary CPU, and assign it the specified idle task. -@@ -889,6 +896,10 @@ void handle_IPI(int ipinr, struct pt_regs *regs) - } - break; - -+ case IPI_FFA_SRI: -+ acs_ffa_sri_handler(); -+ break; -+ - #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST - case IPI_TIMER: - irq_enter(); -diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c -index 0868a9d81..2cbd78adf 100644 ---- a/drivers/irqchip/irq-gic-v3.c -+++ b/drivers/irqchip/irq-gic-v3.c -@@ -69,6 +69,9 @@ static DEFINE_STATIC_KEY_TRUE(supports_deactivate_key); - static struct gic_kvm_info gic_v3_kvm_info; - static DEFINE_PER_CPU(bool, has_rss); - -+/* ACS GIC Patch */ -+struct irq_domain *acs_irq_domain = NULL; -+ - #define MPIDR_RS(mpidr) (((mpidr) & 0xF0UL) >> 4) - #define gic_data_rdist() (this_cpu_ptr(gic_data.rdists.rdist)) - #define gic_data_rdist_rd_base() (gic_data_rdist()->rd_base) -@@ -98,6 +101,15 @@ static inline void __iomem *gic_dist_base(struct irq_data *d) - return NULL; - } - -+struct irq_domain* acs_get_irq_domain(void) -+{ -+ if (acs_irq_domain) -+ return acs_irq_domain; -+ -+ return NULL; -+} -+EXPORT_SYMBOL(acs_get_irq_domain); -+ - static void gic_do_wait_for_rwp(void __iomem *base) - { - u32 count = 1000000; /* 1s! */ -@@ -1000,6 +1012,11 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, - return ret; - } - -+ /* ACS GIC Patch */ -+ if (domain) { -+ acs_irq_domain = domain; -+ } -+ - return 0; - } - -diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h -index 35965f41d..9610d55bc 100644 ---- a/include/linux/irqdomain.h -+++ b/include/linux/irqdomain.h -@@ -582,4 +582,7 @@ static inline bool irq_domain_check_msi_remap(void) - } - #endif /* !CONFIG_IRQ_DOMAIN */ - -+/* ACS GIC Patch */ -+struct irq_domain* acs_get_irq_domain(void); -+ - #endif /* _LINUX_IRQDOMAIN_H */ -diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c -index 8b0be4bd6..9d94c7ad2 100644 ---- a/kernel/irq/irqdomain.c -+++ b/kernel/irq/irqdomain.c -@@ -1332,6 +1332,7 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, - irq_free_descs(virq, nr_irqs); - return ret; - } -+EXPORT_SYMBOL(__irq_domain_alloc_irqs); - - /* The irq_data was moved, fix the revmap to refer to the new location */ - static void irq_domain_fix_revmap(struct irq_data *d) --- -2.18.0 - diff --git a/ffa-acs-drv/linux_ffa_acs.sh b/ffa-acs-drv/linux_ffa_acs.sh deleted file mode 100755 index a378c66..0000000 --- a/ffa-acs-drv/linux_ffa_acs.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -## - # - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License version 2 as - # published by the Free Software Foundation. - # - # This program is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this program. If not, see . - # - # Copyright (C) 2021 Arm Limited - # -## - -echo "==================================================================" -echo "This script will compile the Linux FFA ACS Kernel module " -echo "==================================================================" - -FFA_ACS_PATH=`pwd` -if [ -z $KERNEL_SRC ] -then - echo "Error: set KERNEL_SRC path" - exit 0 -fi - -if [ $(uname -m) != "aarch64" ] && [ -z $CROSS_COMPILE ] -then - echo "Error: set CROSS_COMPILE path" - exit 0 -fi - -cd $FFA_ACS_PATH/pal_linux -make clean -make -cp ffa_acs_pal.o $FFA_ACS_PATH/ - -cd $FFA_ACS_PATH/val/ -make clean -make -cp ffa_acs_val.o $FFA_ACS_PATH/ - -cd $FFA_ACS_PATH/test/ -make clean -make -cp ffa_acs_test.o $FFA_ACS_PATH/ - -cd $FFA_ACS_PATH/ -make diff --git a/ffa-acs-drv/pal_linux/Makefile b/ffa-acs-drv/pal_linux/Makefile deleted file mode 100644 index 8c3ae91..0000000 --- a/ffa-acs-drv/pal_linux/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -## @file - # FFA ACS Kernel module Makefile - # - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License version 2 as - # published by the Free Software Foundation. - # - # This program is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this program. If not, see . - # - # Copyright (C) 2021 Arm Limited - # - # -## - -export CROSS_COMPILE ?= aarch64-linux-gnu- -export ARCH ?= arm64 - -# ACS Make commandline arguments -VERBOSITY ?= 3 -PLATFORM_NS_HYPERVISOR_PRESENT ?= 0 -PLATFORM_SPMC_EL ?= 2 -PLATFORM_SP_EL ?= 1 -SUITE ?= all -PLATFORM_FFA_V_1_0 ?= 0 -PLATFORM_FFA_V_1_1 ?= 0 -PLATFORM_FFA_V_ALL ?= 1 - -ACS_MACROS += -DVM1_COMPILE -DTARGET_LINUX -ACS_MACROS += -DVERBOSITY=$(VERBOSITY) -ACS_MACROS += -DPLATFORM_NS_HYPERVISOR_PRESENT=$(PLATFORM_NS_HYPERVISOR_PRESENT) -ACS_MACROS += -DPLATFORM_SPMC_EL=$(PLATFORM_SPMC_EL) -ACS_MACROS += -DPLATFORM_SP_EL=$(PLATFORM_SP_EL) -ACS_MACROS += -DSUITE=$(SUITE) -ACS_MACROS += -DPLATFORM_FFA_V_1_0=$(PLATFORM_FFA_V_1_0) -ACS_MACROS += -DPLATFORM_FFA_V_1_1=$(PLATFORM_FFA_V_1_1) -ACS_MACROS += -DPLATFORM_FFA_V_ALL=$(PLATFORM_FFA_V_ALL) - -#since we have copied the files locally -ACS_DIR ?= . -PAL_SRC = $(ACS_DIR)/src - -ACS_INCLUDE = -I$(PWD)/$(ACS_DIR)/inc -I$(PWD)/$(ACS_DIR)/../common/inc -obj-m += ffa_acs_pal.o - -ffa_acs_pal-objs += $(PAL_SRC)/pal_driver.o \ - $(PAL_SRC)/pal_mmio.o \ - $(PAL_SRC)/pal_irq.o \ - $(PAL_SRC)/pal_smmuv3_testengine.o \ - $(PAL_SRC)/pal_vcpu_setup.o \ - $(PAL_SRC)/pal_misc.o - -ccflags-y=$(ACS_MACROS) $(ACS_INCLUDE) -Wall -Werror - -all: -ifeq ($(KERNEL_SRC),) - echo " KERNEL_SRC variable should be set to kernel path " - exit 1 -else - echo "Kernel source is set to $(KERNEL_SRC)" -endif - - make -C $(KERNEL_SRC) M=$(PWD) modules - -modules_install: - $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install - -clean: - make -C $(KERNEL_SRC) M=$(PWD) clean - find $(ACS_DIR) -type f -name "*.o" -delete - find $(ACS_DIR) -type f -name "*.o.cmd" -delete - diff --git a/ffa-acs-drv/pal_linux/inc/pal_arch_helpers.h b/ffa-acs-drv/pal_linux/inc/pal_arch_helpers.h deleted file mode 100644 index 71b3d78..0000000 --- a/ffa-acs-drv/pal_linux/inc/pal_arch_helpers.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - */ - -#ifndef ARCH_HELPERS_H -#define ARCH_HELPERS_H - -#define MPIDR_MT_MASK (1 << 24) -#define MPIDR_AFFLVL_MASK 0xffUL -#define MPIDR_AFF0_SHIFT 0 -#define MPIDR_AFF1_SHIFT (8) -#define MPIDR_AFF2_SHIFT (16) -#define MPIDR_AFF3_SHIFT 32UL - -/* - * The MPIDR_MAX_AFFLVL count starts from 0. Take care to - * add one while using this macro to define array sizes. - * TODO: Support only the first 3 affinity levels for now. - */ -#define MPIDR_MAX_AFFLVL (2) - -#define MPID_MASK (MPIDR_MT_MASK | \ - (MPIDR_AFFLVL_MASK << MPIDR_AFF3_SHIFT) | \ - (MPIDR_AFFLVL_MASK << MPIDR_AFF2_SHIFT) | \ - (MPIDR_AFFLVL_MASK << MPIDR_AFF1_SHIFT) | \ - (MPIDR_AFFLVL_MASK << MPIDR_AFF0_SHIFT)) - -/* Define function for system instruction with type specifier */ -#define DEFINE_SYSOP_TYPE_FUNC(_op, _type) \ -static inline void _op ## _type(void) \ -{ \ - __asm__ (#_op " " #_type); \ -} - -DEFINE_SYSOP_TYPE_FUNC(dsb, sy) -DEFINE_SYSOP_TYPE_FUNC(dmb, sy) -DEFINE_SYSOP_TYPE_FUNC(dmb, st) - -#endif /* ARCH_HELPERS_H */ diff --git a/ffa-acs-drv/pal_linux/inc/pal_config_def.h b/ffa-acs-drv/pal_linux/inc/pal_config_def.h deleted file mode 100644 index 702178d..0000000 --- a/ffa-acs-drv/pal_linux/inc/pal_config_def.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - */ - -#ifndef _PAL_CONFIG_H_ -#define _PAL_CONFIG_H_ - -#ifndef __ASSEMBLY__ -#include "pal_arch_helpers.h" -#endif - -#define PLATFORM_PAGE_SIZE 0x1000 - -#define PAGE_SIZE_4K 0x1000 -#define PAGE_SIZE_16K (4 * 0x1000) -#define PAGE_SIZE_64K (16 * 0x1000) - -/* Non-secure UART assigned to VM1 - PL011_UART2_BASE */ -#define PLATFORM_NS_UART_BASE 0x1c0b0000 -#define PLATFORM_NS_UART_SIZE 0x10000 - -/* Secure UART assigned to SP1 - PL011_UART2_BASE */ -#define PLATFORM_S_UART_BASE 0x1c0b0000 -#define PLATFORM_S_UART_SIZE 0x10000 - -/* Non-volatile memory range assigned to SP3 */ -#define PLATFORM_NVM_BASE (0x80000000+0x2800000) -#define PLATFORM_NVM_SIZE 0x10000 - -/* Base address of watchdog assigned to SP3 */ -#define PLATFORM_WDOG_BASE 0x1C0F0000 //(SP805) -#define PLATFORM_WDOG_SIZE 0x10000 -#define PLATFORM_WDOG_LOAD_VALUE (0x3E7 * 10 * 1000) // 10sec -#define PLATFORM_WD_INTR_NUM 32 - -/* Base address of trusted watchdog (SP805) */ -#define PLATFORM_SP805_TWDOG_BASE 0x2A490000 -#define PLATFORM_TWDOG_SIZE 0x10000 -#define PLATFORM_TWDOG_INTID 56 - -#define PLATFORM_NS_WD_BASE 0x2A440000 -#define PLATFORM_NS_WD_SIZE 0x1000 -#define PLATFORM_NS_WD_INTR 59 - -/* - * Base address of read only memory region - * TODO: Need to update read_only memory - */ -#define PLATFORM_MEM_READ_ONLY_BASE 0x00000000 -#define PLATFORM_MEM_READ_ONLY_SIZE 0x1000 - -/* SMMU stream id */ -#define PLATFORM_SMMU_STREAM_ID 1 - -/* - * Retrieving of memory region by specifying address ranges. - * this is about retrieving memory without handle value and - * specifying the offset field in the endpoint memory access descriptor. - * Supported values: 0(NOT_SUPPORTED), 1(SUPPORTED) - */ -#define PLATFORM_MEM_RETRIEVE_USING_ADDRESS_RANGES 0 - -/* INNER_SHAREBLE and OUTER_SHAREABLE flag support - * Supported values: 0(NOT_SUPPORTED), 1(SUPPORTED) - */ -#define PLATFORM_OUTER_SHAREABLE_SUPPORT_ONLY 0 -#define PLATFORM_INNER_SHAREABLE_SUPPORT_ONLY 1 -#define PLATFORM_INNER_OUTER_SHAREABLE_SUPPORT 0 - -/* - * Secure Partition manifest info. - */ - -/* Test Partition IDs assigned by the system */ -#define PLATFORM_SP1_ID (1 | (1 << 15)) -#define PLATFORM_SP2_ID (2 | (1 << 15)) -#define PLATFORM_SP3_ID (3 | (1 << 15)) - -#if (PLATFORM_NS_HYPERVISOR_PRESENT == 1) - #if (PLATFORM_PRIMARY_SCHEDULER_EL == 2) - #define PLATFORM_VM1_ID 1 - #define PLATFORM_VM2_ID 2 - #define PLATFORM_VM3_ID 3 - #elif (PLATFORM_PRIMARY_SCHEDULER_EL == 1) - // Assuming Primary scheduler ID = 1 - #define PLATFORM_VM1_ID 2 - #define PLATFORM_VM2_ID 3 - #define PLATFORM_VM3_ID 4 - #endif -#endif - -/* - * CPU info - */ -#define PLATFORM_NO_OF_CPUS 8 -#endif /* _PAL_CONFIG_H_ */ diff --git a/ffa-acs-drv/pal_linux/inc/pal_smmuv3_testengine.h b/ffa-acs-drv/pal_linux/inc/pal_smmuv3_testengine.h deleted file mode 100644 index 28fedfb..0000000 --- a/ffa-acs-drv/pal_linux/inc/pal_smmuv3_testengine.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - */ - -#ifndef _PAL_SMMUV3_TESTENGINE_H_ -#define _PAL_SMMUV3_TESTENGINE_H_ - -#include "pal_interfaces.h" - -/* The register file consists of two pages, each of which is 64 KiB - * Page 0 : 'User' page - * 1 : 'Privileged' page - * - * Each page consists of a number of frames, each of which corresponds to an independent - * thread of work. - * Frame 0 in the User page corresponds to Frame 0 in the Priv page. - * Each Frame is 128 bytes long. - */ - -/* PCTRL bit 0 -- ssd-ns -- 1 if the stream belongs to the non-secure world. - * 0 if the stream belongs to the secure world - */ - -/* The engine memcpy's from region [begin, end_incl] to address udata[0]. - * - * If stride is 0 then ENGINE_ERROR is produced, udata[2] contains the error - * address. No MSI is generated. - * - * If stride is 1 then this is a normal memcpy(). If stride is larger then - * not all the data will be copied. - * - * The order and size of the transactions used are determined randomly using - * seed. If seed is: - * 0 -- do them from lowest address to highest address - * ~0u -- do them in reverse order - * otherwise use the value as a seed to do them in random order - * The ability to do them in a non-random order means that we stand a - * chance of getting merged event records. - * - * This models a work-load to start with some reads and then do some writes. - * ENGINE_MEMCPY = 2. - */ - -/* Poll 'cmd' until not being ENGINE_MEMCPY: - * - ENGINE_FRAME_MISCONFIGURED - * - ENGINE_ERROR - * - ENGINE_NO_FRAME - * - ENGINE_HALTED -- The engine is halted. All others are errors of one kind - * or another. - */ - -/* Privileged page base address */ -#define P_FRAME_BASE 0x2bff0000 -/* User page base address */ -#define U_FRAME_BASE 0x2bfe0000 -/* Each frame is 128 bytes long */ -#define FRAME_SIZE 0x80 - -/* Privileged frame fields */ -#define PCTRL 0x0 -#define DOWNSTREAM_PORT_INDEX 0x4 -#define STREAM_ID 0x8 -#define SUBSTREAM_ID 0xC - -/* User frame fields */ -#define CMD 0x0 -#define UCTRL 0x4 -#define SEED 0x24 -#define BEGIN 0x28 -#define END_CTRL 0x30 -#define STRIDE 0x38 -#define UDATA 0x40 - -#define NO_SUBSTREAMID 0xFFFFFFFF - -enum cmd_t -{ - /* The frame was misconfigured. */ - ENGINE_FRAME_MISCONFIGURED = ~0u - 1, - - /* The engine encountered an error (downstream transaction aborted). */ - ENGINE_ERROR = ~0u, - - /* This frame is unimplemented or in use by the secure world. - * - * A user _can_ write this to cmd and it will be considered to be ENGINE_HALTED. - */ - ENGINE_NO_FRAME = 0, - - /* The engine is halted. */ - ENGINE_HALTED = 1, - - /* This initiates memory transfer from source to destination */ - ENGINE_MEMCPY = 2 -}; - -/* Configures SMMU test engine and initiates DMA transfer from source address to destination */ -uint32_t smmuv3_configure_testengine(uint32_t stream_id, uint64_t source, uint64_t dest, - uint64_t size, bool secure); - -#endif /* _PAL_SMMUV3_TESTENGINE_H_ */ diff --git a/ffa-acs-drv/pal_linux/src/pal_driver.c b/ffa-acs-drv/pal_linux/src/pal_driver.c deleted file mode 100644 index 0545afe..0000000 --- a/ffa-acs-drv/pal_linux/src/pal_driver.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * PSA FFA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - */ - -#include -#include -#include -#include -#include - -#include "pal_interfaces.h" -#include "pal_smmuv3_testengine.h" - -#define MSG_SIZE 80 - -uint32_t pal_printf(const char *msg, uint64_t data1, uint64_t data2) -{ - char buf[MSG_SIZE]; - - snprintf(buf, MSG_SIZE, msg, data1, data2); - printk("%s", buf); - - return PAL_SUCCESS; -} - -uint32_t pal_nvm_write(uint32_t offset, void *buffer, size_t size) -{ - /* Empty api - not in use */ - (void)offset; - (void)buffer; - (void)size; - return PAL_SUCCESS; -} - -uint32_t pal_nvm_read(uint32_t offset, void *buffer, size_t size) -{ - /* Empty api - not in use */ - (void)offset; - (void)buffer; - (void)size; - return PAL_SUCCESS; -} - -uint32_t pal_watchdog_enable(void) -{ - /* Empty api - not in use */ - return PAL_SUCCESS; -} - -uint32_t pal_watchdog_disable(void) -{ - /* Empty api - not in use */ - return PAL_SUCCESS; -} - -uint32_t pal_twdog_enable(uint32_t ms) -{ - /* Empty api - not in use */ - (void)ms; - return PAL_SUCCESS; -} - -uint32_t pal_twdog_disable(void) -{ - /* Empty api - not in use */ - return PAL_SUCCESS; -} - -void pal_twdog_intr_enable(void) -{ - /* Empty api - not in use */ - return; -} - -void pal_twdog_intr_disable(void) -{ - /* Empty api - not in use */ - return; -} - -void pal_ns_wdog_enable(uint32_t ms) -{ - pal_mmio_write32(PLATFORM_NS_WD_BASE + 0x8, ms); - pal_mmio_write32(PLATFORM_NS_WD_BASE, 1); -} - -void pal_ns_wdog_disable(void) -{ - pal_mmio_write32(PLATFORM_NS_WD_BASE, 0); -} - -void pal_ns_wdog_intr_enable(void) -{ - /* Empty api - not in use */ - return; -} - -void pal_ns_wdog_intr_disable(void) -{ - /* Empty api - not in use */ - return; -} - -uint64_t pal_sleep(uint32_t ms) -{ - /* Empty api - not in use */ - (void)ms; - return PAL_SUCCESS; -} - -void pal_secure_intr_enable(uint32_t int_id, enum interrupt_pin pin) -{ - /* Empty api - not in use */ - return; -} - -void pal_secure_intr_disable(uint32_t int_id, enum interrupt_pin pin) -{ - /* Empty api - not in use */ - return; -} - -uint32_t pal_smmu_device_configure(uint32_t stream_id, uint64_t source, uint64_t dest, - uint64_t size, bool secure) -{ - return smmuv3_configure_testengine(stream_id, source, dest, size, secure); -} - -MODULE_LICENSE("GPL"); diff --git a/ffa-acs-drv/pal_linux/src/pal_irq.c b/ffa-acs-drv/pal_linux/src/pal_irq.c deleted file mode 100644 index 2135f79..0000000 --- a/ffa-acs-drv/pal_linux/src/pal_irq.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * FF-A ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - * Author: Mahesh Bireddy - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pal_interfaces.h" -#include "pal_irq.h" - -static int8_t *dev = "FFA"; - -void pal_irq_setup(void) -{ - return; -} - -int pal_irq_handler_dispatcher(void) -{ - return 0; -} - -void pal_irq_enable(unsigned int irq_num, uint8_t irq_priority) -{ - return; -} - -void pal_irq_disable(unsigned int irq_num) -{ - return; -} - -int pal_irq_register_handler(unsigned int irq_num, handler_irq_t irq_handler) -{ - uint64_t flags = 0; - int32_t ret = 0; - int32_t virq; - struct irq_domain *domain = NULL; - struct irq_fwspec *fwspec; - - domain = acs_get_irq_domain(); - if (!domain) { - pal_printf("Domain is null\n", 0, 0); - return PAL_ERROR; - } - - fwspec = kmalloc(sizeof(struct irq_fwspec), GFP_KERNEL); - if (!fwspec) { - pal_printf("Fwspec allocation failed\n", 0, 0); - return PAL_ERROR; - } - - fwspec->param_count = 3; - fwspec->param[0] = 0; - /* Interrupt type LEVEL 0 EDGE RISING 1 */ - fwspec->param[1] = irq_num-32; - fwspec->param[2] = 4; - fwspec->fwnode = domain->fwnode; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) - fwspec->fwnode->type = FWNODE_IRQCHIP; -#endif - - if (irq_domain_is_hierarchy(domain)) { - virq = __irq_domain_alloc_irqs(domain, -1, 1, NUMA_NO_NODE, fwspec, false, NULL); - if (virq <= 0) { - ret = PAL_ERROR; - goto error; - } - } else { - /* Create mapping */ - virq = irq_create_mapping(domain, irq_num); - if (!virq) { - ret = PAL_ERROR; - goto error; - } - } - - ret = request_irq(virq, (irq_handler_t)irq_handler, flags, "FFA", dev); - if (ret) { - pal_printf("ERROR: Cannot request IRQ %x err %d\n", irq_num, ret); - ret = PAL_ERROR; - goto error; - } - -error: - kfree(fwspec); - return ret; -} - -int pal_irq_unregister_handler(unsigned int irq_num) -{ - uint32_t virq; - struct irq_domain *domain = NULL; - - domain = acs_get_irq_domain(); - virq = irq_create_mapping(domain, irq_num); - free_irq(virq, dev); - irq_dispose_mapping(virq); - - return PAL_SUCCESS; -} - -void pal_send_sgi(unsigned int sgi_id, unsigned int core_pos) -{ - return; -} diff --git a/ffa-acs-drv/pal_linux/src/pal_misc.c b/ffa-acs-drv/pal_linux/src/pal_misc.c deleted file mode 100644 index 3f86603..0000000 --- a/ffa-acs-drv/pal_linux/src/pal_misc.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * FF-A ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - * Author: Jaykumar P Patel - * - */ - -#include -#include -#include -#include "pal_interfaces.h" - -/* Note - This is unused for linux target */ -uint32_t pal_get_endpoint_device_map(void **region_list, size_t *no_of_mem_regions) -{ - *region_list = NULL; - *no_of_mem_regions = 0; - - return PAL_SUCCESS; -} - -uint32_t pal_terminate_simulation(void) -{ - return PAL_SUCCESS; -} - -void *pal_mem_virt_to_phys(void *va) -{ - return (void *)virt_to_phys(va); -} - -void *pal_memory_alloc(uint64_t size) -{ - uint32_t order = (size/PAGE_SIZE_4K)/2; - void *ptr; - - ptr = (void *)__get_free_pages(GFP_KERNEL, order); - if (!ptr) - { - pal_printf("\tpal_memory_alloc failed \n", 0, 0); - return NULL; - } - - return ptr; -} - -uint32_t pal_memory_free(void *address, uint64_t size) -{ - uint32_t order = (size/PAGE_SIZE_4K)/2; - - free_pages((uint64_t)address, order); - - return PAL_SUCCESS; -} - -int pal_memcmp(void *src, void *dest, size_t len) -{ - return memcmp(src, dest, len); -} - -void *pal_memset(void *dst, int val, size_t count) -{ - memset(dst, val, count); - return dst; -} - -void *pal_memcpy(void *dst, const void *src, size_t len) -{ - return memcpy(dst, src, len); -} diff --git a/ffa-acs-drv/pal_linux/src/pal_mmio.c b/ffa-acs-drv/pal_linux/src/pal_mmio.c deleted file mode 100644 index 4aa2685..0000000 --- a/ffa-acs-drv/pal_linux/src/pal_mmio.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * FF-A ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - * Author: Mahesh Bireddy - * - */ - -#include -#include -#include -#include "pal_interfaces.h" -#include "pal_mmio.h" - -/* MMIO read/write access functions */ -/** - @brief Provides a single point of abstraction to read 8 bit data from - Memory Mapped IO address - - @param addr 64-bit address - - @return 8-bit data read from the input address -**/ -uint8_t pal_mmio_read8(uint64_t addr) -{ - uint8_t data; - void __iomem *p; - - p = ioremap(addr, 16); - data = ioread8(p); - - iounmap(p); - - return data; -} - -/** - @brief Provides a single point of abstraction to read 16 bit data from - Memory Mapped IO address - - @param addr 64-bit address - - @return 16-bit data read from the input address -**/ -uint16_t pal_mmio_read16(uint64_t addr) -{ - uint16_t data; - void __iomem *p; - - p = ioremap(addr, 16); - data = ioread16(p); - - iounmap(p); - - return data; -} - -/** - @brief Provides a single point of abstraction to read 64 bit data from - Memory Mapped IO address - - @param addr 64-bit address - - @return 64-bit data read from the input address -**/ -uint64_t pal_mmio_read64(uint64_t addr) -{ - uint64_t data; - void __iomem *p; - - p = ioremap(addr, 16); - data = ioread64(p); - - iounmap(p); - - return data; -} - -/** - @brief Provides a single point of abstraction to read 32-bit data from - Memory Mapped IO address - - @param addr 64-bit address - - @return 32-bit data read from the input address -**/ -uint32_t pal_mmio_read32(uint64_t addr) -{ - uint32_t data; - void __iomem *p; - - if (addr & 0x3) { - addr = addr & ~(0x3); //make sure addr is aligned to 4 bytes - } - p = ioremap(addr, 16); - //Print(L"Address = %8x ", addr); - data = ioread32(p); - - //Print(L" data = %8x \n", data); - iounmap(p); - - return data; -} - -/** - @brief Provides a single point of abstraction to write 8-bit data to - Memory Mapped IO address - - @param addr 64-bit address - @param data 8-bit data to write to address - - @return None -**/ -void pal_mmio_write8(uint64_t addr, uint8_t data) -{ - void __iomem *p; - p = ioremap(addr, 16); - //Print(L"Address = %8x Data = %8x \n", addr, data); - iowrite8(data, p); - - iounmap(p); -} - -/** - @brief Provides a single point of abstraction to write 16-bit data to - Memory Mapped IO address - - @param addr 64-bit address - @param data 16-bit data to write to address - - @return None -**/ -void pal_mmio_write16(uint64_t addr, uint16_t data) -{ - void __iomem *p; - p = ioremap(addr, 16); - //Print(L"Address = %8x Data = %8x \n", addr, data); - iowrite16(data, p); - - iounmap(p); -} - -/** - @brief Provides a single point of abstraction to write 64-bit data to - Memory Mapped IO address - - @param addr 64-bit address - @param data 64-bit data to write to address - - @return None -**/ -void pal_mmio_write64(uint64_t addr, uint64_t data) -{ - void __iomem *p; - p = ioremap(addr, 16); - //Print(L"Address = %16x Data = %16x \n", addr, data); - iowrite64(data, p); - - iounmap(p); -} - -/** - @brief Provides a single point of abstraction to write 32-bit data to - Memory Mapped IO address - - @param addr 64-bit address - @param data 32-bit data to write to address - - @return None -**/ -void pal_mmio_write32(uint64_t addr, uint32_t data) -{ - void __iomem *p; - p = ioremap(addr, 16); - //Print(L"Address = %8x Data = %8x \n", addr, data); - iowrite32(data, p); - - iounmap(p); -} diff --git a/ffa-acs-drv/pal_linux/src/pal_smmuv3_testengine.c b/ffa-acs-drv/pal_linux/src/pal_smmuv3_testengine.c deleted file mode 100644 index b97ceee..0000000 --- a/ffa-acs-drv/pal_linux/src/pal_smmuv3_testengine.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * PSA FFA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - */ - -#include -#include -#include -#include - -#include "pal_interfaces.h" -#include "pal_smmuv3_testengine.h" - -#define PAGE_SIZE_4K 0x1000 -#define F_IDX(n) (n * FRAME_SIZE) -#define TIME_OUT 0x100000 - -uint32_t smmuv3_configure_testengine(uint32_t stream_id, uint64_t source, uint64_t dest, - uint64_t size, bool secure) -{ - uint32_t num_frames = (uint32_t)size/PAGE_SIZE_4K; - uint64_t begin = 0; - uint64_t end_ctrl; - uint64_t o_buf; - uint32_t ssd_ns; - uint32_t data; - uint64_t time_out = TIME_OUT; - uint32_t i; - - /* TODO Add assert condtion for source and destination address */ - if (num_frames < 1) - return PAL_ERROR; - - if (secure) - ssd_ns = 0; - else - ssd_ns = 1; - - for (i=0; i < num_frames; i++) - { - begin = source + (i * PAGE_SIZE_4K); - end_ctrl = begin + (PAGE_SIZE_4K - 1); - o_buf = dest + (i * PAGE_SIZE_4K); - /* Initialize the Privileged frame */ - pal_mmio_write32((P_FRAME_BASE + PCTRL + F_IDX(i)), ssd_ns); - pal_mmio_write32((P_FRAME_BASE + DOWNSTREAM_PORT_INDEX + F_IDX(i)), 0); - pal_mmio_write32((P_FRAME_BASE + STREAM_ID + F_IDX(i)), stream_id); - pal_mmio_write32((P_FRAME_BASE + SUBSTREAM_ID + F_IDX(i)), NO_SUBSTREAMID); - - /* Initialize the user frame */ - pal_mmio_write32((U_FRAME_BASE + UCTRL + F_IDX(i)), 0); - pal_mmio_write32((U_FRAME_BASE + SEED + F_IDX(i)), 0); - pal_mmio_write64((U_FRAME_BASE + BEGIN + F_IDX(i)), begin); - pal_mmio_write64((U_FRAME_BASE + END_CTRL + F_IDX(i)), end_ctrl); - pal_mmio_write32((U_FRAME_BASE + STRIDE + F_IDX(i)), 0x1); - pal_mmio_write64((U_FRAME_BASE + UDATA + F_IDX(i)), o_buf); - pal_mmio_write32((U_FRAME_BASE + CMD + F_IDX(i)), ENGINE_MEMCPY); - - while (--time_out) - { - data = pal_mmio_read32((U_FRAME_BASE + CMD + F_IDX(i))); - - if (data == ENGINE_MEMCPY) - continue; - - if (data != ENGINE_HALTED) - { - pal_printf("ERROR: SMMU data transfer failed\n", 0, 0); - return PAL_ERROR; - } - else - break; - } - - if (!time_out) - { - pal_printf("ERROR: SMMU test engine timeout\n", 0, 0); - return PAL_ERROR; - } - - time_out = TIME_OUT; - } - - - if (pal_memcmp((void *)begin, (void *)dest, size)) - { - pal_printf("ERROR: SMMU: Data mismatched\n", 0, 0); - return PAL_ERROR; - } - - return PAL_SUCCESS; -} diff --git a/ffa-acs-drv/pal_linux/src/pal_vcpu_setup.c b/ffa-acs-drv/pal_linux/src/pal_vcpu_setup.c deleted file mode 100644 index 7716389..0000000 --- a/ffa-acs-drv/pal_linux/src/pal_vcpu_setup.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * FF-A ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2021 Arm Limited - * - * Author: Mahesh Bireddy - * - */ - -#include -#include -#include -#include "pal_interfaces.h" - -uint32_t pal_get_no_of_cpus(void) -{ - return num_online_cpus(); -} - -uint32_t pal_get_cpuid(uint64_t mpdir) -{ - return read_cpuid_id(); -} - -uint64_t pal_get_mpid(uint32_t cpuid) -{ - return read_cpuid_mpidr(); -} - -uint32_t pal_power_on_cpu(uint64_t mpidr) -{ - return PAL_SUCCESS; -} - -uint32_t pal_power_off_cpu(void) -{ - return PAL_SUCCESS; -} - -void pal_secondary_cpu_boot_entry(void) -{ - return; -} diff --git a/ffa-acs-drv/setup.sh b/ffa-acs-drv/setup.sh deleted file mode 100755 index 6604ad9..0000000 --- a/ffa-acs-drv/setup.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -## - # - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License version 2 as - # published by the Free Software Foundation. - # - # This program is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU General Public License for more details. - # - # You should have received a copy of the GNU General Public License - # along with this program. If not, see . - # - # Copyright (C) 2021 Arm Limited - # -## - -echo "==================================================================" -echo "This script will copy the necessary files for Kernel module build " -echo "to the present directory" -echo "==================================================================" - -if [ $# -ne 1 ]; -then - echo "Give ACS_PATH as the arguments to the script" - return 0 -fi - -export ACS_PATH=$1 -echo -e "ACS_PATH is set to -> \e[93m $ACS_PATH\e[0m" - -cp -r $ACS_PATH/val . -cp -r $ACS_PATH/test . -cp -r $ACS_PATH/platform/common . diff --git a/sbsa-acs-drv/files/COPYING b/sbsa-acs-drv/files/COPYING deleted file mode 100644 index 6d45519..0000000 --- a/sbsa-acs-drv/files/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/COPYING b/sbsa-acs-drv/files/platform/pal_linux/files/COPYING deleted file mode 100644 index 6d45519..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/include/pal_exerciser.h b/sbsa-acs-drv/files/platform/pal_linux/files/include/pal_exerciser.h deleted file mode 100644 index a8661ec..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/include/pal_exerciser.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2020 Arm Limited - * - */ - -#ifndef __PAL_EXERCISER_H__ -#define __PAL_EXERCISER_H__ - -#include - -#define MAX_ARRAY_SIZE 32 -#define TEST_REG_COUNT 10 -#define TEST_DDR_REGION_CNT 16 - -typedef struct { - uint64_t buf[MAX_ARRAY_SIZE]; -} EXERCISER_INFO_BLOCK; - -typedef struct { - uint32_t num_exerciser_cards; - EXERCISER_INFO_BLOCK info[]; //Array of information blocks - per stimulus generation controller -} EXERCISER_INFO_TABLE; - -typedef enum { - EXERCISER_NUM_CARDS = 0x1 -} EXERCISER_INFO_TYPE; - -typedef enum { - EDMA_NO_SUPPORT = 0x0, - EDMA_COHERENT = 0x1, - EDMA_NOT_COHERENT = 0x2, - EDMA_FROM_DEVICE = 0x3, - EDMA_TO_DEVICE = 0x4 -} EXERCISER_DMA_ATTR; - -typedef enum { - SNOOP_ATTRIBUTES = 0x1, - LEGACY_IRQ = 0x2, - MSIX_ATTRIBUTES = 0x3, - DMA_ATTRIBUTES = 0x4, - P2P_ATTRIBUTES = 0x5, - PASID_ATTRIBUTES = 0x6 -} EXERCISER_PARAM_TYPE; - -typedef enum { - EXERCISER_RESET = 0x1, - EXERCISER_ON = 0x2, - EXERCISER_OFF = 0x3, - EXERCISER_ERROR = 0x4 -} EXERCISER_STATE; - -typedef enum { - START_DMA = 0x1, - GENERATE_MSI = 0x2, - GENERATE_L_INTR = 0x3, //Legacy interrupt - MEM_READ = 0x4, - MEM_WRITE = 0x5, - CLEAR_INTR = 0x6, - PASID_TLP_START = 0x7, - PASID_TLP_STOP = 0x8, - TXN_NO_SNOOP_ENABLE = 0x9, - TXN_NO_SNOOP_DISABLE = 0xa, - START_TXN_MONITOR = 0xb, - STOP_TXN_MONITOR = 0xc -} EXERCISER_OPS; - -typedef enum { - ACCESS_TYPE_RD = 0x0, - ACCESS_TYPE_RW = 0x1 -} ECAM_REG_ATTRIBUTE; - -struct ecam_reg_data { - uint32_t offset; //Offset into 4096 bytes ecam config reg space - uint32_t attribute; - uint32_t value; -}; - -struct exerciser_data_cfg_space { - struct ecam_reg_data reg[TEST_REG_COUNT]; -}; - -typedef enum { - DEVICE_nGnRnE = 0x0, - DEVICE_nGnRE = 0x1, - DEVICE_nGRE = 0x2, - DEVICE_GRE = 0x3 -} ARM_DEVICE_MEM; - -typedef enum { - NORMAL_NC = 0x4, - NORMAL_WT = 0x5 -} ARM_NORMAL_MEM; - -typedef enum { - MMIO_PREFETCHABLE = 0x0, - MMIO_NON_PREFETCHABLE = 0x1 -} BAR_MEM_TYPE; - -struct exerciser_data_bar_space { - void *base_addr; - BAR_MEM_TYPE type; -}; - -typedef union exerciser_data { - struct exerciser_data_cfg_space cfg_space; - struct exerciser_data_bar_space bar_space; -} exerciser_data_t; - -typedef enum { - EXERCISER_DATA_CFG_SPACE = 0x1, - EXERCISER_DATA_BAR0_SPACE = 0x2, -} EXERCISER_DATA_TYPE; - - -void pal_exerciser_create_info_table(EXERCISER_INFO_TABLE *exerciser_info_table); -uint32_t pal_exerciser_get_info(EXERCISER_INFO_TYPE type, uint32_t instance); -uint32_t pal_exerciser_set_param(EXERCISER_PARAM_TYPE type, uint64_t value1, uint64_t value2, uint32_t instance); -uint32_t pal_exerciser_get_param(EXERCISER_PARAM_TYPE type, uint64_t *value1, uint64_t *value2, uint32_t instance); -uint32_t pal_exerciser_set_state(EXERCISER_STATE state, uint64_t *value, uint32_t instance); -uint32_t pal_exerciser_get_state(EXERCISER_STATE *state, uint32_t bdf); -uint32_t pal_exerciser_ops(EXERCISER_OPS ops, uint64_t param, uint32_t instance); -uint32_t pal_exerciser_get_data(EXERCISER_DATA_TYPE type, exerciser_data_t *data, uint32_t instance); - -#endif diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/include/pal_linux.h b/sbsa-acs-drv/files/platform/pal_linux/files/include/pal_linux.h deleted file mode 100644 index b6f83b2..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/include/pal_linux.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2018, 2021, 2023 Arm Limited - * - * Author: Prasanth Pulla - * - */ - -#ifndef __PAL_LINUX_H__ -#define __PAL_LINUX_H__ - -#include -#include -#include -#include -#include "val/include/pal_interface.h" - -#define PAL_LINUX_SUCCESS 0x0 -#define PAL_LINUX_ERR 0xEDCB1234 //some impropable value? -#define PAL_LINUX_SKIP 0x10000000 - -typedef enum { - PER_FLAG_MSI_ENABLED = 0x2 -}PER_FLAGS_e; - -#define DMA_NOT_SUPPORTED 0x0 -#define DMA_COHERENT 0x1 -#define DMA_NOT_COHERENT 0x2 -#define DMA_COHERENT_MASK 0xF - -#define IOMMU_ATTACHED 0x10 -#define IOMMU_ATTACHED_MASK 0xF0 - -#define PCI_EP 0x100 -#define PCI_EP_MASK 0xF00 - -uint64_t pal_get_iort_ptr(void); - -uint64_t pal_get_mcfg_ptr(void); - -uint64_t pal_get_madt_ptr(void); - -#define NOT_IMPLEMENTED 0x4B1D - -acpi_status user_function (acpi_handle handle, uint32_t level, void *context, void **return_value); - -uint32_t pal_get_device_path(const char *hid, char hid_path[][MAX_NAMED_COMP_LENGTH]); - -uint32_t pal_smmu_is_etr_behind_catu(char *etr_path); - -#define MIN_NUM_MSG 20 -#define NUM_MSG_GROW(n) n*2 -typedef struct __PAL_SBSA_MSG__ { - char string[92]; - unsigned long data; -}pal_msg_parms_t; - -#define MSG_SIZE sizeof(pal_msg_parms_t) - -extern char *g_msg_buf; -extern int tail_msg; -extern int num_msg; - -extern uint32_t g_print_level; - -int pal_smmu_check_dev_attach(struct device *dev); - -#define AVS_PRINT_ERR 5 /* Only Errors. use this to de-clutter the terminal and focus only on specifics */ -#define AVS_PRINT_WARN 4 /* Only warnings & errors. use this to de-clutter the terminal and focus only on specifics */ -#define AVS_PRINT_TEST 3 /* Test description and result descriptions. THIS is DEFAULT */ -#define AVS_PRINT_DEBUG 2 /* For Debug statements. contains register dumps etc */ -#define AVS_PRINT_INFO 1 /* Print all statements. Do not use unless really needed */ - -#define sbsa_print(verbosity, string, data) \ - if(verbosity >= g_print_level) { \ - pal_print(string, data); \ - } - -#endif diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/include/sbsa_pcie_enum.h b/sbsa-acs-drv/files/platform/pal_linux/files/include/sbsa_pcie_enum.h deleted file mode 100644 index 4ac6cf4..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/include/sbsa_pcie_enum.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2018, 2022 Arm Limited - * - * Author: Prasanth Pulla - * - */ - -#ifndef __SBSA_PCIE_ENUM_H__ -#define __SBSA_PCIE_ENUM_H__ - - -#define PCIE_EXTRACT_BDF_SEG(bdf) ((bdf >> 24) & 0xFF) -#define PCIE_EXTRACT_BDF_BUS(bdf) ((bdf >> 16) & 0xFF) -#define PCIE_EXTRACT_BDF_DEV(bdf) ((bdf >> 8) & 0xFF) -#define PCIE_EXTRACT_BDF_FUNC(bdf) (bdf & 0xFF) - -#define PCIE_CREATE_BDF(Seg, Bus, Dev, Func) ((Seg << 24) | (Bus << 16) | (Dev << 8) | Func) - - -struct pci_dev * -pal_pci_get_dev(unsigned int class_code, struct pci_dev *dev); - -struct pci_dev * -pal_pci_get_dev_next (struct pci_dev *from_dev); - -unsigned long -pal_pcie_get_base(struct pci_dev *dev, unsigned int bar_index); - -unsigned int -pal_pcie_get_bdf(struct pci_dev *dev); - -unsigned int -pal_pcie_get_bdf_wrapper(unsigned int class_code, unsigned int start_bdf); - -void * -pal_pci_bdf_to_dev(unsigned int bdf); - -void -pal_pci_read_config_byte(uint32_t bdf, uint8_t offset, uint8_t *val); - -void -pal_pci_write_config_byte(uint32_t bdf, uint8_t offset, uint8_t val); - -unsigned int -pal_pcie_check_device_valid(unsigned int bdf); - -void -*pal_mem_calloc(unsigned int num, unsigned int size); - -#endif diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_acpi.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_acpi.c deleted file mode 100644 index f060e68..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_acpi.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2018, 2021 Arm Limited - * - * Author: Prasanth Pulla - * - */ - -#include "include/pal_linux.h" - -#include -#include -#include -#include - -uint64_t -pal_get_madt_ptr(void) -{ - struct acpi_table_header *madt_table; - acpi_status status; - - status = acpi_get_table(ACPI_SIG_MADT, 0, &madt_table); - - return (uint64_t)madt_table; -} - -uint64_t -pal_get_mcfg_ptr(void) -{ - struct acpi_table_header *mcfg_table; - acpi_status status; - - status = acpi_get_table(ACPI_SIG_MCFG, 0, &mcfg_table); - - return (uint64_t)mcfg_table; - -} - -uint64_t -pal_get_iort_ptr(void) -{ - struct acpi_table_header *iort_table; - acpi_status status; - - status = acpi_get_table(ACPI_SIG_IORT, 0, &iort_table); - - return (uint64_t)iort_table; -} - -uint32_t -pal_target_is_bm() -{ - return 0; -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_dma.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_dma.c deleted file mode 100644 index 3f098bf..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_dma.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2018, 2021, 2023-2024 Arm Limited - * - * Author: Prasanth Pulla - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "include/pal_linux.h" -#include "include/sbsa_pcie_enum.h" -#include -#include - -int -bsa_scsi_sata_get_dma_addr(struct ata_port *ap, dma_addr_t *dma_addr, unsigned int *dma_len); - - -unsigned long long int -pal_dma_mem_alloc(void **buffer, unsigned int length, void *port, unsigned int flags) -{ - dma_addr_t mem_dma; - - if (flags == DMA_COHERENT) { - *buffer = dmam_alloc_coherent(((struct ata_port *)port)->dev, length, &mem_dma, GFP_KERNEL); - if (!(*buffer)) { - pr_err("SBSA-DRV - Alloc failure %s \n", __func__); - return -ENOMEM; - } - } else { - *buffer = kmalloc(length, GFP_KERNEL); - mem_dma = dma_map_single(((struct ata_port *)port)->dev, *buffer, length, DMA_BIDIRECTIONAL); - if (dma_mapping_error(((struct ata_port *)port)->dev, mem_dma)) { - pr_err("SBSA_DRV : DMA Map single page failed.\n"); - kfree(*buffer); - return -1; - } - } - memset(*buffer, 0, length); - - return mem_dma; -} - -void -pal_dma_scsi_get_dma_addr(void *port, void *dma_addr, unsigned int *dma_len) -{ - - bsa_scsi_sata_get_dma_addr(port, dma_addr, dma_len); -} - -void -pal_dma_mem_free(void *buffer, addr_t mem_dma, unsigned int length, void *port, unsigned int flags) -{ - - if (flags == DMA_COHERENT) { - dmam_free_coherent(((struct ata_port *)port)->dev, length, buffer, mem_dma); - } else { - dma_unmap_single(((struct ata_port *)port)->dev, mem_dma, length, DMA_BIDIRECTIONAL); - kfree(buffer); - } - -} - - -void -pal_dma_poll_for_completion(unsigned int timeout) -{ - - /* scsi execute takes care of this. */ - return; - -} - -void -pal_dma_create_info_table(DMA_INFO_TABLE *dma_info_table) -{ - - struct Scsi_Host *shost; - struct ata_port *ap; - struct scsi_device *sdev = NULL; - unsigned int i = 0, j = 0; - - dma_info_table->num_dma_ctrls = 0; - - do { - shost = scsi_host_lookup(i++); - if (shost) { - sdev = NULL; - ap = ata_shost_to_port(shost); - if ((ap == NULL) || (ap->dev == NULL)) - continue; //Not a ATA port - if ((ap->scsi_host == NULL) || (ap->scsi_host != shost)) - continue; //Not a valid ATA Port - do { - /* get the device connected to this host */ - sdev = __scsi_iterate_devices(shost, sdev); - if (sdev) { - dma_info_table->info[j].host = shost; - dma_info_table->info[j].port = ap; - dma_info_table->info[j].target = sdev; - dma_info_table->info[j].flags = bsa_dev_get_dma_attr(shost->dma_dev); - - /* if we did not get coherence attribute from ACPI/PCI, get it from FDT */ - if (dma_info_table->info[j].flags == 0) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(4,19,0) - dma_info_table->info[j].flags = shost->dma_dev->dma_coherent; -#else - dma_info_table->info[j].flags = shost->dma_dev->archdata.dma_coherent; -#endif - } - if (pal_smmu_check_dev_attach(ap->dev)) - dma_info_table->info[j].flags |= IOMMU_ATTACHED; - dma_info_table->info[j++].type = sdev->type; - dma_info_table->num_dma_ctrls++; - } - } while(sdev); - scsi_host_put(shost); - } - } while(shost); - -} - -unsigned int -pal_dma_start_from_device(void *dma_target_buf, unsigned int length, - void *host, void *dev) -{ - unsigned char scsi_cmd[16]; - int result; - struct scsi_sense_hdr sshdr; - struct scsi_device *sdev = (struct scsi_device *)dev; -#if LINUX_VERSION_CODE > KERNEL_VERSION(6,2,0) - const struct scsi_exec_args exec_args = { - .sshdr = &sshdr, - }; -#endif - - memset(&scsi_cmd[0], 0, 15); - scsi_cmd[0] = READ_10; - - /* - * bytes 7 - 8: length of the command. - */ - // put_unaligned_le16(length, &scsi_cmd[7]); - scsi_cmd[8] = 1; //Hard-coded to 1 block for now - - scsi_cmd[10] = 0; /* reserved */ - scsi_cmd[11] = 0; /* control */ - -#if LINUX_VERSION_CODE > KERNEL_VERSION(6,2,0) - result = scsi_execute_cmd(sdev, scsi_cmd, DMA_FROM_DEVICE, - dma_target_buf, length, - 10000, 3, &exec_args); -#else - result = scsi_execute_req(sdev, scsi_cmd, DMA_FROM_DEVICE, - dma_target_buf, length, &sshdr, - 10000, 3, NULL); -#endif - - return result; -} - -unsigned int -pal_dma_start_to_device(void *dma_source_buf, unsigned int length, - void *host, void *target, unsigned int timeout) -{ - - unsigned char cmd[10]; - int ret; - struct scsi_device *sdev = (struct scsi_device *)target; - - memset(cmd, 0, 10); - - cmd[0] = WRITE_10; - cmd[8] = 1; //one block only for now - -#if LINUX_VERSION_CODE > KERNEL_VERSION(6,2,0) - ret = scsi_execute_cmd(sdev, cmd, DMA_TO_DEVICE, dma_source_buf, length, - timeout, 1, NULL); -#else - ret = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, dma_source_buf, length, - NULL, timeout, 1, NULL); -#endif - - return 0; -} - - -static int -is_pte(uint64_t val) -{ - return (val & 0x2); -} - -/* Decode memory attribute and shareabilty from page table descriptor val*/ -static void -decode_mem_attr_sh(uint64_t val, uint32_t *attr, uint32_t *sh) -{ - uint64_t mair = read_sysreg(mair_el1); - uint32_t attrindx = (val & PTE_ATTRINDX_MASK) >> 2; - *attr = (mair >> (attrindx * 8)) & 0xff; - *sh = (val & PTE_SHARED) >> 8; - pr_info("In decode_mem_attr_sh with attr=%x, sh=%x\n", *attr, *sh); -} - -int -pal_dma_mem_get_attrs(void *buf, uint32_t *attr, uint32_t *sh) -{ - pud_t *pud = NULL; - pmd_t *pmd; - pte_t *pte; - pgd_t *pgd; - - pgd = pgd_offset_k((uint64_t)buf); - if(!pgd) - return -1; - sbsa_print(AVS_PRINT_DEBUG, "DEBUG : pgd from pgd_offset_k: 0x%llx\n", (uint64_t)(pgd->pgd)); - - pud = pud_offset((p4d_t *) pgd, (uint64_t)buf); - if(!pud) - return -1; - sbsa_print(AVS_PRINT_DEBUG, "DEBUG : pud from pud_offset: 0x%llx\n", (uint64_t)(pud_val(*pud))); - - if(!(pud_val(*pud) & 0x2)) { - decode_mem_attr_sh(pud_val(*pud), attr, sh); - return 0; - } - - pmd = pmd_offset(pud, (uint64_t)buf); - if(!pmd) - return -1; - sbsa_print(AVS_PRINT_DEBUG, "DEBUG : pmd from pmd_offset: 0x%llx\n", (uint64_t)(pmd_val(*pmd))); - - if(!(pmd_val(*pmd) & 0x2)) { - decode_mem_attr_sh(pmd_val(*pmd), attr, sh); - return 0; - } - - pte = pte_offset_kernel(pmd, (uint64_t)buf); - if(!pte) - return -1; - sbsa_print(AVS_PRINT_DEBUG, "DEBUG : pte from pte_offset_kernel: 0x%llx\n", (uint64_t)(pte_val(*pte))); - - if(is_pte(pte_val(*pte))) { - decode_mem_attr_sh(pte_val(*pte), attr, sh); - return 0; - } - - return -1; -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_exerciser.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_exerciser.c deleted file mode 100644 index ee4ca1f..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_exerciser.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2020 Arm Limited - * - */ - -#include "include/pal_exerciser.h" - -/** - @brief This API popultaes information from all the PCIe stimulus generation IP available - in the system into exerciser_info_table structure - @param exerciser_info_table - Table pointer to be filled by this API - @return exerciser_info_table - Contains info to communicate with stimulus generation hardware -**/ -void pal_exerciser_create_info_table(EXERCISER_INFO_TABLE *exerciser_info_table) -{ - return; -} - -/** - @brief This API returns the requested information about the PCIe stimulus hardware - @param type - Information type required from the stimulus hadrware - @param instance - Stimulus hadrware instance number - @return value - Information value for input type -**/ -uint32_t pal_exerciser_get_info(EXERCISER_INFO_TYPE type, uint32_t instance) -{ - return 0; -} - -/** - @brief This API writes the configuration parameters of the PCIe stimulus generation hardware - @param type - Parameter type that needs to be set in the stimulus hadrware - @param value1 - Parameter 1 that needs to be set - @param value2 - Parameter 2 that needs to be set - @param instance - Stimulus hardware instance number - @return status - SUCCESS if the input paramter type is successfully written -**/ -uint32_t pal_exerciser_set_param(EXERCISER_PARAM_TYPE type, uint64_t value1, uint64_t value2, uint32_t instance) -{ - return 0; -} - -/** - @brief This API reads the configuration parameters of the PCIe stimulus generation hardware - @param type - Parameter type that needs to be read from the stimulus hadrware - @param value1 - Parameter 1 that is read from hardware - @param value2 - Parameter 2 that is read from hardware - @param instance - Stimulus hardware instance number - @return status - SUCCESS if the requested paramter type is successfully read -**/ -uint32_t pal_exerciser_get_param(EXERCISER_PARAM_TYPE type, uint64_t *value1, uint64_t *value2, uint32_t instance) -{ - return 0; -} - -/** - @brief This API sets the state of the PCIe stimulus generation hardware - @param state - State that needs to be set for the stimulus hadrware - @param value - Additional information associated with the state - @param instance - Stimulus hardware instance number - @return status - SUCCESS if the input state is successfully written to hardware -**/ -uint32_t pal_exerciser_set_state(EXERCISER_STATE state, uint64_t *value, uint32_t instance) -{ - return 0; -} - -/** - @brief This API obtains the state of the PCIe stimulus generation hardware - @param state - State that needs to be set for the stimulus hadrware - @param Bdf - Stimulus hardware bdf number - @return status - SUCCESS if the state is successfully read from hardware -**/ -uint32_t pal_exerciser_get_state(EXERCISER_STATE *state, uint32_t instance) -{ - *state = EXERCISER_ON; - return 0; -} - -/** - @brief This API performs the input operation using the PCIe stimulus generation hardware - @param ops - Operation thta needs to be performed with the stimulus hadrware - @param value - Additional information to perform the operation - @param instance - Stimulus hardware instance number - @return status - SUCCESS if the operation is successfully performed using the hardware -**/ -uint32_t pal_exerciser_ops(EXERCISER_OPS ops, uint64_t param, uint32_t instance) -{ - return 0; -} - -/** - @brief This API returns test specific data from the PCIe stimulus generation hardware - @param type - data type for which the data needs to be returned - @param data - test specific data to be be filled by pal layer - @param instance - Stimulus hardware instance number - @return status - SUCCESS if the requested data is successfully filled -**/ -uint32_t pal_exerciser_get_data(EXERCISER_DATA_TYPE type, exerciser_data_t *data, uint32_t instance) -{ - return 0; -} - -/** - @brief This API returns if the device is a exerciser - @param bdf - Bus/Device/Function - @return 1 - true 0 - false -**/ -uint32_t -pal_is_bdf_exerciser(uint32_t bdf) -{ - return 0; -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_gic.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_gic.c deleted file mode 100644 index d2b19e2..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_gic.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2021 Arm Limited - * - */ - -#include "include/pal_linux.h" -#include -#include -#include -#include - -unsigned int pal_gic_install_isr(unsigned int int_id, void (*isr)(void)) -{ - unsigned long long flags = 0; - unsigned int ret = 0; - unsigned int virq; - struct irq_domain *domain = NULL; - struct irq_fwspec *fwspec; - - domain = acs_get_irq_domain(); - if (!domain) { - sbsa_print(AVS_PRINT_ERR, "\n Domain is null", 0); - return 1; - } - - fwspec = kmalloc(sizeof(struct irq_fwspec), GFP_KERNEL); - if (!fwspec) { - sbsa_print(AVS_PRINT_ERR, "\n Kmalloc failed", 0); - return 1; - } - - fwspec->param_count = 2; - fwspec->param[0] = int_id; - /* Interrupt type LEVEL 0 EDGE RISING 1 */ - fwspec->param[1] = 0; - fwspec->param[2] = 0; - fwspec->fwnode = domain->fwnode; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) - fwspec->fwnode->type = FWNODE_IRQCHIP; -#endif - - if (irq_domain_is_hierarchy(domain)) { - virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec); - if (virq <= 0) { - ret = 1; - goto error; - } - } else { - /* Create mapping */ - virq = irq_create_mapping(domain, int_id); - if (!virq) { - ret = 1; - goto error; - } - } - - ret = request_irq(virq, (irq_handler_t)isr, flags, "SBSA", NULL); - if (ret != 0) { - sbsa_print(AVS_PRINT_ERR, "\n IRQ registration failure %x", int_id); - sbsa_print(AVS_PRINT_ERR, " \n err %d", ret); - ret = 1; - goto error; - } - -error: - kfree(fwspec); - return ret; -} - -void pal_gic_end_of_interrupt(unsigned int int_id) -{ - return; -} - -uint32_t pal_gic_request_irq(unsigned int irq_num, unsigned int mapped_irq_num, void *isr) -{ - return request_irq(mapped_irq_num, (irq_handler_t)isr, 0, NULL, NULL); -} - -void pal_gic_free_irq(unsigned int irq_num, unsigned int mapped_irq_num) -{ - free_irq(mapped_irq_num, NULL); -} - -/* Placeholder for MSI related implementation*/ -uint32_t pal_gic_request_msi(unsigned int its_id, unsigned int device_id, - unsigned int int_id, unsigned int msi_index, - unsigned int *msi_addr, unsigned int *msi_data) -{ - return 0; -} - -/* Placeholder for MSI related implementation*/ -void pal_gic_free_msi(unsigned int its_id, unsigned int device_id, - unsigned int int_id, unsigned int msi_index) -{ - return; -} - -/* Placeholder for ITS Configuration */ -uint32_t pal_gic_its_configure(void) -{ - return 0; -} - -/* Placeholder for returning max LPI supported */ -uint32_t pal_gic_get_max_lpi_id(void) -{ - return 0; -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_iovirt.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_iovirt.c deleted file mode 100644 index 96c5e2f..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_iovirt.c +++ /dev/null @@ -1,563 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2019, 2021-2023 Arm Limited - * - * Author: Sakar Arora - * - */ - -#include -#include -#include -#include - -#include "include/pal_linux.h" -#include "include/sbsa_pcie_enum.h" - - -#if LINUX_VERSION_CODE < KERNEL_VERSION(4,18,0) -struct acpi_iort_pmcg { - uint64_t page0_base_address; - uint32_t overflow_gsiv; - uint32_t node_reference; -}; -#endif - -/** - @brief Dump the input block -**/ -static void -dump_block(IOVIRT_BLOCK *block) -{ - uint32_t i; - NODE_DATA_MAP *map = &block->data_map[0]; - switch(block->type) { - case ACPI_IORT_NODE_ITS_GROUP: - sbsa_print(AVS_PRINT_INFO, "\nITS Group:\n Num ITS:%d\n", (*map).id[0]); - for(i = 0; i < block->data.its_count; i++) - sbsa_print(AVS_PRINT_INFO, "%d ", (*map).id[i]); - sbsa_print(AVS_PRINT_INFO, "\n", 0); - return; - case ACPI_IORT_NODE_NAMED_COMPONENT: - pr_info("\nNamed Component:\n Device Name:%s\n", block->data.named_comp.name); - pr_info(" CCA Attribute: 0x%x\n", block->data.named_comp.cca); - break; - case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: - sbsa_print(AVS_PRINT_INFO, "\nRoot Complex:\n PCI segment number:%d\n", block->data.rc.segment); - break; - case ACPI_IORT_NODE_SMMU: - case ACPI_IORT_NODE_SMMU_V3: - pr_info("\nSMMU:\n Major Rev:%d\n Base Address:0x%lld\n", - block->data.smmu.arch_major_rev, block->data.smmu.base); - break; - case IOVIRT_NODE_PMCG: - pr_info("\nPMCG:\n Base:0x%llx\n Overflow GSIV:0x%x\n Node Reference:0x%x\n", - block->data.pmcg.base, block->data.pmcg.overflow_gsiv, block->data.pmcg.node_ref); - - break; - } - sbsa_print(AVS_PRINT_INFO, "Number of ID Mappings:%d\n", block->num_data_map); - for(i = 0; i < block->num_data_map; i++, map++) { - pr_info("\n input_base:0x%x\n id_count:0x%x\n output_base:0x%x\n output ref:0x%x\n", - (*map).map.input_base, (*map).map.id_count, - (*map).map.output_base, (*map).map.output_ref); - } - sbsa_print(AVS_PRINT_INFO, "\n", 0); -} - -static void -dump_iovirt_table(IOVIRT_INFO_TABLE *iort) -{ - uint32_t i; - IOVIRT_BLOCK *block = &iort->blocks[0]; - sbsa_print(AVS_PRINT_INFO, "Number of IOVIRT blocks = %d\n", iort->num_blocks); - for(i = 0; i < iort->num_blocks; i++, block = IOVIRT_NEXT_BLOCK(block)) - dump_block(block); -} - -/** - @brief Check ID mappings in all blocks for any overlap of ID ranges - @param iovirt IoVirt table -**/ - - -static int -smmu_ctx_int_distinct(uint64_t *ctx_int, int ctx_int_cnt) { - int i, j; - for(i = 0; i < ctx_int_cnt - 1; i++) { - for(j = i + 1; j < ctx_int_cnt; j++) { - if(*((uint32_t *)&ctx_int[i]) == *((uint32_t *)&ctx_int[j])) - return 0; - } - } - return 1; -} - -static void -check_mapping_overlap(IOVIRT_INFO_TABLE *iovirt) -{ - IOVIRT_BLOCK *key_block, *block, *tmp; - NODE_DATA_MAP *key_map, *map; - uint32_t n_key_blocks, n_blocks, n_key_maps, n_maps; - uint32_t key_start, key_end, start, end; - /* Starting from first block, compare each mapping with all the */ - /* mappings that follow it in the table */ - for(key_block = &iovirt->blocks[0], n_key_blocks = iovirt->num_blocks; - n_key_blocks > 0; - key_block = IOVIRT_NEXT_BLOCK(key_block), n_key_blocks--) - { - if(key_block->type == ACPI_IORT_NODE_ITS_GROUP) - continue; - for(key_map = &key_block->data_map[0], n_key_maps = key_block->num_data_map; - n_key_maps > 0; - key_map++, n_key_maps--) - { - key_start = (*key_map).map.output_base; - key_end = key_start + (*key_map).map.id_count - 1; - for(block = key_block, n_blocks = n_key_blocks; - n_blocks > 0; - block = IOVIRT_NEXT_BLOCK(block), n_blocks--) - { - if(block->type == ACPI_IORT_NODE_ITS_GROUP) - continue; - n_maps = block->num_data_map; - map = &block->data_map[0]; - if(block == key_block) - { - map = key_map+1; - n_maps--; - } - for(;n_maps > 0; map++, n_maps--) - { - if((*map).map.output_ref != (*key_map).map.output_ref) - continue; - start = (*map).map.output_base; - end = start + (*map).map.id_count - 1; - if((key_start >= start && key_start <= end) || - (key_end >= start && key_end <= end) || - (key_start < start && key_end > end)) - { - tmp = ACPI_ADD_PTR(IOVIRT_BLOCK, iovirt, (*map).map.output_ref); - if(tmp->type == ACPI_IORT_NODE_ITS_GROUP) { - key_block->flags |= (1 << IOVIRT_FLAG_DEVID_OVERLAP_SHIFT); - block->flags |= (1 << IOVIRT_FLAG_DEVID_OVERLAP_SHIFT); - } - else - { - key_block->flags |= (1 << IOVIRT_FLAG_STRID_OVERLAP_SHIFT); - block->flags |= (1 << IOVIRT_FLAG_STRID_OVERLAP_SHIFT); - } - } - } - } - } - } -} - -/** - @brief Find block in IovirtTable - @param key Block to search - @param iovirt_table Table to in which block is to be searched - @return offset of block, if found - 0, if block not found -**/ -static uint32_t -find_block(IOVIRT_BLOCK *key, IOVIRT_INFO_TABLE *iovirt_table) -{ - IOVIRT_BLOCK *block = &iovirt_table->blocks[0]; - uint8_t *cmp_end; - uint32_t i, cmp_size; - for(i = 0; i < iovirt_table->num_blocks; i++, block = IOVIRT_NEXT_BLOCK(block)) - { - cmp_end = (uint8_t*)&block->flags; - cmp_size = cmp_end - (uint8_t*)block; - if(key->type == block->type) - { - /* Compare identfiers array as well in case of ITS group */ - if(block->type == ACPI_IORT_NODE_ITS_GROUP) - cmp_size += (block->data.its_count * sizeof(uint32_t) + sizeof(block->flags)); - if(!memcmp(key, block, cmp_size)) - return (uint8_t*)block - (uint8_t*)iovirt_table; - } - } - return 0; -} - -/** - @brief Add iovirt block for given iort node - - @param *iort ACPI IORT table base pointer - @param *iort_node IORT node base address pointer - @param *iovirt_table IO Virt Table base address pointer - @param **block Pointer to IORT block base address pointer, - where IORT block is to be added. This is modified - to the next address where new IORT block - can be created. - @return offset from the IO Virt table base address to the IORT block - base address passed in **block - OR - offset from the IO Virt table base address to the IORT block - base address where this block is already present in the - table. -**/ -static uint32_t -iovirt_add_block(struct acpi_table_iort *iort, struct acpi_iort_node *iort_node, IOVIRT_INFO_TABLE *iovirt_table, IOVIRT_BLOCK **block) -{ - uint32_t offset, *count, i; - IOVIRT_BLOCK *next_block; - IOVIRT_BLOCK *temp_block; - NODE_DATA *temp_data; - NODE_DATA_MAP *data_map = &((*block)->data_map[0]); - NODE_DATA *data = &((*block)->data); - void *node_data = &(iort_node->node_data[0]); - struct acpi_iort_node *node_ref_block; - - pr_info("IORT node offset:%lx, type: %d\n", (uint8_t*)iort_node - (uint8_t*)iort, iort_node->type); - - memset(data, 0, sizeof(NODE_DATA)); - - /* Populate the fields independent of node type */ - (*block)->type = iort_node->type; - (*block)->num_data_map = iort_node->mapping_count; - /* Populate fields dependent on node type */ - switch(iort_node->type) - { - case ACPI_IORT_NODE_ITS_GROUP: - (*data).its_count = ((struct acpi_iort_its_group*)node_data)->its_count; - /* ITS Group does not have ID mappings, but variable length array of identifiers */ - /* Populate the array here itself, and we are done with ITS group node */ - memcpy(&(*data_map).id[0], &((struct acpi_iort_its_group*)node_data)->identifiers[0], sizeof(uint32_t) * (*data).its_count); - /* Override the num_data_map value. For every 4 ITS identifiers, */ - /* we have one data map */ - (*block)->num_data_map = ((*data).its_count + 3)/4; - count = &iovirt_table->num_its_groups; - break; - case ACPI_IORT_NODE_NAMED_COMPONENT: - strncpy((char*)(*data).named_comp.name, (char*)&((struct acpi_iort_named_component*)node_data)->device_name[0], 16); - (*data).named_comp.cca = (uint32_t)(((struct acpi_iort_named_component*)node_data)->memory_properties & IOVIRT_CCA_MASK); - count = &iovirt_table->num_named_components; - break; - case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: - (*data).rc.segment = ((struct acpi_iort_root_complex*)node_data)->pci_segment_number; - (*data).rc.cca = (uint32_t)(((struct acpi_iort_root_complex*)node_data)->memory_properties & IOVIRT_CCA_MASK); - (*data).rc.ats_attr = ((struct acpi_iort_root_complex*)node_data)->ats_attribute; - (*data).rc.smmu_base = 0; /* initialize smmu_base info for root complex */ - count = &iovirt_table->num_pci_rcs; - break; - case ACPI_IORT_NODE_SMMU: - (*data).smmu.base = ((struct acpi_iort_smmu *)node_data)->base_address; - (*data).smmu.arch_major_rev = 2; - count = &iovirt_table->num_smmus; - break; - case ACPI_IORT_NODE_SMMU_V3: - (*data).smmu.base = ((struct acpi_iort_smmu_v3 *)node_data)->base_address; - (*data).smmu.arch_major_rev = 3; - count = &iovirt_table->num_smmus; - break; - case IOVIRT_NODE_PMCG: - (*data).pmcg.base = ((struct acpi_iort_pmcg *)node_data)->page0_base_address; - (*data).pmcg.overflow_gsiv = ((struct acpi_iort_pmcg *)node_data)->overflow_gsiv; - (*data).pmcg.node_ref = ((struct acpi_iort_pmcg *)node_data)->node_reference; - next_block = ACPI_ADD_PTR(IOVIRT_BLOCK, data_map, (*block)->num_data_map * sizeof(NODE_DATA_MAP)); - offset = iovirt_add_block(iort, ACPI_ADD_PTR(struct acpi_iort_node, iort, (*data).pmcg.node_ref), - iovirt_table, &next_block); - /* if the PMCG node is associated with a SMMU, store SMMU base */ - node_ref_block = ACPI_ADD_PTR(struct acpi_iort_node, iort, (*data).pmcg.node_ref); - if (node_ref_block->type == ACPI_IORT_NODE_SMMU - || node_ref_block->type == ACPI_IORT_NODE_SMMU_V3) { - (*data).pmcg.smmu_base = ((struct acpi_iort_smmu *)node_ref_block->node_data)->base_address; - } - else { - (*data).pmcg.smmu_base = 0; - } - count = &iovirt_table->num_pmcgs; - break; - default: - sbsa_print(AVS_PRINT_ERR, "Invalid IORT node type\n", 0); - return (uint32_t) -1; - } - - (*block)->flags = 0; - - /* Have we already added this block? */ - /* If so, return the block offset */ - offset = find_block(*block, iovirt_table); - if(offset) - return offset; - - if(iort_node->type == ACPI_IORT_NODE_SMMU) { - if(!smmu_ctx_int_distinct(ACPI_ADD_PTR(uint64_t, iort_node, ((struct acpi_iort_smmu *)node_data)->context_interrupt_offset), - ((struct acpi_iort_smmu *)node_data)->context_interrupt_count)) - (*block)->flags |= (1 << IOVIRT_FLAG_SMMU_CTX_INT_SHIFT); - } - - /* Calculate the position where next block should be added */ - next_block = ACPI_ADD_PTR(IOVIRT_BLOCK, data_map, (*block)->num_data_map * sizeof(NODE_DATA_MAP)); - - if((*block)->type != ACPI_IORT_NODE_ITS_GROUP) - { - struct acpi_iort_id_mapping *map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, iort_node, iort_node->mapping_offset); - /* For each id mapping copy the fields to corresponding data map fields */ - for(i = 0; i < (*block)->num_data_map; i++) - { - (*data_map).map.input_base = map->input_base; - (*data_map).map.id_count = map->id_count; - (*data_map).map.output_base = map->output_base; - /* We don't know if the iort node referred to by map->output_*/ - /* reference is already added as a block. So try to add it and */ - /* store the returned offset in the relevant data map field. */ - /* We know this function will return offset of newly block or */ - /* already added block */ - offset = iovirt_add_block(iort, - ACPI_ADD_PTR(struct acpi_iort_node, iort, map->output_reference), - iovirt_table, - &next_block); - (*data_map).map.output_ref = offset; - data_map++; - map++; - - /* Derive the smmu base to which this RC node is connected. - * If the RC is behind a SMMU, save SMMU base to RC structure. - * Else save NULL pointer. - */ - temp_block = ACPI_ADD_PTR(IOVIRT_BLOCK, iovirt_table, offset); - if (((*block)->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) && - ((temp_block->type == ACPI_IORT_NODE_SMMU) || - (temp_block->type == ACPI_IORT_NODE_SMMU_V3))) { - temp_data = &(temp_block->data); - (*data).rc.smmu_base = (*temp_data).smmu.base; - } - - /* If this node is a named component, Check whether it is behind a SMMU - * store the SMMU base in named component info structure if true, else - * save NULL pointer. - */ - temp_block = ACPI_ADD_PTR(IOVIRT_BLOCK, iovirt_table, offset); - if (((*block)->type == ACPI_IORT_NODE_NAMED_COMPONENT) && - ((temp_block->type == ACPI_IORT_NODE_SMMU) || - (temp_block->type == ACPI_IORT_NODE_SMMU_V3))) { - temp_data = &(temp_block->data); - (*data).named_comp.smmu_base = (*temp_data).smmu.base; - } - - } - } - /* So we successfully added a new block. Calculate its offset */ - offset = (uint8_t*)(*block) - (uint8_t*)iovirt_table; - /* Inform the caller about the address at which next block must be added */ - *block = next_block; - /* Increment the general and type specific block counters */ - iovirt_table->num_blocks++; - *count = *count + 1; - return offset; -} - -/** - @brief Parses ACPI IORT table and populates the local iovirt table -**/ -void -pal_iovirt_create_info_table(IOVIRT_INFO_TABLE *iovirt_table) -{ - struct acpi_table_iort *iort; - struct acpi_iort_node *iort_node, *iort_end; - IOVIRT_BLOCK *next_block; - uint32_t i; - - if (iovirt_table == NULL) - return; - - /* Initialize counters */ - iovirt_table->num_blocks = 0; - iovirt_table->num_smmus = 0; - iovirt_table->num_pci_rcs = 0; - iovirt_table->num_named_components = 0; - iovirt_table->num_its_groups = 0; - iovirt_table->num_pmcgs = 0; - - iort = (struct acpi_table_iort *)pal_get_iort_ptr(); - - if (iort == NULL) { - return; - } - - /* Point to the first Iovirt table block */ - next_block = &(iovirt_table->blocks[0]); - - /* Point to the first IORT node */ - iort_node = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->node_offset); - iort_end = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->header.length); - /* Create iovirt block for each IORT node*/ - for (i = 0; i < iort->node_count; i++) { - if (iort_node >= iort_end) { - sbsa_print(AVS_PRINT_ERR, "Bad IORT table \n", 0); - return; - } - iovirt_add_block(iort, iort_node, iovirt_table, &next_block); - iort_node = ACPI_ADD_PTR(struct acpi_iort_node, iort_node, iort_node->length); - } - dump_iovirt_table(iovirt_table); - check_mapping_overlap(iovirt_table); -} - -/** - @brief Check if given SMMU node has unique context bank interrupt ids - - @param smmu_block smmu IOVIRT block base address - - @return 0 if test fails, 1 if test passes -**/ - -uint32_t -pal_iovirt_check_unique_ctx_intid(uint64_t smmu_block) -{ - IOVIRT_BLOCK *block = (IOVIRT_BLOCK *)smmu_block; - if(block->flags & (1 << IOVIRT_FLAG_SMMU_CTX_INT_SHIFT)) - return 0; - return 1; - -} - -/** - @brief Check if given root complex node has unique requestor id to stream id mapping - - @param rc_block root complex IOVIRT block base address - - @return 0 if test fails, 1 if test passes -**/ - -uint32_t -pal_iovirt_unique_rid_strid_map(uint64_t rc_block) -{ - IOVIRT_BLOCK *block = (IOVIRT_BLOCK *)rc_block; - if(block->flags & (1 << IOVIRT_FLAG_STRID_OVERLAP_SHIFT)) - return 0; - return 1; -} - -uint64_t -pal_iovirt_get_rc_smmu_base(IOVIRT_INFO_TABLE *iovirt, uint32_t rc_seg_num, uint32_t rid) -{ - uint32_t i, j; - IOVIRT_BLOCK *block; - NODE_DATA_MAP *map; - uint32_t mapping_found; - uint32_t oref, sid, id = 0; - - /* Search for root complex block with same segment number, and in whose id */ - /* mapping range 'rid' falls. Calculate the output id */ - block = &(iovirt->blocks[0]); - mapping_found = 0; - for (i = 0; i < iovirt->num_blocks; i++, block = IOVIRT_NEXT_BLOCK(block)) - { - if (block->type == IOVIRT_NODE_PCI_ROOT_COMPLEX - && block->data.rc.segment == rc_seg_num) - { - for (j = 0, map = &block->data_map[0]; j < block->num_data_map; j++, map++) - { - if(rid >= (*map).map.input_base - && rid <= ((*map).map.input_base + (*map).map.id_count)) - { - id = rid - (*map).map.input_base + (*map).map.output_base; - oref = (*map).map.output_ref; - mapping_found = 1; - break; - } - } - } - } - - if (!mapping_found) { - sbsa_print(AVS_PRINT_ERR, - "Requestor ID to Stream ID/Device ID mapping not found\n", 0); - return 0xFFFFFFFF; - } - - block = (IOVIRT_BLOCK*)((uint8_t*)iovirt + oref); - if(block->type == IOVIRT_NODE_SMMU || block->type == IOVIRT_NODE_SMMU_V3) - { - sid = id; - id = 0; - for(i = 0, map = &block->data_map[0]; i < block->num_data_map; i++, map++) - { - if(sid >= (*map).map.input_base && sid <= ((*map).map.input_base + - (*map).map.id_count)) - { - sbsa_print(AVS_PRINT_DEBUG, " find RC block->data.smmu.base : %llx", block->data.smmu.base); - return block->data.smmu.base; - } - } - } - - /* The Root Complex represented by rc_seg_num - * is not behind any SMMU. Return NULL pointer - */ - sbsa_print(AVS_PRINT_DEBUG, "No SMMU found behind the RootComplex with segment :%x", rc_seg_num); - return 0; -} - -/** - @brief This function is called by the val function pal_get_device_path - when the hid type is found - - @param handle device handle - @param level nesting level - @param context data to be passed from caller function - @param return_value return value passed to caller function pal_get_device_path - - @return 1 if test fails, 0 if test passes -**/ -acpi_status user_function(acpi_handle handle, uint32_t level, - void *context, void **return_value) -{ - acpi_status status; - static uint32_t count; - struct acpi_buffer buffer; - char (*path_buffer)[MAX_NAMED_COMP_LENGTH] = context; - - buffer.length = ACPI_ALLOCATE_BUFFER; - status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); - strncpy((char *)path_buffer[count++], (char *)(buffer.pointer), 16); - return status; -} - -/** - @brief Check the hid in ACPI and copy te full path of hid - - @param hid hardware ID to get the path for - @param hid_path 2D array in which the path is copied - - @return 1 if test fails, 0 if test passes -**/ -uint32_t -pal_get_device_path(const char *hid, char hid_path[][MAX_NAMED_COMP_LENGTH]) -{ - acpi_status status; - status = acpi_get_devices(hid, user_function, (void *)hid_path, NULL); - return status; -} - -/** - @brief Platform defined method to check if CATU is behind an ETR device - - @param etr_path full path of ETR device - - @return 0 - Success, NOT_IMPLEMENTED - API not implemented, Other values - Failure -**/ -uint32_t -pal_smmu_is_etr_behind_catu(char *etr_path) -{ - return NOT_IMPLEMENTED; -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_misc.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_misc.c deleted file mode 100644 index f4f7b43..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_misc.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2023 Arm Limited - * - * Author: Prasanth Pulla - * - */ - -#include -#include -#include -#include "include/pal_linux.h" -#include -#include - -unsigned int *gSharedMemory; - -extern int tail_msg; -int num_msg = MIN_NUM_MSG; - -/** - @brief Provides a single point of abstraction to read 8 bit data from - Memory Mapped IO address - - @param addr 64-bit address - - @return 8-bit data read from the input address -**/ -uint8_t pal_mmio_read8(uint64_t addr) -{ - uint8_t data; - void __iomem *p; - - p = ioremap(addr, 16); - data = ioread8(p); - - //Print(L"Address = %8x ", addr); - //Print(L" data = %8x \n", data); - iounmap(p); - - return data; -} - -/** - @brief Provides a single point of abstraction to read 16 bit data from - Memory Mapped IO address - - @param addr 64-bit address - - @return 16-bit data read from the input address -**/ -uint16_t pal_mmio_read16(uint64_t addr) -{ - uint16_t data; - void __iomem *p; - - p = ioremap(addr, 16); - data = ioread16(p); - - //Print(L"Address = %8x ", addr); - //Print(L" data = %8x \n", data); - iounmap(p); - - return data; -} - -/** - @brief Provides a single point of abstraction to read 64 bit data from - Memory Mapped IO address - - @param addr 64-bit address - - @return 64-bit data read from the input address -**/ -uint64_t pal_mmio_read64(uint64_t addr) -{ - uint64_t data; - void __iomem *p; - - p = ioremap(addr, 16); - data = ioread64(p); - - //Print(L"Address = %16x ", addr); - //Print(L" data = %16x \n", data); - iounmap(p); - - return data; -} - -/** - @brief Provides a single point of abstraction to read 32-bit data from - Memory Mapped IO address - - @param addr 64-bit address - - @return 32-bit data read from the input address -**/ -uint32_t pal_mmio_read(uint64_t addr) -{ - uint32_t data; - void __iomem *p; - - if (addr & 0x3) { - sbsa_print(AVS_PRINT_INFO, "\n Error-Input address is not aligned. Masking the last 2 bits \n", 0); - addr = addr & ~(0x3); //make sure addr is aligned to 4 bytes - } - p = ioremap(addr, 16); - //Print(L"Address = %8x ", addr); - data = ioread32(p); - - //Print(L" data = %8x \n", data); - iounmap(p); - - return data; -} - -/** - @brief Provides a single point of abstraction to write 8-bit data to - Memory Mapped IO address - - @param addr 64-bit address - @param data 8-bit data to write to address - - @return None -**/ -void pal_mmio_write8(uint64_t addr, uint8_t data) -{ - void __iomem *p; - p = ioremap(addr, 16); - //Print(L"Address = %8x Data = %8x \n", addr, data); - iowrite8(data, p); - - iounmap(p); -} - -/** - @brief Provides a single point of abstraction to write 16-bit data to - Memory Mapped IO address - - @param addr 64-bit address - @param data 16-bit data to write to address - - @return None -**/ -void pal_mmio_write16(uint64_t addr, uint16_t data) -{ - void __iomem *p; - p = ioremap(addr, 16); - //Print(L"Address = %8x Data = %8x \n", addr, data); - iowrite16(data, p); - - iounmap(p); -} - -/** - @brief Provides a single point of abstraction to write 64-bit data to - Memory Mapped IO address - - @param addr 64-bit address - @param data 64-bit data to write to address - - @return None -**/ -void pal_mmio_write64(uint64_t addr, uint64_t data) -{ - void __iomem *p; - p = ioremap(addr, 16); - //Print(L"Address = %16x Data = %16x \n", addr, data); - iowrite64(data, p); - - iounmap(p); -} - -/** - @brief Provides a single point of abstraction to write 32-bit data to - Memory Mapped IO address - - @param addr 64-bit address - @param data 32-bit data to write to address - - @return None -**/ -void pal_mmio_write(uint64_t addr, uint32_t data) -{ - void __iomem *p; - p = ioremap(addr, 16); - //Print(L"Address = %8x Data = %8x \n", addr, data); - iowrite32(data, p); - - iounmap(p); -} - -/** - @brief Sends a formatted string to the output console - - @param string An ASCII string - @param data data for the formatted output - - @return None -**/ -void pal_print(char *string, uint64_t data) -{ - printk(string, data); -} - -/** - @brief this function is irrelevant for linux code -**/ -void pal_print_raw(uint64_t addr, char *string, uint64_t data) -{ -} - -/** - @brief Allocates memory of the requested size - - @param sizeo - Size of memory region to be allocated - - @return Virtual address if success, NULL on failure -**/ -void *pal_mem_alloc(unsigned int size) -{ - - return kzalloc(size, GFP_KERNEL); - -} - -/** - @brief Allocates cacheable memory of the requested size - - @param bdf - BDF of the requesting pcie device - @param size - Size of memory region to be allocated - @param pa - Physical address of the allocated memory - - @return virtual address if success, NULL on failure -**/ -void *pal_mem_alloc_cacheable(uint32_t bdf, uint32_t size, void **pa) -{ - void *buf_virt; - dma_addr_t buf_phys; - struct device *dev; - - dev = pal_pci_bdf_to_dev(bdf); - buf_virt = dma_alloc_coherent(dev, size, &buf_phys, GFP_KERNEL); - - *pa = (void *)buf_phys; - return buf_virt; -} - -/** - @brief Free the memory allocated by UEFI Framework APIs - @param Buffer the base address of the memory range to be freed - - @return None -**/ -void pal_mem_free(void *buffer) -{ - - kfree(buffer); -} - -/** - @brief Compare the two input buffer content - @param src - Source buffer to be compared - @dest dest - Destination buffer to be compared - - @return Zero if buffer content are equal, else non-zero -**/ -int pal_mem_compare(void *src, void *dest, uint32_t len) -{ - return memcmp(src, dest, len); -} - -/** - @brie a buffer with a known specified input value - @param buf - Pointer to the buffer to fill - @param size - Number of bytes in buffer to fill - @param value - Value to fill buffer with - - @return None -**/ -void pal_mem_set(void *buf, uint32_t size, uint8_t value) -{ - memset(buf, value, size); -} - -/** - @brief Free the cacheable memory allocated by Linux DMA Framework APIs - - @param bdf - BDF of the requesting pcie device - @param size - Size of memory region to be freed - @param va - Virtual address of the memory to be freed - @param pa - Physical address of the memory to be freed - - @return None -**/ -void pal_mem_free_cacheable(uint32_t bdf, uint32_t size, void *va, void *pa) -{ - struct device *dev; - - dev = pal_pci_bdf_to_dev(bdf); - dma_free_coherent(dev, size, va, (dma_addr_t)pa); -} - -/** - @brief Returns the physical address of the input virtual address - - @param va - Virtual address of the memory to be converted - - @return Physical address -**/ -void *pal_mem_virt_to_phys(void *va) -{ - return (void *)virt_to_phys(va); -} - -/** - @brief Allocate memory which is to be used to share data across PEs - - @param num_pe - Number of PEs in the system - @param sizeofentry - Size of memory region allocated to each PE - - @return None -**/ -void pal_mem_allocate_shared(unsigned int num_pe, unsigned int sizeofentry) -{ - gSharedMemory = 0; - - gSharedMemory = kmalloc((num_pe * sizeofentry), GFP_KERNEL); - - return; - -} - -/** - @brief Return the base address of the shared memory region to the VAL layer -**/ -uint64_t pal_mem_get_shared_addr(void) -{ - - return (uint64_t) (gSharedMemory); -} - -/** - @brief Free the shared memory region allocated above -**/ -void pal_mem_free_shared(void) -{ - kfree ((void *)gSharedMemory); -} - -/** - @brief Place holder for Memory Copy -**/ -void *pal_memcpy(void *dest_buffer, void *src_buffer, uint32_t len) -{ - return NULL; -} - -/** - @brief Place holder for Stalling the CPU for Number of Microseconds -**/ -uint64_t pal_time_delay_ms(uint64_t time_ms) -{ - return 0; -} - -/** - @brief Place holder for Comparing two Strings -**/ -uint32_t pal_strncmp(char8_t *str1, char8_t *str2, uint32_t len) -{ - return 0; -} - -/** - @brief Place holder for returning virtual address of input physical address -**/ -void *pal_mem_phys_to_virt(uint64_t pa) -{ - return NULL; -} - -/** - @brief Place holder for returning memory page size -**/ -uint32_t pal_mem_page_size(void) -{ - return 0; -} - -/** - @brief Place holder for Allocating requested number of pages -**/ -void *pal_mem_alloc_pages(uint32_t num_pages) -{ - return NULL; -} - -/** - @brief Place holder for Freeing number of pages starting - from a given address -**/ -void pal_mem_free_pages(void *page_base, uint32_t num_pages) -{ -} - -/** - * @brief Allocates requested buffer size in bytes with zeros in a contiguous memory - * and returns the base address of the range. - * - * @param Size allocation size in bytes - * @retval if SUCCESS pointer to allocated memory - * @retval if FAILURE NULL - */ -void * -pal_mem_calloc(unsigned int num, unsigned int Size) -{ - - return kcalloc(num, Size, GFP_KERNEL); -} - -/** - @brief Allocates memory with the given alignement. - - @param Alignment Specifies the alignment. - @param Size Requested memory allocation size. - - @return Pointer to the allocated memory with requested alignment. -**/ -void * -pal_aligned_alloc(uint32_t alignment, uint32_t size) -{ - void *Mem = NULL; - void **Aligned_Ptr = NULL; - - /* Generate mask for the Alignment parameter*/ - uint64_t Mask = ~(uint64_t)(alignment - 1); - - /* Allocate memory with extra bytes, so we can return an aligned address*/ - Mem = (void *)pal_mem_alloc(size + alignment); - - if( Mem == NULL) - return 0; - - /* Add the alignment to allocated memory address and align it to target alignment*/ - Aligned_Ptr = (void **)(((uint64_t) Mem + alignment-1) & Mask); - - /* Using a double pointer to store the address of allocated - memory location so that it can be used to free the memory later */ - Aligned_Ptr[-1] = Mem; - - return Aligned_Ptr; -} - -/** - @brief Free the aligned memory allocated - @param Buffer the base address of the memory range to be freed - - @return None -**/ -void pal_mem_free_aligned(void *buffer) -{ - - kfree(((void **)buffer)[-1]); -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie.c deleted file mode 100644 index 6efff10..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie.c +++ /dev/null @@ -1,685 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2024, Arm Limited - * - * Author: Prasanth Pulla - * Daniil Egranov - * - */ - -#include "include/pal_linux.h" - -#include -#include -#include -#include -#include -#include -#include - -/** - @brief Read a device MSI(X) vector - - @param dev pointer to a pci_dev device structure - @param entry pointer to a msi_desc structure assosiated with a device - @param vector pointer to a MSI(X) vector structure - - @return vector MSI(X) vector -**/ - -static -uint64_t irq_to_hwirq(uint32_t irq) -{ - struct irq_data *d = irq_get_irq_data(irq); - if (d) - return d->hwirq; - return 0; -} - -static -void -pal_pci_read_msi_vector (struct pci_dev *dev, struct msi_desc *entry, PERIPHERAL_VECTOR_BLOCK *vector) -{ - int pos; - uint16_t data; - void __iomem *base; - - if(dev == NULL || entry == NULL || vector == NULL) { - return; - } - - vector->vector_lower_addr = 0; - vector->vector_upper_addr = 0; - vector->vector_data = 0; - vector->vector_control = 0; - vector->vector_irq_base = irq_to_hwirq(entry->irq); - vector->vector_mapped_irq_base = entry->irq; - vector->vector_n_irqs = entry->nvec_used; - -#if LINUX_VERSION_CODE > KERNEL_VERSION(5,16,0) - if (entry->pci.msi_attrib.is_msix) { - base = entry->pci.mask_base + - entry->msi_index * PCI_MSIX_ENTRY_SIZE; -#else - if (entry->msi_attrib.is_msix) { - base = entry->mask_base + - entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE; -#endif - vector->vector_lower_addr = readl (base + PCI_MSIX_ENTRY_LOWER_ADDR); - vector->vector_upper_addr = readl (base + PCI_MSIX_ENTRY_UPPER_ADDR); - vector->vector_data = readl (base + PCI_MSIX_ENTRY_DATA); - vector->vector_control = readl (base + PCI_MSIX_ENTRY_VECTOR_CTRL); - } else { - pos = dev->msi_cap; - pci_read_config_dword (dev, pos + PCI_MSI_ADDRESS_LO, - &vector->vector_lower_addr); -#if LINUX_VERSION_CODE > KERNEL_VERSION(5,16,0) - if (entry->pci.msi_attrib.is_64) { -#else - if (entry->msi_attrib.is_64) { -#endif - pci_read_config_dword (dev, pos + PCI_MSI_ADDRESS_HI, - &vector->vector_upper_addr); - pci_read_config_word (dev, pos + PCI_MSI_DATA_64, &data); - } else { - pci_read_config_word (dev, pos + PCI_MSI_DATA_32, &data); - } - vector->vector_data = data; - } -} - -/** - @brief Create a list of MSI(X) vectors for a device - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - @param mvector pointer to a MSI(X) list address - - @return mvector list of MSI(X) vectors - @return number of MSI(X) vectors -**/ -uint32_t -pal_get_msi_vectors (uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn, PERIPHERAL_VECTOR_LIST **mvector) -{ - struct pci_dev *pdev; - struct msi_desc *entry; - uint32_t vcount; - PERIPHERAL_VECTOR_LIST *head; - - vcount = 0; - head = NULL; - - if(mvector == NULL) - return 0; - - pdev = pci_get_domain_bus_and_slot (seg, bus, PCI_DEVFN (dev, fn)); - - if(pdev != NULL) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(5,16,0) - msi_lock_descs(&pdev->dev); - msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ALL) { -#else - for_each_pci_msi_entry (entry, pdev) { -#endif - if (head == NULL) { - head = kmalloc (sizeof (PERIPHERAL_VECTOR_LIST), GFP_KERNEL); - if(head == NULL) { - break; - } - head->next = NULL; - *mvector = head; - } else { - head->next = kmalloc (sizeof (PERIPHERAL_VECTOR_LIST), GFP_KERNEL); - if(head->next == NULL) { - break; - } - head = head->next; - head->next = NULL; - } - pal_pci_read_msi_vector (pdev, entry, &head->vector); - vcount++; - } -#if LINUX_VERSION_CODE > KERNEL_VERSION(5,16,0) - msi_unlock_descs(&pdev->dev); -#endif - } - - return vcount; -} - -uint64_t -pal_pcie_get_mcfg_ecam(void) -{ - struct acpi_table_mcfg *mcfg; - struct acpi_mcfg_allocation *cfg_table; - - mcfg = (struct acpi_table_mcfg *)pal_get_mcfg_ptr(); - - if (!mcfg) - return 0; - - cfg_table = (struct acpi_mcfg_allocation *) &mcfg[1]; - - if (cfg_table) - return cfg_table->address; - else - return 0; -} - - -/** - @brief Fill the PCIE Info table with the details of the PCIe sub-system - **/ -void -pal_pcie_create_info_table(PCIE_INFO_TABLE *PcieTable) -{ - unsigned int i = 0, length; - struct acpi_table_mcfg *mcfg; - struct acpi_mcfg_allocation *entry; - - length = sizeof(struct acpi_table_mcfg); - - PcieTable->num_entries = 0; - mcfg = (struct acpi_table_mcfg *)pal_get_mcfg_ptr(); - - if (!mcfg) - return; - - entry = (struct acpi_mcfg_allocation *) &mcfg[1]; - - do{ - PcieTable->block[i].ecam_base = entry->address; - PcieTable->block[i].start_bus_num = entry->start_bus_number; - PcieTable->block[i].end_bus_num = entry->end_bus_number; - PcieTable->block[i].segment_num = entry->pci_segment; - length += sizeof(struct acpi_mcfg_allocation); - entry++; - i++; - PcieTable->num_entries++; - } while((length < mcfg->header.length) && (entry)); - - return; -} - -/** - @brief Get legacy IRQ routing for a PCI device - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - @param irq_map pointer to IRQ map structure - - @return irq_map IRQ routing map - @return staus code -**/ - -uint32_t -pal_pcie_get_legacy_irq_map(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn, PERIPHERAL_IRQ_MAP *irq_map) -{ - acpi_status status; - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; - struct acpi_pci_routing_table *entry; - acpi_handle handle = NULL; - struct pci_dev *pdev; - uint32_t irq_count; - - /* Get a root bridge device */ - pdev = pci_get_domain_bus_and_slot (seg, bus, PCI_DEVFN (dev, fn)); - if (pdev == NULL || !pdev->bus->bridge) { - return 1; - } - - /* Get handle for _PRT */ - handle = ACPI_HANDLE (pdev->bus->bridge); - if (!handle) { - return 2; - } - - /* Get routing irq data from _PRT */ - status = acpi_get_irq_routing_table(handle, &buffer); - if (ACPI_FAILURE(status)) { - kfree(buffer.pointer); - return 3; - } - - entry = buffer.pointer; - status = 0; - while (entry && (entry->length > 0)) { - - /* - * The 'source' field expected to be NULL, and the 'source_index' - * field specifies the IRQ value, which is hard-wired to specific interrupt inputs - * on the interrupt controller. - */ - if ((uint32_t)*entry->source != 0) { - status = 4; - break; - } - - /* - * Expecting pins A, B, C and D - */ - if (entry->pin > 3) { - status = 5; - break; - } - - irq_count = irq_map->legacy_irq_map[entry->pin].irq_count; - if (irq_count >= MAX_IRQ_CNT) { - status = 6; - break; - } else { - irq_map->legacy_irq_map[entry->pin].irq_list[irq_count] = entry->source_index; - irq_map->legacy_irq_map[entry->pin].irq_count++; - } - - entry = (struct acpi_pci_routing_table *) ((unsigned long)entry + entry->length); - } - - kfree(buffer.pointer); - return status; -} - -/** - @brief Checks if device is behind SMMU - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - - @return staus code:0 -> not present, nonzero -> present -**/ -uint32_t -pal_pcie_is_device_behind_smmu(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - struct pci_dev *pdev; - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - if(pdev->dev.iommu_group) - return 1; - else - return 0; -} - -/** - @brief Return the DMA addressability of the device - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - - @return DMA Mask : 0, 0xffffffff or 0xffffffffffff -**/ -uint32_t -pal_pcie_is_devicedma_64bit(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - struct pci_dev *pdev; - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - - if (pdev) { - sbsa_print(AVS_PRINT_INFO,"dma mask is %llx \n", *pdev->dev.dma_mask); - if (*pdev->dev.dma_mask == DMA_BIT_MASK(64)) - return 1; - else - return 0; - } - return 0; -} - -/** - @brief Return if driver present for a pcie device - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - - @return Driver present or not : 0, 1 -**/ -uint32_t -pal_pcie_device_driver_present(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - struct pci_dev *pdev; - struct pci_driver *driver; - - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - - if (pdev) { - driver = (*pdev).driver; - if (driver && driver->name) { - sbsa_print(AVS_PRINT_INFO,"driver name is %s \n", *driver->name); - return 1; - } - else - return 0; - } - return 0; -} - -/** - @brief Get bdf of root port - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - @param seg PCI segment number - - @return BDF of root port - @return staus code -**/ -uint32_t -pal_pcie_get_root_port_bdf(uint32_t *seg, uint32_t *bus, uint32_t *dev, uint32_t *func) -{ - struct pci_dev *pdev, *root_port = NULL; - pdev = pci_get_domain_bus_and_slot(*seg, *bus, PCI_DEVFN(*dev, *func)); - if(pdev->bus->self == NULL) - return 1; - -#if LINUX_VERSION_CODE > KERNEL_VERSION(5,7,0) - root_port = pcie_find_root_port(pdev); -#else - root_port = pci_find_pcie_root_port(pdev); -#endif - - if(root_port == NULL) - return 2; - - *bus = root_port->bus->number; - *dev = PCI_SLOT(root_port->devfn); - *func = PCI_FUNC(root_port->devfn); - *seg = pci_domain_nr(root_port->bus); - return 0; -} - -/** - @brief Get the PCIe device/port type - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - - @return Returns PCIe device/port type -**/ -uint32_t -pal_pcie_get_pcie_type(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - struct pci_dev *pdev; - - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - if(pdev == NULL) - return 0; - - return pci_pcie_type(pdev); -} - -/** - @brief Get the PCIe device snoop bit transaction attribute - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - - @return 0 snoop - 1 no snoop - 2 device error -**/ -uint32_t -pal_pcie_get_snoop_bit(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - struct pci_dev *pdev; - u16 devctl_cap; - uint32_t ret_val; - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - if(pdev == NULL) - return 2; - - pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &devctl_cap); - /* Extract bit 11 (no snoop) */ - ret_val = (devctl_cap >> DEVCTL_SNOOP_BIT) & 0x1; - - return ret_val; -} - -/** - @brief Get the PCIe device DMA support - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - - @return 0 no support - 1 support - 2 device error -**/ -uint32_t -pal_pcie_get_dma_support(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - struct pci_dev *pdev; - uint32_t ret_val; - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - if(pdev == NULL) - return 2; - - ret_val = device_dma_supported(&pdev->dev); - - return ret_val; -} - -/** - @brief Get the PCIe device DMA coherency support - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - - @return 0 DMA is not coherent - 1 DMA is coherent - 2 device error -**/ -uint32_t -pal_pcie_get_dma_coherent(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - struct pci_dev *pdev; - enum dev_dma_attr dma_attr; - uint32_t ret_val; - - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - if(pdev == NULL) - return 2; - - ret_val = 0; - dma_attr = device_get_dma_attr(&pdev->dev); - if (dma_attr == DEV_DMA_COHERENT) { - ret_val = 1; - } - - return ret_val; -} - -void -pal_pcie_read_ext_cap_word(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn, - uint32_t ext_cap_id, uint8_t offset, uint16_t *val) -{ - struct pci_dev *pdev; - int pos; - - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - if(pdev == NULL) { - *val = 0; - return; - } - - pos = pci_find_ext_capability(pdev, ext_cap_id); - if (!pos) { - *val = 0; - return; - } - - pci_read_config_word(pdev, pos + offset, val); -} - -/** - @brief This API checks the PCIe Hierarchy Supports P2P - 1. Caller - Test Suite - @return 1 - P2P feature not supported 0 - P2P feature supported -**/ -uint32_t -pal_pcie_p2p_support(void) -{ - /* - * TODO - * PCIe support for peer to peer - * transactions is platform implementation specific - */ - - return 1; -} - -/** - @brief This API checks the PCIe device P2P support - 1. Caller - Test Suite - @param bdf - PCIe BUS/Device/Function - @return 1 - P2P feature not supported 0 - P2P feature supported -**/ -uint32_t -pal_pcie_dev_p2p_support(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - /* - * TODO - * Root port or Switch support for peer to peer - * transactions is platform implementation specific - */ - - return 1; -} - -uint32_t pal_pcie_io_read_cfg(uint32_t bdf, uint32_t offset, uint32_t *data) -{ - return 0; -} - -/** - @brief Placeholder To Perform PCIe Write - **/ -void pal_pcie_io_write_cfg(uint32_t bdf, uint32_t offset, uint32_t data) -{ - -} - -/** - @brief Placeholder To Perform PCIe Enumeration - **/ -void pal_pcie_enumerate(void) -{ - -} - -/** - @brief Placeholder To check if a PCIe device has an Address - translation cache or not. - **/ -uint32_t -pal_pcie_is_cache_present(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - return 0; -} - -/** - @brief Gets RP support of transaction forwarding. - - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - @param seg PCI segment number - - @return 0 if rp not involved in transaction forwarding - 1 if rp is involved in transaction forwarding -**/ -uint32_t -pal_pcie_get_rp_transaction_frwd_support(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - return 1; -} - -/** - @brief Returns whether a PCIe Function is an on-chip peripheral or not - - @param bdf - Segment/Bus/Dev/Func in the format of PCIE_CREATE_BDF - @return Returns 1 if the Function is on-chip peripheral, 0 if it is - not an on-chip peripheral -**/ -uint32_t -pal_pcie_is_onchip_peripheral(uint32_t bdf) -{ - return 0; -} - -/** - @brief Checks the discovered PCIe hierarchy is matching with the - topology described in info table. - @return Returns 0 if device entries matches , 1 if there is mismatch. -**/ -uint32_t -pal_pcie_check_device_list() -{ - return 0; -} - -/** - @brief Placeholder to return the memory offset - This offset is platform-specific. It needs to - be modified according to the requirement. - @param bdf - PCIe BUS/Device/Function - @param mem_type - If the memory is Pre-fetchable or Non-prefetchable memory - @return memory offset -**/ -uint32_t -pal_pcie_mem_get_offset(uint32_t bdf, PCIE_MEM_TYPE_INFO_e mem_type) -{ - - return 0; -} - -/** - @brief Reads 32-bit data from BAR space pointed by Bus, - Device, Function and register offset. - - @param Bdf - BDF value for the device - @param address - BAR memory address - @param *data - 32 bit value at BAR address - @return success/failure -**/ -uint32_t -pal_pcie_bar_mem_read(uint32_t Bdf, uint64_t address, uint32_t *data) -{ - *data = pal_mmio_read(address); - return 0; -} - -/** - @brief Write 32-bit data to BAR space pointed by Bus, - Device, Function and register offset. - - @param Bdf - BDF value for the device - @param address - BAR memory address - @param data - 32 bit value to writw BAR address - @return success/failure -**/ -uint32_t -pal_pcie_bar_mem_write(uint32_t Bdf, uint64_t address, uint32_t data) -{ - pal_mmio_write(address, data); - return 0; -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie_enumeration.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie_enumeration.c deleted file mode 100644 index da5e175..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pcie_enumeration.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2018, 2022 Arm Limited - * - * Author: Prasanth Pulla - * - */ - -#include -#include - -#include "include/sbsa_pcie_enum.h" -#include "include/pal_linux.h" - - -/** - @brief Returns the Bus, Dev, Function (in the form seg<<24 | bus<<16 | Dev <<8 | func) - for a matching class code. - - @param ClassCode - is a 32bit value of format ClassCode << 16 | sub_class_code - @param StartBdf - is 0 : start enumeration from Host bridge - is not 0 : start enumeration from the input segment, bus, dev - this is needed as multiple controllers with same class code are - potentially present in a system. - @return the BDF of the device matching the class code -**/ -struct pci_dev * -pal_pci_get_dev(unsigned int class_code, struct pci_dev *dev) -{ - - return pci_get_class(class_code, dev); -} - -/** - @brief Returns next PCI device - - @param from_dev previous PCI device or NULL - - @return Next PCI device or NULL -**/ -struct pci_dev * -pal_pci_get_dev_next (struct pci_dev *from_dev) -{ - - return pci_get_device (PCI_ANY_ID, PCI_ANY_ID, from_dev); -} - -/** - @brief This API returns the Base Address Register value for a given BDF and index - @param bdf - the device whose PCI Config space BAR needs to be returned. - @param bar_index - the '0' based BAR index identifying the correct 64-bit BAR - - @return the 64-bit BAR value -*/ -unsigned long -pal_pcie_get_base(struct pci_dev *dev, unsigned int bar_index) -{ - - return dev->resource[bar_index].start; -} - -unsigned int -pal_pcie_get_bdf(struct pci_dev *dev) -{ - - return (PCIE_CREATE_BDF(pci_domain_nr(dev->bus), dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn))); -} - -unsigned int -pal_pcie_get_bdf_wrapper(unsigned int class_code, unsigned int bdf) -{ - uint32_t seg; - uint32_t bus; - uint32_t dev; - uint32_t fn; - struct pci_dev *pdev; - - pdev = NULL; - if (bdf) { - seg = PCIE_EXTRACT_BDF_SEG (bdf); - bus = PCIE_EXTRACT_BDF_BUS(bdf); - dev = PCIE_EXTRACT_BDF_DEV(bdf); - fn = PCIE_EXTRACT_BDF_FUNC(bdf); - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - } - - pdev = pal_pci_get_dev(class_code, pdev); - return pal_pcie_get_bdf(pdev); -} - -void * -pal_pci_bdf_to_dev(unsigned int bdf) -{ - uint32_t seg; - uint32_t bus; - uint32_t dev; - uint32_t fn; - struct pci_dev *pdev; - - seg = PCIE_EXTRACT_BDF_SEG (bdf); - bus = PCIE_EXTRACT_BDF_BUS(bdf); - dev = PCIE_EXTRACT_BDF_DEV(bdf); - fn = PCIE_EXTRACT_BDF_FUNC(bdf); - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - - if (pdev) - return ((void *)(&pdev->dev)); - - return NULL; -} - -void pal_pci_read_config_byte(uint32_t bdf, uint8_t offset, uint8_t *val) -{ - uint32_t seg; - uint32_t bus; - uint32_t dev; - uint32_t fn; - struct pci_dev *pdev; - - seg = PCIE_EXTRACT_BDF_SEG (bdf); - bus = PCIE_EXTRACT_BDF_BUS(bdf); - dev = PCIE_EXTRACT_BDF_DEV(bdf); - fn = PCIE_EXTRACT_BDF_FUNC(bdf); - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - - pci_read_config_byte(pdev, offset, val); -} - -void pal_pci_write_config_byte(uint32_t bdf, uint8_t offset, uint8_t val) -{ - uint32_t seg; - uint32_t bus; - uint32_t dev; - uint32_t fn; - struct pci_dev *pdev; - - seg = PCIE_EXTRACT_BDF_SEG (bdf); - bus = PCIE_EXTRACT_BDF_BUS(bdf); - dev = PCIE_EXTRACT_BDF_DEV(bdf); - fn = PCIE_EXTRACT_BDF_FUNC(bdf); - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - - pci_write_config_byte(pdev, offset, val); -} - -/** - @brief This API is checks if the bdf obtained - is valid or not - - @param bdf - @return 0 if bdf is valid else 1 -**/ - -unsigned int -pal_pcie_check_device_valid(unsigned int bdf) -{ - uint32_t seg; - uint32_t bus; - uint32_t dev; - uint32_t fn; - struct pci_dev *pdev; - - seg = PCIE_EXTRACT_BDF_SEG (bdf); - bus = PCIE_EXTRACT_BDF_BUS(bdf); - dev = PCIE_EXTRACT_BDF_DEV(bdf); - fn = PCIE_EXTRACT_BDF_FUNC(bdf); - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - - if (pdev) - return 0; - - return 1; - -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pe.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pe.c deleted file mode 100644 index de3d8c7..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_pe.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2018, 2021, 2023, Arm Limited - * - * Author: Prasanth Pulla - * - */ - -#include "include/pal_linux.h" -#include -#include -#include -#include -#include - -/** - @brief This API fills in the PE_INFO Table with information about the PEs in the - system. This is achieved by parsing the ACPI - MADT table. - - @param PeTable - Address where the PE information needs to be filled. - - @return None -**/ -void -pal_pe_create_info_table(PE_INFO_TABLE *PeTable) -{ - unsigned int length=0, table_length=0; - PE_INFO_ENTRY *ptr; - struct acpi_table_madt *madt; - struct acpi_madt_generic_interrupt *entry; - - /* initialise number of PEs to zero */ - PeTable->header.num_of_pe = 0; - - madt = (struct acpi_table_madt *)pal_get_madt_ptr(); - - if (!madt) { - pr_err("Can't parse PE info MADT table not found."); - return; - } - - table_length = madt->header.length; - length = sizeof(struct acpi_table_madt); - entry = (struct acpi_madt_generic_interrupt *) &madt[1]; - ptr = PeTable->pe_info; - - do { - if (entry->header.type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { - ptr->mpidr = entry->arm_mpidr; - ptr->pe_num = PeTable->header.num_of_pe; - ptr->pmu_gsiv = entry->performance_interrupt; - pr_info("MPIDR %llx PE num %x \n", ptr->mpidr, ptr->pe_num); - ptr++; - PeTable->header.num_of_pe++; - } - length += entry->header.length; - entry = (struct acpi_madt_generic_interrupt *) ((u8 *)entry + (entry->header.length)); - - } while(length < table_length); -} - -/** - @brief Install Exception Handler using UEFI CPU Architecture protocol's - Register Interrupt Handler API - - @param ExceptionType - AARCH64 Exception type - @param esr - Function pointer of the exception handler - - @return status of the API -**/ -unsigned int -pal_pe_install_esr(unsigned int ExceptionType, void (*esr)(unsigned long long, void *)) -{ - - return 1; -} - -void -pal_pe_increment_elr(unsigned long long offset) -{ -} - -void -pal_pe_data_cache_ops_by_va(unsigned long long addr, unsigned type) -{ -} - -/** - @brief Make the SMC call using AARCH64 Assembly code - - @param Argumets to pass to the EL3 firmware - - @return None -**/ -void -pal_pe_call_smc(ARM_SMC_ARGS *ArmSmcArgs, int32_t conduit) -{ -} - - -/** - @brief Make a PSCI CPU_ON call using SMC instruction. - Pass PAL Assembly code entry as the start vector for the PSCI ON call - - @param Argumets to pass to the EL3 firmware - - @return None -**/ -void -pal_pe_execute_payload(ARM_SMC_ARGS *ArmSmcArgs) -{ -} - -void -pal_pe_update_elr(void *context, unsigned long long offset) -{ -} - -unsigned long long -pal_pe_get_far(void *context) -{ - return 0; -} - -unsigned long long -pal_pe_get_esr(void *context) -{ - return 0; -} - -int32_t -pal_psci_get_conduit (void) -{ - return 0; -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_peripherals.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_peripherals.c deleted file mode 100644 index cfb9bb9..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_peripherals.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2018, 2020, 2022 Arm Limited - * - * Author: Prasanth Pulla - * - */ - -#include -#include -#include -#include - -#include "include/pal_linux.h" -#include "include/sbsa_pcie_enum.h" -//#include "include/platform_override.h" - -#define USB_CLASSCODE 0x0C0330 -#define SATA_CLASSCODE 0x010601 -#define BAR0 0 -#define BAR1 1 -#define BAR2 2 -#define BAR3 3 -#define BAR4 4 -#define BAR5 5 - -void -pal_peripheral_create_dma_table(void); - -void -pal_peripheral_create_info_table(PERIPHERAL_INFO_TABLE *peripheralInfoTable) -{ - - struct pci_dev *pdev = NULL; - int max_pasids; - PERIPHERAL_INFO_BLOCK *per_info; - - per_info = peripheralInfoTable->info; - - peripheralInfoTable->header.num_usb = 0; - peripheralInfoTable->header.num_sata = 0; - peripheralInfoTable->header.num_uart = 0; - peripheralInfoTable->header.num_all = 0; - - /* Collect all PCI devices */ - do { - pdev = pal_pci_get_dev_next (pdev); - if (pdev != NULL) { - per_info->base0 = pal_pcie_get_base (pdev, BAR0); - per_info->bdf = pal_pcie_get_bdf (pdev); - per_info->msi = pdev->msi_enabled; - per_info->msix = pdev->msix_enabled; - if (per_info->msi || per_info->msix) - per_info->flags = PER_FLAG_MSI_ENABLED; - else - per_info->flags = 0; - per_info->irq = pci_irq_vector(pdev, 0); - max_pasids = pci_max_pasids(pdev); - per_info->max_pasids = (max_pasids < 0)?0:max_pasids; - peripheralInfoTable->header.num_all++; - - switch (pdev->class) { - /* check for any XHCI - USB Controllers */ - case USB_CLASSCODE: - per_info->type = PERIPHERAL_TYPE_USB; - sbsa_print(AVS_PRINT_INFO, "Found a USB controller %4x \n", per_info->bdf); - peripheralInfoTable->header.num_usb++; - break; - /* check for any AHCI - SATA Controllers */ - case SATA_CLASSCODE: - per_info->type = PERIPHERAL_TYPE_SATA; - sbsa_print(AVS_PRINT_INFO, "Found a SATA controller %4x \n", per_info->bdf); - per_info->base1 = pal_pcie_get_base (pdev, BAR5); - peripheralInfoTable->header.num_sata++; - break; - default: - per_info->type = PERIPHERAL_TYPE_OTHER; - break; - } - per_info++; - } - } while (pdev != NULL); - - per_info->type = 0xFF; //indicate end of table - -} - -/** - @brief Check if PCI device is PCI Express capable - - @param seg PCI segment number - @param bus PCI bus address - @param dev PCI device address - @param fn PCI function number - - @return staus code: - 1: PCIe capable, 0: No PCIe capable -**/ -uint32_t pal_peripheral_is_pcie(uint32_t seg, uint32_t bus, uint32_t dev, uint32_t fn) -{ - struct pci_dev *pdev; - - pdev = pci_get_domain_bus_and_slot(seg, bus, PCI_DEVFN(dev, fn)); - if (pdev == NULL) - return 0; - - if (pci_is_pcie(pdev)) - return 1; - else - return 0; -} - -unsigned long long -pal_memory_ioremap(void *addr, uint32_t size, uint32_t attr) -{ - switch(attr) { - case DEVICE_nGnRnE: - return ((unsigned long long)pci_remap_cfgspace((phys_addr_t)addr, size)); - break; - case DEVICE_nGnRE: - return ((unsigned long long)ioremap((phys_addr_t)addr, size)); - break; - case DEVICE_nGRE: - return ((unsigned long long)ioremap((phys_addr_t)addr, size)); - break; - case DEVICE_GRE: - return ((unsigned long long)ioremap((phys_addr_t)addr, size)); - break; - case NORMAL_NC: - return ((unsigned long long)ioremap_wc((phys_addr_t)addr, size)); - break; - case NORMAL_WT: - return ((unsigned long long)ioremap_wt((phys_addr_t)addr, size)); - break; - default: - return ((unsigned long long)ioremap_wc((phys_addr_t)addr, size)); - } - -} - -void -pal_memory_unmap(void *addr) -{ - - iounmap((char *)addr); -} - -/** - @brief Placeholder for Returning the address of unpopulated - memory of requested instance. - -**/ -unsigned long long -pal_memory_get_unpopulated_addr(unsigned long long *addr, uint32_t instance) -{ - return 0; -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_smmu.c b/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_smmu.c deleted file mode 100644 index ed0004c..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/files/src/pal_smmu.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * SBSA ACS Platform module. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Copyright (C) 2016-2019, 2021 Arm Limited - * - * Author: Prasanth Pulla - * - */ - -#include -#include -#include -#include -#include - -#include "include/pal_linux.h" - -#define SMMU_V3_IDR1 0x4 -#define SMMU_V3_IDR1_PASID_SHIFT 6 -#define SMMU_V3_IDR1_PASID_MASK 0x1f - -int pal_smmu_check_dev_attach(struct device *dev) -{ - if (!dev) - return 0; - return (iommu_get_domain_for_dev(dev) == NULL) ? 0 : 1; -} - -void -pal_smmu_device_start_monitor_iova(void *port) -{ - if (!pal_smmu_check_dev_attach(((struct ata_port *)port)->dev)) { - sbsa_print(AVS_PRINT_WARN, "\n This device is not behind an SMMU ", 0); - return; - } - - bsa_iommu_dev_start_monitor(((struct ata_port *)port)->dev); -} - -void -pal_smmu_device_stop_monitor_iova(void *port) -{ - if (!pal_smmu_check_dev_attach(((struct ata_port *)port)->dev)) { - sbsa_print(AVS_PRINT_WARN, "\n This device is not behind an SMMU ", 0); - return; - } - bsa_iommu_dev_stop_monitor(((struct ata_port *)port)->dev); -} - -/** - @brief This API checks if the input DMA address is part of the Device IOVA address table. - 1. Caller - Validation Abstraction Layer. - 2. Prerequisite - pal_smmu_device_start_monitor_iova - @param port - Device port whose domain IOVA table is checked - @param dma_addr - DMA address which is checked - @return status - SUCCESS if the input address is part of the IOVA range. -**/ -unsigned int -pal_smmu_check_device_iova(void *port, unsigned long long dma_addr) -{ - void *curr_node = NULL; - unsigned int index = 0; - unsigned long long base; - unsigned long int size; - phys_addr_t phys; - - if (!pal_smmu_check_dev_attach(((struct ata_port *)port)->dev)) { - sbsa_print(AVS_PRINT_WARN, "\n This device is not behind an SMMU ", 0); - return PAL_LINUX_SKIP; - } - - /* Check if this address was used in the last few transactions of the IOMMU layer */ - - do { - size = bsa_iommu_iova_get_addr(index, &base); - if (size) { - if ((dma_addr >= base) && (dma_addr < (base + size))) { - return PAL_LINUX_SUCCESS; - } - index++; - } - }while(size); - - /* Did not find it above - Check the active IOVA table entries now */ - do { - curr_node = bsa_iommu_dma_get_iova(((struct ata_port *)port)->dev, &base, &size, &phys, curr_node); - if (curr_node) { - pr_info("Device IOVA entry is %llx size = %lx phys = %llx \n", base, size, phys); - if ((dma_addr >= base) && (dma_addr < (base + size))) { - return PAL_LINUX_SUCCESS; - } - } - } while(curr_node); - - - return PAL_LINUX_ERR; -} - -uint32_t -pal_smmu_max_pasids(uint64_t smmu_base) -{ - uint32_t reg = pal_mmio_read(smmu_base + SMMU_V3_IDR1); - uint32_t pasid_bits = reg >> SMMU_V3_IDR1_PASID_SHIFT & SMMU_V3_IDR1_PASID_MASK; - if(pasid_bits == 0) - return 0; - return (1 << pasid_bits); -} - -uint32_t -pal_smmu_create_pasid_entry(uint64_t smmu_base, uint32_t pasid) -{ - return 0; -} - -uint32_t -pal_smmu_disable(uint64_t smmu_base) -{ - return 0; -} - -uint64_t -pal_smmu_pa2iova(uint64_t smmu_base, uint64_t pa) -{ - return 0; -} diff --git a/sbsa-acs-drv/files/platform/pal_linux/sbsa-acs-pal.bb b/sbsa-acs-drv/files/platform/pal_linux/sbsa-acs-pal.bb deleted file mode 100644 index c40c298..0000000 --- a/sbsa-acs-drv/files/platform/pal_linux/sbsa-acs-pal.bb +++ /dev/null @@ -1,20 +0,0 @@ - -SUMMARY = "Compiles sbsa pal" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e" - -inherit module - -SRC_URI = " file://Makefile \ - file://include/ \ - file://src/ \ - file://val/include/pal_interface.h \ - file://COPYING \ - " -S = "${WORKDIR}" - - -do_install_append () { - cp "${S}"/sbsa_acs_pal.o ${DEPLOY_DIR_IMAGE}/ -} - diff --git a/sbsa-acs-drv/files/setup.sh b/sbsa-acs-drv/files/setup.sh deleted file mode 100755 index 980fb42..0000000 --- a/sbsa-acs-drv/files/setup.sh +++ /dev/null @@ -1,17 +0,0 @@ - -echo "==================================================================" -echo "This script will copy the necessary files for Kernel module build " -echo "to the present directory" -echo "==================================================================" - -if [ $# -ne 1 ]; -then - echo "Give AVS_PATH as the arguments to the script" - return 0 -fi - -export AVS_PATH=$1 -echo -e "AVS_PATH is set to -> \e[93m $AVS_PATH\e[0m" - -cp -r $AVS_PATH/val . -cp -r $AVS_PATH/test_pool . diff --git a/sbsa-acs-drv/sbsa-acs-drv.bb b/sbsa-acs-drv/sbsa-acs-drv.bb deleted file mode 100644 index 3d1ffe4..0000000 --- a/sbsa-acs-drv/sbsa-acs-drv.bb +++ /dev/null @@ -1,31 +0,0 @@ -SUMMARY = "Compiles driver. This depends on pal and val compilation" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e" - -inherit module - -do_configure[depends] += "sbsa-acs-pal:do_install \ - sbsa-acs-val:do_install \ - sbsa-acs-test:do_install " - -SRC_URI = " file://Makefile \ - file://sbsa_acs_drv.c \ - file://sbsa_acs_drv.h \ - file://val/include \ - file://COPYING \ - " -S = "${WORKDIR}" - -do_configure_append () { - cp ${DEPLOY_DIR_IMAGE}/sbsa_acs_pal.o ${S} - cp ${DEPLOY_DIR_IMAGE}/sbsa_acs_val.o ${S} - cp ${DEPLOY_DIR_IMAGE}/sbsa_acs_test.o ${S} -} - -do_install_append () { - rm ${DEPLOY_DIR_IMAGE}/sbsa_acs_pal.o - rm ${DEPLOY_DIR_IMAGE}/sbsa_acs_val.o - rm ${DEPLOY_DIR_IMAGE}/sbsa_acs_test.o -} -# The inherit of module.bbclass will automatically name module packages with -# "kernel-module-" prefix as required by the oe-core build environment. -- GitLab