Skip to content

Commit 59ca166

Browse files
author
Marko Kiiskila
committed
sys/defs; add default definitions for sec_XXX_core. New section
definitions for sec_XXX_secret. Place enc_flash structure within the secret section.
1 parent 04ff389 commit 59ca166

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

hw/bsp/native/src/hal_bsp.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "mcu/native_bsp.h"
3131
#include "mcu/mcu_hal.h"
3232
#include "hal/hal_i2c.h"
33+
#include "defs/sections.h"
3334
#include "ef_tinycrypt/ef_tinycrypt.h"
3435

3536
#if MYNEWT_VAL(SIM_ACCEL_PRESENT)
@@ -40,7 +41,7 @@ static struct sim_accel os_bsp_accel0;
4041
static struct uart_dev os_bsp_uart0;
4142
static struct uart_dev os_bsp_uart1;
4243

43-
static struct eflash_tinycrypt_dev ef_dev0 = {
44+
static sec_data_secret struct eflash_tinycrypt_dev ef_dev0 = {
4445
.etd_dev = {
4546
.efd_hal = {
4647
.hf_itf = &enc_flash_funcs,

hw/bsp/nrf52dk/src/hal_bsp.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "mcu/nrf52_hal.h"
3030
#include "mcu/nrf52_periph.h"
3131
#include "bsp/bsp.h"
32+
#include "defs/sections.h"
3233
#if MYNEWT_VAL(SOFT_PWM)
3334
#include "pwm/pwm.h"
3435
#include "soft_pwm/soft_pwm.h"
@@ -63,7 +64,7 @@ static const struct hal_bsp_mem_dump dump_cfg[] = {
6364
};
6465

6566
#if MYNEWT_VAL(ENC_FLASH_DEV)
66-
struct eflash_nrf5x_dev enc_flash_dev0 = {
67+
static sec_data_secret struct eflash_nrf5x_dev enc_flash_dev0 = {
6768
.end_dev = {
6869
.efd_hal = {
6970
.hf_itf = &enc_flash_funcs,

sys/defs/include/defs/sections.h

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef H_DEFS_SECTIONS_
21+
#define H_DEFS_SECTIONS_
22+
23+
#include <bsp/bsp.h>
24+
25+
#ifdef __cplusplus
26+
extern "C" {
27+
#endif
28+
29+
/**
30+
* BSP/MCU can specify special sections it wants to use.
31+
* But it does not have to, and if it doesn't define them, then here is the
32+
* default.
33+
*/
34+
/*
35+
* XXX explanation of when to use these 3?
36+
*/
37+
#ifndef sec_data_core
38+
#define sec_data_core
39+
#endif
40+
#ifndef sec_bss_core
41+
#define sec_bss_core
42+
#endif
43+
#ifndef sec_bss_nz_core
44+
#define sec_bss_nz_core
45+
#endif
46+
47+
/**
48+
* Sensitive data (eg keys), which should be excluded from corefiles.
49+
*/
50+
#ifndef sec_bss_secret
51+
#define sec_bss_secret
52+
#endif
53+
#ifndef sec_data_secret
54+
#define sec_data_secret
55+
#endif
56+
57+
#ifdef __cplusplus
58+
}
59+
#endif
60+
61+
62+
#endif /* H_DEFS_SECTIONS_ */

0 commit comments

Comments
 (0)