mirror of
https://github.com/lowRISC/ibex.git
synced 2025-04-22 04:47:25 -04:00
[examples/sw] Add a pmp smoke test
This commit is contained in:
parent
f8b6d468c3
commit
bb6427d276
2 changed files with 40 additions and 0 deletions
14
examples/sw/simple_system/pmp_smoke_test/Makefile
Normal file
14
examples/sw/simple_system/pmp_smoke_test/Makefile
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Copyright lowRISC contributors.
|
||||
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Generate a baremetal application
|
||||
|
||||
# Name of the program $(PROGRAM).c will be added as a source file
|
||||
PROGRAM = pmp_smoke_test
|
||||
PROGRAM_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
# Any extra source files to include in the build. Use the upper case .S
|
||||
# extension for assembly files
|
||||
EXTRA_SRCS :=
|
||||
|
||||
include ${PROGRAM_DIR}/../common/common.mk
|
26
examples/sw/simple_system/pmp_smoke_test/pmp_smoke_test.c
Normal file
26
examples/sw/simple_system/pmp_smoke_test/pmp_smoke_test.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright lowRISC contributors.
|
||||
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// Basic smoke test for PMP. The test sets up a read-only PMP region then tries
|
||||
// to write to it. It is intended for use with an external checking method (such
|
||||
// as the Ibex co-simulation system) and does not report pass or fail.
|
||||
|
||||
volatile unsigned int test_int = 10;
|
||||
|
||||
// Locked read only for lowest region, NA4 matching
|
||||
#define TEST_PMPCFG0 0x91
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
unsigned int pmpaddr0 = ((unsigned int)&test_int) >> 2;
|
||||
|
||||
__asm__ volatile(
|
||||
"csrw pmpaddr0, %1\n"
|
||||
"csrw pmpcfg0, %0\n"
|
||||
:
|
||||
: "r"(TEST_PMPCFG0), "r"(pmpaddr0));
|
||||
|
||||
test_int = 12;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue