mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-03 13:39:53 +00:00
Preventing instruction fetch from RAM for Link except iram.text, which is used for hibernation. Stm32 on Snow does not support MPU. Tested on Link using commands 'crash nxtext/nxdata/nxstack', which run code from .iram.text, .data section, and the stack, respectively: ... RAM locked. Exclusion 20005980-200059a0 ... > crash nxtext Running from 20005984 > crash nxdata === PROCESS EXCEPTION: 04 ====== xPSR: 61000000 === r0 :00000000 r1 :0000dff2 r2 :00000005 r3 :0000086d r4 :00000000 r5 :00000032 r6 :2000544c r7 :00000000 r8 :00000000 r9 :20005456 r10:00000000 r11:00000000 r12:20005961 sp :20002748 lr :000008d7 pc :20005960 Instruction access violation mmfs = 1, shcsr = 70001, hfsr = 0, dfsr = 0 =========== Process Stack Contents =========== 200027b0: 0000086d 00000002 0000d504 00009f27 200027c0: 2000544c 20005452 00000000 00000000 200027d0: 00000000 00000000 00000000 00000000 200027e0: 00000000 00000000 00000000 00000cbb Rebooting... > crash nxstack === PROCESS EXCEPTION: 04 ====== xPSR: 20000200 === r0 :00000070 r1 :00000047 r2 :00000000 r3 :200027a8 r4 :00000000 r5 :00000001 r6 :2000544c r7 :00000000 r8 :00000000 r9 :20005456 r10:00000000 r11:00000000 r12:00000002 sp :20002740 lr :00000913 pc :200027ac Instruction access violation mmfs = 1, shcsr = 70001, hfsr = 0, dfsr = 0 =========== Process Stack Contents =========== 200027ac: 00000070 00000047 00000002 0000d57c 200027bc: 00009f9f 2000544c 20005452 00000000 200027cc: 00000000 00000000 00000000 00000000 200027dc: 00000000 00000000 00000000 00000000 Rebooting... BUG=chrome-os-partner:16904 BRANCH=master TEST=stated above Change-Id: I7c6593c527f29609442f33550f9d16755f32297c Signed-off-by: Daisuke Nojiri <dnojiri@google.com> Reviewed-on: https://chromium-review.googlesource.com/51337 Reviewed-by: Randall Spangler <rspangler@chromium.org>
85 lines
2.2 KiB
C
85 lines
2.2 KiB
C
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* MPU module for Cortex-M3 */
|
|
|
|
#ifndef __CROS_EC_MPU_H
|
|
#define __CROS_EC_MPU_H
|
|
|
|
#include "common.h"
|
|
|
|
#define MPU_TYPE REG32(0xe000ed90)
|
|
#define MPU_CTRL REG32(0xe000ed94)
|
|
#define MPU_NUMBER REG32(0xe000ed98)
|
|
#define MPU_BASE REG32(0xe000ed9c)
|
|
#define MPU_SIZE REG16(0xe000eda0)
|
|
#define MPU_ATTR REG16(0xe000eda2)
|
|
|
|
#define MPU_CTRL_PRIVDEFEN (1 << 2)
|
|
#define MPU_CTRL_HFNMIENA (1 << 1)
|
|
#define MPU_CTRL_ENABLE (1 << 0)
|
|
#define MPU_ATTR_NX (1 << 12)
|
|
#define MPU_ATTR_NOACCESS (0 << 8)
|
|
#define MPU_ATTR_FULLACCESS (3 << 8)
|
|
/* Suggested in table 3-6 of Stellaris LM4F232H5QC Datasheet and table 38 of
|
|
* STM32F10xxx Cortex-M3 programming manual for internal sram. */
|
|
#define MPU_ATTR_INTERNALSRAM 6
|
|
|
|
/**
|
|
* Configure a region
|
|
*
|
|
* region: Number of the region to update
|
|
* addr: Base address of the region
|
|
* size: Size of the region in bytes
|
|
* attr: Attribute of the region. Current value will be overwritten if enable
|
|
* is set.
|
|
* enable: Enables the region if non zero. Otherwise, disables the region.
|
|
*
|
|
* Returns EC_SUCCESS on success or EC_ERROR_INVAL if a parameter is invalid.
|
|
*/
|
|
int mpu_config_region(uint8_t region, uint32_t addr, uint32_t size,
|
|
uint16_t attr, uint8_t enable);
|
|
|
|
/**
|
|
* Set a region non-executable.
|
|
*
|
|
* region: number of the region
|
|
* addr: base address of the region
|
|
* size: size of the region in bytes
|
|
*/
|
|
int mpu_nx_region(uint8_t region, uint32_t addr, uint32_t size);
|
|
|
|
/**
|
|
* Enable MPU */
|
|
void mpu_enable(void);
|
|
|
|
/**
|
|
* Returns the value of MPU type register
|
|
*
|
|
* Bit fields:
|
|
* [15:8] Number of the data regions implemented or 0 if MPU is not present.
|
|
* [1] 0: unified (no distinction between instruction and data)
|
|
* 1: separated
|
|
*/
|
|
uint32_t mpu_get_type(void);
|
|
|
|
/* Location of iram.text */
|
|
extern char __iram_text_start;
|
|
extern char __iram_text_end;
|
|
|
|
/**
|
|
* Lock down RAM
|
|
*/
|
|
int mpu_protect_ram(void);
|
|
|
|
/**
|
|
* Initialize MPU.
|
|
* It disables all regions if MPU is implemented. Otherwise, returns
|
|
* EC_ERROR_UNIMPLEMENTED.
|
|
*/
|
|
int mpu_pre_init(void);
|
|
|
|
#endif /* __CROS_EC_MPU_H */
|