Intel® Quark™ Microcontroller Software Interface  1.4.0
Intel® Quark™ Microcontroller BSP
qm_mpr.h
1 /*
2  * {% copyright %}
3  */
4 
5 #ifndef __QM_MPR_H__
6 #define __QM_MPR_H__
7 
8 #include "qm_common.h"
9 #include "qm_soc_regs.h"
10 
11 /**
12  * Memory Protection Region control for Quark Microcontrollers.
13  *
14  * @defgroup groupMPR MPR
15  * @{
16  */
17 
18 /* MPR mask enable. */
19 #define QM_SRAM_MPR_EN_MASK_ENABLE BIT(0)
20 /* MPR mask lock. */
21 #define QM_SRAM_MPR_EN_MASK_LOCK BIT(1)
22 /* MPR mask host. */
23 #define QM_SRAM_MPR_AGENT_MASK_HOST BIT(0)
24 /* MPR mask ss. */
25 #if (QUARK_SE)
26 #define QM_SRAM_MPR_AGENT_MASK_SS BIT(1)
27 #endif
28 /* MPR mask dma. */
29 #define QM_SRAM_MPR_AGENT_MASK_DMA BIT(2)
30 
31 typedef void (*qm_mpr_callback_t)(void *);
32 
33 /** SRAM Memory Protection Region configuration type. */
34 typedef struct {
35  uint8_t en_lock_mask; /**< Enable/lock bitmask */
36  uint8_t agent_read_en_mask; /**< Per-agent read enable bitmask */
37  uint8_t agent_write_en_mask; /**< Per-agent write enable bitmask */
38  uint8_t up_bound; /**< 1KB-aligned upper addr */
39  uint8_t low_bound; /**< 1KB-aligned lower addr */
41 
42 typedef enum {
43  MPR_VIOL_MODE_INTERRUPT = 0,
44  MPR_VIOL_MODE_RESET,
45  MPR_VIOL_MODE_PROBE
46 } qm_mpr_viol_mode_t;
47 
48 /**
49  * Configure SRAM controller's Memory Protection Region.
50  *
51  * @param [in] id Which MPR to configure.
52  * @param [in] cfg MPR configuration.
53  * @return int 0 on success, error code otherwise.
54  */
55 int qm_mpr_set_config(const qm_mpr_id_t id, const qm_mpr_config_t *const cfg);
56 
57 /**
58  * Configure MPR violation behaviour
59  *
60  * @param [in] mode (generate interrupt, warm reset, enter probe mode).
61  * @param [in] callback_fn for interrupt mode (only).
62  * @param [in] data user data for interrupt mode (only).
63  * @return int 0 on success, error code otherwise.
64  * */
65 int qm_mpr_set_violation_policy(const qm_mpr_viol_mode_t mode,
66  qm_mpr_callback_t callback_fn, void *data);
67 
68 /**
69  * Save MPR context.
70  *
71  * Save the configuration of the specified MPR peripheral
72  * before entering sleep.
73  *
74  * MPR configuration is lost after sleep and can therefore
75  * be modified even if this configuration was locked before sleep.
76  * To support persistent configuration, the configuration must be
77  * restored when resuming as part of the bootloader.
78  *
79  * @param[out] ctx MPR context structure. This must not be NULL.
80  *
81  * @return Standard errno return type for QMSI.
82  * @retval 0 on success.
83  * @retval Negative @ref errno for possible error codes.
84  */
86 
87 /**
88  * Restore MPR context.
89  *
90  * Restore the configuration of the specified MPR peripheral
91  * after exiting sleep.
92  *
93  * MPR configuration is lost after sleep and can therefore
94  * be modified even if this configuration was locked before sleep.
95  * To support persistent configuration, the configuration must be
96  * restored when resuming as part of the bootloader.
97  *
98  * @param[in] ctx MPR context structure. This must not be NULL.
99  *
100  * @return Standard errno return type for QMSI.
101  * @retval 0 on success.
102  * @retval Negative @ref errno for possible error codes.
103  */
104 int qm_mpr_restore_context(const qm_mpr_context_t *const ctx);
105 
106 /**
107  * @}
108  */
109 
110 #endif /* __QM_MPR_H__ */
int qm_mpr_set_violation_policy(const qm_mpr_viol_mode_t mode, qm_mpr_callback_t callback_fn, void *data)
Configure MPR violation behaviour.
Definition: qm_mpr.c:89
qm_mpr_id_t
Definition: qm_soc_regs.h:1286
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
MPR context type.
Definition: qm_soc_regs.h:1629
uint8_t en_lock_mask
Enable/lock bitmask.
Definition: qm_mpr.h:35
int qm_mpr_restore_context(const qm_mpr_context_t *const ctx)
Restore MPR context.
Definition: qm_mpr.c:167
uint8_t low_bound
1KB-aligned lower addr
Definition: qm_mpr.h:39
uint8_t up_bound
1KB-aligned upper addr
Definition: qm_mpr.h:38
int qm_mpr_save_context(qm_mpr_context_t *const ctx)
Save MPR context.
Definition: qm_mpr.c:160
uint8_t agent_write_en_mask
Per-agent write enable bitmask.
Definition: qm_mpr.h:37
SRAM Memory Protection Region configuration type.
Definition: qm_mpr.h:34
uint8_t agent_read_en_mask
Per-agent read enable bitmask.
Definition: qm_mpr.h:36