@h2loop/autosar 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,25 +5,44 @@
5
5
  "NvM": {
6
6
  "detect": {"header": "NvM.h", "contains": "NvM_BlockDescriptorType"},
7
7
  "sourceIncludes": ["NvM.h"],
8
- "macros": [
9
- {"name": "NVM_TOTAL_NUM_OF_NVRAM_BLOCKS", "value": "max:NvMBlockDescriptor/NvMNvramBlockIdentifier+1"}
10
- ],
8
+ "macros": [{"name": "NVM_TOTAL_NUM_OF_NVRAM_BLOCKS", "value": "max:NvMBlockDescriptor/NvMNvramBlockIdentifier+1"}],
11
9
  "tables": [
12
10
  {
13
- "name": "NvM_BlockDescriptorTable", "type": "NvM_BlockDescriptorType", "qualifier": "NVM_CONST",
14
- "rows": "NvMBlockDescriptor", "size": "NVM_TOTAL_NUM_OF_NVRAM_BLOCKS", "designated": true,
15
- "doc": "indexed by NvMNvramBlockIdentifier (0 and 1 are reserved, SWS_NvM_00478)",
11
+ "name": "NvM_BlockDescriptorTable",
12
+ "type": "NvM_BlockDescriptorType",
13
+ "qualifier": "NVM_CONST",
14
+ "rows": "NvMBlockDescriptor",
15
+ "size": "NVM_TOTAL_NUM_OF_NVRAM_BLOCKS",
16
+ "designated": true,
17
+ "doc": "indexed by NvMNvramBlockIdentifier (0 and 1 are reserved block IDs)",
16
18
  "fields": [
17
- {"name": "RamBlockDataAddress", "path": "param:NvMRamBlockDataAddress", "default": "NULL_PTR",
18
- "extern": "VAR(uint8, NVM_APPL_DATA) {}[]"},
19
+ {
20
+ "name": "RamBlockDataAddress",
21
+ "path": "param:NvMRamBlockDataAddress",
22
+ "default": "NULL_PTR",
23
+ "extern": "VAR(uint8, NVM_APPL_DATA) {}[]"
24
+ },
19
25
  {"name": "NvBlockLength", "path": "param:NvMNvBlockLength"},
20
- {"name": "FeeBlockNumber", "path": [["sub:NvMTargetBlockReference", "sub:NvMFeeRef", "ref:NvMNameOfFeeBlock", "param:FeeBlockNumber"],
21
- ["sub:NvMTargetBlockReference", "sub:NvMEaRef", "ref:NvMNameOfEaBlock", "param:EaBlockNumber"]]},
22
- {"name": "ManagementType", "path": "param:NvMBlockManagementType"},
26
+ {
27
+ "name": "FeeBlockNumber",
28
+ "path": [
29
+ ["sub:NvMTargetBlockReference", "sub:NvMFeeRef", "ref:NvMNameOfFeeBlock", "param:FeeBlockNumber"],
30
+ ["sub:NvMTargetBlockReference", "sub:NvMEaRef", "ref:NvMNameOfEaBlock", "param:EaBlockNumber"]
31
+ ]
32
+ },
33
+ {
34
+ "name": "ManagementType",
35
+ "path": "param:NvMBlockManagementType",
36
+ "enum": {"NVM_BLOCK_NATIVE": 0, "NVM_BLOCK_REDUNDANT": 1, "NVM_BLOCK_DATASET": 2},
37
+ "doc": "NvM.h types the field as uint8 without literal values; the SWS defines no C encoding either (ECUC_NvM_00062 is an ECUC enum). Encoded in the SWS_NvM_00137 listing order, not the def's alphabetical literal order."
38
+ },
23
39
  {"name": "UseCrc", "path": "param:NvMBlockUseCrc"},
24
- {"name": "SingleBlockCallback", "path": ["sub:NvMSingleBlockCallback", "param:NvMSingleBlockCallbackFnc"],
25
- "default": "NULL_PTR",
26
- "extern": "FUNC(Std_ReturnType, NVM_APPL_CODE) {}(NvM_BlockRequestType BlockRequest, NvM_RequestResultType JobResult)"}
40
+ {
41
+ "name": "SingleBlockCallback",
42
+ "path": ["sub:NvMSingleBlockCallback", "param:NvMSingleBlockCallbackFnc"],
43
+ "default": "NULL_PTR",
44
+ "extern": "FUNC(Std_ReturnType, NVM_APPL_CODE) {}(NvM_BlockRequestType BlockRequest, NvM_RequestResultType JobResult)"
45
+ }
27
46
  ]
28
47
  }
29
48
  ]
@@ -31,9 +50,7 @@
31
50
  "Dem": {
32
51
  "detect": {"header": "Dem.h", "contains": "Dem_EventIdType"},
33
52
  "genericTables": true,
34
- "macros": [
35
- {"name": "DEM_NUMBER_OF_EVENTS", "value": "max:DemEventParameter/DemEventId"}
36
- ]
53
+ "macros": [{"name": "DEM_NUMBER_OF_EVENTS", "value": "max:DemEventParameter/DemEventId"}]
37
54
  },
38
55
  "PduR": {
39
56
  "detect": {"header": "PduR.h", "contains": "PduR_RoutingPathType"},
@@ -44,30 +61,53 @@
44
61
  ],
45
62
  "tables": [
46
63
  {
47
- "name": "PduR_RoutingPaths", "type": "PduR_RoutingPathType", "qualifier": "PDUR_CONST", "static": true,
48
- "rows": "PduRSrcPdu", "size": "PDUR_NUMBER_OF_SRC_PDUS",
49
- "doc": "indexed by PduRSourcePduHandleId", "comment": "name",
64
+ "name": "PduR_RoutingPaths",
65
+ "type": "PduR_RoutingPathType",
66
+ "qualifier": "PDUR_CONST",
67
+ "static": true,
68
+ "rows": "PduRSrcPdu",
69
+ "size": "PDUR_NUMBER_OF_SRC_PDUS",
70
+ "doc": "indexed by PduRSourcePduHandleId",
71
+ "comment": "name",
50
72
  "fields": [
51
- {"name": "DestModule", "path": ["back:PduRRoutingPath/PduRSrcPduRRef", "ref:PduRDestPduRRef", "peer:PduRDestPduRef", "module"],
52
- "fmt": "PDUR_DEST_{MIP}"},
53
- {"name": "DestLowerPduId", "path": ["back:PduRRoutingPath/PduRSrcPduRRef", "ref:PduRDestPduRRef", "peer:PduRDestPduRef", "sym"]},
73
+ {
74
+ "name": "DestModule",
75
+ "path": ["back:PduRRoutingPath/PduRSrcPduRRef", "ref:PduRDestPduRRef", "peer:PduRDestPduRef", "module"],
76
+ "fmt": "PDUR_DEST_{MIP}"
77
+ },
78
+ {
79
+ "name": "DestLowerPduId",
80
+ "path": ["back:PduRRoutingPath/PduRSrcPduRRef", "ref:PduRDestPduRRef", "peer:PduRDestPduRef", "sym"]
81
+ },
54
82
  {"name": "DestPduRPduId", "path": ["back:PduRRoutingPath/PduRSrcPduRRef", "ref:PduRDestPduRRef", "sym"]}
55
83
  ]
56
84
  },
57
85
  {
58
- "name": "PduR_TxConfUpperPduId", "type": "PduIdType", "qualifier": "PDUR_CONST", "static": true, "scalar": true,
59
- "rows": "PduRDestPdu", "size": "PDUR_NUMBER_OF_DEST_PDUS",
86
+ "name": "PduR_TxConfUpperPduId",
87
+ "type": "PduIdType",
88
+ "qualifier": "PDUR_CONST",
89
+ "static": true,
90
+ "scalar": true,
91
+ "rows": "PduRDestPdu",
92
+ "size": "PDUR_NUMBER_OF_DEST_PDUS",
60
93
  "doc": "indexed by PduRDestPduHandleId: the upper (Com) I-PDU to confirm when the source PDU asks for it (PduRSrcPduUpTxConf)",
61
94
  "fields": [
62
- {"name": "UpperPduId", "path": ["back:PduRRoutingPath/PduRDestPduRRef", "ref:PduRSrcPduRRef", "peer:PduRSrcPduRef@Com", "sym"],
63
- "when": ["back:PduRRoutingPath/PduRDestPduRRef", "ref:PduRSrcPduRRef", "param:PduRSrcPduUpTxConf"],
64
- "default": "COMSTACK_INVALID_PDUID"}
95
+ {
96
+ "name": "UpperPduId",
97
+ "path": ["back:PduRRoutingPath/PduRDestPduRRef", "ref:PduRSrcPduRRef", "peer:PduRSrcPduRef@Com", "sym"],
98
+ "when": ["back:PduRRoutingPath/PduRDestPduRRef", "ref:PduRSrcPduRRef", "param:PduRSrcPduUpTxConf"],
99
+ "default": "COMSTACK_INVALID_PDUID"
100
+ }
65
101
  ]
66
102
  }
67
103
  ],
68
104
  "objects": [
69
- {"name": "PduR_Config", "type": "PduR_PBConfigType", "qualifier": "PDUR_CONST",
70
- "init": ["PduR_RoutingPaths", "PduR_TxConfUpperPduId", "PDUR_NUMBER_OF_SRC_PDUS", "PDUR_NUMBER_OF_DEST_PDUS"]}
105
+ {
106
+ "name": "PduR_Config",
107
+ "type": "PduR_PBConfigType",
108
+ "qualifier": "PDUR_CONST",
109
+ "init": ["PduR_RoutingPaths", "PduR_TxConfUpperPduId", "PDUR_NUMBER_OF_SRC_PDUS", "PDUR_NUMBER_OF_DEST_PDUS"]
110
+ }
71
111
  ]
72
112
  },
73
113
  "CanIf": {
@@ -79,19 +119,32 @@
79
119
  ],
80
120
  "tables": [
81
121
  {
82
- "name": "CanIf_TxPduConfig", "type": "CanIf_TxPduConfigType", "qualifier": "CANIF_CONST", "static": true,
83
- "rows": "CanIfTxPduCfg", "size": "CANIF_NUMBER_OF_TX_PDUS", "comment": "sym",
122
+ "name": "CanIf_TxPduConfig",
123
+ "type": "CanIf_TxPduConfigType",
124
+ "qualifier": "CANIF_CONST",
125
+ "static": true,
126
+ "rows": "CanIfTxPduCfg",
127
+ "size": "CANIF_NUMBER_OF_TX_PDUS",
128
+ "comment": "sym",
84
129
  "doc": "indexed by CanIfTxPduId",
85
130
  "fields": [
86
131
  {"name": "CanId", "path": "param:CanIfTxPduCanId", "fmt": "hex"},
87
132
  {"name": "Dlc", "path": ["ref:CanIfTxPduRef", "param:PduLength"]},
88
- {"name": "Hth", "path": ["ref:CanIfTxPduBufferRef", "ref:CanIfBufferHthRef", "ref:CanIfHthIdSymRef", "sym"]},
133
+ {
134
+ "name": "Hth",
135
+ "path": ["ref:CanIfTxPduBufferRef", "ref:CanIfBufferHthRef", "ref:CanIfHthIdSymRef", "sym"]
136
+ },
89
137
  {"name": "UpperPduId", "path": ["peer:CanIfTxPduRef@PduR", "sym"]}
90
138
  ]
91
139
  },
92
140
  {
93
- "name": "CanIf_RxPduConfig", "type": "CanIf_RxPduConfigType", "qualifier": "CANIF_CONST", "static": true,
94
- "rows": "CanIfRxPduCfg", "size": "CANIF_NUMBER_OF_RX_PDUS", "comment": "sym",
141
+ "name": "CanIf_RxPduConfig",
142
+ "type": "CanIf_RxPduConfigType",
143
+ "qualifier": "CANIF_CONST",
144
+ "static": true,
145
+ "rows": "CanIfRxPduCfg",
146
+ "size": "CANIF_NUMBER_OF_RX_PDUS",
147
+ "comment": "sym",
95
148
  "doc": "indexed by CanIfRxPduId",
96
149
  "fields": [
97
150
  {"name": "CanId", "path": "param:CanIfRxPduCanId", "fmt": "hex"},
@@ -103,8 +156,222 @@
103
156
  }
104
157
  ],
105
158
  "objects": [
106
- {"name": "CanIf_Config", "type": "CanIf_ConfigType", "qualifier": "CANIF_CONST",
107
- "init": ["CanIf_TxPduConfig", "CanIf_RxPduConfig", "CANIF_NUMBER_OF_TX_PDUS", "CANIF_NUMBER_OF_RX_PDUS"]}
159
+ {
160
+ "name": "CanIf_Config",
161
+ "type": "CanIf_ConfigType",
162
+ "qualifier": "CANIF_CONST",
163
+ "init": ["CanIf_TxPduConfig", "CanIf_RxPduConfig", "CANIF_NUMBER_OF_TX_PDUS", "CANIF_NUMBER_OF_RX_PDUS"]
164
+ }
165
+ ]
166
+ },
167
+ "Com": {
168
+ "detect": {"header": "Com.h", "contains": "Com_SignalInfoType"},
169
+ "sourceIncludes": ["Com.h"],
170
+ "sets": {
171
+ "TxSignals": {
172
+ "rows": "ComSignal",
173
+ "where": [{"path": ["back:ComIPdu/ComIPduSignalRef", "param:ComIPduDirection"], "in": ["SEND"]}]
174
+ },
175
+ "RxSignals": {
176
+ "rows": "ComSignal",
177
+ "where": [{"path": ["back:ComIPdu/ComIPduSignalRef", "param:ComIPduDirection"], "in": ["RECEIVE"]}]
178
+ },
179
+ "TxIPdus": {"rows": "ComIPdu", "where": [{"path": "param:ComIPduDirection", "in": ["SEND"]}]},
180
+ "RxIPdus": {"rows": "ComIPdu", "where": [{"path": "param:ComIPduDirection", "in": ["RECEIVE"]}]}
181
+ },
182
+ "handleLayout": [
183
+ {"param": "ComHandleId", "sets": ["TxSignals", "RxSignals"]},
184
+ {"param": "ComIPduHandleId", "sets": ["TxIPdus", "RxIPdus"]}
185
+ ],
186
+ "require": [
187
+ {
188
+ "rows": "ComSignal",
189
+ "path": "param:ComSignalEndianness",
190
+ "in": ["LITTLE_ENDIAN"],
191
+ "why": "Com_PackBits/Com_UnpackBits pack LSB-first from ComBitPosition (Com_SignalInfoType has no endianness field)"
192
+ },
193
+ {"rows": "ComIPdu", "path": "param:ComIPduType", "in": ["NORMAL"], "why": "Com.c has no TP (large data) path"},
194
+ {
195
+ "rows": "ComSignal",
196
+ "path": "param:ComUpdateBitPosition",
197
+ "in": [null],
198
+ "why": "Com_SignalInfoType has no update bit"
199
+ }
200
+ ],
201
+ "unsupported": [
202
+ {"rows": "ComSignalGroup", "why": "Com.h has no signal-group table (Com_SignalGroupIdType only)"},
203
+ {"rows": "ComGwMapping", "why": "Com.c has no signal gateway"},
204
+ {"rows": "ComFilter", "why": "Com.c has no transmission mode selection (ComFilter / TMS)"},
205
+ {"rows": "ComTxModeFalse", "why": "Com.c has no transmission mode selection (ComTxModeFalse)"}
206
+ ],
207
+ "macros": [
208
+ {"name": "COM_NUMBER_OF_TX_SIGNALS", "value": "count:@TxSignals"},
209
+ {"name": "COM_NUMBER_OF_RX_SIGNALS", "value": "count:@RxSignals"},
210
+ {"name": "COM_NUMBER_OF_TX_IPDUS", "value": "count:@TxIPdus"},
211
+ {"name": "COM_NUMBER_OF_RX_IPDUS", "value": "count:@RxIPdus"},
212
+ {"name": "COM_NUMBER_OF_IPDUS", "value": "count:ComIPdu"}
213
+ ],
214
+ "vars": [
215
+ {
216
+ "name": "Com_IPduBuffer_{}",
217
+ "rows": "ComIPdu",
218
+ "type": "uint8",
219
+ "qualifier": "COM_VAR",
220
+ "static": true,
221
+ "size": ["ref:ComPduIdRef", "param:PduLength"],
222
+ "section": "VAR_NOINIT_UNSPECIFIED"
223
+ }
224
+ ],
225
+ "tables": [
226
+ {
227
+ "name": "Com_TxSignalInfo",
228
+ "type": "Com_SignalInfoType",
229
+ "qualifier": "COM_CONST",
230
+ "static": true,
231
+ "rows": "@TxSignals",
232
+ "size": "COM_NUMBER_OF_TX_SIGNALS",
233
+ "designated": true,
234
+ "comment": "sym",
235
+ "doc": "Tx signals, indexed by ComHandleId (Com_SendSignal: TxSignals[SignalId])",
236
+ "fields": [
237
+ {"name": "BitPosition", "path": "param:ComBitPosition"},
238
+ {"name": "BitSize", "path": "param:ComBitSize"},
239
+ {
240
+ "name": "Type",
241
+ "path": "param:ComSignalType",
242
+ "enum": {
243
+ "BOOLEAN": "COM_SIGTYPE_BOOLEAN",
244
+ "UINT8": "COM_SIGTYPE_UINT8",
245
+ "UINT16": "COM_SIGTYPE_UINT16",
246
+ "UINT32": "COM_SIGTYPE_UINT32",
247
+ "SINT8": "COM_SIGTYPE_SINT8",
248
+ "SINT16": "COM_SIGTYPE_SINT16",
249
+ "SINT32": "COM_SIGTYPE_SINT32"
250
+ }
251
+ },
252
+ {"name": "IPduRef", "path": ["back:ComIPdu/ComIPduSignalRef", "sym"]},
253
+ {"name": "InitValue", "path": "param:ComSignalInitValue", "fmt": "int", "default": "0u"},
254
+ {
255
+ "name": "TransferProperty",
256
+ "path": "param:ComTransferProperty",
257
+ "enum": {
258
+ "PENDING": "COM_XFER_PENDING",
259
+ "TRIGGERED": "COM_XFER_TRIGGERED",
260
+ "TRIGGERED_ON_CHANGE": "COM_XFER_TRIGGERED_ON_CHANGE"
261
+ },
262
+ "default": "COM_XFER_PENDING"
263
+ },
264
+ {"name": "Notification", "path": "call:rteSignalCallback", "default": "NULL_PTR"}
265
+ ]
266
+ },
267
+ {
268
+ "name": "Com_RxSignalInfo",
269
+ "type": "Com_SignalInfoType",
270
+ "qualifier": "COM_CONST",
271
+ "static": true,
272
+ "rows": "@RxSignals",
273
+ "size": "COM_NUMBER_OF_RX_SIGNALS",
274
+ "designated": "{sym} - COM_NUMBER_OF_TX_SIGNALS",
275
+ "comment": "sym",
276
+ "doc": "Rx signals, indexed by ComHandleId - COM_NUMBER_OF_TX_SIGNALS (Com_ReceiveSignal)",
277
+ "fields": [
278
+ {"name": "BitPosition", "path": "param:ComBitPosition"},
279
+ {"name": "BitSize", "path": "param:ComBitSize"},
280
+ {
281
+ "name": "Type",
282
+ "path": "param:ComSignalType",
283
+ "enum": {
284
+ "BOOLEAN": "COM_SIGTYPE_BOOLEAN",
285
+ "UINT8": "COM_SIGTYPE_UINT8",
286
+ "UINT16": "COM_SIGTYPE_UINT16",
287
+ "UINT32": "COM_SIGTYPE_UINT32",
288
+ "SINT8": "COM_SIGTYPE_SINT8",
289
+ "SINT16": "COM_SIGTYPE_SINT16",
290
+ "SINT32": "COM_SIGTYPE_SINT32"
291
+ }
292
+ },
293
+ {"name": "IPduRef", "path": ["back:ComIPdu/ComIPduSignalRef", "sym"]},
294
+ {"name": "InitValue", "path": "param:ComSignalInitValue", "fmt": "int", "default": "0u"},
295
+ {
296
+ "name": "TransferProperty",
297
+ "path": "param:ComTransferProperty",
298
+ "enum": {
299
+ "PENDING": "COM_XFER_PENDING",
300
+ "TRIGGERED": "COM_XFER_TRIGGERED",
301
+ "TRIGGERED_ON_CHANGE": "COM_XFER_TRIGGERED_ON_CHANGE"
302
+ },
303
+ "default": "COM_XFER_PENDING"
304
+ },
305
+ {"name": "Notification", "path": "call:rteSignalCallback", "default": "NULL_PTR"}
306
+ ]
307
+ },
308
+ {
309
+ "name": "Com_TxIPduInfo",
310
+ "type": "Com_TxIPduInfoType",
311
+ "qualifier": "COM_CONST",
312
+ "static": true,
313
+ "rows": "@TxIPdus",
314
+ "size": "COM_NUMBER_OF_TX_IPDUS",
315
+ "designated": true,
316
+ "comment": "sym",
317
+ "doc": "Tx I-PDUs, indexed by ComIPduHandleId; CycleTicks = ComTxModeTimePeriod / ComMainTxTimeBase of the I-PDU's ComMainFunctionTx",
318
+ "fields": [
319
+ {"name": "PduRSrcPduId", "path": ["peer:ComPduIdRef@PduR/PduRSrcPdu", "sym"]},
320
+ {"name": "Length", "path": ["ref:ComPduIdRef", "param:PduLength"]},
321
+ {
322
+ "name": "TxMode",
323
+ "path": ["sub:ComTxIPdu", "sub:ComTxModeTrue", "sub:ComTxMode", "param:ComTxModeMode"],
324
+ "enum": {
325
+ "NONE": "COM_TXMODE_NONE",
326
+ "DIRECT": "COM_TXMODE_DIRECT",
327
+ "PERIODIC": "COM_TXMODE_PERIODIC",
328
+ "MIXED": "COM_TXMODE_MIXED"
329
+ },
330
+ "default": "COM_TXMODE_NONE"
331
+ },
332
+ {
333
+ "name": "CycleTicks",
334
+ "path": ["sub:ComTxIPdu", "sub:ComTxModeTrue", "sub:ComTxMode", "param:ComTxModeTimePeriod"],
335
+ "divide": ["ref:ComIPduMainFunctionRef", "param:ComMainTxTimeBase"],
336
+ "default": "0u"
337
+ },
338
+ {"name": "Buffer", "path": "name", "fmt": "Com_IPduBuffer_{}"}
339
+ ]
340
+ },
341
+ {
342
+ "name": "Com_RxIPduInfo",
343
+ "type": "Com_RxIPduInfoType",
344
+ "qualifier": "COM_CONST",
345
+ "static": true,
346
+ "rows": "@RxIPdus",
347
+ "size": "COM_NUMBER_OF_RX_IPDUS",
348
+ "designated": "{sym} - COM_NUMBER_OF_TX_IPDUS",
349
+ "comment": "sym",
350
+ "doc": "Rx I-PDUs, indexed by ComIPduHandleId - COM_NUMBER_OF_TX_IPDUS; TimeoutTicks = smallest non-zero ComFirstTimeout/ComTimeout of the I-PDU's signals without update bit (SWS_Com_00291) / ComMainRxTimeBase",
351
+ "fields": [
352
+ {"name": "Length", "path": ["ref:ComPduIdRef", "param:PduLength"]},
353
+ {
354
+ "name": "TimeoutTicks",
355
+ "agg": {
356
+ "over": "ComIPduSignalRef",
357
+ "params": ["ComFirstTimeout", "ComTimeout"],
358
+ "op": "min_nonzero",
359
+ "skipIf": "ComUpdateBitPosition"
360
+ },
361
+ "divide": ["ref:ComIPduMainFunctionRef", "param:ComMainRxTimeBase"],
362
+ "default": "0u"
363
+ },
364
+ {"name": "Buffer", "path": "name", "fmt": "Com_IPduBuffer_{}"}
365
+ ]
366
+ }
367
+ ],
368
+ "objects": [
369
+ {
370
+ "name": "Com_Config",
371
+ "type": "Com_ConfigType",
372
+ "qualifier": "COM_CONST",
373
+ "init": ["Com_TxSignalInfo", "Com_RxSignalInfo", "Com_TxIPduInfo", "Com_RxIPduInfo"]
374
+ }
108
375
  ]
109
376
  }
110
377
  }
@@ -31,6 +31,26 @@ class Ctx:
31
31
  sources: list = field(default_factory=list) # project .c/.h files (static + in-house), for SchM scans
32
32
  generating: set = field(default_factory=set) # module names generated in this run
33
33
  available: set = field(default_factory=set) # header basenames reachable by the build (incl. the output dir)
34
+ out_headers: dict = field(default_factory=dict) # headers of other generators (e.g. the RTE) in the project's output dir
35
+
36
+ def module_release(self, mip: str) -> tuple:
37
+ """AUTOSAR release the module's generated configuration is built for: the published information of its
38
+ static code (<MIP>_AR_RELEASE_*_VERSION in <Mip>.h, SWS_BSW_00059), which SWS_BSW_00036-style checks compare
39
+ against; the ECUC schema release only when the project has no such header."""
40
+ f = self.headers.get(f"{mip}.h")
41
+ rel = published_release(f, mip.upper()) if f else None
42
+ return rel or self.release
43
+
44
+ def header_text(self, name: str) -> Optional[str]:
45
+ """Text of a project header or of another generator's header in the output dir (None if absent)."""
46
+ f = self.headers.get(name) or self.out_headers.get(name)
47
+ if not f:
48
+ return None
49
+ try:
50
+ with open(f, errors="replace") as fh:
51
+ return fh.read()
52
+ except OSError:
53
+ return None
34
54
 
35
55
  def xsym(self, c: Container, here: ModuleCfg, used: set) -> str:
36
56
  """Symbol of a container for use in module `here`: the TPS_ECUC_02108 name when its provider header
@@ -46,12 +66,32 @@ class Ctx:
46
66
  return f"{W.c_uint(v)} /* {sym} */" if v is not None else sym
47
67
 
48
68
 
69
+ def published_release(path: str, MIP: str) -> Optional[tuple]:
70
+ """(major, minor, revision) from <MIP>_AR_RELEASE_{MAJOR,MINOR,REVISION}_VERSION in a header, if defined."""
71
+ import re
72
+ try:
73
+ with open(path, errors="replace") as fh:
74
+ t = fh.read()
75
+ except OSError:
76
+ return None
77
+ v = []
78
+ for k in ("MAJOR", "MINOR", "REVISION"):
79
+ m = re.search(rf"#\s*define\s+{re.escape(MIP)}_AR_RELEASE_{k}_VERSION\s+\(?(\d+)", t)
80
+ v.append(int(m.group(1)) if m else None)
81
+ if v[0] is None or v[1] is None:
82
+ return None
83
+ return (v[0], v[1], v[2] or 0)
84
+
85
+
49
86
  class ModuleOutput:
50
87
  def __init__(self, ctx: Ctx, mc: ModuleCfg):
51
88
  self.ctx = ctx
52
89
  self.mc = mc
53
90
  self.mip = mc.mip
54
91
  self.MIP = mc.MIP
92
+ self.release = ctx.module_release(mc.mip)
93
+ self.vars: dict = {} # rank -> [(section, text)]: RAM objects (e.g. I-PDU buffers) next to the tables
94
+ self.errors: list = [] # configuration the static-code binding cannot represent (generation fails)
55
95
  self.groups: list = [] # (title, [define lines])
56
96
  self.types: list = []
57
97
  self.hdecls: list = []
@@ -86,6 +126,12 @@ class ModuleOutput:
86
126
  if e not in lst:
87
127
  lst.append(e)
88
128
 
129
+ def var(self, rank: int, section: str, text: str):
130
+ """A RAM object owned by the configuration (e.g. a buffer the const tables point to)."""
131
+ rank = max(rank, 1)
132
+ self.vars.setdefault(rank, []).append((section, text))
133
+ self.tables.setdefault(rank, [])
134
+
89
135
  def include(self, h: str):
90
136
  if h not in self.c_includes:
91
137
  self.c_includes.append(h)
@@ -100,7 +146,7 @@ class ModuleOutput:
100
146
  return "sha256:" + h.hexdigest()[:16]
101
147
 
102
148
  def _banner(self, name: str) -> str:
103
- return W.banner(name, self.mc.name, self.mc.variant, self.ctx.release, self.ctx.cg.rel_files(self.mc),
149
+ return W.banner(name, self.mc.name, self.mc.variant, self.release, self.ctx.cg.rel_files(self.mc),
104
150
  self._digest)
105
151
 
106
152
  def render(self) -> dict:
@@ -111,7 +157,7 @@ class ModuleOutput:
111
157
  parts = [self._banner(hname), "", f"#ifndef {g}", f"#define {g}", ""]
112
158
  for inc in self.h_includes:
113
159
  parts.append(f'#include "{inc}"')
114
- maj, mnr, rev = self.ctx.release
160
+ maj, mnr, rev = self.release
115
161
  sw = [int(x) if x.isdigit() else 0 for x in ENGINE_VERSION.split("-")[0].split(".")][:3]
116
162
  ver = [(f"{self.MIP}_CFG_AR_RELEASE_MAJOR_VERSION", f"{maj}u"),
117
163
  (f"{self.MIP}_CFG_AR_RELEASE_MINOR_VERSION", f"{mnr}u"),
@@ -151,6 +197,12 @@ class ModuleOutput:
151
197
  if externs:
152
198
  text += ["/* Objects owned by other modules / the application, referenced by this configuration */",
153
199
  *externs, ""]
200
+ sections: dict = {}
201
+ for r in sorted(ranks):
202
+ for sec, v in self.vars.get(r, []):
203
+ sections.setdefault(sec, []).append(v)
204
+ for sec in sorted(sections):
205
+ text += [W.memmap(self.mip, "\n".join(sections[sec]), sec), ""]
154
206
  text += [W.memmap(self.mip, "\n\n".join(body)), ""]
155
207
  out[fname] = "\n".join(text)
156
208
  out.update(self.extra_files)
@@ -204,8 +256,23 @@ def scalar_macros(cg: CgModel, mo: ModuleOutput):
204
256
  mo.group(f"Pre-compile parameters of {c.def_name} ({c.path})", lines)
205
257
 
206
258
 
259
+ def enum_literal_values(literals: list) -> list:
260
+ """C values of enumeration literals used in #if comparisons.
261
+
262
+ When every literal is <common stem><decimal number> with distinct numbers (NVM_API_CONFIG_CLASS_1..3), the
263
+ number in the name is the value: the name states the ordinal (SWS_NvM_00560..00562 API configuration class
264
+ 1/2/3), so #if (X >= X_2) keeps its meaning and no literal is 0. Otherwise the def literal order is used (the
265
+ ECUC def lists literals alphabetically, so that order carries no meaning beyond being stable).
266
+ """
267
+ import re
268
+ m = [re.fullmatch(r"(.*?)(\d+)", x) for x in literals]
269
+ if all(m) and len({x.group(1) for x in m}) == 1 and len({int(x.group(2)) for x in m}) == len(literals):
270
+ return [int(x.group(2)) for x in m]
271
+ return list(range(len(literals)))
272
+
273
+
207
274
  def enum_literals(mo: ModuleOutput, d: D.DefNode):
208
- """Guarded values for module-prefixed enum literals used in #if comparisons (def literal order)."""
275
+ """Guarded values for module-prefixed enum literals used in #if comparisons (see enum_literal_values)."""
209
276
  lits = [x for x in d.literals if x.upper().startswith(mo.MIP + "_")]
210
277
  if not lits or len(lits) != len(d.literals):
211
278
  return
@@ -213,8 +280,9 @@ def enum_literals(mo: ModuleOutput, d: D.DefNode):
213
280
  if key in mo.defined:
214
281
  return
215
282
  mo.defined.add(key)
216
- lines = [f"#ifndef {lit}\n" + W.define(lit, W.c_uint(i)) + "\n#endif" for i, lit in enumerate(d.literals)]
217
- mo.groups.append((f"Literals of {d.name} (def literal order; the static code may predefine them)", lines))
283
+ vals = enum_literal_values(d.literals)
284
+ lines = [f"#ifndef {lit}\n" + W.define(lit, W.c_uint(v)) + "\n#endif" for v, lit in zip(vals, d.literals)]
285
+ mo.groups.append((f"Literals of {d.name} (the static code may predefine them)", lines))
218
286
 
219
287
 
220
288
  def symbolic_names(cg: CgModel, mo: ModuleOutput):