RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
memscrub.h
1/* MEMSCRUB driver interface
2 *
3 * COPYRIGHT (c) 2017.
4 * Cobham Gaisler AB.
5 *
6 * The license and distribution terms for this file may be
7 * found in the file LICENSE in this distribution or at
8 * http://www.rtems.org/license/LICENSE.
9 */
10
11#ifndef __MEMSCRUB_H__
12#define __MEMSCRUB_H__
13
14#include <stdint.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#define MEMSCRUB_ERR_OK 0
21#define MEMSCRUB_ERR_EINVAL -1
22#define MEMSCRUB_ERR_ERROR -2
23
24extern void memscrub_register_drv(void);
25
26/*
27 * MEMORYSCRUBBER CONFIG register fields
28 */
29#define CONFIG_DELAY_BIT 8
30#define CONFIG_IRQD_BIT 7
31#define CONFIG_SERA_BIT 5
32#define CONFIG_LOOP_BIT 4
33#define CONFIG_MODE_BIT 2
34#define CONFIG_ES_BIT 1
35#define CONFIG_SCEN_BIT 0
36
37#define CONFIG_DELAY (0xff << CONFIG_DELAY_BIT)
38#define CONFIG_IRQD (0x1 << CONFIG_IRQD_BIT)
39#define CONFIG_SERA (0x1 << CONFIG_SERA_BIT)
40#define CONFIG_LOOP (0x1 << CONFIG_LOOP_BIT)
41#define CONFIG_MODE (0x3 << CONFIG_MODE_BIT)
42#define CONFIG_ES (0x1 << CONFIG_ES_BIT)
43#define CONFIG_SCEN (0x1 << CONFIG_SCEN_BIT)
44#define CONFIG_MODE_SCRUB (0x0 << CONFIG_MODE_BIT)
45#define CONFIG_MODE_REGEN (0x1 << CONFIG_MODE_BIT)
46#define CONFIG_MODE_INIT (0x2 << CONFIG_MODE_BIT)
47
48#define MEMSCRUB_OPTIONS_INTERRUPTDONE_ENABLE CONFIG_IRQD
49#define MEMSCRUB_OPTIONS_INTERRUPTDONE_DISABLE 0
50#define MEMSCRUB_OPTIONS_EXTERNALSTART_ENABLE CONFIG_ES
51#define MEMSCRUB_OPTIONS_EXTERNALSTART_DISABLE 0
52#define MEMSCRUB_OPTIONS_LOOPMODE_ENABLE CONFIG_LOOP
53#define MEMSCRUB_OPTIONS_LOOPMODE_DISABLE 0
54#define MEMSCRUB_OPTIONS_SECONDARY_MEMRANGE_ENABLE CONFIG_SERA
55#define MEMSCRUB_OPTIONS_SECONDARY_MEMRANGE_DISABLE 0
56
57/* Scrubbing modes */
58extern int memscrub_init_start(uint32_t value, uint8_t delay, int options);
59extern int memscrub_scrub_start(uint8_t delay, int options);
60extern int memscrub_regen_start(uint8_t delay, int options);
61extern int memscrub_stop(void);
62extern int memscrub_active(void);
63
64/* Set/get memory ranges */
65extern int memscrub_range_set(uint32_t start, uint32_t end);
66extern int memscrub_range_get(uint32_t * start, uint32_t * end);
67extern int memscrub_secondary_range_set(uint32_t start, uint32_t end);
68extern int memscrub_secondary_range_get(uint32_t * start, uint32_t * end);
69
70/* Interrupts */
71/* MEMSCRUB Interrupts */
72/* Function Interrupt-Code ISR callback prototype.
73 * arg - Custom arg provided by user
74 * access - AHB Access that failed
75 * ahbstatus - AHB status register of the MEMSCRUB core
76 * status - status register of the MEMSCRUB core
77 */
78typedef void (*memscrub_isr_t)(void *arg, uint32_t ahbaccess,
79 uint32_t ahbstatus, uint32_t scrubstatus);
80extern int memscrub_isr_register(memscrub_isr_t isr, void * data);
81extern int memscrub_isr_unregister(void);
82
83extern int memscrub_error_status(uint32_t *ahbaccess, uint32_t *ahbstatus,
84 uint32_t *scrubstatus);
85
86/* Set the different error thresholds. */
87
88/*
89 * MEMORYSCRUBBER AHBS register fields
90 */
91#define AHBS_CECNT_BIT 22
92#define AHBS_UECNT_BIT 14
93#define AHBS_DONE_BIT 13
94#define AHBS_SEC_BIT 11
95#define AHBS_SBC_BIT 10
96#define AHBS_CE_BIT 9
97#define AHBS_NE_BIT 8
98#define AHBS_HW_BIT 7
99#define AHBS_HM_BIT 3
100#define AHBS_HS_BIT 0
101
102#define AHBS_CECNT (0x3ff << AHBS_CECNT_BIT)
103#define AHBS_UECNT (0xff << AHBS_UECNT_BIT)
104#define AHBS_DONE (1 << AHBS_DONE_BIT)
105#define AHBS_SEC (1 << AHBS_SEC_BIT)
106#define AHBS_SBC (1 << AHBS_SBC_BIT)
107#define AHBS_CE (1 << AHBS_CE_BIT)
108#define AHBS_NE (1 << AHBS_NE_BIT)
109#define AHBS_HW (1 << AHBS_HW_BIT)
110#define AHBS_HM (0xf << AHBS_HM_BIT)
111#define AHBS_HS (0x7 << AHBS_HS_BIT)
112
113/*
114 * MEMORYSCRUBBER STAT register fields
115 */
116#define STAT_RUNCOUNT_BIT 22
117#define STAT_BLKCOUNT_BIT 14
118#define STAT_DONE_BIT 13
119#define STAT_BURSTLEN_BIT 1
120#define STAT_ACTIVE_BIT 0
121
122#define STAT_RUNCOUNT (0x3ff << STAT_RUNCOUNT_BIT)
123#define STAT_BLKCOUNT (0xff << STAT_BLKCOUNT_BIT)
124#define STAT_DONE (0x1 << STAT_DONE_BIT)
125#define STAT_BURSTLEN (0xf << STAT_BURSTLEN_BIT)
126#define STAT_ACTIVE (0x1 << STAT_ACTIVE_BIT)
127
128/*
129 * MEMORYSCRUBBER AHBERC register fields
130 */
131#define AHBERC_CECNTT_BIT 22
132#define AHBERC_UECNTT_BIT 14
133#define AHBERC_CECTE_BIT 1
134#define AHBERC_UECTE_BIT 0
135
136#define AHBERC_CECNTT (0x3ff << AHBERC_CECNTT_BIT)
137#define AHBERC_UECNTT (0xff << AHBERC_UECNTT_BIT)
138#define AHBERC_CECTE (0x1 << AHBERC_CECTE_BIT)
139#define AHBERC_UECTE (0x1 << AHBERC_UECTE_BIT)
140
141/*
142 * MEMORYSCRUBBER ETHRES register fields
143 */
144#define ETHRES_RECT_BIT 22
145#define ETHRES_BECT_BIT 14
146#define ETHRES_RECTE_BIT 1
147#define ETHRES_BECTE_BIT 0
148
149#define ETHRES_RECT (0x3ff << ETHRES_RECT_BIT)
150#define ETHRES_BECT (0xff << ETHRES_BECT_BIT)
151#define ETHRES_RECTE (0x1 << ETHRES_RECTE_BIT)
152#define ETHRES_BECTE (0x1 << ETHRES_BECTE_BIT)
153
154#define MEMSCRUB_OPTIONS_AHBERROR_CORTHRES_ENABLE AHBERC_CECTE
155#define MEMSCRUB_OPTIONS_AHBERROR_CORTHRES_DISABLE 0
156#define MEMSCRUB_OPTIONS_AHBERROR_UNCORTHRES_ENABLE AHBERC_UECTE
157#define MEMSCRUB_OPTIONS_AHBERROR_UNCORTHRES_DISABLE 0
158#define MEMSCRUB_OPTIONS_SCRUBERROR_RUNTHRES_ENABLE ETHRES_RECTE
159#define MEMSCRUB_OPTIONS_SCRUBERROR_RUNTHRES_DISABLE 0
160#define MEMSCRUB_OPTIONS_SCRUBERROR_BLOCKTHRES_ENABLE ETHRES_BECTE
161#define MEMSCRUB_OPTIONS_SCRUBERROR_BLOCKTHRES_DISABLE 0
162extern int memscrub_ahberror_setup(int uethres, int cethres, int options);
163extern int memscrub_scruberror_setup(int blkthres, int runthres,
164 int options);
165
166extern int memscrub_scrub_position(uint32_t * position);
167
168#ifdef __cplusplus
169}
170#endif
171
172#endif