forked from ARM-software/SCP-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fch_polled/unit_test: Add unit tests for fch_polled
This change adds unit tests for new fch_polled module. Change-Id: Ia6ec7e5d009afd6c75cff3894ef4e7a98b4e19f3 Signed-off-by: Girish Pathak <[email protected]> Signed-off-by: Ahmed Gadallah <[email protected]>
- Loading branch information
1 parent
53823a0
commit db575b2
Showing
9 changed files
with
1,114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# Arm SCP/MCP Software | ||
# Copyright (c) 2023, Arm Limited and Contributors. All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
|
||
set(TEST_SRC mod_fch_polled) | ||
set(TEST_FILE mod_fch_polled) | ||
|
||
set(UNIT_TEST_TARGET mod_${TEST_MODULE}_unit_test) | ||
|
||
set(MODULE_SRC ${MODULE_ROOT}/${TEST_MODULE}/src) | ||
set(MODULE_INC ${MODULE_ROOT}/${TEST_MODULE}/include) | ||
list(APPEND OTHER_MODULE_INC ${MODULE_ROOT}/transport/include) | ||
list(APPEND OTHER_MODULE_INC ${MODULE_ROOT}/timer/include) | ||
|
||
set(MODULE_UT_SRC ${CMAKE_CURRENT_LIST_DIR}) | ||
set(MODULE_UT_INC ${CMAKE_CURRENT_LIST_DIR}) | ||
set(MODULE_UT_MOCK_SRC ${CMAKE_CURRENT_LIST_DIR}/mocks) | ||
|
||
list(APPEND MOCK_REPLACEMENTS fwk_module) | ||
list(APPEND MOCK_REPLACEMENTS fwk_core) | ||
list(APPEND MOCK_REPLACEMENTS fwk_interrupt) | ||
list(APPEND MOCK_REPLACEMENTS fwk_id) | ||
|
||
include(${SCP_ROOT}/unit_test/module_common.cmake) | ||
|
||
target_compile_definitions(${UNIT_TEST_TARGET} PRIVATE BUILD_HAS_MOD_TRANSPORT) | ||
target_compile_definitions(${UNIT_TEST_TARGET} PRIVATE BUILD_HAS_FAST_CHANNELS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Arm SCP/MCP Software | ||
* Copyright (c) 2023, Arm Limited and Contributors. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#include <Mockfwk_module.h> | ||
|
||
#include <mod_fch_polled.h> | ||
|
||
#include <fwk_element.h> | ||
#include <fwk_id.h> | ||
#include <fwk_macros.h> | ||
|
||
#define FCH_MIN_POLL_RATE_US 4000 | ||
|
||
#define SCP_SCMI_FAST_CHANNEL_BASE 0xA0000000 | ||
#define SCP_SYSTEM_ACCESS_PORT1_BASE 0xB0000000 | ||
|
||
#define FAKE_RATE_LIMIT 0x0FFF | ||
|
||
enum fake_fch_polled { | ||
FAKE_FCH_POLLED_0, | ||
FAKE_FCH_POLLED_1, | ||
FAKE_FCH_POLLED_COUNT, | ||
}; | ||
|
||
#define FCH_ADDR_INIT(scp_addr, ap_addr) \ | ||
&((struct mod_fch_polled_channel_config){ \ | ||
.fch_addr = { \ | ||
.local_view_address = scp_addr, \ | ||
.target_view_address = ap_addr, \ | ||
} }) | ||
|
||
static struct mod_fch_polled_config fake_fch_config = { | ||
.fch_alarm_id = FWK_ID_SUB_ELEMENT_INIT(FWK_MODULE_IDX_TIMER, 0, 0), | ||
.fch_poll_rate = FCH_MIN_POLL_RATE_US, | ||
.rate_limit = FAKE_RATE_LIMIT, | ||
}; | ||
|
||
static struct mod_fch_polled_config fake_fch_config_2 = { | ||
.fch_alarm_id = FWK_ID_SUB_ELEMENT_INIT(FWK_MODULE_IDX_TIMER, 0, 0), | ||
.fch_poll_rate = (FCH_MIN_POLL_RATE_US - 1), | ||
.rate_limit = FAKE_RATE_LIMIT, | ||
}; | ||
|
||
/*! | ||
*\brief Fast Channels in shared memory. Similar to mod_scmi_perf | ||
*/ | ||
struct mod_scmi_perf_fast_channel_limit { | ||
/*! Performance limit max. */ | ||
uint32_t range_max; | ||
/*! Performance limit min. */ | ||
uint32_t range_min; | ||
}; | ||
|
||
/*! | ||
*\brief Fast channels memory offset | ||
*/ | ||
enum mod_scmi_perf_fast_channel_memory_offset { | ||
MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_LEVEL_SET = 0, | ||
MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_LIMIT_SET = sizeof(uint32_t), | ||
MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_LEVEL_GET = | ||
sizeof(uint32_t) + sizeof(struct mod_scmi_perf_fast_channel_limit), | ||
MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_LIMIT_GET = | ||
sizeof(uint32_t) * 2 + sizeof(struct mod_scmi_perf_fast_channel_limit), | ||
MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_TOTAL = sizeof(uint32_t) * 2 + | ||
sizeof(struct mod_scmi_perf_fast_channel_limit) * 2 | ||
}; | ||
|
||
#define FCH_ADDRESS_LEVEL_SET(PERF_IDX) \ | ||
(SCP_SCMI_FAST_CHANNEL_BASE + \ | ||
MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_LEVEL_SET + \ | ||
(MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_TOTAL * PERF_IDX)) | ||
|
||
#define FCH_ADDRESS_LIMIT_SET(PERF_IDX) \ | ||
(SCP_SCMI_FAST_CHANNEL_BASE + \ | ||
MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_LIMIT_SET + \ | ||
(MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_TOTAL * PERF_IDX)) | ||
|
||
#define FCH_ADDRESS_LEVEL_SET_AP(PERF_IDX) \ | ||
(SCP_SCMI_FAST_CHANNEL_BASE + \ | ||
MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_LEVEL_SET + \ | ||
(MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_TOTAL * PERF_IDX) - \ | ||
SCP_SYSTEM_ACCESS_PORT1_BASE) | ||
|
||
#define FCH_ADDRESS_LIMIT_SET_AP(PERF_IDX) \ | ||
(SCP_SCMI_FAST_CHANNEL_BASE + \ | ||
MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_LIMIT_SET + \ | ||
(MOD_SCMI_PERF_FAST_CHANNEL_OFFSET_TOTAL * PERF_IDX) - \ | ||
SCP_SYSTEM_ACCESS_PORT1_BASE) | ||
|
||
static const struct fwk_element fake_fch_polled_element_table[] = { | ||
[0] = { | ||
.name = "FCH_0_LEVEL_SET", | ||
.data = FCH_ADDR_INIT( | ||
FCH_ADDRESS_LEVEL_SET(0), | ||
FCH_ADDRESS_LEVEL_SET_AP(0) | ||
) | ||
}, | ||
[1] = { | ||
.name = "FCH_0_LIMIT_SET", | ||
.data =FCH_ADDR_INIT( | ||
FCH_ADDRESS_LIMIT_SET(0), | ||
FCH_ADDRESS_LIMIT_SET_AP(0) | ||
), | ||
}, | ||
|
||
}; | ||
|
||
static const struct fwk_element *fch_polled_get_element_table( | ||
fwk_id_t module_id) | ||
{ | ||
return fake_fch_polled_element_table; | ||
} | ||
|
||
struct fwk_module_config config_fake_fch_polled = { | ||
.data = &fake_fch_config, | ||
.elements = FWK_MODULE_DYNAMIC_ELEMENTS(fch_polled_get_element_table), | ||
}; | ||
|
||
static fwk_id_t fake_fch_0 = | ||
FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_FCH_POLLED, FAKE_FCH_POLLED_0); | ||
|
||
static const fwk_id_t fake_fch_1 = | ||
FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_FCH_POLLED, FAKE_FCH_POLLED_1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Arm SCP/MCP Software | ||
* Copyright (c) 2023, Arm Limited and Contributors. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef TEST_FWK_MODULE_MODULE_IDX_H | ||
#define TEST_FWK_MODULE_MODULE_IDX_H | ||
|
||
#include <fwk_id.h> | ||
|
||
enum fwk_module_idx { | ||
FWK_MODULE_IDX_TRANSPORT, | ||
FWK_MODULE_IDX_TIMER, | ||
FWK_MODULE_IDX_FCH_POLLED, | ||
FWK_MODULE_IDX_COUNT, | ||
}; | ||
|
||
#endif /* TEST_FWK_MODULE_MODULE_IDX_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"DisableFormat": true, | ||
"SortIncludes": false, | ||
} |
Oops, something went wrong.