Changeset 7b968a2e in rtems


Ignore:
Timestamp:
12/09/22 09:20:17 (4 months ago)
Author:
Christian Mauderer <christian.mauderer@…>
Branches:
master
Children:
f845b95a
Parents:
26050b5f
git-author:
Christian Mauderer <christian.mauderer@…> (12/09/22 09:20:17)
git-committer:
Christian Mauderer <christian.mauderer@…> (12/15/22 08:20:52)
Message:

bsps/atsam: Add NULL pointer protection

Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • bsps/arm/atsam/README

    r26050b5f r7b968a2e  
    6060console devices (used by default).
    6161
     62Use ATSAM_MEMORY_NULL_SIZE=XYZ to set the size of NULL pointer protection area
     63in bytes (default 0x00000000).
     64
    6265Use ATSAM_MEMORY_TCM_SIZE=XYZ to set the size of tightly coupled memories (TCM)
    63 in bytes (default 0x00000000).
     66in bytes (default 0x00000000). Note: ITCM is reduced by the
     67ATSAM_MEMORY_NULL_SIZE.
    6468
    6569Use ATSAM_MEMORY_INTFLASH_SIZE=XYZ to set the size of internal flash in bytes
  • bsps/arm/atsam/contrib/libraries/libboard/source/board_lowlevel.c

    r26050b5f r7b968a2e  
    348348                                   | SCB_SHCSR_USGFAULTENA_Msk);
    349349
     350#ifdef __rtems__
     351        dwRegionBaseAddr =
     352                ((uintptr_t)atsam_memory_null_begin) |
     353                MPU_REGION_VALID |
     354                MPU_NULL_REGION;
     355        if (atsam_memory_null_begin != atsam_memory_itcm_end) {
     356                dwRegionAttr =
     357                        MPU_AP_NO_ACCESS |
     358                        MPU_REGION_EXECUTE_NEVER |
     359                        MPU_CalMPURegionSize((uintptr_t)atsam_memory_null_size) |
     360                        MPU_REGION_ENABLE;
     361        } else {
     362                dwRegionAttr = MPU_REGION_DISABLE;
     363        }
     364        MPU_SetRegion(dwRegionBaseAddr, dwRegionAttr);
     365#endif /* __rtems__ */
     366
    350367        /* Enable the MPU region */
    351368#ifndef __rtems__
  • bsps/arm/atsam/include/bsp.h

    r26050b5f r7b968a2e  
    9090} if_atsam_config;
    9191
     92extern char atsam_memory_null_begin[];
     93extern char atsam_memory_null_end[];
     94extern char atsam_memory_null_size[];
     95
    9296extern char atsam_memory_dtcm_begin[];
    9397extern char atsam_memory_dtcm_end[];
  • bsps/arm/atsam/include/libchip/include/mpu.h

    r26050b5f r7b968a2e  
    5757#define MPU_SYSTEM_REGION                       (12)
    5858#ifdef __rtems__
     59#define MPU_NULL_REGION                         (13)
    5960/* Reserve the region with highest priority for user applications */
    6061#define MPU_USER_DEFINED_REGION                 (15)
  • bsps/arm/atsam/start/bspstarthooks.c

    r26050b5f r7b968a2e  
    107107  uint32_t itcmcr_sz;
    108108
    109   tcm_size = (uintptr_t) atsam_memory_itcm_size;
     109  tcm_size = (uintptr_t) atsam_memory_dtcm_size;
    110110  itcmcr_sz = (SCB->ITCMCR & SCB_ITCMCR_SZ_Msk) >> SCB_ITCMCR_SZ_Pos;
    111111
  • spec/build/bsps/arm/atsam/bspatsam.yml

    r26050b5f r7b968a2e  
    297297- role: build-dependency
    298298  uid: optnocachesz
     299- role: build-dependency
     300  uid: optnullsz
    299301- role: build-dependency
    300302  uid: optoscmain
  • spec/build/bsps/arm/atsam/linkcmds.yml

    r26050b5f r7b968a2e  
    33content: |
    44  MEMORY {
    5     ITCM      : ORIGIN = 0x00000000, LENGTH = ${ATSAM_MEMORY_TCM_SIZE}
     5    NULL      : ORIGIN = 0x00000000, LENGTH = ${ATSAM_MEMORY_NULL_SIZE}
     6    ITCM      : ORIGIN = ${ATSAM_MEMORY_NULL_SIZE}, LENGTH = ((${ATSAM_MEMORY_TCM_SIZE} > ${ATSAM_MEMORY_NULL_SIZE}) ? (${ATSAM_MEMORY_TCM_SIZE} - ${ATSAM_MEMORY_NULL_SIZE}) : 0)
    67    INTFLASH  : ORIGIN = 0x00400000, LENGTH = ${ATSAM_MEMORY_INTFLASH_SIZE}
    78    DTCM      : ORIGIN = 0x20000000, LENGTH = ${ATSAM_MEMORY_TCM_SIZE}
     
    1314
    1415  /* Must be used only for MPU definitions */
     16
     17  atsam_memory_null_begin = ORIGIN (NULL);
     18  atsam_memory_null_end = ORIGIN (NULL) + LENGTH (NULL);
     19  atsam_memory_null_size = LENGTH (NULL);
    1520
    1621  atsam_memory_itcm_begin = ORIGIN (ITCM);
  • spec/build/bsps/arm/atsam/opttcmsz.yml

    r26050b5f r7b968a2e  
    1010default-by-variant: []
    1111description: |
    12   size of tightly coupled memories (TCM) in bytes
     12  Size of tightly coupled memories (TCM) in bytes.  Note that the ITCM is
     13  reduced by the ATSAM_MEMORY_NULL_SIZE option.  DTCM is unaffected.
    1314enabled-by: true
    1415format: '{:#010x}'
Note: See TracChangeset for help on using the changeset viewer.