kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/mpu_hal' into 'master'
soc: mpu hal fixes See merge request espressif/esp-idf!7895pull/5106/head
commit
5d3591c037
|
@ -22,7 +22,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline uint32_t cpu_ll_id_to_addr(int id)
|
||||
static inline uint32_t mpu_ll_id_to_addr(int id)
|
||||
{
|
||||
// vpn - id
|
||||
// 0x00000000 = 0
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline uint32_t cpu_ll_id_to_addr(int id)
|
||||
static inline uint32_t mpu_ll_id_to_addr(int id)
|
||||
{
|
||||
// vpn - id
|
||||
// 0x00000000 = 0
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
void mpu_hal_set_region_access(int id, mpu_access_t access)
|
||||
{
|
||||
uint32_t addr = cpu_ll_id_to_addr(id);
|
||||
uint32_t addr = mpu_ll_id_to_addr(id);
|
||||
|
||||
switch (access)
|
||||
{
|
||||
|
@ -48,6 +48,9 @@ void mpu_hal_set_region_access(int id, mpu_access_t access)
|
|||
case MPU_REGION_RWX:
|
||||
mpu_ll_set_region_rwx(addr);
|
||||
break;
|
||||
case MPU_REGION_ILLEGAL:
|
||||
mpu_ll_set_region_illegal(addr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include "unity.h"
|
||||
|
||||
#include "esp_attr.h"
|
||||
|
||||
#include "hal/mpu_hal.h"
|
||||
|
||||
volatile static int RTC_NOINIT_ATTR access = 0;
|
||||
|
||||
static void trigger_illegal_access(void)
|
||||
{
|
||||
access = 0;
|
||||
intptr_t addr = 0x60000000;
|
||||
volatile int __attribute__((unused)) val = 0;
|
||||
|
||||
val = *((int*) addr);
|
||||
++access;
|
||||
TEST_ASSERT_EQUAL(1, access);
|
||||
printf("Sucessfully accessed location %p\r\n", (void*)addr);
|
||||
|
||||
mpu_hal_set_region_access(3, MPU_REGION_ILLEGAL); // 0x60000000
|
||||
++access;
|
||||
|
||||
val = *((int*) addr);
|
||||
++access;
|
||||
}
|
||||
|
||||
void check_access(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(2, access);
|
||||
}
|
||||
|
||||
TEST_CASE_MULTIPLE_STAGES("Can set illegal access regions", "[soc][mpu]",
|
||||
trigger_illegal_access,
|
||||
check_access);
|
Ładowanie…
Reference in New Issue