tao_z
2022-05-29 fa8669b0092240642af78e84c0e89f596444fdad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
 
#ifndef __FBL_DEF_H__
#define __FBL_DEF_H__
 
/***********************************************************************************************************************
 *  INCLUDES
 **********************************************************************************************************************/
 
/* Basic type definitions */
#include "typedef.h"
 
/***********************************************************************************************************************
 *  VERSION
 **********************************************************************************************************************/
 
/* ##V_CFG_MANAGEMENT ##CQProject : FblDef CQComponent : Implementation */
#define FBLDEF_VERSION 0x0245u
#define FBLDEF_RELEASE_VERSION 0x00u
 
#ifndef NULL
#define NULL ((void *)0)
#endif
 
#ifndef SWM_DATA_ALIGN
#define SWM_DATA_ALIGN 0
#endif
 
#define OP_STATUS_OK ((int8_t)0)      /**< the operation was successful */
#define OP_STATUS_BUSY ((int8_t)1)    /**< the operation is ongoing, call back later. */
#define OP_STATUS_FAIL ((int8_t)(-1)) /**< the operation failed :( */
 
/* CanTransmit return values */
#ifndef kCanTxOk
#define kCanTxOk 0 /* Msg transmitted                        */
#endif
#ifndef kCanTxFailed
#define kCanTxFailed 1 /* Tx path switched off                   */
#endif
#define kCanTxInProcess 2
 
/* Define return code of several functions   */
#define kFblOk 0
#define kFblFailed 1
 
/* Parameters for ApplFblStartup() */
#define kStartupPreInit 0
#define kStartupPostInit 1
#define kStartupStayInBoot 2
 
/* Programming request flag */
#define kProgRequest (tFblProgStatus)0x01u
#define kNoProgRequest FblInvertBits(kProgRequest, tFblProgStatus)
 
#define kProgRequestWithResponse 0x02 /* External programming request with response required */
#define kProgRequestNoResponse 0x03   /* No response required to programming request */
/* Application validation  */
#define kApplValid 1   /* Application is fully programmed */
#define kApplInvalid 0 /* Operational software is missing */
 
/* Memory status (flash erased detection) */
#define kFlashErased 1
#define kFlashNotErased 0
 
/* Define return code of security access functions */
/* Starts at three for future merge with GM values */
#define kFblSecNewSeedIssued 3        /* seed */
#define kFblSecGranted 4              /* seed - key - status */
#define kFblSecDeniedLocked 5         /* status */
#define kFblSecDeniedIncorrectLevel 6 /* seed */
#define kFblSecDeniedInvalidKey 7
 
/* Position of boot block: */
/* FBL_TOP_BOOT_BLOCK: The boot block is mapped to the high addresses */
/* FBL_BOTTOM_BOOT_BLOCK: The boot block is mapped to the low addresses */
 
#if !defined(FBL_REPEAT_CALL_CYCLE)
/* Set default to 1ms for repeat time of main loop */
#define FBL_REPEAT_CALL_CYCLE 1
#endif
 
#ifdef FBL_ENABLE_BANKING
#else
#define FBL_CALL_TYPE
#endif /* FBL_ENABLE_BANKING */
 
/* Defines to convert BigEndian bytes into short or long values ********************/
#ifndef C_CPUTYPE_LITTLEENDIAN
#define C_CPUTYPE_LITTLEENDIAN
#endif
#ifdef C_CPUTYPE_BIGENDIAN
#ifdef C_CPUTYPE_32BIT
#define FblBytesToLong(hiWrd_hiByt, hiWrd_loByt, loWrd_hiByt, loWrd_loByt) \
   (((uint32_t)(hiWrd_hiByt) << 24) |                                      \
    ((uint32_t)(hiWrd_loByt) << 16) |                                      \
    ((uint32_t)(loWrd_hiByt) << 8) |                                       \
    ((uint32_t)(loWrd_loByt)))
#else
#define FblBytesToLong(hiWrd_hiByt, hiWrd_loByt, loWrd_hiByt, loWrd_loByt) \
   (uint32_t) * (V_MEMRAM0 V_MEMRAM1_FAR uint32_t V_MEMRAM2_FAR *)(&(hiWrd_hiByt))
#endif
#endif
#ifdef C_CPUTYPE_LITTLEENDIAN
#define FblBytesToLong(hiWrd_hiByt, hiWrd_loByt, loWrd_hiByt, loWrd_loByt) \
   (((uint32_t)(hiWrd_hiByt) << 24) |                                      \
    ((uint32_t)(hiWrd_loByt) << 16) |                                      \
    ((uint32_t)(loWrd_hiByt) << 8) |                                       \
    ((uint32_t)(loWrd_loByt)))
#endif
 
#define FBL_BIT0 0x01u
#define FBL_BIT1 0x02u
#define FBL_BIT2 0x04u
#define FBL_BIT3 0x08u
#define FBL_BIT4 0x10u
#define FBL_BIT5 0x20u
#define FBL_BIT6 0x40u
#define FBL_BIT7 0x80u
 
/* Macros and values for fblMode */
#define START_FROM_APPL FBL_BIT0
#define START_FROM_RESET FBL_BIT1
#define APPL_CORRUPT FBL_BIT2
#define STAY_IN_FBL FBL_BIT3
#define FBL_RESET_REQUEST FBL_BIT4
#define WAIT_FOR_PING FBL_BIT5
#define FBL_START_WITH_RESP FBL_BIT6
#define FBL_START_WITH_PING FBL_BIT7
#define SetFblMode(state) (fblMode = (uint8_t)((fblMode) | (state)))
#define GetFblMode() ((uint8_t)(fblMode & 0x0Fu))
#if defined(FBL_ENABLE_STAY_IN_BOOT)
#define GetFblWaitForPing() (fblMode & WAIT_FOR_PING)
#endif
#define FblSetShutdownRequest() SetFblMode(FBL_RESET_REQUEST)
extern uint8_t fblMode;
 
/* Defines for response after reset */
#define RESET_RESPONSE_NOT_REQUIRED ((uint8_t)0x00)
#define RESET_RESPONSE_SDS_REQUIRED ((uint8_t)0x01)
#define RESET_RESPONSE_ECURESET_REQUIRED ((uint8_t)0x02)
#define RESET_RESPONSE_KEYOFFON_REQUIRED ((uint8_t)0x03)
 
/* Access macros for FblHeader elements for application */
#define GetFblMainVersion() (FblHeaderTable->kFblMainVersion)
#define GetFblSubVersion() (FblHeaderTable->kFblSubVersion)
#define GetFblReleaseVersion() (FblHeaderTable->kFblBugFixVersion)
#define GetFblBuildVersion() (FblHeaderTable->kFblBuildVersion)
#if defined(FBL_ENABLE_COMMON_DATA)
#define GetFblCommonDataPtr() (FblHeaderTable->pFblCommonData)
#endif
 
#define FBL_START_PARAM ((void *)0)
#define CallFblStart(pParam) (FblHeaderTable->FblStartFct)((pParam))
 
/* macros to harmonize type casts for inverting bits */
#define FblInvertBits(x, type) ((type) ~((type)(x)))
#define FblInvert8Bit(x) (FblInvertBits((x), uint8_t))
#define FblInvert16Bit(x) (FblInvertBits((x), vuint16))
#define FblInvert32Bit(x) (FblInvertBits((x), vuint32))
 
/* Always use table for physical flash pages */
#define FBL_FLASHBLOCK_TABLE
 
/***********************************************************************************************************************
 *  TYPEDEFS
 **********************************************************************************************************************/
 
typedef uint8_t tFblResult;     /**< FBL result codes */
typedef uint8_t tFblProgStatus; /**< Status of reprogramming flag */
typedef uint8_t tApplStatus;    /**< Application valid status */
typedef uint8_t tMagicFlag;     /**< Application valid flag */
typedef uint8_t tFlashStatus;   /**< Flash erased status flag */
 
#if defined(C_CPUTYPE_8BIT) && !defined(FBL_PROCESSOR_BANKED)
typedef vuint16 FBL_ADDR_TYPE;
typedef vuint16 FBL_MEMSIZE_TYPE;
#define MEMSIZE_OK
#else
typedef uint32_t FBL_ADDR_TYPE;
typedef uint32_t FBL_MEMSIZE_TYPE;
#define MEMSIZE_OK
#endif
 
#define tFblAddress FBL_ADDR_TYPE
#define tFblLength FBL_MEMSIZE_TYPE
 
typedef uint8_t FBL_MEMID_TYPE;
 
#ifdef MEMSIZE_OK
#else
#error "Error in FBL_DEF.H: C_CPUTYPE_ not defined."
#endif
 
/***********************************************************************************************************************
 *  DEFINES
 **********************************************************************************************************************/
 
#define kFblDiagTimeP2 FBL_DIAG_TIME_P2MAX
#define kFblDiagTimeP2Star FBL_DIAG_TIME_P3MAX
 
/*****************************************************************************/
 
/***********************************************************************************************************************
 *  GLOBAL DATA
 **********************************************************************************************************************/
 
#endif /* __FBL_DEF_H__ */
 
/***********************************************************************************************************************
 *  END OF FILE: FBL_DEF.H
 **********************************************************************************************************************/