1//=============================================================================
2//! @file
3//! @author GEMS
4//! @date 7 October 2026
5//! @brief Ginmake identity measurements and restored model calibration access.
6//! @details CM7 owns XCP and persistence; live multi-value updates can tear.
7//=============================================================================
8// (c) Copyright 2026 General Engine Management Systems (GEMS) Ltd
9//=============================================================================
10
11#ifndef CDX_CAL_H_INCLUDED
12#define CDX_CAL_H_INCLUDED
13//=============================================================================
14
15// [MIN_VERSION,2.83]
16
17//=============================================================================
18// Includes
19//=============================================================================
20
21#if defined(CDX_USER_HEADER) && !defined(CDX_USER_H_INCLUDED)
22#include CDX_USER_HEADER
23#endif
24
25#include "cdx_memory.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31//=============================================================================
32// Ginmake API Measurements
33//=============================================================================
34
35//! @brief Read-only XCP EPK address in CM7's view of the model descriptor.
36#define CDX_CAL_IDENTITY_ADDRESS 0x20200418u
37//! @brief Identity span: EPK, IPC hash and model name, including zero padding.
38#define CDX_CAL_IDENTITY_SIZE 160u
39//! @brief Virtual XCP base of the declared shared calibration span, not a C pointer.
40#define CDX_CAL_PARAMETERS_ADDRESS 0xf000u
41// [META,EPK_ADDR,{CDX_CAL_IDENTITY_ADDRESS}]
42// [WORDWRITES]
43// [LITTLEENDIAN]
44// [CONNECTION,XcpCAN]
45// [PROTOCOL,XCP,8,8]
46// [LSB_FIRST][SEGMENT,rom,Identity,CDX_SEG_IDENTITY,,none]
47// [SEGMENT_ADDRESS,Identity,CDX_CAL_IDENTITY_ADDRESS,CDX_CAL_IDENTITY_SIZE,,.model_ipc_descriptor]
48// [ATTRIBUTES,PrgType=DATA,MemoryType=ROM,Attribute=INTERN,NUM_PAGES=0,ADDRESS_EXTENSION=0]
49
50//! @brief Read-only firmware identity measurement exposed by CM7 XCP.
51//! @note This is a Ginmake description, not an additional allocated object.
52//! Model-specific writable persistent parameters belong in the model's own
53//! annotated header or Simulink.Parameter inputs, not in this API header.
54typedef struct CDX_CAL_IDENTITY_STRUCT
55{
56 // [SEGMENT_BEGIN,CDX_SEG_IDENTITY]
57 // [VAR_PREFIX,CDX_identity.]
58 //! @brief Null-terminated read-only model EPK; unused bytes are zero.
59 uint8_t epk[64]; // [ECU_STRING,ID_EPK][DESCRIPTION,Model firmware build identity]
60 //! @brief IPC DBC hash: 20 raw SHA-1 bytes then 12 zero bytes; all zero means absent.
61 uint8_t ipc_dbc_hash[32];
62 //! @brief User-selected model station name; defaults to the model/project name.
63 uint8_t name[64]; // [ECU_STRING,ID_NAME][DESCRIPTION,Model station name]
64 // [VAR_PREFIX,]
65 // [SEGMENT_END,CDX_SEG_IDENTITY]
66} CDX_CAL_IDENTITY;
67
68//=============================================================================
69// Prototypes
70//=============================================================================
71
72//-----------------------------------------------------------------------------
73//! @brief Obtain the active shared calibration data without copying defaults.
74//! @param size Nonnull output receives the model-declared size, zero on failure.
75//! @return Pointer into noncacheable shared RAM, or NULL without valid calibration.
76//! @note Available during CDX_app_system_init and model initialization after CM7
77//! restores compatible stored values. Valid only for the current model session.
78//! The same span is registered with CDX_memory_* at its actual 32-bit address.
79//! Do not overwrite it with model defaults during initialization. No inter-core
80//! mutex or model pause is provided; grouped writes and snapshots may tear.
81void* CDX_calibration_data_get(uint32_t* size);
82
83#ifdef __cplusplus
84}
85#endif
86
87//=============================================================================
88#endif // CDX_CAL_H_INCLUDED
89//=============================================================================
90// End of File
91//=============================================================================