Embedded SDK
Embedded SDK
lib_ux
include
ux_loc_flow_engine.h
Go to the documentation of this file.
1
2
/*******************************************************************************
3
* Ledger Nano S - Secure firmware
4
* (c) 2022 Ledger
5
*
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* 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, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
********************************************************************************/
18
19
#pragma once
20
21
#include "os_seed.h"
22
#include "os_helpers.h"
23
27
#define UX_LOC_STEP_FLOWS( \
28
stepname, layoutkind, preinit, timeout_ms, validate_flow, error_flow, ...) \
29
void stepname##_init(unsigned int stack_slot) \
30
{ \
31
preinit; \
32
ux_layout_##layoutkind##_init(stack_slot); \
33
ux_layout_set_timeout(stack_slot, timeout_ms); \
34
} \
35
const ux_loc_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
36
const ux_flow_step_t stepname = { \
37
stepname##_init, \
38
&stepname##_val, \
39
validate_flow, \
40
error_flow, \
41
}
42
43
#define UX_LOC_STEP(stepname, layoutkind, preinit, timeout_ms, validate_cb, error_flow, ...) \
44
UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
45
void stepname##_init(unsigned int stack_slot) \
46
{ \
47
preinit; \
48
ux_layout_##layoutkind##_init(stack_slot); \
49
ux_layout_set_timeout(stack_slot, timeout_ms); \
50
} \
51
const ux_loc_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
52
const ux_flow_step_t stepname = { \
53
stepname##_init, \
54
&stepname##_val, \
55
stepname##_validate, \
56
error_flow, \
57
}
58
62
#define UX_LOC_STEP_CB(stepname, layoutkind, validate_cb, ...) \
63
UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
64
const ux_loc_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
65
const ux_flow_step_t stepname = { \
66
ux_layout_##layoutkind##_init, \
67
&stepname##_val, \
68
stepname##_validate, \
69
NULL, \
70
}
71
// deprecated
72
#define UX_LOC_FLOW_DEF_VALID UX_LOC_STEP_VALID
73
// deprecated
74
#define UX_LOC_STEP_VALID UX_LOC_STEP_CB
75
79
#define UX_LOC_STEP_FLOWCB(stepname, layoutkind, validate_flow, error_flow, ...) \
80
const ux_loc_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
81
const ux_flow_step_t stepname = { \
82
ux_layout_##layoutkind##_init, \
83
&stepname##_val, \
84
validate_flow, \
85
error_flow, \
86
}
87
92
#define UX_LOC_STEP_CB_INIT(stepname, layoutkind, preinit, validate_cb, ...) \
93
UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
94
void stepname##_init(unsigned int stack_slot) \
95
{ \
96
preinit; \
97
ux_layout_##layoutkind##_init(stack_slot); \
98
} \
99
const ux_loc_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
100
const ux_flow_step_t stepname = { \
101
stepname##_init, \
102
&stepname##_val, \
103
stepname##_validate, \
104
NULL, \
105
}
106
110
#define UX_LOC_STEP_TIMEOUT(stepname, layoutkind, timeout_ms, validate_flow, ...) \
111
void stepname##_init(unsigned int stack_slot) \
112
{ \
113
ux_layout_##layoutkind##_init(stack_slot); \
114
ux_layout_set_timeout(stack_slot, timeout_ms); \
115
} \
116
const ux_loc_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
117
const ux_flow_step_t stepname = { \
118
stepname##_init, \
119
&stepname##_val, \
120
validate_flow, \
121
NULL, \
122
}
123
127
#define UX_LOC_STEP_NOCB(stepname, layoutkind, ...) \
128
const ux_loc_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
129
const ux_flow_step_t stepname = { \
130
ux_layout_##layoutkind##_init, \
131
&stepname##_val, \
132
NULL, \
133
NULL, \
134
}
135
// deprecated
136
#define UX_FLOW_DEF_NOCB UX_STEP_NOCB
137
142
#define UX_LOC_STEP_NOCB_INIT(stepname, layoutkind, preinit, ...) \
143
void stepname##_init(unsigned int stack_slot) \
144
{ \
145
preinit; \
146
ux_layout_##layoutkind##_init(stack_slot); \
147
} \
148
const ux_loc_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
149
const ux_flow_step_t stepname = { \
150
stepname##_init, \
151
&stepname##_val, \
152
NULL, \
153
NULL, \
154
}
155
160
#define UX_LOC_STEP_NOCB_POSTINIT(stepname, layoutkind, postinit, ...) \
161
void stepname##_init(unsigned int stack_slot) \
162
{ \
163
ux_layout_##layoutkind##_init(stack_slot); \
164
postinit; \
165
} \
166
const ux_loc_layout_##layoutkind##_params_t stepname##_val = __VA_ARGS__; \
167
const ux_flow_step_t stepname = { \
168
stepname##_init, \
169
&stepname##_val, \
170
NULL, \
171
NULL, \
172
}
173
174
// Define a flow that will display several pages, using a specific formatting:
175
// ie \b to switch Bold On/Off, \n to force a new line etc
176
#define UX_LOC_PAGES(stepname, index) \
177
const ux_loc_layout_params_t stepname##_val = {index}; \
178
const ux_flow_step_t stepname = { \
179
ux_layout_pages_init, \
180
&stepname##_val, \
181
NULL, \
182
NULL, \
183
}
184
#define UX_LOC_PAGES_NOCB UX_LOC_PAGES
185
186
#define UX_LOC_PAGES_INIT(stepname, preinit, index) \
187
void stepname##_init(unsigned int stack_slot) \
188
{ \
189
preinit; \
190
ux_layout_pages_init(stack_slot); \
191
} \
192
const ux_loc_layout_params_t stepname##_val = {index}; \
193
const ux_flow_step_t stepname = { \
194
stepname##_init, \
195
&stepname##_val, \
196
NULL, \
197
NULL, \
198
}
199
200
#define UX_LOC_PAGES_INIT_ERROR(stepname, preinit, error, index) \
201
void stepname##_init(unsigned int stack_slot) \
202
{ \
203
preinit; \
204
ux_layout_pages_init(stack_slot); \
205
} \
206
const ux_loc_layout_params_t stepname##_val = {index}; \
207
const ux_flow_step_t stepname = { \
208
stepname##_init, \
209
&stepname##_val, \
210
NULL, \
211
error, \
212
}
213
214
#define UX_LOC_PAGES_CB(stepname, validate_cb, index) \
215
UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
216
const ux_loc_layout_params_t stepname##_val = {index}; \
217
const ux_flow_step_t stepname = { \
218
ux_layout_pages_init, \
219
&stepname##_val, \
220
stepname##_validate, \
221
NULL, \
222
}
223
224
#define UX_LOC_PAGES_VALID UX_LOC_PAGES_CB
225
226
#define UX_LOC_PAGES_CB_INIT(stepname, preinit, validate_cb, index) \
227
UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
228
void stepname##_init(unsigned int stack_slot) \
229
{ \
230
preinit; \
231
ux_layout_pages_init(stack_slot); \
232
} \
233
const ux_loc_layout_params_t stepname##_val = {index}; \
234
const ux_flow_step_t stepname = { \
235
stepname##_init, \
236
&stepname##_val, \
237
stepname##_validate, \
238
NULL, \
239
}
240
241
#define UX_LOC_PAGES_POSTINIT(stepname, postinit, index) \
242
void stepname##_init(unsigned int stack_slot) \
243
{ \
244
ux_layout_pages_init(stack_slot); \
245
postinit; \
246
} \
247
const ux_loc_layout_params_t stepname##_val = {index}; \
248
const ux_flow_step_t stepname = { \
249
stepname##_init, \
250
&stepname##_val, \
251
NULL, \
252
NULL, \
253
}
254
255
#define UX_LOC_PAGES_TIMEOUT(stepname, timeout_ms, validate_cb, index) \
256
void stepname##_init(unsigned int stack_slot) \
257
{ \
258
ux_layout_pages_init(stack_slot); \
259
ux_layout_set_timeout(stack_slot, timeout_ms); \
260
} \
261
const ux_loc_layout_params_t stepname##_val = {index}; \
262
const ux_flow_step_t stepname = { \
263
stepname##_init, \
264
&stepname##_val, \
265
validate_cb, \
266
NULL, \
267
}
268
269
// Define a flow that will display several pages, using a specific formatting:
270
// ie \b to switch Bold On/Off, \n to force a new line etc with a pager
271
// The provided index will contain the title, and index+1 the remaining text
272
#define UX_LOC_PAGING(stepname, index) \
273
const ux_loc_layout_params_t stepname##_val = {index}; \
274
const ux_flow_step_t stepname = { \
275
ux_loc_layout_paging_init, \
276
&stepname##_val, \
277
NULL, \
278
NULL, \
279
}
280
281
// Define a flow that will display several pages, using a specific formatting:
282
// ie \b to switch Bold On/Off, \n to force a new line etc
283
#define UX_PAGES(stepname, text) \
284
const ux_layout_pages_params_t stepname##_val = {text}; \
285
const ux_flow_step_t stepname = { \
286
ux_layout_pages_init, \
287
&stepname##_val, \
288
NULL, \
289
NULL, \
290
}
291
292
#define UX_PAGES_INIT(stepname, preinit, text) \
293
void stepname##_init(unsigned int stack_slot) \
294
{ \
295
preinit; \
296
ux_layout_pages_init(stack_slot); \
297
} \
298
const ux_layout_pages_params_t stepname##_val = {text}; \
299
const ux_flow_step_t stepname = { \
300
stepname##_init, \
301
&stepname##_val, \
302
NULL, \
303
NULL, \
304
}
305
306
#define UX_PAGES_CB(stepname, validate_cb, text) \
307
UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
308
const ux_layout_pages_params_t stepname##_val = {text}; \
309
const ux_flow_step_t stepname = { \
310
ux_layout_pages_init, \
311
&stepname##_val, \
312
stepname##_validate, \
313
NULL, \
314
}
315
316
#define UX_PAGES_CB_INIT(stepname, preinit, validate_cb, text) \
317
UX_FLOW_CALL(stepname##_validate, { validate_cb; }) \
318
void stepname##_init(unsigned int stack_slot) \
319
{ \
320
preinit; \
321
ux_layout_pages_init(stack_slot); \
322
} \
323
const ux_layout_pages_params_t stepname##_val = {text}; \
324
const ux_flow_step_t stepname = { \
325
stepname##_init, \
326
&stepname##_val, \
327
stepname##_validate, \
328
NULL, \
329
}
330
331
#define UX_PAGES_POSTINIT(stepname, postinit, text) \
332
void stepname##_init(unsigned int stack_slot) \
333
{ \
334
ux_layout_pages_init(stack_slot); \
335
postinit; \
336
} \
337
const ux_layout_pages_params_t stepname##_val = {text}; \
338
const ux_flow_step_t stepname = { \
339
stepname##_init, \
340
&stepname##_val, \
341
NULL, \
342
NULL, \
343
}
344
345
#define UX_PAGES_TIMEOUT(stepname, timeout_ms, validate_cb, text) \
346
void stepname##_init(unsigned int stack_slot) \
347
{ \
348
ux_layout_pages_init(stack_slot); \
349
ux_layout_set_timeout(stack_slot, timeout_ms); \
350
} \
351
const ux_layout_pages_params_t stepname##_val = {text}; \
352
const ux_flow_step_t stepname = { \
353
stepname##_init, \
354
&stepname##_val, \
355
validate_cb, \
356
NULL, \
357
}
358
359
#define UX_PAGES_NOCB UX_PAGES
360
361
// deprecated
362
#define UX_PAGES_VALID UX_PAGES_CB
363
364
#include "ux.h"
Generated by
1.9.1