blob: 94ba268666755c5bc5a1520484a877dcc89f12e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <service/test_runner/provider/backend/simple_c/simple_c_test_runner.h>
#include <config/interface/platform_config.h>
#include <stdint.h>
/**
* Secure Partition configuration tests for checking configuartion
* data passed to an SP at initialisation. These tests assume
* use of the FFA manifest for any SP deployments of
* deployments/env_test.
*/
/*
* Check that the loaded configuration includes one or more
* device regions.
*/
static bool check_device_region_loaded(struct test_failure *failure)
{
return platform_config_device_region_count() > 0;
}
/*
* Check that a device region for a 'trng' device has been loaded
* and that values are as expected.
*/
static bool check_trng_device_region_loaded(struct test_failure *failure)
{
bool passed = false;
struct device_region *dev_region = platform_config_device_query("trng", 0);
if (dev_region) {
passed =
(dev_region->dev_instance == 0) &&
(dev_region->io_region_size == 0x1000);
}
platform_config_device_query_free(dev_region);
return passed;
}
/*
* Check access to some trng registers
*/
static bool check_trng_register_access(struct test_failure *failure)
{
bool passed = false;
struct device_region *dev_region = platform_config_device_query("trng", 0);
if (dev_region) {
/* Expect reset values to be read from a selection of TRNG registers */
uint32_t reg_val;
passed = true;
/* PID4 */
if (passed) {
reg_val = *((volatile uint32_t*)((uint8_t*)dev_region->base_addr + 0xfd0));
passed = (reg_val == 0x00000004);
failure->line_num = __LINE__;
failure->info = reg_val;
}
/* PID0 */
if (passed) {
reg_val = *((volatile uint32_t*)((uint8_t*)dev_region->base_addr + 0xfe0));
passed = (reg_val == 0x000000aa);
failure->line_num = __LINE__;
failure->info = reg_val;
}
}
return passed;
}
/**
* Define an register test group
*/
void sp_config_tests_register(void)
{
static const struct simple_c_test_case sp_config_tests[] = {
{.name = "DevRegionLoaded", .test_func = check_device_region_loaded},
{.name = "TrngDevRegionLoaded", .test_func = check_trng_device_region_loaded},
{.name = "TrngRegAccess", .test_func = check_trng_register_access}
};
static const struct simple_c_test_group sp_config_test_group =
{
.group = "SpConfigTests",
.num_test_cases = sizeof(sp_config_tests)/sizeof(struct simple_c_test_case),
.test_cases = sp_config_tests
};
simple_c_test_runner_register_group(&sp_config_test_group);
}
|