diff options
author | Yicheng Li <yichengli@chromium.org> | 2020-05-27 11:36:08 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-30 05:16:20 +0000 |
commit | 3590a14bcf9a1a575d41464285efe981f21dfdb6 (patch) | |
tree | ff3b47d98c4375315f3c4b54cde2004bc34af88d /test | |
parent | 77ae633c41e958ec91193c48ad3fbd6012d6739e (diff) | |
download | chrome-ec-3590a14bcf9a1a575d41464285efe981f21dfdb6.tar.gz |
test: Add on-device test for calculating MPU regions for RW
MPU logic needs to represent RW with no more than 2 MPU regions
when locking RW. Add on-device unit test for this calculation.
BRANCH=none
BUG=b:155410753
TEST=make -j BOARD=bloonchipper
TEST=make -j BOARD=nucleo-f412zg test-mpu
Then flash the test binary to nucleo board
runtest on device ==> Pass
Change-Id: Idc746efa9419d31cdae9c6fccc499c92160ac593
Signed-off-by: Yicheng Li <yichengli@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2218595
Diffstat (limited to 'test')
-rw-r--r-- | test/mpu.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/mpu.c b/test/mpu.c index b8c881364d..5675633087 100644 --- a/test/mpu.c +++ b/test/mpu.c @@ -6,6 +6,7 @@ #include <stdbool.h> #include "mpu.h" #include "mpu_private.h" +#include "string.h" #include "system.h" #include "test_util.h" @@ -21,12 +22,22 @@ struct mpu_info mpu_info = { .num_mpu_regions = 8, .mpu_is_unified = true }; + +struct mpu_rw_regions expected_rw_regions = { .num_regions = 2, + .addr = { 0x08060000, + 0x08080000 }, + .size = { 0x20000, 0x80000 } }; #elif defined(CHIP_VARIANT_STM32H7X3) struct mpu_info mpu_info = { .has_mpu = true, .num_mpu_regions = 16, .mpu_is_unified = true }; + +struct mpu_rw_regions expected_rw_regions = { .num_regions = 1, + .addr = { 0x08100000, + 0x08200000 }, + .size = { 0x100000, 0 } }; #else #error "MPU info not defined for this chip. Please add it." #endif @@ -155,6 +166,16 @@ test_static int test_mpu_protect_code_ram(void) return EC_SUCCESS; } +test_static int test_mpu_get_rw_regions(void) +{ + struct mpu_rw_regions rw_regions = mpu_get_rw_regions(); + int rv = memcmp(&rw_regions, &expected_rw_regions, + sizeof(expected_rw_regions)); + + TEST_EQ(rv, 0, "%d"); + return EC_SUCCESS; +} + void run_test(void) { enum ec_image cur_image = system_get_image_copy(); @@ -192,6 +213,8 @@ void run_test(void) RUN_TEST(reset_mpu); RUN_TEST(test_mpu_protect_data_ram); RUN_TEST(reset_mpu); + RUN_TEST(test_mpu_get_rw_regions); + RUN_TEST(reset_mpu); /* This test must be last because it generates a panic */ RUN_TEST(test_mpu_update_region_valid_region); RUN_TEST(reset_mpu); |