Intel® Quark™ Microcontroller Software Interface  1.4.0
Intel® Quark™ Microcontroller BSP
ss_init.c
1 /*
2  * {% copyright %}
3  */
4 
5 #include "ss_init.h"
6 #include "qm_mpr.h"
7 
8 /* Sensor Subsystem application's pointer to the entry point (Flash0) */
9 #define SS_APP_PTR_ADDR (0x40000000)
10 
11 #if (UNIT_TEST)
12 uint32_t __sensor_reset_vector[1];
13 #else
14 extern uint32_t __sensor_reset_vector[];
15 #endif
16 
17 /* Set-up an MPR to protect ARC IVT (only ARC will have access to it). */
18 static void sensor_vectors_protect(void)
19 {
20  /*
21  * MPR config:
22  * - Enable and lock MPR
23  * - Allow R/W access to ARC only
24  * - Protect first kB of SRAM (i.e., where ARC IVT is located)
25  */
26  static const qm_mpr_config_t cfg = {
27  .en_lock_mask =
28  QM_SRAM_MPR_EN_MASK_ENABLE | QM_SRAM_MPR_EN_MASK_LOCK,
29  .agent_read_en_mask = QM_SRAM_MPR_AGENT_MASK_SS,
30  .agent_write_en_mask = QM_SRAM_MPR_AGENT_MASK_SS,
31  .up_bound = 0,
32  .low_bound = 0,
33  };
35 }
36 
38 {
39  /* Write the ARC reset vector.
40  *
41  * The ARC reset vector is in SRAM. The first 4 bytes of the Sensor
42  * Subsystem Flash partition point to the application entry point
43  * (pointer located at SS_APP_PTR_ADDR).
44  * Write the pointer to the application entry point into the reset
45  * vector.
46  */
47  volatile uint32_t *ss_reset_vector = __sensor_reset_vector;
48  volatile uint32_t *sensor_startup = (uint32_t *)SS_APP_PTR_ADDR;
49 
50  *ss_reset_vector = *sensor_startup;
51 
52  /* Set up an MPR to protect ARC IVT from other agents. */
53  sensor_vectors_protect();
54 
55  /* Request ARC Run */
56  QM_SCSS_SS->ss_cfg |= QM_SS_CFG_ARC_RUN_REQ_A;
57 }
int qm_mpr_set_config(const qm_mpr_id_t id, const qm_mpr_config_t *const cfg)
Configure SRAM controller's Memory Protection Region.
Definition: qm_mpr.c:24
uint8_t en_lock_mask
Enable/lock bitmask.
Definition: qm_mpr.h:35
void sensor_activation(void)
Initialise the sensor subsystem.
Definition: ss_init.c:37
SRAM Memory Protection Region configuration type.
Definition: qm_mpr.h:34
Memory Protection Region 1.
Definition: qm_soc_regs.h:1288