diff --git a/Makefile b/Makefile index e1b494cffedddd38aa773aa0cc45ccae196c45be..765000ee0f12f412fb5563a2b30dbaf277a3b569 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ #/** @file -# * Copyright (c) 2019-2021 Arm Limited or its affiliates. All rights reserved. +# * Copyright (c) 2019-2023 Arm Limited or its affiliates. All rights reserved. # * SPDX-License-Identifier : Apache-2.0 # * # * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,6 +26,8 @@ MOCKER=mocker LINUX=linux SGM776=sgm776 TC=tc +JUNO=juno +GENERIC_SCMI=generic_scmi COMMON=common #Set PLATFORM @@ -48,8 +50,12 @@ ifeq ($(PLAT),$(LINUX)) PLAT_DIR=$(DIR)/$(SGM776) $(DIR)/$(COMMON) else ifeq ($(TARGET),$(TC)) PLAT_DIR=$(DIR)/$(TC) $(DIR)/$(COMMON) + else ifeq ($(TARGET),$(JUNO)) + PLAT_DIR=$(DIR)/$(JUNO) $(DIR)/$(COMMON) + else ifeq ($(TARGET),$(GENERIC_SCMI)) + PLAT_DIR=$(DIR)/$(GENERIC_SCMI) $(DIR)/$(COMMON) else - $(error TARGET $(TARGET) is invalid. Provide valid TARGET value (sgm776 or tc) as TARGET=tc or TARGET=sgm776) + $(error TARGET $(TARGET) is invalid. Provide valid TARGET value) endif TARGET_UPPER=$(shell echo $(TARGET) | tr '[:lower:]' '[:upper:]') endif @@ -71,6 +77,8 @@ DIRS+=$(PLAT_DIR)/$(PLAT) endif BUILD_ALL=$(DIRS) +export TRANS=mailbox + # Name for directory within each subdir that contains its header files export HEADER_DIR=include diff --git a/docs/guide_linux_testing.md b/docs/guide_linux_testing.md index 53946f7ad1df631fe9353c7381061c3d860f14e1..7e0c86770ab87955e7a723ea6debea22130e10dc 100644 --- a/docs/guide_linux_testing.md +++ b/docs/guide_linux_testing.md @@ -9,11 +9,12 @@ Table of Contents: * [Mailbox test driver](#mailbox-test-driver) * [Doorbell support patches for mailbox](#doorbell-support-patches-for-mailbox) * [Additional changes to enable mailbox test driver](#additional-changes-to-enable-mailbox-test-driver) + * [SCMI Raw mode support](#scmi-raw-driver) - [Kernel build](#kernel-build) Introduction ------- -This document lists the instructions that must be followed to run SCMI ACS as Linux application using the mailbox test driver interface on SGM/TC target. +This document lists the instructions that must be followed to run SCMI ACS as Linux application using one of the available test interfaces on any of the available targets. For an introduction to the System Guidance for Mobile (SGM) platforms, please refer to the [Arm Developer documentation]. Software Stack @@ -22,7 +23,13 @@ Arm provides a [super-project] with guides for building and running a full softw Linux kernel ------- -The following changes must be made in the Linux kernel source code after downloading the software stack for SGM/TC. +There are two main ways in which the SCMI ACS, running as a Linux application, can inject and snoop SCMI traffic back and forth from the SCMI backend server that is intended to be tested. + +A test interface based on the Mailbox test driver was provided at first: this setup assumes that the SCMI backend server under test is placed in a setup where the communication channel is based on mailboxes and you'll need a properly configured Mailbox test driver as detailed below. + +Alternatively, on more recent kernels, the standard SCMI stack can be configured to expose on debugfs a few entries can be used to inject and snoop bare SCMI raw messages; this way the traffic going back and forth will use whatever underlying transport is currently configured on the system: as a consequence it is possible to verify the compliance of the SCMI server under test no matter where it is placed and which transport medium eploys. + +The following alternative changes must be made in the Linux kernel source code after downloading the software stack for SGM/TC. ### Mailbox test driver To use SCMI test agent on SGM/TC target, the Linux kernel must be rebuilt to include the mailbox test driver with mailbox doorbell support and additional changes. Doorbell support patches for mailbox, and additional changes to enable mailbox test driver are tested against Linux kernel version 4.13. @@ -58,6 +65,44 @@ waitq_err: ``` The current change in mailbox test driver is not an ideal solution. A better solution is to use sysfs entry for configurability. This enhancement will be upstreamed in the future, thereby making this change redundant. +### SCMI Raw mode support +Alternatively, on supported Kernels, it is possible to configure the SCMI test agent on any target to use the Kernel SCMI Raw access mode; in such a case the Kernel must be rebuild enabling CONFIG_ARM_SCMI_RAW_MODE_SUPPORT=y and the SCMI ACS suite itself must be rebuild specifying TRANS=raw on the make command line, like in: + +> `make PLAT=linux TRANS=raw TARGET=sgm776 PROTOCOLS=base,clock,power_domain,performance,system_power,sensor,voltage,reset VERBOSE=1` + +If TRANS= is not specified the usual Mailbox driver backend is instead compiled into the SCMI ACS suite. + +No device tree change is needed in this case. + +The SCMI ACS then starts injecting/snooping SCMI messages via the following debugfs API entries, as exposed by the Kernel OSPM Agent running in Raw mode: + +``` + /sys/kernel/debug/scmi/ + `-- 0 + |-- atomic_threshold_us + |-- instance_name + |-- raw + | |-- channels + | | |-- 0x10 + | | | |-- message + | | | `-- message_async + | | `-- 0x13 + | | |-- message + | | `-- message_async + | |-- errors + | |-- message + | |-- message_async + | |-- notification + | `-- reset + `-- transport + |-- is_atomic + |-- max_msg_size + |-- max_rx_timeout_ms + |-- rx_max_msg + |-- tx_max_msg + `-- type +``` + ## Kernel build Build the kernel and device tree after making the changes and use the run-scripts for running the SGM/TC @@ -65,7 +110,7 @@ For instructions to build the test suite for Linux platform and running it, see - - - - - - - - - - - - - - - - -_Copyright (c) 2019-2020, Arm Limited and Contributors. All rights reserved._ +_Copyright (c) 2019-2023, Arm Limited and Contributors. All rights reserved._ [ARM Developer documentation]: https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms [Mailbox doorbell support patches]: https://lkml.org/lkml/2017/5/24/339 diff --git a/docs/user_guide.md b/docs/user_guide.md index 159c07b716a76c5bf7b096def1ec2892c2230ef0..a8c5456538ff8f34021226089141b75d60a72337 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -104,8 +104,19 @@ The output will be libscmi_test.a and scmi_test_agent for the Linux platform in The scmi_test_agent app supports the command-line option '-r' to optionally enable relaxed protocol versioning checks: when enabled the relevant testcases are run even if the SCMI Server under test advertised to implement a greater protocol version (i.e. newer) than the one officially supported by the current test-suite for that test-case and, in such a case, the protocol version mismatch is logged. This behaviour could possibly lead to false positives if the newer protocol version specification introduced some non-backward compatible change: for this reason the relaxed checks are off by default andhave to be explicitly enabled using the '-r' switch. +Instead of using the mailbox test driver, alternatively, the SCMI test suite can be build to make use of the Kernel SCMI Raw access interface by specifying TRANS=raw on the make commandline: + +>`make PLAT=linux TRANS=raw TARGET=sgm776 PROTOCOLS=base,clock,power_domain,performance,system_power,sensor,reset VERBOSE=1` + **NOTE**: -* You must rebuild the Linux kernel and device trees for LINUX by following the [Guide to test SCMI on LINUX]. +* In both cases you must rebuild the Linux kernel (and the device tree in the mailbox test driver case) for LINUX by following the [Guide to test SCMI on LINUX]. + +##### 2.2.1 OSPM Agent Generic SCMI target support - EXPERIMENTAL +Additionally, it is possible to alternatively built the SCMI test suite to run against a generic SCMI implementation specifying TARGET=generic_scmi as in: + +make PLAT=linux TARGET=generic_scmi PROTOCOLS=base,clock,power_domain,performance,system_power,sensor,reset,voltage VERBOSE=1 + +Such generic target relaxes its expectations about number and name of agents, resources and protocols expected to be found on the system: in other words it tries to test whatever protocol and resource it could find during the initial BASE discovery phase without enforcing any specific assumption like with SGM/TX targets. #### 2.3 Baremetal @@ -138,6 +149,18 @@ To run the test suite on the Linux platform, execute the following command in th The test logs are captured in a report file arm\_scmi\_test\_log.txt in the same directory as the executable. +#### OSPM test agent command-line options + +A few command-line option can be provided when running the test suite in the Linux platform. + +>`Usage: ./scmi_test_agent [-r][-p ]` + +where: +``` + -r: relax protocol version checking. Tests will be run even if the supported SCMI protocol version, + as advertised by the platform, is newer than the version supported by the testcase. + -p : provide a different SCMI debugfs root path. Default is: /sys/kernel/debug/scmi/0/ +``` ### Running in Baremetal environment To run the test suite on the baremetal environment, invoke to `arm_scmi_agent_execute()` from test framework. For more details, refer to [Validation Methodology Document]. @@ -220,7 +243,7 @@ Each individual check delivers a PASS, FAIL, or SKIPPED. - - - - - - - - - - - - - - - - - -_Copyright (c) 2019-2020, Arm Limited and Contributors. All rights reserved._ +_Copyright (c) 2019-2023, Arm Limited and Contributors. All rights reserved._ [Linaro Release]: https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/ [Validation Methodology Document]: ./Arm_SCMI_Validation_Methodology.pdf "SCMI Test Suite Design" diff --git a/linux_app/app.c b/linux_app/app.c index 0d1b9dbacb7ae5012f45606b5eda9acbcfb3b15d..b367850520ff88fcd665d614b0c8bbbeeebbd1c9 100644 --- a/linux_app/app.c +++ b/linux_app/app.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,26 +34,32 @@ int main(int argc, char *argv[]) uint32_t num_pass; uint32_t num_fail; uint32_t num_skip; + char *scmi_raw_root_path = NULL; - while ((opt = getopt(argc, argv, "r")) != -1) { + while ((opt = getopt(argc, argv, "rp:")) != -1) { switch (opt) { case 'r': relaxed_version_checks = true; break; + case 'p': + scmi_raw_root_path = optarg; + break; default: /* '?' */ - fprintf(stderr, "Usage: %s [-r]\n", + fprintf(stderr, "Usage: %s [-r][-p ]\n", argv[0]); exit(EXIT_FAILURE); } } val_print(VAL_PRINT_ERR, "\n\n **** SCMI Compliance Suite **** "); - - if (val_initialize_system((void *) NULL)) { + if (val_initialize_system(scmi_raw_root_path)) { val_print(VAL_PRINT_ERR, "\n **** INIT FAILED ***"); return 0; } + val_print(VAL_PRINT_INFO, "\n Using *%s* SCMI protocol version checking", + relaxed_version_checks ? "relaxed" : "strict"); + val_print(VAL_PRINT_ERR, "\n\n *** Starting BASE tests ***"); val_base_execute_tests(); diff --git a/platform/baremetal/pal_platform.c b/platform/baremetal/pal_platform.c index 9ec4b56f25a6019f0e026bc9797ef0ca11e806c9..e28f103e745d0e8c144a0a1b90b82af610a2db60 100644 --- a/platform/baremetal/pal_platform.c +++ b/platform/baremetal/pal_platform.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -87,6 +87,26 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, message_header_rcv, status, return_values_count, return_values); } +/** + @brief This API is used to call platform function to send command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + arm_scmi_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, return_values); +} + + /** @brief This API is used to receive delayed response @param message header received diff --git a/platform/linux/common/Makefile b/platform/linux/common/Makefile index b436bda2fa533f3a504e063f7900f38857952244..531b6cf420a6da74fc1cb99867c7ba4b2de869f2 100644 --- a/platform/linux/common/Makefile +++ b/platform/linux/common/Makefile @@ -1,5 +1,5 @@ #/** @file -# * Copyright (c) 2021 Arm Limited or its affiliates. All rights reserved. +# * Copyright (c) 2021-2023 Arm Limited or its affiliates. All rights reserved. # * SPDX-License-Identifier : Apache-2.0 # * # * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,4 +15,24 @@ # * limitations under the License. #**/ -include ${TOP}/platform/build_platform.mk +H_FILES := $(wildcard $(HEADER_DIR)/*.h) +OBJS := $(PLATFORM_OBJ_DIR)/transport_${TRANS}.o $(PLATFORM_OBJ_DIR)/common.o + +all: all_platform + +all_platform: $(OBJS) + @echo "### Finished building with makefile at `pwd` ###" + +$(PLATFORM_OBJ_DIR)/transport_${TRANS}.o: transport_${TRANS}.c $(H_FILES) + @echo "$(CC) $(D_NAMES) $(CFLAGS) $(I_DIRS) -c $< -o $@" + $(CC) $(D_NAMES) $(CFLAGS) $(I_DIRS) -g -c $< -o $@ + +$(PLATFORM_OBJ_DIR)/common.o: common.c $(H_FILES) + @echo "$(CC) $(D_NAMES) $(CFLAGS) $(I_DIRS) -c $< -o $@" + $(CC) $(D_NAMES) $(CFLAGS) $(I_DIRS) -g -c $< -o $@ + +clean: clean_platform + +clean_platform: + +.PHONY: clean diff --git a/platform/linux/common/transport_mailbox.c b/platform/linux/common/transport_mailbox.c index 80d18ae29aeb6811afe1508a7b8a2a9438fc9ee7..8ade155afc1577d53589f34b3f1ef404e8aaa395 100644 --- a/platform/linux/common/transport_mailbox.c +++ b/platform/linux/common/transport_mailbox.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2019-2021 Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2019-2023 Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,14 +34,14 @@ #define NO_ERROR 0 #define ERROR 5 -#ifdef TARGET_TC +#if defined TARGET_TC #define MB_SIGNAL_FILE "/sys/kernel/debug/6000000.mailbox-test/signal" #define MB_MESSAGE_FILE "/sys/kernel/debug/6000000.mailbox-test/message" -#endif - -#ifdef TARGET_SGM776 +#elif defined TARGET_SGM776 #define MB_SIGNAL_FILE "/sys/kernel/debug/mailbox/signal" #define MB_MESSAGE_FILE "/sys/kernel/debug/mailbox/message" +#else + #error "TARGET unsupported with mailbox transport !" #endif /* mailbox memory byte offset mapping */ @@ -64,6 +64,14 @@ enum { MB_LENGTH_MESSAGE_HEADER = 0x4 } mailbox_byte_length; +/*! + * @brief Interface function that performs any needed Linux initialization. + */ +uint32_t linux_initialize_system(void *info) +{ + return NO_ERROR; +} + /*! * @brief Interface function that sends a * command to mailbox driver interfaces and receives a platform @@ -185,6 +193,22 @@ int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, return NO_ERROR; } +/*! + * @brief Interface function that sends an asynchronous + * command to mailbox driver interfaces and receives the platform + * immediate reply message. Delayed response is collected with a dedicated function. + * + * Same behaviour as synchronous command for mailbox transport really. + */ + int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + return linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + /*! * @brief Interface function that waits for * delayed response. diff --git a/platform/linux/common/transport_raw.c b/platform/linux/common/transport_raw.c new file mode 100644 index 0000000000000000000000000000000000000000..24f4ea631d9706a6a3dedff99cf4ea8db5754eec --- /dev/null +++ b/platform/linux/common/transport_raw.c @@ -0,0 +1,431 @@ +/** @file + * Copyright (c) 2023 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. + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "val_interface.h" + +#define NO_ERROR 0 +#define ERROR 5 + +#define TRANS_DEFAULT_BASE_PATH "/sys/kernel/debug/scmi/0" + +#define TRANS_MAX_MSG_SZ_FILE "transport/max_msg_size" +#define TRANS_RX_TMO_MS "transport/max_rx_timeout_ms" + +#define TRANS_RAW_RESET_FILE "raw/reset" +#define TRANS_MESSAGE_FILE "raw/message" +#define TRANS_MESSAGE_ASYNC_FILE "raw/message_async" +#define TRANS_NOTIF_FILE "raw/notification" +#define TRANS_ERROR_FILE "raw/errors" + +#define MAX_BUF 32 +#define MESSAGE_PAYLOAD_START 4 + +struct linux_scmi_raw_config { + int fd_base; + int fd_reset; + unsigned long max_msg_size; + unsigned long rx_timeout_ms; + void *buffer; +}; + +static struct linux_scmi_raw_config *rawc; + +static int linux_read_integer_from_file(int fd_base, char *filepath, + unsigned long *val) +{ + int fd, count; + unsigned long value; + unsigned char buffer[MAX_BUF]; + + *val = 0; + fd = openat(fd_base, filepath, O_RDONLY | O_NONBLOCK); + if (fd < 0) + return ERROR; + + bzero(buffer, MAX_BUF); + /* read returned message into the buffer */ + count = read(fd, buffer, MAX_BUF); + if (count < 0) { + close(fd); + return ERROR; + } + + value = strtoul((const char *)buffer, NULL, 10); + if (value == ULONG_MAX) { + close(fd); + return ERROR; + } + + *val = value; + close(fd); + + return 0; +} + +static void scmi_raw_mode_cleanup(void) +{ + if (!rawc) + return; + + close(rawc->fd_reset); + close(rawc->fd_base); + + free(rawc->buffer); + free(rawc); +} + +static void term_handler(int sig) +{ + scmi_raw_mode_cleanup(); + + raise(sig); +} + +/*! + * @brief Interface function that performs any needed Linux initialization. + */ +uint32_t linux_initialize_system(void *info) +{ + int ret; + const char *base_path = TRANS_DEFAULT_BASE_PATH; + struct linux_scmi_raw_config *conf; + struct sigaction action; + + conf = malloc(sizeof(*conf)); + if (!conf) + return ERROR; + + memset(conf, 0, sizeof(*conf)); + + if (info) + base_path = (const char *)info; + val_print(VAL_PRINT_INFO, "\n Using SCMI kernel Raw transport rooted at:%s/raw", base_path); + + conf->fd_base = open(base_path, O_RDONLY | O_NONBLOCK); + if (conf->fd_base < 0) { + val_print(VAL_PRINT_ERR, "\n Failed to open:%s", base_path); + goto err_conf; + } + + ret = linux_read_integer_from_file(conf->fd_base, TRANS_RX_TMO_MS, + &conf->rx_timeout_ms); + if (ret) + goto err_fd_base; + + ret = linux_read_integer_from_file(conf->fd_base, TRANS_MAX_MSG_SZ_FILE, + &conf->max_msg_size); + if (ret) + goto err_fd_base; + + /* Add space for the SCMI message header */ + conf->max_msg_size += sizeof(uint32_t); + conf->buffer = malloc(conf->max_msg_size); + if (!conf->buffer) + goto err_fd_base; + + conf->fd_reset = openat(conf->fd_base, + TRANS_RAW_RESET_FILE, O_RDWR | O_SYNC); + if (conf->fd_reset < 0) + goto err_buffer; + + bzero(&action, sizeof(struct sigaction)); + action.sa_handler = term_handler; + action.sa_flags = SA_RESETHAND; + ret = sigaction(SIGINT, &action, 0); + if (ret) + goto err_fd_reset; + + /* Flush any pending SCMI messages on start...just in case */ + val_print(VAL_PRINT_INFO, "\n Resetting SCMI kernel Raw queues."); + write(conf->fd_reset, "Y\n", 3); + + rawc = conf; + atexit(scmi_raw_mode_cleanup); + + return NO_ERROR; + +err_fd_reset: + close(conf->fd_reset); +err_buffer: + free(conf->buffer); +err_fd_base: + close(conf->fd_base); +err_conf: + free(conf); + + return ERROR; +} + +static int32_t __linux_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values, const char *filepath) +{ + int fd_message; + uint32_t ret = 0; + struct pollfd pfd; + ssize_t count; + uint32_t counter; + uint8_t *buffer; + + buffer = rawc->buffer; + memset(buffer, 0x0, rawc->max_msg_size); + + for (counter = 0; counter < 4; ++counter) + buffer[counter] = (message_header_send >> (counter * 8)) & 0xFF; + + for (counter = 0; counter < (parameter_count * 4); counter += 4) { + uint32_t byte_shift; + + for (byte_shift = 0; byte_shift < 4; ++byte_shift) { + buffer[MESSAGE_PAYLOAD_START+counter+byte_shift] = + (parameters[counter/4] >> (byte_shift * 8)) & 0xFF; + } + } + + fd_message = openat(rawc->fd_base, filepath, O_RDWR | O_SYNC); + if (fd_message < 0) + return ERROR; + + write(fd_message, buffer, + sizeof(uint32_t) + parameter_count * sizeof(uint32_t)); + + /* polling */ + pfd.fd = fd_message; + pfd.events = POLLIN; + ret = poll(&pfd, 1, rawc->rx_timeout_ms + 1000); + if (ret <= 0) { + close(fd_message); + return ERROR; + } + + /* read returned message into the buffer */ + count = read(fd_message, buffer, rawc->max_msg_size); + if (count < 0) { + close(fd_message); + return ERROR;\ + } + + /* read the payload part */ + for (counter = 0; counter < count / 4; ++counter) { + if (counter == 0) { + // extract header + *message_header_rcv = *((uint32_t *)buffer + counter); + } + else if (counter == 1) { + // extract status + *status = *((uint32_t *)buffer + counter); + } + else { + // extract payload + // return_values starts from 0, hence subtract 2 here + return_values[(counter - 2)] = *((uint32_t *)buffer + counter); + (*return_values_count)++; + } + } + + close(fd_message); + + return NO_ERROR; +} + +/*! + * @brief Interface function that sends a + * command to SCMI raw message interfaces and receives a platform + * message. + */ +int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + return __linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values, TRANS_MESSAGE_FILE); +} + +/*! + * @brief Interface function that sends an asynchronous + * command to SCMI raw message interfaces and receives the platform + * immediate reply message. Delayed response is collected with a dedicated function. + */ +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + return __linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values, TRANS_MESSAGE_ASYNC_FILE); +} + +/*! + * @brief Interface function that waits for + * delayed response. + */ +int linux_wait_for_response(uint32_t *message_header_rcv, + int32_t *status, size_t *return_values_count, uint32_t *return_values, + bool *message_ready, uint32_t timeout) +{ + int fd_message; + uint32_t ret = 0; + uint8_t *buffer; + uint32_t counter; + struct pollfd pfd; + ssize_t count; + + buffer = rawc->buffer; + memset(buffer, 0x0, rawc->max_msg_size); + + fd_message = openat(rawc->fd_base, TRANS_MESSAGE_FILE, O_RDONLY | O_SYNC); + if (fd_message < 0) + return ERROR; + + /* polling */ + pfd.fd = fd_message; + pfd.events = POLLIN; + ret = poll(&pfd, 1, rawc->rx_timeout_ms + 1000); + if (ret <= 0) { + close(fd_message); + return ERROR; + } + + /* read returned message into the buffer */ + count = read(fd_message, buffer, rawc->max_msg_size); + if (count < 0) { + close(fd_message); + return ERROR; + } + + /* read the payload part */ + for (counter = 0; counter < count / 4; ++counter) { + if (counter == 0) { + // extract header + *message_header_rcv = *((uint32_t *)buffer + counter); + } + else if (counter == 1) { + // extract status + *status = *((uint32_t *)buffer + counter); + } + else { + // extract payload + // return_values starts from 0, hence subtract 2 here + return_values[(counter - 2)] = *((uint32_t *)buffer + counter); + (*return_values_count)++; + } + } + + close(fd_message); + + return NO_ERROR; +} + +/*! + * @brief Interface function that waits for + * notification. + */ +int linux_wait_for_notification(uint32_t *message_header_rcv, + size_t *return_values_count, uint32_t *return_values, + uint32_t timeout) +{ + int fd_message; + uint32_t ret = 0; + uint8_t *buffer; + uint32_t counter; + struct pollfd pfd; + ssize_t count; + + buffer = rawc->buffer; + memset(buffer, 0x0, rawc->max_msg_size); + + fd_message = openat(rawc->fd_base, TRANS_NOTIF_FILE, O_RDONLY | O_SYNC); + if (fd_message < 0) + return ERROR; + + /* polling */ + pfd.fd = fd_message; + pfd.events = POLLIN; + ret = poll(&pfd, 1, timeout * 30); + if (ret <= 0) { + close(fd_message); + return ERROR; + } + + /* read returned message into the buffer */ + count = read(fd_message, buffer, rawc->max_msg_size); + if (count < 0) { + close(fd_message); + return ERROR; + } + + /* read the payload part */ + for (counter = 0; counter < count / 4; ++counter) { + if (counter == 0) { + // extract header + // plus 1 to skip the Length + *message_header_rcv = *((uint32_t *)buffer + counter); + } + else { + // extract payload + return_values[(counter - 1)] = *((uint32_t *)buffer + counter); + (*return_values_count)++; + } + } + + close(fd_message); + + return NO_ERROR; +} + +/*! + * @brief Interface function that gets accessible device for given agent + */ +uint32_t linux_agent_get_accessible_device(uint32_t agent_id) +{ + return NO_ERROR; +} + +/*! + * @brief Interface function that gets inaccessible device for given agent + */ +uint32_t linux_agent_get_inaccessible_device(uint32_t agent_id) +{ + return NO_ERROR; +} + +/*! + * @brief Interface function that gets protocol which can access given device + */ +uint32_t linux_device_get_accessible_protocol(uint32_t device_id) +{ + return NO_ERROR; +} + + diff --git a/platform/linux/generic_scmi/Makefile b/platform/linux/generic_scmi/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..e1f163bffc510b5a8b5314462af5bbbed6b59e71 --- /dev/null +++ b/platform/linux/generic_scmi/Makefile @@ -0,0 +1,18 @@ +#/** @file +# * Copyright (c) 2023, 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. +#**/ + +include ${TOP}/platform/build_platform.mk diff --git a/platform/linux/generic_scmi/include/pal_base_expected.h b/platform/linux/generic_scmi/include/pal_base_expected.h new file mode 100644 index 0000000000000000000000000000000000000000..bbe71613f080a90681f3906b648bde8a47a01779 --- /dev/null +++ b/platform/linux/generic_scmi/include/pal_base_expected.h @@ -0,0 +1,25 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_BASE_EXPECTED_H__ +#define __PAL_BASE_EXPECTED_H__ + +#include + +#define UNTRUSTED 0 + +#endif /* __PAL_BASE_EXPECTED_H__ */ diff --git a/platform/linux/generic_scmi/include/pal_clock_expected.h b/platform/linux/generic_scmi/include/pal_clock_expected.h new file mode 100644 index 0000000000000000000000000000000000000000..92b92b465fa629837ba072d6a05e3f84ea99dba0 --- /dev/null +++ b/platform/linux/generic_scmi/include/pal_clock_expected.h @@ -0,0 +1,28 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_CLOCK_EXPECTED_H__ +#define __PAL_CLOCK_EXPECTED_H__ + +/* Expected CLOCK parameters */ +#ifdef CLOCK_PROTOCOL + +#define UNSUPPORTED 1 + +#endif + +#endif /* __PAL_CLOCK_EXPECTED_H__ */ diff --git a/platform/linux/generic_scmi/include/pal_platform.h b/platform/linux/generic_scmi/include/pal_platform.h new file mode 100644 index 0000000000000000000000000000000000000000..2f977c46d35c4828c8c3d5c51ff8a371f3c15777 --- /dev/null +++ b/platform/linux/generic_scmi/include/pal_platform.h @@ -0,0 +1,57 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_PLATFORM_H__ +#define __PAL_PLATFORM_H__ + +#include +#include +#include + +#define TIMEOUT 100 + +#define LOG_FILE "arm_scmi_test_log.txt" + +int linux_map_phys_to_virt(unsigned long paddr, size_t length, + unsigned long *vaddr); + +int linux_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, + size_t length); + +uint32_t linux_initialize_system(void *info); + +int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + +int linux_wait_for_notification(uint32_t *message_header_rcv, + size_t *return_values_count, uint32_t *return_values, + uint32_t timeout); + +int linux_wait_for_response(uint32_t *message_header_rcv, + int32_t *status, size_t *return_values_count, uint32_t *return_values, + bool *message_ready, uint32_t timeout); + +uint32_t linux_agent_get_accessible_device(uint32_t agent_id); +uint32_t linux_agent_get_inaccessible_device(uint32_t agent_id); +uint32_t linux_device_get_accessible_protocol(uint32_t device_id); + +#endif diff --git a/platform/linux/generic_scmi/pal_base.c b/platform/linux/generic_scmi/pal_base.c new file mode 100644 index 0000000000000000000000000000000000000000..32c036f538fed0251016e54ac4deaf7d1caa6e0b --- /dev/null +++ b/platform/linux/generic_scmi/pal_base.c @@ -0,0 +1,109 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#include "pal_interface.h" +#include "pal_base_expected.h" + +/** + @brief This API is used to check vendor name + @param none + @return vendor name +**/ +char *pal_base_get_expected_vendor_name(void) +{ + return PAL_SCMI_ANYNAME; +} + +/** + @brief This API is used for checking subvendor name + @param none + @return subvendor name +**/ +char *pal_base_get_expected_subvendor_name(void) +{ + return PAL_SCMI_ANYNAME; +} + +/** + @brief This API is used for checking implementation version + @param none + @return implementation version +**/ +uint32_t pal_base_get_expected_implementation_version(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking num of agents + @param none + @return num of agents +**/ +uint32_t pal_base_get_expected_num_agents(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking num of protocols agent have access + @param none + @return num of protocols +**/ +uint32_t pal_base_get_expected_num_protocols(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking if agent is trusted + @param agent id + @return true/false +**/ +uint32_t pal_check_trusted_agent(uint32_t agent_id) +{ + return UNTRUSTED; +} + +/** + @brief This API is used to get device which agent can access + @param agent id + @return device id +**/ +uint32_t pal_agent_get_accessible_device(uint32_t agent_id) +{ + return linux_agent_get_accessible_device(agent_id); +} + +/** + @brief This API is used to get device which agent cannot access + @param agent id + @return device id +**/ +uint32_t pal_agent_get_inaccessible_device(uint32_t agent_id) +{ + return linux_agent_get_inaccessible_device(agent_id); +} + +/** + @brief This API is used to get protocol by which given device can be access + @param device id + @return protocol id +**/ +uint32_t pal_device_get_accessible_protocol(uint32_t device_id) +{ + return linux_device_get_accessible_protocol(device_id); +} diff --git a/platform/linux/generic_scmi/pal_clock.c b/platform/linux/generic_scmi/pal_clock.c new file mode 100644 index 0000000000000000000000000000000000000000..04b0f06b3fbc833b6457f0d7545996263e09c823 --- /dev/null +++ b/platform/linux/generic_scmi/pal_clock.c @@ -0,0 +1,62 @@ +/** @file + * Copyright (c) 2023 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. +**/ +#ifdef CLOCK_PROTOCOL + +#include "pal_interface.h" +#include "pal_clock_expected.h" + +/** + @brief This API is used for checking num of clocks + @param none + @return num of clocks +**/ +uint32_t pal_clock_get_expected_num_clocks(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking max num of pending async cmd support for clock + @param none + @return max num of pending async cmd +**/ +uint32_t pal_clock_get_expected_max_async_cmd(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking num of rates a clock supports + @param clock id + @return num of rates a clock supports +**/ +uint32_t pal_clock_get_expected_number_of_rates(uint32_t clock_id) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API checks if clock supports config change + @param clock id + @return supported / unsupported +**/ +uint32_t pal_check_clock_config_change_support(uint32_t clock_id) +{ + return UNSUPPORTED; +} + +#endif diff --git a/platform/linux/generic_scmi/pal_performance.c b/platform/linux/generic_scmi/pal_performance.c new file mode 100644 index 0000000000000000000000000000000000000000..229a7e3f6259b6dde81966e5a7d06d0e3ca4adcf --- /dev/null +++ b/platform/linux/generic_scmi/pal_performance.c @@ -0,0 +1,81 @@ +/** @file + * Copyright (c) 2023 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. +**/ +#ifdef PERFORMANCE_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking number of perf domains + @param none + @return num of perf domains +**/ +uint32_t pal_performance_get_expected_num_domains(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking perf statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_performance_get_expected_stats_addr_low(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking perf statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_performance_get_expected_stats_addr_high(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_performance_get_expected_stats_addr_len(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking domain name + @param perf domain id + @return perf domain name +**/ +uint8_t *pal_performance_get_expected_name(uint32_t domain_id) +{ + return PAL_SCMI_ANYNAME; +} + +/** + @brief This API is used for checking num of level for perf domain + @param perf domain id + @return num of level for perf domain +**/ +uint32_t pal_performance_get_expected_number_of_level(uint32_t domain_id) +{ + return PAL_SCMI_ANYTHING; +} + +#endif diff --git a/platform/linux/generic_scmi/pal_platform.c b/platform/linux/generic_scmi/pal_platform.c new file mode 100644 index 0000000000000000000000000000000000000000..c2b8712114ef37ca2641e62ebe9d149e922b987b --- /dev/null +++ b/platform/linux/generic_scmi/pal_platform.c @@ -0,0 +1,142 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#include "pal_platform.h" +#include "pal_interface.h" + +/** + @brief This API is used to map a physical memory area to a virtual one. + @param paddr physical address to map + @param length size of the memory to map + @param vaddr the mapped resulting virtual address + @return 0 on Success +**/ +int pal_map_phys_to_virt(unsigned long paddr, size_t length, unsigned long *vaddr) +{ + return linux_map_phys_to_virt(paddr, length, vaddr); +} + +/** + @brief This API is used to unmap a previously mapped memory area + @param paddr physical address that has been mapped + @param length size of the mapped memory + @param vaddr the mapped virtual address + @return 0 on Success +**/ +int pal_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length) +{ + return linux_unmap_phys_to_virt(paddr, vaddr, length); +} + +/** + @brief This API is used to call platform function to send command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + +/** + @brief This API is used to call platform function to send async command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message_async(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + +/** + @brief This API is used to initialize platform to run tests if needed + @param platform info + @return success / failure +**/ +uint32_t pal_initialize_system(void *info) +{ + return linux_initialize_system(info); +} + +/** + @brief This API is used to print test log + @param args values to be printed + @return none +**/ +void pal_print(uint32_t print_level, const char *format, va_list args) +{ + FILE *file_ptr = fopen(LOG_FILE, "a"); + if (file_ptr) + { + vfprintf(file_ptr, format, args); + fclose(file_ptr); + } + else + printf("ERROR: Log File opening failed"); +} + +/** + @brief This API is used to receive delayed response + @param message header received + @param status of command processed + @param return values count + @param return values list + **/ +void pal_receive_delayed_response(uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + uint32_t timeout = TIMEOUT; /* In ms*/ + + linux_wait_for_response(message_header_rcv, status, + return_values_count, return_values, NULL, timeout); +} + +/** + @brief This API is used to receive notifications from platform + @param message header received + @param return values count + @param return values list + **/ +void pal_receive_notification(uint32_t *message_header_rcv, size_t *return_values_count, + uint32_t *return_values) +{ + uint32_t timeout = TIMEOUT; /* In ms*/ + + linux_wait_for_notification(message_header_rcv, + return_values_count, return_values, timeout); +} + diff --git a/platform/linux/generic_scmi/pal_power_domain.c b/platform/linux/generic_scmi/pal_power_domain.c new file mode 100644 index 0000000000000000000000000000000000000000..c5ec0a8d525b600567de3ad04bd980c7f7afcd7a --- /dev/null +++ b/platform/linux/generic_scmi/pal_power_domain.c @@ -0,0 +1,61 @@ +/** @file + * Copyright (c) 2023 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. +**/ +#ifdef POWER_DOMAIN_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking num of power domain + @param none + @return num of power domain +**/ +uint32_t pal_power_get_expected_num_domains(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking power domain statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_power_get_expected_stats_addr_low(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking power domain statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_power_get_expected_stats_addr_high(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking power domain statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_power_get_expected_stats_addr_len(void) +{ + return PAL_SCMI_ANYTHING; +} + +#endif diff --git a/platform/linux/generic_scmi/pal_reset.c b/platform/linux/generic_scmi/pal_reset.c new file mode 100644 index 0000000000000000000000000000000000000000..ebf75822305701e77b77f46d2632bd8db0115507 --- /dev/null +++ b/platform/linux/generic_scmi/pal_reset.c @@ -0,0 +1,42 @@ +/** @file + * Copyright (c) 2023 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. +**/ +#ifdef RESET_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking num of reset domain + @param none + @return num of reset domain +**/ +uint32_t pal_reset_get_expected_num_domains(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking reset domain name + @param domain id + @return reset domain name +**/ +uint8_t *pal_reset_get_expected_name(uint32_t domain_id) +{ + return PAL_SCMI_ANYNAME; +} + +#endif + diff --git a/platform/linux/generic_scmi/pal_sensor.c b/platform/linux/generic_scmi/pal_sensor.c new file mode 100644 index 0000000000000000000000000000000000000000..1a61b0ab88ee3a1c19fdbec3ca46022cb2184ec1 --- /dev/null +++ b/platform/linux/generic_scmi/pal_sensor.c @@ -0,0 +1,61 @@ +/** @file + * Copyright (c) 2023 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. +**/ +#ifdef SENSOR_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking num of sensors + @param none + @return num of sensors +**/ +uint32_t pal_sensor_get_expected_num_sensors(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking sensor statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_sensor_get_expected_stats_addr_low(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking sensor statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_sensor_get_expected_stats_addr_high(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking sensor statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_sensor_get_expected_stats_addr_len(void) +{ + return PAL_SCMI_ANYTHING; +} + +#endif diff --git a/platform/linux/generic_scmi/pal_voltage.c b/platform/linux/generic_scmi/pal_voltage.c new file mode 100755 index 0000000000000000000000000000000000000000..6b10fa2c2df7b480df96eda59e597a7f7bb3846f --- /dev/null +++ b/platform/linux/generic_scmi/pal_voltage.c @@ -0,0 +1,42 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifdef VOLTAGE_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking num of voltage domain + @param none + @return num of voltage domain +**/ +uint32_t pal_voltage_get_expected_num_domains(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking voltage domain name + @param domain id + @return voltage domain name +**/ +uint8_t *pal_voltage_get_expected_name(uint32_t domain_id) +{ + return PAL_SCMI_ANYNAME; +} + +#endif diff --git a/platform/linux/juno/Makefile b/platform/linux/juno/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..e1f163bffc510b5a8b5314462af5bbbed6b59e71 --- /dev/null +++ b/platform/linux/juno/Makefile @@ -0,0 +1,18 @@ +#/** @file +# * Copyright (c) 2023, 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. +#**/ + +include ${TOP}/platform/build_platform.mk diff --git a/platform/linux/juno/include/pal_base_expected.h b/platform/linux/juno/include/pal_base_expected.h new file mode 100644 index 0000000000000000000000000000000000000000..a7ec82a75e496b4b8730fed5604521cd049c83f8 --- /dev/null +++ b/platform/linux/juno/include/pal_base_expected.h @@ -0,0 +1,43 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_BASE_EXPECTED_H__ +#define __PAL_BASE_EXPECTED_H__ + +#include + +#define UNTRUSTED 0 + +static uint32_t supported_protocols[] = { + PWR_DOMAIN_PROTOCOL_ID, + SYSTEM_POWER_PROTOCOL_ID, + PERFORMANCE_PROTOCOL_ID, + CLOCK_PROTOCOL_ID, + SENSOR_PROTOCOL_ID, +}; + +static char *agents[] = { + "OSPM", "PSCI" +}; + +/* Expected BASE parameters */ + +static char *vendor_name = "arm"; +static char *subvendor_name = "arm"; +static uint32_t implementation_version = VERSION_ENCODE32(2, 10, 0); + +#endif /* __PAL_BASE_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_clock_expected.h b/platform/linux/juno/include/pal_clock_expected.h new file mode 100644 index 0000000000000000000000000000000000000000..23be62c7e870768930610e3b39ebe23081444e4b --- /dev/null +++ b/platform/linux/juno/include/pal_clock_expected.h @@ -0,0 +1,40 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_CLOCK_EXPECTED_H__ +#define __PAL_CLOCK_EXPECTED_H__ + +/* Expected CLOCK parameters */ +#ifdef CLOCK_PROTOCOL + +#define UNSUPPORTED 1 + +static uint32_t num_clocks = 0x06; +static uint32_t num_of_clock_rates[] = { + 0x5, /* BIG_CLK */ + 0x5, /* LITTLE_CLK */ + 0x5, /* GPU_CLK */ + 0x1, /* HDLCD_0 */ + 0x1, /* HDLCD_1 */ + 0x7 /* I2SCLK */ +}; + +uint32_t max_num_pending_async_rate_chg_supported = 0; + +#endif + +#endif /* __PAL_CLOCK_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_performance_expected.h b/platform/linux/juno/include/pal_performance_expected.h new file mode 100644 index 0000000000000000000000000000000000000000..3de843853fb2428363a3c06e7ec40b51522f99b1 --- /dev/null +++ b/platform/linux/juno/include/pal_performance_expected.h @@ -0,0 +1,41 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_PERFORMANCE_EXPECTED_H__ +#define __PAL_PERFORMANCE_EXPECTED_H__ + +/* Expected PERFORMANCE parameters */ +#ifdef PERFORMANCE_PROTOCOL +static uint32_t num_perf_domains = 0x03; + +static uint32_t perf_num_performance_levels[] = { + 5, /* BIG_CPU */ + 5, /* LITTLE_CPU */ + 5 /* GPU */ +}; + +static char *performance_domain_names[] = { + "BIG_CPU", + "LITTLE_CPU", + "GPU" +}; + +uint32_t statistics_address_low_perf = 0; +uint32_t statistics_address_len_perf = 0; +#endif + +#endif /* __PAL_PERFORMANCE_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_platform.h b/platform/linux/juno/include/pal_platform.h new file mode 100644 index 0000000000000000000000000000000000000000..7241e8d3f267e423df5d4b64a37e9728e594ba2f --- /dev/null +++ b/platform/linux/juno/include/pal_platform.h @@ -0,0 +1,69 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_PLATFORM_H__ +#define __PAL_PLATFORM_H__ + +#include +#include +#include + +#define LOG_FILE "arm_scmi_test_log.txt" + +#define VERSION_ENCODE32(MAJOR, MINOR, PATCH) (((MAJOR & 0xff) << 24) | \ + ((MINOR & 0xff) << 16)| \ + (PATCH & 0xffff)) +#define BASE_PROTOCOL_ID 0x10 +#define PWR_DOMAIN_PROTOCOL_ID 0x11 +#define SYSTEM_POWER_PROTOCOL_ID 0x12 +#define PERFORMANCE_PROTOCOL_ID 0x13 +#define CLOCK_PROTOCOL_ID 0x14 +#define SENSOR_PROTOCOL_ID 0x15 +#define RESET_PROTOCOL_ID 0x16 +#define APCORE_PROTOCOL_ID 0x09 + +#define TIMEOUT 100 + +int linux_map_phys_to_virt(unsigned long paddr, size_t length, + unsigned long *vaddr); + +int linux_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, + size_t length); + +uint32_t linux_initialize_system(void *info); + +int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + +int linux_wait_for_notification(uint32_t *message_header_rcv, + size_t *return_values_count, uint32_t *return_values, + uint32_t timeout); + +int linux_wait_for_response(uint32_t *message_header_rcv, + int32_t *status, size_t *return_values_count, uint32_t *return_values, + bool *message_ready, uint32_t timeout); + +uint32_t linux_agent_get_accessible_device(uint32_t agent_id); +uint32_t linux_agent_get_inaccessible_device(uint32_t agent_id); +uint32_t linux_device_get_accessible_protocol(uint32_t device_id); + +#endif diff --git a/platform/linux/juno/include/pal_power_domain_expected.h b/platform/linux/juno/include/pal_power_domain_expected.h new file mode 100644 index 0000000000000000000000000000000000000000..1c9837a712dbd8297ae119b86df241d725d68e5c --- /dev/null +++ b/platform/linux/juno/include/pal_power_domain_expected.h @@ -0,0 +1,29 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_POWER_DOMAIN_EXPECTED_H__ +#define __PAL_POWER_DOMAIN_EXPECTED_H__ + +/* Expected POWER DOMAIN parameters */ +#ifdef POWER_DOMAIN_PROTOCOL +static uint32_t num_power_domains = 0x0a; +uint32_t statistics_address_low_pow = 0; +uint32_t statistics_address_len_pow = 0; + +#endif + +#endif /* __PAL_POWER_DOMAIN_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_reset_expected.h b/platform/linux/juno/include/pal_reset_expected.h new file mode 100644 index 0000000000000000000000000000000000000000..af9ef667278e1bae20f5d3d8c8672b954b7e6dc2 --- /dev/null +++ b/platform/linux/juno/include/pal_reset_expected.h @@ -0,0 +1,30 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_RESET_EXPECTED_H__ +#define __PAL_RESET_EXPECTED_H__ + +#ifdef RESET_PROTOCOL + +uint32_t num_reset_domains = 0x0; + +static char *reset_domain_names[] = { + NULL, +}; +#endif + +#endif /* __PAL_RESET_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_sensor_expected.h b/platform/linux/juno/include/pal_sensor_expected.h new file mode 100644 index 0000000000000000000000000000000000000000..785a50880a93b4efde0c9a586552d1a3ddb3e513 --- /dev/null +++ b/platform/linux/juno/include/pal_sensor_expected.h @@ -0,0 +1,29 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_SENSOR_EXPECTED_H__ +#define __PAL_SENSOR_EXPECTED_H__ + +#ifdef SENSOR_PROTOCOL + +static uint32_t num_sensors = 0x09; +uint32_t statistics_address_low_snsr = 0; +uint32_t statistics_address_len_snsr = 0; + +#endif + +#endif /* __PAL_SENSOR_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_voltage_expected.h b/platform/linux/juno/include/pal_voltage_expected.h new file mode 100755 index 0000000000000000000000000000000000000000..87ff6fbb3c1ab4b56f9fe5ce48880a2d3f71faaa --- /dev/null +++ b/platform/linux/juno/include/pal_voltage_expected.h @@ -0,0 +1,30 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifndef __PAL_VOLTAGE_EXPECTED_H__ +#define __PAL_VOLTAGE_EXPECTED_H__ + +#ifdef VOLTAGE_PROTOCOL + +uint32_t num_voltage_domains = 0x00; + +static char *voltage_domain_names[] = { + NULL, +}; +#endif + +#endif /* __PAL_VOLTAGE_EXPECTED_H__ */ diff --git a/platform/linux/juno/pal_base.c b/platform/linux/juno/pal_base.c new file mode 100644 index 0000000000000000000000000000000000000000..87507f3fd24e447c603b46d434a468eaae4ea65d --- /dev/null +++ b/platform/linux/juno/pal_base.c @@ -0,0 +1,109 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#include "pal_interface.h" +#include "pal_base_expected.h" + +/** + @brief This API is used to check vendor name + @param none + @return vendor name +**/ +char *pal_base_get_expected_vendor_name(void) +{ + return vendor_name; +} + +/** + @brief This API is used for checking subvendor name + @param none + @return subvendor name +**/ +char *pal_base_get_expected_subvendor_name(void) +{ + return subvendor_name; +} + +/** + @brief This API is used for checking implementation version + @param none + @return implementation version +**/ +uint32_t pal_base_get_expected_implementation_version(void) +{ + return implementation_version; +} + +/** + @brief This API is used for checking num of agents + @param none + @return num of agents +**/ +uint32_t pal_base_get_expected_num_agents(void) +{ + return NUM_ELEMS(agents); +} + +/** + @brief This API is used for checking num of protocols agent have access + @param none + @return num of protocols +**/ +uint32_t pal_base_get_expected_num_protocols(void) +{ + return NUM_ELEMS(supported_protocols); +} + +/** + @brief This API is used for checking if agent is trusted + @param agent id + @return true/false +**/ +uint32_t pal_check_trusted_agent(uint32_t agent_id) +{ + return UNTRUSTED; +} + +/** + @brief This API is used to get device which agent can access + @param agent id + @return device id +**/ +uint32_t pal_agent_get_accessible_device(uint32_t agent_id) +{ + return linux_agent_get_accessible_device(agent_id); +} + +/** + @brief This API is used to get device which agent cannot access + @param agent id + @return device id +**/ +uint32_t pal_agent_get_inaccessible_device(uint32_t agent_id) +{ + return linux_agent_get_inaccessible_device(agent_id); +} + +/** + @brief This API is used to get protocol by which given device can be access + @param device id + @return protocol id +**/ +uint32_t pal_device_get_accessible_protocol(uint32_t device_id) +{ + return linux_device_get_accessible_protocol(device_id); +} diff --git a/platform/linux/juno/pal_clock.c b/platform/linux/juno/pal_clock.c new file mode 100644 index 0000000000000000000000000000000000000000..68b039f889bb16182553a4ce23390acc363bc41a --- /dev/null +++ b/platform/linux/juno/pal_clock.c @@ -0,0 +1,62 @@ +/** @file + * Copyright (c) 2023, 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. +**/ +#ifdef CLOCK_PROTOCOL + +#include "pal_interface.h" +#include "pal_clock_expected.h" + +/** + @brief This API is used for checking num of clocks + @param none + @return num of clocks +**/ +uint32_t pal_clock_get_expected_num_clocks(void) +{ + return num_clocks; +} + +/** + @brief This API is used for checking max num of pending async cmd support for clock + @param none + @return max num of pending async cmd +**/ +uint32_t pal_clock_get_expected_max_async_cmd(void) +{ + return max_num_pending_async_rate_chg_supported; +} + +/** + @brief This API is used for checking num of rates a clock supports + @param clock id + @return num of rates a clock supports +**/ +uint32_t pal_clock_get_expected_number_of_rates(uint32_t clock_id) +{ + return num_of_clock_rates[clock_id]; +} + +/** + @brief This API checks if clock supports config change + @param clock id + @return supported / unsupported +**/ +uint32_t pal_check_clock_config_change_support(uint32_t clock_id) +{ + return UNSUPPORTED; +} + +#endif diff --git a/platform/linux/juno/pal_performance.c b/platform/linux/juno/pal_performance.c new file mode 100644 index 0000000000000000000000000000000000000000..f63bff552df14ab751220af7194990cca08e3292 --- /dev/null +++ b/platform/linux/juno/pal_performance.c @@ -0,0 +1,82 @@ +/** @file + * Copyright (c) 2023, 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. +**/ +#ifdef PERFORMANCE_PROTOCOL + +#include "pal_interface.h" +#include "pal_performance_expected.h" + +/** + @brief This API is used for checking number of perf domains + @param none + @return num of perf domains +**/ +uint32_t pal_performance_get_expected_num_domains(void) +{ + return num_perf_domains; +} + +/** + @brief This API is used for checking perf statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_performance_get_expected_stats_addr_low(void) +{ + return statistics_address_low_perf; +} + +/** + @brief This API is used for checking perf statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_performance_get_expected_stats_addr_high(void) +{ + return (statistics_address_low_perf + statistics_address_len_perf); +} + +/** + @brief This API is used for checking statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_performance_get_expected_stats_addr_len(void) +{ + return statistics_address_len_perf; +} + +/** + @brief This API is used for checking domain name + @param perf domain id + @return perf domain name +**/ +uint8_t *pal_performance_get_expected_name(uint32_t domain_id) +{ + return (uint8_t *)&performance_domain_names[domain_id][0]; +} + +/** + @brief This API is used for checking num of level for perf domain + @param perf domain id + @return num of level for perf domain +**/ +uint32_t pal_performance_get_expected_number_of_level(uint32_t domain_id) +{ + return perf_num_performance_levels[domain_id]; +} + +#endif diff --git a/platform/linux/juno/pal_platform.c b/platform/linux/juno/pal_platform.c new file mode 100644 index 0000000000000000000000000000000000000000..9d14ff28b54a1c1fb5bd32c656b3e8cd3f3feb91 --- /dev/null +++ b/platform/linux/juno/pal_platform.c @@ -0,0 +1,141 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#include "pal_platform.h" +#include "pal_interface.h" + +/** + @brief This API is used to map a physical memory area to a virtual one. + @param paddr physical address to map + @param length size of the memory to map + @param vaddr the mapped resulting virtual address + @return 0 on Success +**/ +int pal_map_phys_to_virt(unsigned long paddr, size_t length, unsigned long *vaddr) +{ + return linux_map_phys_to_virt(paddr, length, vaddr); +} + +/** + @brief This API is used to unmap a previously mapped memory area + @param paddr physical address that has been mapped + @param length size of the mapped memory + @param vaddr the mapped virtual address + @return 0 on Success +**/ +int pal_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length) +{ + return linux_unmap_phys_to_virt(paddr, vaddr, length); +} + +/** + @brief This API is used to call platform function to send command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + +/** + @brief This API is used to call platform function to send async command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message_async(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + +/** + @brief This API is used to initialize platform to run tests if needed + @param platform info + @return success / failure +**/ +uint32_t pal_initialize_system(void *info) +{ + return linux_initialize_system(info); +} + +/** + @brief This API is used to print test log + @param args values to be printed + @return none +**/ +void pal_print(uint32_t print_level, const char *format, va_list args) +{ + FILE *file_ptr = fopen(LOG_FILE, "a"); + if (file_ptr) { + vfprintf(file_ptr, format, args); + fclose(file_ptr); + } else { + printf("ERROR: Log File opening failed"); + } +} + +/** + @brief This API is used to receive delayed response + @param message header received + @param status of command processed + @param return values count + @param return values list + **/ +void pal_receive_delayed_response(uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + uint32_t timeout = TIMEOUT; /* In ms*/ + + linux_wait_for_response(message_header_rcv, status, + return_values_count, return_values, NULL, timeout); +} + +/** + @brief This API is used to receive notifications from platform + @param message header received + @param return values count + @param return values list + **/ +void pal_receive_notification(uint32_t *message_header_rcv, size_t *return_values_count, + uint32_t *return_values) +{ + uint32_t timeout = TIMEOUT; /* In ms*/ + + linux_wait_for_notification(message_header_rcv, + return_values_count, return_values, timeout); +} + diff --git a/platform/linux/juno/pal_power_domain.c b/platform/linux/juno/pal_power_domain.c new file mode 100644 index 0000000000000000000000000000000000000000..12c0140dbeaebc0e22335fab2fa5ee46bc56bcdb --- /dev/null +++ b/platform/linux/juno/pal_power_domain.c @@ -0,0 +1,62 @@ +/** @file + * Copyright (c) 2023, 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. +**/ +#ifdef POWER_DOMAIN_PROTOCOL + +#include "pal_interface.h" +#include "pal_power_domain_expected.h" + +/** + @brief This API is used for checking num of power domain + @param none + @return num of power domain +**/ +uint32_t pal_power_get_expected_num_domains(void) +{ + return num_power_domains; +} + +/** + @brief This API is used for checking power domain statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_power_get_expected_stats_addr_low(void) +{ + return statistics_address_low_pow; +} + +/** + @brief This API is used for checking power domain statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_power_get_expected_stats_addr_high(void) +{ + return (statistics_address_low_pow + statistics_address_len_pow); +} + +/** + @brief This API is used for checking power domain statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_power_get_expected_stats_addr_len(void) +{ + return statistics_address_len_pow; +} + +#endif diff --git a/platform/linux/juno/pal_reset.c b/platform/linux/juno/pal_reset.c new file mode 100644 index 0000000000000000000000000000000000000000..510e0cd68a95afbf9945cec2fb7be8f4aa384a55 --- /dev/null +++ b/platform/linux/juno/pal_reset.c @@ -0,0 +1,43 @@ +/** @file + * Copyright (c) 2023, 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. +**/ +#ifdef RESET_PROTOCOL + +#include "pal_interface.h" +#include "pal_reset_expected.h" + +/** + @brief This API is used for checking num of reset domain + @param none + @return num of reset domain +**/ +uint32_t pal_reset_get_expected_num_domains(void) +{ + return num_reset_domains; +} + +/** + @brief This API is used for checking reset domain name + @param domain id + @return reset domain name +**/ +uint8_t *pal_reset_get_expected_name(uint32_t domain_id) +{ + return (uint8_t *)reset_domain_names[domain_id]; +} + +#endif + diff --git a/platform/linux/juno/pal_sensor.c b/platform/linux/juno/pal_sensor.c new file mode 100644 index 0000000000000000000000000000000000000000..d93a3b130ad495f1ca9354398f9bc50216b0f66d --- /dev/null +++ b/platform/linux/juno/pal_sensor.c @@ -0,0 +1,62 @@ +/** @file + * Copyright (c) 2023, 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. +**/ +#ifdef SENSOR_PROTOCOL + +#include "pal_interface.h" +#include "pal_sensor_expected.h" + +/** + @brief This API is used for checking num of sensors + @param none + @return num of sensors +**/ +uint32_t pal_sensor_get_expected_num_sensors(void) +{ + return num_sensors; +} + +/** + @brief This API is used for checking sensor statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_sensor_get_expected_stats_addr_low(void) +{ + return statistics_address_low_snsr; +} + +/** + @brief This API is used for checking sensor statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_sensor_get_expected_stats_addr_high(void) +{ + return (statistics_address_low_snsr + statistics_address_len_snsr); +} + +/** + @brief This API is used for checking sensor statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_sensor_get_expected_stats_addr_len(void) +{ + return statistics_address_len_snsr; +} + +#endif diff --git a/platform/linux/juno/pal_voltage.c b/platform/linux/juno/pal_voltage.c new file mode 100755 index 0000000000000000000000000000000000000000..9fb1c68bc07b597c7b9fd860de6b365a9ebc3bb3 --- /dev/null +++ b/platform/linux/juno/pal_voltage.c @@ -0,0 +1,43 @@ +/** @file + * Copyright (c) 2023, 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. +**/ + +#ifdef VOLTAGE_PROTOCOL + +#include "pal_interface.h" +#include "pal_voltage_expected.h" + +/** + @brief This API is used for checking num of voltage domain + @param none + @return num of voltage domain +**/ +uint32_t pal_voltage_get_expected_num_domains(void) +{ + return num_voltage_domains; +} + +/** + @brief This API is used for checking voltage domain name + @param domain id + @return voltage domain name +**/ +uint8_t *pal_voltage_get_expected_name(uint32_t domain_id) +{ + return (uint8_t *)voltage_domain_names[domain_id]; +} + +#endif diff --git a/platform/linux/sgm776/include/pal_platform.h b/platform/linux/sgm776/include/pal_platform.h index 6e93a361594eddd575308761b929266aa8c6859c..002a71b02ec3954b584e04c0de951b41fcde33f1 100644 --- a/platform/linux/sgm776/include/pal_platform.h +++ b/platform/linux/sgm776/include/pal_platform.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,10 +46,16 @@ int linux_map_phys_to_virt(unsigned long paddr, size_t length, int linux_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length); +uint32_t linux_initialize_system(void *info); + int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + int linux_wait_for_notification(uint32_t *message_header_rcv, size_t *return_values_count, uint32_t *return_values, uint32_t timeout); diff --git a/platform/linux/sgm776/pal_platform.c b/platform/linux/sgm776/pal_platform.c index 20d1adca2bef6e1a5d20aba7e94596da8f5f5a55..4ad0a212ed8b8aae6ffd14c3040bb9fd8855682a 100644 --- a/platform/linux/sgm776/pal_platform.c +++ b/platform/linux/sgm776/pal_platform.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2019-2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2019-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -62,6 +62,26 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, return_values); } +/** + @brief This API is used to call platform function to send async command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message_async(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + /** @brief This API is used to initialize platform to run tests if needed @param platform info @@ -69,7 +89,7 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, **/ uint32_t pal_initialize_system(void *info) { - return 0; /* No initialization needed for SGM to run test */ + return linux_initialize_system(info); } /** diff --git a/platform/linux/tc/include/pal_platform.h b/platform/linux/tc/include/pal_platform.h index 4f5e07979eb16b8c92271d6aaeef72fedfff9bcc..777c1e6d5be02b411a8850af5ba72b5af764ac07 100644 --- a/platform/linux/tc/include/pal_platform.h +++ b/platform/linux/tc/include/pal_platform.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,10 +44,16 @@ int linux_map_phys_to_virt(unsigned long paddr, size_t length, int linux_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length); +uint32_t linux_initialize_system(void *info); + int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + int linux_wait_for_notification(uint32_t *message_header_rcv, size_t *return_values_count, uint32_t *return_values, uint32_t timeout); diff --git a/platform/linux/tc/pal_platform.c b/platform/linux/tc/pal_platform.c index 3cb196c99fae0e86504cff1186bf32aedb4107d4..2c50181aeb3af629d62159739e359a9cf7a186a0 100644 --- a/platform/linux/tc/pal_platform.c +++ b/platform/linux/tc/pal_platform.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -62,6 +62,26 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, return_values); } +/** + @brief This API is used to call platform function to send async command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message_async(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + /** @brief This API is used to initialize platform to run tests if needed @param platform info @@ -69,7 +89,7 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, **/ uint32_t pal_initialize_system(void *info) { - return 0; /* No initialization needed for TC to run test */ + return linux_initialize_system(info); } /** diff --git a/platform/mocker/pal_platform.c b/platform/mocker/pal_platform.c index c75b6c5d497fe9b963afa7e3af1e4f17486e97de..5c6f9e51a0aff420b4f4be5a8fa4ee21e6c4eedd 100644 --- a/platform/mocker/pal_platform.c +++ b/platform/mocker/pal_platform.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -99,6 +99,15 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, } } +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + pal_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + void pal_receive_delayed_response(uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values) { diff --git a/test_pool/clock/test_c009.c b/test_pool/clock/test_c009.c index d341c90f9534f61584d0d71a4459cbcae6fcf108..d6c1138ce60e0a36187eff0f770ededce8f2b697 100644 --- a/test_pool/clock/test_c009.c +++ b/test_pool/clock/test_c009.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -102,10 +102,13 @@ uint32_t clock_rate_set_sync_check(void) val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, &return_value_count, return_values); - if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) + if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) + if (val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + + if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; val_print_return_values(return_value_count, return_values); diff --git a/test_pool/clock/test_c010.c b/test_pool/clock/test_c010.c index a9aa54574cccaf76dfa9c4cf65f404394a5adf5d..ef1f1f27bbc329eefe7a126c3312df21b0bdf700 100644 --- a/test_pool/clock/test_c010.c +++ b/test_pool/clock/test_c010.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -75,10 +75,13 @@ uint32_t clock_rate_set_async_check(void) val_send_message(cmd_msg_hdr, param_count, &clock_id, &rsp_msg_hdr, &status, &return_value_count, return_values); - if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) + if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) + if (val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + + if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; val_print_return_values(return_value_count, return_values); @@ -107,7 +110,7 @@ uint32_t clock_rate_set_async_check(void) parameters[param_count++] = new_rate_low; parameters[param_count++] = new_rate_high; cmd_msg_hdr = val_msg_hdr_create(PROTOCOL_CLOCK, CLOCK_RATE_SET, COMMAND_MSG); - val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, + val_send_message_async(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, &return_value_count, return_values); if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) diff --git a/test_pool/clock/test_c011.c b/test_pool/clock/test_c011.c index 91cfb11833c469da4775f83d3106c423402375df..df291507315d1ae8809d9f1a7ee9943792e8bd52 100644 --- a/test_pool/clock/test_c011.c +++ b/test_pool/clock/test_c011.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -66,10 +66,13 @@ uint32_t clock_rate_set_invalid_param_check(void) val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, &return_value_count, return_values); - if (val_compare_status(status, SCMI_INVALID_PARAMETERS) != VAL_STATUS_PASS) + if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) + if (val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + + if (val_compare_status(status, SCMI_INVALID_PARAMETERS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; val_print(VAL_PRINT_TEST, "\n [Check 2] Query with invalid flag"); diff --git a/test_pool/clock/test_c015.c b/test_pool/clock/test_c015.c index affd155e4f1bdad3a842641b6674c499f3e107ce..6c2eaa41dce74d5865fcdb41350dd4cc93539bfe 100644 --- a/test_pool/clock/test_c015.c +++ b/test_pool/clock/test_c015.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,7 +45,13 @@ uint32_t clock_config_set_invalid_attr_check(void) for (clock_id = 0; clock_id < num_clocks; clock_id++) { + bool could_be_denied = false; + val_print(VAL_PRINT_TEST, "\n CLOCK ID: %d", clock_id); + + if (val_check_clock_config_change_support(clock_id) == 1) + could_be_denied = true; + val_print(VAL_PRINT_TEST, "\n [Check 1] Query with invalid attribute"); /* Clock config set with invalid attributes should fail with INVALID_PARAMETERS */ @@ -60,6 +66,10 @@ uint32_t clock_config_set_invalid_attr_check(void) if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; + if (could_be_denied && + val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + if (val_compare_status(status, SCMI_INVALID_PARAMETERS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; } diff --git a/test_pool/clock/test_c017.c b/test_pool/clock/test_c017.c index 85aba92adf037eba8091792099675b27c2135ed9..440d54dd8460ba5916bf9c043caf17a69f43b707 100644 --- a/test_pool/clock/test_c017.c +++ b/test_pool/clock/test_c017.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -53,12 +53,12 @@ uint32_t clock_config_set_check(void) for (clock_id = 0; clock_id < num_clocks; clock_id++) { + bool could_be_denied = false; val_print(VAL_PRINT_TEST, "\n CLOCK ID: %d", clock_id); - /* Skip if always on clock*/ if (val_check_clock_config_change_support(clock_id) == 1) - continue; + could_be_denied = true; run_flag = 1; /* Find new attribute from previously stored value */ @@ -81,6 +81,13 @@ uint32_t clock_config_set_check(void) if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; + if (could_be_denied && + val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + + if (val_compare_status(status, SCMI_NOT_SUPPORTED) == VAL_STATUS_PASS) + continue; + if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; diff --git a/test_pool/performance/test_d026.c b/test_pool/performance/test_d026.c index b1ab7fe94af578892b09adaecc3ead213ec71152..cc6e29de8b9c2f08f1e3a3fc89d4828599324161 100644 --- a/test_pool/performance/test_d026.c +++ b/test_pool/performance/test_d026.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ uint32_t performance_limit_set_async(void) { int32_t status; + uint32_t ret = VAL_STATUS_PASS; uint32_t rsp_msg_hdr; uint32_t cmd_msg_hdr; size_t param_count; @@ -156,40 +157,36 @@ uint32_t performance_limit_set_async(void) val_print(VAL_PRINT_TEST, "\n [Check 5] Wait for limit change notify"); VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); - val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values); - - val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : %08x", rsp_msg_hdr); - if (val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(rsp_msg_hdr, 10, 17), PROTOCOL_PERFORMANCE)) - return VAL_STATUS_FAIL; - if (val_compare("MSG TYPE ", VAL_EXTRACT_BITS(rsp_msg_hdr, 8, 9), NOTIFICATION_MSG)) - return VAL_STATUS_FAIL; - if (val_compare("MSG ID ", VAL_EXTRACT_BITS(rsp_msg_hdr, 0, 7), PERFORMANCE_LIMITS_CHANGED)) - return VAL_STATUS_FAIL; - + val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values, + PROTOCOL_PERFORMANCE, PERFORMANCE_LIMITS_CHANGED); val_print_return_values(return_value_count, return_values); - if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) - return VAL_STATUS_FAIL; - if (val_compare("RANGE MAX ", return_values[NOTIFICATION_RANGE_MAX_OFFSET], tmp_max)) - return VAL_STATUS_FAIL; - if (val_compare("RANGE MIN ", return_values[NOTIFICATION_RANGE_MIN_OFFSET], range_min)) - return VAL_STATUS_FAIL; + if (return_value_count < 3) + ret = VAL_STATUS_FAIL; + else { + if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) + ret = VAL_STATUS_FAIL; + else if (val_compare("RANGE MAX ", return_values[NOTIFICATION_RANGE_MAX_OFFSET], tmp_max)) + ret = VAL_STATUS_FAIL; + else if (val_compare("RANGE MIN ", return_values[NOTIFICATION_RANGE_MIN_OFFSET], range_min)) + ret = VAL_STATUS_FAIL; + } /* Disable limit change notification for the domain */ - val_print(VAL_PRINT_TEST, "\n [Check 6] Disable limit change notify for domain_id: %d", + val_print(VAL_PRINT_TEST, "\n [Check 6] Disable limit change notify for domain_id: %d", domain_id); - VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); - parameters[param_count++] = domain_id; - parameters[param_count++] = NOTIFY_DISABLE; - cmd_msg_hdr = val_msg_hdr_create(PROTOCOL_PERFORMANCE, PERFORMANCE_NOTIFY_LIMITS, COMMAND_MSG); - val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, - &return_value_count, return_values); + VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); + parameters[param_count++] = domain_id; + parameters[param_count++] = NOTIFY_DISABLE; + cmd_msg_hdr = val_msg_hdr_create(PROTOCOL_PERFORMANCE, PERFORMANCE_NOTIFY_LIMITS, COMMAND_MSG); + val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, + &return_value_count, return_values); - if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) - return VAL_STATUS_FAIL; + if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) + return VAL_STATUS_FAIL; - if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) - return VAL_STATUS_FAIL; + if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) + return VAL_STATUS_FAIL; val_print(VAL_PRINT_TEST, "\n [Check 7] Restore perf limits for domain_id: %d", domain_id); @@ -208,6 +205,6 @@ uint32_t performance_limit_set_async(void) if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - return VAL_STATUS_PASS; + return ret; } diff --git a/test_pool/performance/test_d027.c b/test_pool/performance/test_d027.c index bdbbfd63483a14d4f9dbc7993a098cdf1eef65af..c61eb7053696ce73278c37eb44e9e9b30138af0b 100644 --- a/test_pool/performance/test_d027.c +++ b/test_pool/performance/test_d027.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ uint32_t performance_level_set_async(void) { int32_t status; + uint32_t ret = VAL_STATUS_PASS; uint32_t rsp_msg_hdr; uint32_t cmd_msg_hdr; size_t param_count; @@ -156,21 +157,17 @@ uint32_t performance_level_set_async(void) val_print(VAL_PRINT_TEST, "\n [Check 5] Wait for level change notify"); VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); - val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values); - - val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : %08x", rsp_msg_hdr); - if (val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(rsp_msg_hdr, 10, 17), PROTOCOL_PERFORMANCE)) - return VAL_STATUS_FAIL; - if (val_compare("MSG TYPE ", VAL_EXTRACT_BITS(rsp_msg_hdr, 8, 9), NOTIFICATION_MSG)) - return VAL_STATUS_FAIL; - if (val_compare("MSG ID ", VAL_EXTRACT_BITS(rsp_msg_hdr, 0, 7), PERFORMANCE_LEVEL_CHANGED)) - return VAL_STATUS_FAIL; - + val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values, + PROTOCOL_PERFORMANCE, PERFORMANCE_LEVEL_CHANGED); val_print_return_values(return_value_count, return_values); - if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) - return VAL_STATUS_FAIL; - if (val_compare("PERF LEVEL ", return_values[NOTIFICATION_LEVEL_OFFSET], cur_level)) - return VAL_STATUS_FAIL; + if (return_value_count < 2) + ret = VAL_STATUS_FAIL; + else { + if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) + ret = VAL_STATUS_FAIL; + if (val_compare("PERF LEVEL ", return_values[NOTIFICATION_LEVEL_OFFSET], cur_level)) + ret = VAL_STATUS_FAIL; + } /* Disable level change notification for the domain */ @@ -207,6 +204,6 @@ uint32_t performance_level_set_async(void) if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - return VAL_STATUS_PASS; + return ret; } diff --git a/test_pool/sensor/test_m006.c b/test_pool/sensor/test_m006.c index 0271dc0d7f75ce0c524420a1a6a1261ac3f288d2..4d13d1f4741e7ae6e338ea365e73d7c42d24d6b5 100644 --- a/test_pool/sensor/test_m006.c +++ b/test_pool/sensor/test_m006.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +19,7 @@ #include "val_sensor.h" #define TEST_NUM (SCMI_SENSOR_TEST_NUM_BASE + 6) -#define TEST_DESC "Sensor trip pnt notify invalid event_ctrl chk" +#define TEST_DESC "Sensor trip point notify invalid event_ctrl chk" #define MAX_PARAMETER_SIZE 2 diff --git a/test_pool/sensor/test_m014.c b/test_pool/sensor/test_m014.c index 83931845f6d8af2f8c4b5099bc76c2259ebe8cf7..a99eec9ae0e796b641dcc51ed4784618f9ba3db7 100644 --- a/test_pool/sensor/test_m014.c +++ b/test_pool/sensor/test_m014.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -62,8 +62,8 @@ uint32_t sensor_reading_get_async_mode(void) parameters[param_count++] = sensor_id; parameters[param_count++] = SENSOR_READ_ASYNC_MODE; cmd_msg_hdr = val_msg_hdr_create(PROTOCOL_SENSOR, SENSOR_READING_GET, COMMAND_MSG); - val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, - &return_value_count, return_values); + val_send_message_async(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, + &return_value_count, return_values); if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; @@ -77,7 +77,7 @@ uint32_t sensor_reading_get_async_mode(void) val_print(VAL_PRINT_TEST, "\n [Check 2] Wait for delayed response"); VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); - val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values); + val_receive_delayed_response(&rsp_msg_hdr, &status, &return_value_count, return_values); val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : 0x%08x", rsp_msg_hdr); if (val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(rsp_msg_hdr, 10, 17), PROTOCOL_SENSOR)) diff --git a/val/include/pal_interface.h b/val/include/pal_interface.h index c2b5cd784562ddb2d0e39f04da9b799ed9adcf09..5802f98a63519d662eec3f8ee6d16b13f6d27ab8 100644 --- a/val/include/pal_interface.h +++ b/val/include/pal_interface.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -40,6 +40,9 @@ #define PAL_STATUS_PASS 0x0 #define PAL_STATUS_NO_TESTS 0x1 +#define PAL_SCMI_ANYNAME NULL +#define PAL_SCMI_ANYTHING 0xFFFFFFFF + #define SCMI_NAME_STR_SIZE 16 #define NUM_ELEMS(x) (sizeof(x) / sizeof((x)[0])) #define MAX_RETURNS_SIZE 32 @@ -54,6 +57,9 @@ int pal_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t leng void pal_send_message(uint32_t message_header_send, size_t parameter_count, const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); void pal_print(uint32_t level, const char *string, va_list args); void *pal_memcpy(void *dest, const void *src, size_t size); diff --git a/val/include/val_interface.h b/val/include/val_interface.h index 07a0a289c25a7634ccf74a888073fe55e952f4e9..39876ffdfe108862ee214d0684d22146f0fb1621 100644 --- a/val/include/val_interface.h +++ b/val/include/val_interface.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -124,10 +124,12 @@ int val_map_phys_to_virt(unsigned long paddr, size_t length, unsigned long *vadd int val_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length); void val_send_message(uint32_t msg_hdr, size_t num_parameter, uint32_t *parameter_buffer, uint32_t *rcvd_msg_hdr, int32_t *status, size_t *rcvd_buffer_size, uint32_t *rcvd_buffer); +void val_send_message_async(uint32_t msg_hdr, size_t num_parameter, uint32_t *parameter_buffer, + uint32_t *rcvd_msg_hdr, int32_t *status, size_t *rcvd_buffer_size, uint32_t *rcvd_buffer); void val_receive_delayed_response(uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); void val_receive_notification(uint32_t *message_header_rcv, size_t *return_values_count, - uint32_t *return_values); + uint32_t *return_values, uint32_t exp_proto_id, uint32_t exp_msg_id); uint32_t val_initialize_system(void *info); uint32_t val_test_initialize(uint32_t test_num, char *test_desc); void val_print_return_values(uint32_t count, uint32_t *values); @@ -195,7 +197,7 @@ typedef enum { POWER_STATE_GET, POWER_STATE_NOTIFY, POWER_STATE_CHANGE_REQUESTED_NOTIFY, - POWER_STATE_DOMAIN_NAME_GET, + POWER_DOMAIN_NAME_GET, POWER_PROTOCOL_INVALID_COMMAND } POWER_DOMAIN_COMMANDS; diff --git a/val/val_interface.c b/val/val_interface.c index 136878fdf05c597ed447d3216ca59a445c6984c8..cdd56df4a109375f3ac72e823f5709a3d0ef6690 100644 --- a/val/val_interface.c +++ b/val/val_interface.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2019-2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2019-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,6 +25,8 @@ static uint64_t g_test_skip; static uint32_t g_protocol_list; +static uint32_t monotonic_token; + /** @brief This function forms the command message header 1. Caller - ACK. @@ -37,6 +39,7 @@ uint32_t val_msg_hdr_create(uint32_t protocol_id, uint32_t msg_id, uint32_t msg_ { uint32_t msg_hdr = 0; + msg_hdr = msg_hdr | ((monotonic_token++ & 0x3FF) << 18); msg_hdr = msg_hdr | (protocol_id << 10); msg_hdr = msg_hdr | (msg_type << 8); msg_hdr = msg_hdr | msg_id; @@ -45,8 +48,7 @@ uint32_t val_msg_hdr_create(uint32_t protocol_id, uint32_t msg_id, uint32_t msg_ } /** - @brief This function forms the command message header - 1. Caller - ACK. + @brief This function initialize system if required @param none @return none **/ @@ -187,6 +189,11 @@ uint32_t val_compare_msg_hdr(uint32_t sent_msg_hdr, uint32_t rcvd_msg_hdr) **/ uint32_t val_compare(char *parameter, uint32_t rcvd_val, uint32_t exp_val) { + if (exp_val == PAL_SCMI_ANYTHING) { + val_print(VAL_PRINT_TEST, "\n CHECK %s: PASSED [0x%08x] ", parameter, rcvd_val); + return VAL_STATUS_PASS; + } + if (rcvd_val != exp_val) { val_print(VAL_PRINT_ERR, "\n CHECK %s: FAILED", parameter); val_print(VAL_PRINT_ERR, "\n EXPECTED : 0x%08x ", exp_val); @@ -209,6 +216,11 @@ uint32_t val_compare(char *parameter, uint32_t rcvd_val, uint32_t exp_val) **/ uint32_t val_compare_str(char *parameter, char *rcvd_val, char *exp_val, uint32_t len) { + if (exp_val == PAL_SCMI_ANYNAME) { + val_print(VAL_PRINT_TEST, "\n CHECK %s: PASSED [%s] ", parameter, rcvd_val); + return VAL_STATUS_PASS; + } + if (val_strcmp((uint8_t *)rcvd_val, (uint8_t *)exp_val, len)) { val_print(VAL_PRINT_ERR, "\n CHECK %s: FAILED", parameter); val_print(VAL_PRINT_ERR, "\n EXPECTED : %s ", exp_val); @@ -389,6 +401,19 @@ uint32_t val_compare_return_count(uint32_t received, uint32_t expected) return VAL_STATUS_PASS; } +static void val_message_dump(uint32_t msg_hdr, size_t num_parameter, uint32_t *parameter_buffer) +{ + uint32_t i; + + val_print(VAL_PRINT_DEBUG, "\n MSG HDR : 0x%08x", msg_hdr); + val_print(VAL_PRINT_DEBUG, "\n NUM PARAM : %d", num_parameter); + + for (i = 0; i < num_parameter; i++) + { + val_print(VAL_PRINT_DEBUG, "\n PARAMETER[%02d] : 0x%08x", i, parameter_buffer[i]); + } +} + /** @brief This function is used to map a physical address in the virtual memory space of the process @@ -439,31 +464,76 @@ void val_send_message(uint32_t msg_hdr, size_t num_parameter, uint32_t *paramete uint32_t *rcvd_msg_hdr, int32_t *status, size_t *rcvd_buffer_size, uint32_t *rcvd_buffer) { - uint32_t i; - - val_print(VAL_PRINT_DEBUG, "\n MSG HDR : 0x%08x", msg_hdr); - val_print(VAL_PRINT_DEBUG, "\n NUM PARAM : %d", num_parameter); - - for (i = 0; i < num_parameter; i++) - { - val_print(VAL_PRINT_DEBUG, "\n PARAMETER[%02d] : 0x%08x", i, parameter_buffer[i]); - } + val_message_dump(msg_hdr, num_parameter, parameter_buffer); pal_send_message(msg_hdr, num_parameter, parameter_buffer, rcvd_msg_hdr, status, rcvd_buffer_size, rcvd_buffer); } +/** + @brief This function is used to send async command data to platform and receive response + 1. Caller - Test Suite. + @param msg_hdr Command message + @param num_parameter Number of parameter sent to platform + @param parameter_buffer Buffer of sent parameters + @param rcvd_msg_hdr message header received from platform + @param status Status of command processed + @param rcvd_buffer_size Size of return buffer + @param rcvd_buffer return values buffer + @return none +**/ +void val_send_message_async(uint32_t msg_hdr, size_t num_parameter, uint32_t *parameter_buffer, + uint32_t *rcvd_msg_hdr, int32_t *status, size_t *rcvd_buffer_size, + uint32_t *rcvd_buffer) +{ + val_message_dump(msg_hdr, num_parameter, parameter_buffer); + + pal_send_message_async(msg_hdr, num_parameter, parameter_buffer, rcvd_msg_hdr, status, + rcvd_buffer_size, rcvd_buffer); +} + /** @brief This API is used to receive notifications from platform 1. Caller - Test Suite. @param message header received @param return values count @param return values list + @param exp_proto_id + @param exp_msg_id **/ void val_receive_notification(uint32_t *message_header_rcv, size_t *return_values_count, - uint32_t *return_values) -{ - pal_receive_notification(message_header_rcv, return_values_count, return_values); + uint32_t *return_values, uint32_t exp_proto_id, + uint32_t exp_msg_id) +{ + int retries = 10; + bool found = false, timeout = false; + + /* + * Receiving notifications can be tricky since other activity on the system, + * other than the one triggered by the test suite itself, can generate any + * kind of unrelated notification. + * + * In order to handle this, keep on consuming any received notification + * until we found the expected one or we timeout. + * + * Bail out after max_retries anyway to avoid endless loop in case of a + * constant flow of unrelated notifications. + */ + do { + /* Reset before next attempt */ + *return_values_count = 0; + pal_receive_notification(message_header_rcv, return_values_count, return_values); + if (*return_values_count != 0) { + val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : %08x", *message_header_rcv); + if (!val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(*message_header_rcv, 10, 17), exp_proto_id) && + !val_compare("MSG TYPE ", VAL_EXTRACT_BITS(*message_header_rcv, 8, 9), NOTIFICATION_MSG) && + !val_compare("MSG ID ", VAL_EXTRACT_BITS(*message_header_rcv, 0, 7), exp_msg_id)) + found = true; + } else { + val_print(VAL_PRINT_ERR, "\n TIMEOUT WAITING FOR NOTIFICATION - Proto: %02x Msg:%02x", exp_proto_id, exp_msg_id); + timeout = true; + } + } while (!timeout && !found && --retries); } /**