-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibparam_compile_for_cplusplus.patch
402 lines (376 loc) · 12.2 KB
/
libparam_compile_for_cplusplus.patch
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
diff --git a/include/param/param.h b/include/param/param.h
index c10db0d..ef88089 100644
--- a/include/param/param.h
+++ b/include/param/param.h
@@ -16,22 +16,22 @@
*/
typedef enum {
- PARAM_TYPE_UINT8,
- PARAM_TYPE_UINT16,
- PARAM_TYPE_UINT32,
- PARAM_TYPE_UINT64,
- PARAM_TYPE_INT8,
- PARAM_TYPE_INT16,
- PARAM_TYPE_INT32,
- PARAM_TYPE_INT64,
- PARAM_TYPE_XINT8,
- PARAM_TYPE_XINT16,
- PARAM_TYPE_XINT32,
- PARAM_TYPE_XINT64,
- PARAM_TYPE_FLOAT,
- PARAM_TYPE_DOUBLE,
- PARAM_TYPE_STRING,
- PARAM_TYPE_DATA,
+ PARAM_TYPE_UINT8,
+ PARAM_TYPE_UINT16,
+ PARAM_TYPE_UINT32,
+ PARAM_TYPE_UINT64,
+ PARAM_TYPE_INT8,
+ PARAM_TYPE_INT16,
+ PARAM_TYPE_INT32,
+ PARAM_TYPE_INT64,
+ PARAM_TYPE_XINT8,
+ PARAM_TYPE_XINT16,
+ PARAM_TYPE_XINT32,
+ PARAM_TYPE_XINT64,
+ PARAM_TYPE_FLOAT,
+ PARAM_TYPE_DOUBLE,
+ PARAM_TYPE_STRING,
+ PARAM_TYPE_DATA,
} param_type_e;
/**
@@ -59,32 +59,32 @@ typedef enum {
*/
typedef struct param_s {
- /* Parameter declaration */
- uint16_t id;
- uint8_t node;
- param_type_e type;
- uint32_t mask;
- char *name;
- char *unit;
+ /* Parameter declaration */
+ char *name;
+ uint8_t node;
+ uint16_t id;
+ param_type_e type;
+ uint32_t mask;
+ char *unit;
- /* Storage */
- void * addr;
- const struct vmem_s * vmem;
- int array_size;
- int array_step;
+ /* Storage */
+ void * addr;
+ const struct vmem_s * vmem;
+ int array_size;
+ int array_step;
- /* Local info */
- void (*callback)(struct param_s * param, int offset);
- uint32_t timestamp;
+ /* Local info */
+ void (*callback)(struct param_s * param, int offset);
+ uint32_t timestamp;
- /* single linked list:
- * The weird definition format comes from sys/queue.h SLINST_ENTRY() macro */
- struct { struct param_s *sle_next; } next;
+ /* single linked list:
+ * The weird definition format comes from sys/queue.h SLINST_ENTRY() macro */
+ struct { struct param_s *sle_next; } next;
} param_t;
-#define PARAM_LIST_LOCAL 255
+#define PARAM_LIST_LOCAL 255
/**
* DEFINITION HELPERS:
@@ -100,60 +100,60 @@ typedef struct param_s {
*
*/
#define PARAM_DEFINE_STATIC_RAM(_id, _name, _type, _array_count, _array_step, _flags, _callback, _unit, _physaddr, _log) \
- __attribute__((section("param"))) \
- __attribute__((aligned(1))) \
- __attribute__((used)) \
- param_t _name = { \
- .vmem = NULL, \
- .node = PARAM_LIST_LOCAL, \
- .id = _id, \
- .type = _type, \
- .name = #_name, \
- .array_size = _array_count, \
- .array_step = _array_step, \
- .mask = _flags, \
- .unit = _unit, \
- .callback = _callback, \
- .addr = _physaddr, \
- }
+ __attribute__((section("param"))) \
+ __attribute__((aligned(1))) \
+ __attribute__((used)) \
+ param_t _name = { \
+ .name = #_name, \
+ .node = PARAM_LIST_LOCAL, \
+ .id = _id, \
+ .type = _type, \
+ .mask = _flags, \
+ .unit = _unit, \
+ .addr = _physaddr, \
+ .vmem = NULL, \
+ .array_size = _array_count, \
+ .array_step = _array_step, \
+ .callback = _callback, \
+ }
#define PARAM_DEFINE_STATIC_VMEM(_id, _name, _type, _array_count, _array_step, _flags, _callback, _unit, _vmem_name, _vmem_addr, _log) \
- __attribute__((section("param"))) \
- __attribute__((aligned(1))) \
- __attribute__((used)) \
- param_t _name = { \
- .node = PARAM_LIST_LOCAL, \
- .id = _id, \
- .type = _type, \
- .name = #_name, \
- .array_size = _array_count, \
- .array_step = _array_step, \
- .mask = _flags, \
- .callback = _callback, \
- .unit = _unit, \
- .addr = (void *) _vmem_addr, \
- .vmem = &vmem_##_vmem_name, \
- }
+ __attribute__((section("param"))) \
+ __attribute__((aligned(1))) \
+ __attribute__((used)) \
+ param_t _name = { \
+ .name = #_name, \
+ .node = PARAM_LIST_LOCAL, \
+ .id = _id, \
+ .type = _type, \
+ .mask = _flags, \
+ .unit = _unit, \
+ .addr = (void *) _vmem_addr, \
+ .vmem = &vmem_##_vmem_name, \
+ .array_size = _array_count, \
+ .array_step = _array_step, \
+ .callback = _callback, \
+ }
#define PARAM_DEFINE_REMOTE(_name, _node, _id, _type, _array_size, _array_step, _flags, _physaddr) \
- __attribute__((section("param"))) \
- __attribute__((aligned(1))) \
- __attribute__((used)) \
- param_t _name = { \
- .node = _node, \
- .id = _id, \
- .type = _type, \
- .array_size = _array_size, \
- .array_step = _array_step, \
- .name = (char *) #_name, \
- .mask = _flags, \
- .addr = _physaddr, \
- };
+ __attribute__((section("param"))) \
+ __attribute__((aligned(1))) \
+ __attribute__((used)) \
+ param_t _name = { \
+ .name = (char *) #_name, \
+ .node = _node, \
+ .id = _id, \
+ .type = _type, \
+ .mask = _flags, \
+ .addr = _physaddr, \
+ .array_size = _array_size, \
+ .array_step = _array_step, \
+ };
/* Native getter functions, will return native types */
#define PARAM_GET(type, name) \
- type param_get_##name(param_t * param); \
- type param_get_##name##_array(param_t * param, unsigned int i);
+ type param_get_##name(param_t * param); \
+ type param_get_##name##_array(param_t * param, unsigned int i);
PARAM_GET(uint8_t, uint8)
PARAM_GET(uint16_t, uint16)
PARAM_GET(uint32_t, uint32)
@@ -168,10 +168,10 @@ PARAM_GET(double, double)
/* Native setter functions, these take a native type as argument */
#define PARAM_SET(type, name) \
- void param_set_##name(param_t * param, type value); \
- void param_set_##name##_nocallback(param_t * param, type value); \
- void param_set_##name##_array(param_t * param, unsigned int i, type value); \
- void param_set_##name##_array_nocallback(param_t * param, unsigned int i, type value);
+ void param_set_##name(param_t * param, type value); \
+ void param_set_##name##_nocallback(param_t * param, type value); \
+ void param_set_##name##_array(param_t * param, unsigned int i, type value); \
+ void param_set_##name##_array_nocallback(param_t * param, unsigned int i, type value);
PARAM_SET(uint8_t, uint8)
PARAM_SET(uint16_t, uint16)
PARAM_SET(uint32_t, uint32)
diff --git a/include/vmem/vmem_file.h b/include/vmem/vmem_file.h
index b22bcd8..fef3b15 100644
--- a/include/vmem/vmem_file.h
+++ b/include/vmem/vmem_file.h
@@ -11,8 +11,8 @@
#include <vmem/vmem.h>
typedef struct {
- void * physaddr;
- char * filename;
+ void * physaddr;
+ char * filename;
} vmem_file_driver_t;
void vmem_file_init(const vmem_t * vmem);
@@ -20,23 +20,23 @@ void vmem_file_read(const vmem_t * vmem, uint32_t addr, void * dataout, int len)
void vmem_file_write(const vmem_t * vmem, uint32_t addr, void * datain, int len);
#define VMEM_DEFINE_FILE(name_in, strname, filename_in, size_in) \
- uint8_t vmem_##name_in##_buf[size_in] = {}; \
- static const vmem_file_driver_t vmem_##name_in##_driver = { \
- .physaddr = vmem_##name_in##_buf, \
- .filename = filename_in, \
- }; \
- __attribute__((section("vmem"))) \
- __attribute__((aligned(1))) \
- __attribute__((used)) \
- const vmem_t vmem_##name_in = { \
- .type = VMEM_TYPE_FILE, \
- .name = strname, \
- .size = size_in, \
- .read = vmem_file_read, \
- .write = vmem_file_write, \
- .driver = &vmem_##name_in##_driver, \
- .vaddr = vmem_##name_in##_buf, \
- };
+ uint8_t vmem_##name_in##_buf[size_in] = {}; \
+ vmem_file_driver_t vmem_##name_in##_driver = { \
+ .physaddr = vmem_##name_in##_buf, \
+ .filename = filename_in, \
+ }; \
+ __attribute__((section("vmem"))) \
+ __attribute__((aligned(1))) \
+ __attribute__((used)) \
+ vmem_t vmem_##name_in = { \
+ .type = VMEM_TYPE_FILE, \
+ .read = vmem_file_read, \
+ .write = vmem_file_write, \
+ .vaddr = vmem_##name_in##_buf, \
+ .size = size_in, \
+ .name = strname, \
+ .driver = &vmem_##name_in##_driver, \
+ };
#endif /* LIB_PARAM_INCLUDE_VMEM_VMEM_FILE_H_ */
diff --git a/include/vmem/vmem_ram.h b/include/vmem/vmem_ram.h
index 75df671..b75ee73 100644
--- a/include/vmem/vmem_ram.h
+++ b/include/vmem/vmem_ram.h
@@ -14,25 +14,25 @@ void vmem_ram_read(const vmem_t * vmem, uint32_t addr, void * dataout, int len);
void vmem_ram_write(const vmem_t * vmem, uint32_t addr, void * datain, int len);
typedef struct {
- void * physaddr;
+ void * physaddr;
} vmem_ram_driver_t;
#define VMEM_DEFINE_STATIC_RAM(name_in, strname, size_in) \
- uint8_t vmem_##name_in##_heap[size_in] = {}; \
- static const vmem_ram_driver_t vmem_##name_in##_driver = { \
- .physaddr = vmem_##name_in##_heap, \
- }; \
- __attribute__((section("vmem"))) \
- __attribute__((aligned(1))) \
- __attribute__((used)) \
- const vmem_t vmem_##name_in = { \
- .type = VMEM_TYPE_RAM, \
- .name = strname, \
- .size = size_in, \
- .read = vmem_ram_read, \
- .write = vmem_ram_write, \
- .driver = &vmem_##name_in##_driver, \
- .vaddr = vmem_##name_in##_heap, \
- };
+ uint8_t vmem_##name_in##_heap[size_in] = {}; \
+ vmem_ram_driver_t vmem_##name_in##_driver = { \
+ .physaddr = vmem_##name_in##_heap, \
+ }; \
+ __attribute__((section("vmem"))) \
+ __attribute__((aligned(1))) \
+ __attribute__((used)) \
+ vmem_t vmem_##name_in = { \
+ .type = VMEM_TYPE_RAM, \
+ .read = vmem_ram_read, \
+ .write = vmem_ram_write, \
+ .vaddr = vmem_##name_in##_heap, \
+ .size = size_in, \
+ .name = strname, \
+ .driver = &vmem_##name_in##_driver, \
+ };
#endif /* SRC_PARAM_VMEM_RAM_H_ */
diff --git a/src/param/collector/param_collector_config.c b/src/param/collector/param_collector_config.c
index 697750a..80c778e 100644
--- a/src/param/collector/param_collector_config.c
+++ b/src/param/collector/param_collector_config.c
@@ -15,44 +15,44 @@
struct param_collector_config_s param_collector_config[16] = {0};
void param_col_confstr_callback(struct param_s * param, int offset) {
- param_collector_init();
+ param_collector_init();
}
-extern const vmem_t vmem_col;
+extern vmem_t vmem_col;
PARAM_DEFINE_STATIC_VMEM(PARAMID_COLLECTOR_RUN, col_run, PARAM_TYPE_UINT8, 0, sizeof(uint8_t), PM_CONF, NULL, "", col, 0x0, NULL);
PARAM_DEFINE_STATIC_VMEM(PARAMID_COLLECTOR_VERBOSE, col_verbose, PARAM_TYPE_UINT8, 0, sizeof(uint8_t), PM_CONF, NULL, "", col, 0x1, NULL);
PARAM_DEFINE_STATIC_VMEM(PARAMID_COLLECTOR_CNFSTR, col_cnfstr, PARAM_TYPE_STRING, 100, 0, PM_CONF, param_col_confstr_callback, "", col, 0x02, NULL);
void param_collector_init(void) {
- char buf[100];
- param_get_data(&col_cnfstr, buf, 100);
- //int len = strnlen(buf, 100);
- //printf("Init with str: %s, len %u\n", buf, len);
-
- /* Clear config array */
- memset(param_collector_config, 0, sizeof(param_collector_config));
-
- /* Get first token */
- char *saveptr;
- char * str = strtok_r(buf, ",", &saveptr);
- int i = 0;
-
- while ((str) && (strlen(str) > 1)) {
- unsigned int node, interval, mask = 0xFFFFFFFF;
- if (sscanf(str, "%u %u %x", &node, &interval, &mask) != 3) {
- if (sscanf(str, "%u %u", &node, &interval) != 2) {
- printf("Parse error %s", str);
- return;
- }
- }
- //printf("Collect node %u each %u ms, mask %x\n", node, interval, mask);
-
- param_collector_config[i].node = node;
- param_collector_config[i].interval = interval;
- param_collector_config[i].mask = mask;
-
- i++;
- str = strtok_r(NULL, ",", &saveptr);
- }
+ char buf[100];
+ param_get_data(&col_cnfstr, buf, 100);
+ //int len = strnlen(buf, 100);
+ //printf("Init with str: %s, len %u\n", buf, len);
+
+ /* Clear config array */
+ memset(param_collector_config, 0, sizeof(param_collector_config));
+
+ /* Get first token */
+ char *saveptr;
+ char * str = strtok_r(buf, ",", &saveptr);
+ int i = 0;
+
+ while ((str) && (strlen(str) > 1)) {
+ unsigned int node, interval, mask = 0xFFFFFFFF;
+ if (sscanf(str, "%u %u %x", &node, &interval, &mask) != 3) {
+ if (sscanf(str, "%u %u", &node, &interval) != 2) {
+ printf("Parse error %s", str);
+ return;
+ }
+ }
+ //printf("Collect node %u each %u ms, mask %x\n", node, interval, mask);
+
+ param_collector_config[i].node = node;
+ param_collector_config[i].interval = interval;
+ param_collector_config[i].mask = mask;
+
+ i++;
+ str = strtok_r(NULL, ",", &saveptr);
+ }
}