diff --git a/src/debug/tester/CMakeLists.txt b/src/debug/tester/CMakeLists.txt index a38b971ca72f..5b33427b3219 100644 --- a/src/debug/tester/CMakeLists.txt +++ b/src/debug/tester/CMakeLists.txt @@ -1,2 +1,3 @@ add_local_sources(tester.c) add_local_sources(tester_dummy_test.c) +add_local_sources(tester_simple_dram_test.c) diff --git a/src/debug/tester/llext/CMakeLists.txt b/src/debug/tester/llext/CMakeLists.txt index a629ef98ca7b..096cbf65d853 100644 --- a/src/debug/tester/llext/CMakeLists.txt +++ b/src/debug/tester/llext/CMakeLists.txt @@ -4,4 +4,5 @@ sof_llext_build("tester" SOURCES ../tester.c ../tester_dummy_test.c + ../tester_simple_dram_test.c ) diff --git a/src/debug/tester/tester.c b/src/debug/tester/tester.c index 105df8e2dfc6..63cc57a7ab34 100644 --- a/src/debug/tester/tester.c +++ b/src/debug/tester/tester.c @@ -16,6 +16,7 @@ #include #include "tester.h" #include "tester_dummy_test.h" +#include "tester_simple_dram_test.h" /** * Tester module is a framework for a runtime testing that need a special test code @@ -76,6 +77,9 @@ static int tester_init(struct processing_module *mod) case TESTER_MODULE_CASE_DUMMY_TEST: cd->tester_case_interface = &tester_interface_dummy_test; break; + case TESTER_MODULE_CASE_SIMPLE_DRAM_TEST: + cd->tester_case_interface = &tester_interface_simple_dram_test; + break; default: comp_err(dev, "Invalid config, unknown test type"); diff --git a/src/debug/tester/tester.h b/src/debug/tester/tester.h index 99796aa94c0a..ccfb8fabdc5a 100644 --- a/src/debug/tester/tester.h +++ b/src/debug/tester/tester.h @@ -15,6 +15,7 @@ #define TESTER_MODULE_CASE_NO_TEST 0 #define TESTER_MODULE_CASE_DUMMY_TEST 1 +#define TESTER_MODULE_CASE_SIMPLE_DRAM_TEST 2 /** * API of a test case diff --git a/src/debug/tester/tester_simple_dram_test.c b/src/debug/tester/tester_simple_dram_test.c new file mode 100644 index 000000000000..5114c66725c2 --- /dev/null +++ b/src/debug/tester/tester_simple_dram_test.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2025 Intel Corporation. All rights reserved. +// +// Author: Adrian Bonislawski + +#include "tester_simple_dram_test.h" +#include +#include +#include + +/* + * This is a simple test case for DRAM execution + * The test case will copy every 2nd frame of data + * by setting do_copy flag to true/false + */ + +struct tester_module_simple_dram_test_data { + bool do_copy_data; +}; + +static int validate_l3_memory(void *ptr) +{ + if (!((POINTER_TO_UINT(ptr) >= L3_MEM_BASE_ADDR) && + (POINTER_TO_UINT(ptr) < L3_MEM_BASE_ADDR + L3_MEM_SIZE))) + return -EINVAL; + + return 0; +} + +__cold static int simple_dram_test_case_init(struct processing_module *mod, void **ctx) +{ +#if !CONFIG_L3_HEAP + return -EINVAL; +#endif + struct tester_module_simple_dram_test_data *data = + rzalloc(0, 0, SOF_MEM_CAPS_L3, sizeof(*data)); + + if (!data) + return -ENOMEM; + + if (validate_l3_memory(data) != 0) { + rfree(data); + return -EINVAL; + } + + if (validate_l3_memory(tester_interface_simple_dram_test.init) != 0 || + validate_l3_memory(tester_interface_simple_dram_test.process) != 0 || + validate_l3_memory(tester_interface_simple_dram_test.free) != 0) { + rfree(data); + return -EINVAL; + } + + data->do_copy_data = false; + *ctx = data; + return 0; +} + +__cold static int simple_dram_test_case_process(void *ctx, struct processing_module *mod, + struct sof_source **sources, int num_of_sources, + struct sof_sink **sinks, int num_of_sinks, + bool *do_copy) +{ + struct tester_module_simple_dram_test_data *data = ctx; + + /* copy every second cycle */ + *do_copy = data->do_copy_data; + data->do_copy_data = !data->do_copy_data; + + return 0; +} + +__cold static int simple_dram_test_free(void *ctx, struct processing_module *mod) +{ + rfree(ctx); + return 0; +} + +const struct tester_test_case_interface tester_interface_simple_dram_test = { + .init = simple_dram_test_case_init, + .process = simple_dram_test_case_process, + .free = simple_dram_test_free +}; diff --git a/src/debug/tester/tester_simple_dram_test.h b/src/debug/tester/tester_simple_dram_test.h new file mode 100644 index 000000000000..86febb54c06e --- /dev/null +++ b/src/debug/tester/tester_simple_dram_test.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2025 Intel Corporation. + * + * Author: Adrian Bonislawski + */ + +#ifndef TESTER_SIMPLE_DRAM_TEST +#define TESTER_SIMPLE_DRAM_TEST + +#include +#include + +#include "tester.h" + +extern const struct tester_test_case_interface tester_interface_simple_dram_test; + +#endif /* TESTER_DUMMY_TEST */