include rt/arch/mpu.h from rt/mpu.h always on arm-none, fix rust bindings when mpu is available but task-mpu is disabled

This commit is contained in:
Chris Copeland 2024-06-06 09:16:19 -07:00
parent f7a1c0ca63
commit a08d7223a5
Signed by: chrisnc
GPG Key ID: 14550DA72485DF30
2 changed files with 6 additions and 7 deletions

View File

@ -8,7 +8,7 @@ extern "C" {
#define RT_MPU_TASK_REGIONS_ENABLE 0
#endif
#if RT_MPU_TASK_REGIONS_ENABLE
#if defined(__ARM_EABI__) && !defined(__linux__)
#include <rt/arch/mpu.h>
#endif

View File

@ -1,6 +1,4 @@
use core::assert;
use crate::{bindings::RT_MPU_ATTR_PERIPHERAL, task::Task};
use crate::bindings::RT_MPU_ATTR_PERIPHERAL;
#[cfg(any(mpu_v6m, mpu_v7m, mpu_v7r))]
mod v7 {
@ -152,7 +150,7 @@ mod v8m {
impl<const N: usize> Stack<N> {
pub const fn new() -> Stack<N> {
assert!(N % 32 == 0, "stack size must be a multiple of 32 bytes");
core::assert!(N % 32 == 0, "stack size must be a multiple of 32 bytes");
Stack { buf: [0u8; N] }
}
}
@ -197,10 +195,11 @@ mod v8m {
#[cfg(mpu_v8m)]
pub use v8m::{Region, Stack};
pub fn task_mpu_config_init<const N: usize>(task: &Task, regions: &[Region; N]) {
#[cfg(feature = "task-mpu")]
pub fn task_mpu_config_init<const N: usize>(task: &crate::task::Task, regions: &[Region; N]) {
let config = &mut unsafe { &mut *task.t.get() }.mpu_config;
// TODO: make this assert const
assert!(N <= config.regions.len(), "too many MPU regions");
core::assert!(N <= config.regions.len(), "too many MPU regions");
for (i, r) in regions.iter().enumerate() {
config.regions[i] = r.0;
}