-
Notifications
You must be signed in to change notification settings - Fork 8.1k
riscv: pmp: Add macro to convert DT memory attributes to PMP permissions #97499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fsammoura1980
wants to merge
1
commit into
zephyrproject-rtos:main
Choose a base branch
from
fsammoura1980:dt_mem_riscv
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+69
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,13 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(riscv_pmp) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE ${app_sources}) | ||
|
||
target_include_directories(app PRIVATE | ||
${ZEPHYR_BASE}/kernel/include | ||
${ZEPHYR_BASE}/arch/${ARCH}/include | ||
) |
This file contains hidden or 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,3 @@ | ||
CONFIG_ZTEST=y | ||
CONFIG_MULTITHREADING=y | ||
CONFIG_RISCV_PMP=y |
This file contains hidden or 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,35 @@ | ||
/* Copyright (c) 2022 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <kernel_internal.h> | ||
#include <zephyr/tc_util.h> | ||
#include <zephyr/ztest.h> | ||
|
||
ZTEST(riscv_pmp_general, test_dt_pmp_perm_conversion) | ||
{ | ||
uint8_t result; | ||
|
||
result = DT_MEM_RISCV_TO_PMP_PERM(0); | ||
zassert_equal(result, 0, "Expected 0, got 0x%x", result); | ||
|
||
result = DT_MEM_RISCV_TO_PMP_PERM(DT_MEM_RISCV_TYPE_IO_R); | ||
zassert_equal(result, PMP_R, "Expected PMP_R (0x%x), got 0x%x", PMP_R, result); | ||
|
||
result = DT_MEM_RISCV_TO_PMP_PERM(DT_MEM_RISCV_TYPE_IO_W); | ||
zassert_equal(result, PMP_W, "Expected PMP_W (0x%x), got 0x%x", PMP_W, result); | ||
|
||
result = DT_MEM_RISCV_TO_PMP_PERM(DT_MEM_RISCV_TYPE_IO_X); | ||
zassert_equal(result, PMP_X, "Expected PMP_X (0x%x), got 0x%x", PMP_X, result); | ||
|
||
result = DT_MEM_RISCV_TO_PMP_PERM(DT_MEM_RISCV_TYPE_IO_R | DT_MEM_RISCV_TYPE_IO_W); | ||
zassert_equal(result, PMP_R | PMP_W, "Expected R|W (0x%x), got 0x%x", PMP_R | PMP_W, | ||
result); | ||
|
||
result = DT_MEM_RISCV_TO_PMP_PERM(DT_MEM_RISCV_TYPE_IO_R | DT_MEM_RISCV_TYPE_IO_W | | ||
DT_MEM_RISCV_TYPE_IO_X); | ||
zassert_equal(result, PMP_R | PMP_W | PMP_X, "Expected R|W|X (0x%x), got 0x%x", | ||
PMP_R | PMP_W | PMP_X, result); | ||
} | ||
|
||
ZTEST_SUITE(riscv_pmp_general, NULL, NULL, NULL, NULL, NULL); |
This file contains hidden or 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,11 @@ | ||
common: | ||
platform_allow: | ||
- qemu_riscv32 | ||
- qemu_riscv32e | ||
- qemu_riscv64 | ||
filter: CONFIG_RISCV_PMP | ||
ignore_faults: true | ||
|
||
tests: | ||
arch.riscv.pmp.general: | ||
tags: test_framework |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro seems to be internal to PMP driver in #96241 (not for application) and is part of the CONFIG_MEM_ATTR with PMP.
Would you mind to integrate
test_dt_pmp_perm_conversion
into #96241, under tests/arch/riscv/pmp/mem-attr-entries/src/main.c? Thanks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I added it into #96241