TianoCore EDK2 master
Loading...
Searching...
No Matches
mipi_syst.h
1/*
2Copyright (c) 2018, MIPI Alliance, Inc.
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions
7are met:
8
9* Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12* Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
15 distribution.
16
17* Neither the name of the copyright holder nor the names of its
18 contributors may be used to endorse or promote products derived
19 from this software without specific prior written permission.
20
21THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*/
33
34/*
35 * Contributors:
36 * Norbert Schulz (Intel Corporation) - Initial API and implementation
37 */
38
39#ifndef MIPI_SYST_H_INCLUDED
40#define MIPI_SYST_H_INCLUDED
41
42/* SyS-T API version information
43 */
44#define MIPI_SYST_VERSION_MAJOR 1
45#define MIPI_SYST_VERSION_MINOR 0
46#define MIPI_SYST_VERSION_PATCH 0
54#define MIPI_SYST_CONFORMANCE_LEVEL 30
55
72#define MIPI_SYST_MAKE_VERSION_CODE(ma, mi, p) (((ma) << 16) | ((mi)<<8) | (p))
73
75#define MIPI_SYST_VERSION_CODE MIPI_SYST_MAKE_VERSION_CODE(\
76 MIPI_SYST_VERSION_MAJOR,\
77 MIPI_SYST_VERSION_MINOR,\
78 MIPI_SYST_VERSION_PATCH)
79
80/* Macros to trick numeric values like __LINE__ into a string
81 */
82#define _MIPI_SYST_STRINGIFY(x) #x
83#define _MIPI_SYST_CPP_TOSTR(x) _MIPI_SYST_STRINGIFY(x)
84
85#define _MIPI_SYST_VERSION_STRING(a, b, c)\
86 _MIPI_SYST_CPP_TOSTR(a)"."_MIPI_SYST_CPP_TOSTR(b)"."_MIPI_SYST_CPP_TOSTR(c)
87
89#define MIPI_SYST_VERSION_STRING \
90 _MIPI_SYST_VERSION_STRING(\
91 MIPI_SYST_VERSION_MAJOR,\
92 MIPI_SYST_VERSION_MINOR,\
93 MIPI_SYST_VERSION_PATCH)
94
95#ifndef MIPI_SYST_COMPILER_INCLUDED
96#include "mipi_syst/compiler.h"
97#endif
98
99/* String hash macros for compile time computation of catalog ID's.
100 * Notes:
101 * These macros will only be used with optimized builds, otherwise
102 * a lot of runtime code will be generated.
103 *
104 * Only the last 64 bytes of the string are considered for hashing
105 */
106#define _MIPI_SYST_HASH1(s,i,x,l) (x*65599u+(mipi_syst_u8)s[(i)<(l)?((l)-1-(i)):(l)])
107#define _MIPI_SYST_HASH4(s,i,x,l) _MIPI_SYST_HASH1(s,i,_MIPI_SYST_HASH1(s,i+1,_MIPI_SYST_HASH1(s,i+2,_MIPI_SYST_HASH1(s,i+3,x,l),l),l),l)
108#define _MIPI_SYST_HASH16(s,i,x,l) _MIPI_SYST_HASH4(s,i,_MIPI_SYST_HASH4(s,i+4,_MIPI_SYST_HASH4(s,i+8,_MIPI_SYST_HASH4(s,i+12,x,l),l),l),l)
109#define _MIPI_SYST_HASH64(s,i,x,l) _MIPI_SYST_HASH16(s,i,_MIPI_SYST_HASH16(s,i+16,_MIPI_SYST_HASH16(s,i+32,_MIPI_SYST_HASH16(s,i+48,x,l),l),l),l)
110
111#define _MIPI_SYST_HASH_x65599(s,l) ((mipi_syst_u32)_MIPI_SYST_HASH64(s,0,0,l))
112
113#define _MIPI_SYST_HASH_AT_CPP_TIME(str, offset) (_MIPI_SYST_HASH_x65599(str, sizeof(str)-1) + (offset))
114#define _MIPI_SYST_HASH_AT_RUN_TIME(str, offset) (mipi_syst_hash_x65599(str, sizeof(str)-1) + (offset))
115
116#if defined(_MIPI_SYST_OPTIMIZER_ON)
117#define MIPI_SYST_HASH(a, b) _MIPI_SYST_HASH_AT_CPP_TIME((a), (b))
118#else
119#define MIPI_SYST_HASH(a, b) _MIPI_SYST_HASH_AT_RUN_TIME((a),(b))
120#endif
121
122#if defined(__cplusplus)
123extern "C" {
124#endif
125
128enum mipi_syst_msgtype {
137 MIPI_SYST_TYPE_MAX
138};
139
142enum mipi_syst_subtype_string {
151 MIPI_SYST_STRING_MAX
152};
153
156enum mipi_syst_subtype_catalog {
162 MIPI_SYST_CATALOG_MAX
163};
164
167enum mipi_syst_subtype_clock{
169 MIPI_SYST_CLOCK_MAX
170};
171
172enum mipi_syst_subtype_build {
176 MIPI_SYST_BUILD_MAX
177};
178
179struct mipi_syst_header;
180struct mipi_syst_handle;
181struct mipi_syst_scatter_prog;
182
185 union {
186 mipi_syst_u8 b[16];
187 mipi_syst_u64 ll[2];
188 } u;
189};
190
207#define MIPI_SYST_GEN_GUID(l1, w1, w2, w3, l2) \
208 {{\
209 (mipi_syst_u8)((mipi_syst_u32)(l1) >> 24), \
210 (mipi_syst_u8)((mipi_syst_u32)(l1) >> 16), \
211 (mipi_syst_u8)((mipi_syst_u32)(l1) >> 8), \
212 (mipi_syst_u8)((mipi_syst_u32)(l1) >> 0), \
213 (mipi_syst_u8)((mipi_syst_u16)(w1) >> 8), \
214 (mipi_syst_u8)((mipi_syst_u16)(w1) >> 0), \
215 (mipi_syst_u8)((mipi_syst_u16)(w2) >> 8), \
216 (mipi_syst_u8)((mipi_syst_u16)(w2) >> 0), \
217 (mipi_syst_u8)((mipi_syst_u16)(w3) >> 8), \
218 (mipi_syst_u8)((mipi_syst_u16)(w3) >> 0), \
219 (mipi_syst_u8)((mipi_syst_u64)(l2) >> 40), \
220 (mipi_syst_u8)((mipi_syst_u64)(l2) >> 32), \
221 (mipi_syst_u8)((mipi_syst_u64)(l2) >> 24), \
222 (mipi_syst_u8)((mipi_syst_u64)(l2) >> 16), \
223 (mipi_syst_u8)((mipi_syst_u64)(l2) >> 8), \
224 (mipi_syst_u8)((mipi_syst_u64)(l2) >> 0) \
225 }}
226
238 mipi_syst_u16 unit;
239};
240
260#define MIPI_SYST_GEN_ORIGIN_GUID(l1, w1, w2, w3, l2 , u) \
261 {\
262 MIPI_SYST_GEN_GUID(l1, w1, w2, w3, l2) ,\
263 u\
264 }
265
280#define MIPI_SYST_GEN_ORIGIN_MODULE(m , u) \
281 {\
282 MIPI_SYST_GEN_GUID(0,0,0, ((mipi_syst_u16)(m & 0x7F)) << 8, 0 ),\
283 u\
284 }
298typedef void (MIPI_SYST_CALLCONV *mipi_syst_inithook_t)(struct mipi_syst_header *systh,
299 const void *p);
300
311typedef void (MIPI_SYST_CALLCONV *mipi_syst_destroyhook_t)(struct mipi_syst_header *systh);
312
323typedef void (*mipi_syst_inithandle_hook_t)(struct mipi_syst_handle *systh);
324
335typedef void (*mipi_syst_releasehandle_hook_t)(struct mipi_syst_handle *systh);
336
351typedef void (*mipi_syst_msg_write_t)(
352 struct mipi_syst_handle *systh,
353 struct mipi_syst_scatter_prog *scatterprog,
354 const void *pdesc);
355
356#ifdef __cplusplus
357} /* extern C */
358#endif
359#ifndef MIPI_SYST_PLATFORM_INCLUDED
360
395#define MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA
396#undef MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA
408#define MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA
409
422#define MIPI_SYST_PCFG_ENABLE_HEAP_MEMORY
423#undef MIPI_SYST_PCFG_ENABLE_HEAP_MEMORY
424/* MSVC and GNU compiler 64-bit mode */
425
431#if defined(_WIN64) || defined(__x86_64__) || defined (__LP64__)
432#define MIPI_SYST_PCFG_ENABLE_64BIT_ADDR
433#endif
441#if defined(_WIN64) || defined(__x86_64__) || defined (__LP64__)
442#define MIPI_SYST_PCFG_ENABLE_64BIT_IO
443#endif
444
452#define MIPI_SYST_PCFG_ENABLE_INLINE
453
466#if MIPI_SYST_CONFORMANCE_LEVEL > 10
487#define MIPI_SYST_PCFG_ENABLE_DEFAULT_SCATTER_WRITE
488
492#define MIPI_SYST_PCFG_ENABLE_CATID32_API
493
497#define MIPI_SYST_PCFG_ENABLE_CATID64_API
498
502#define MIPI_SYST_PCFG_ENABLE_STRING_API
503
507#define MIPI_SYST_PCFG_ENABLE_WRITE_API
508
512#define MIPI_SYST_PCFG_ENABLE_BUILD_API
513#endif /* MIPI_SYST_CONFORMANCE_LEVEL > 10 */
514
515#if MIPI_SYST_CONFORMANCE_LEVEL > 20
524#define MIPI_SYST_PCFG_ENABLE_PRINTF_API
525#undef MIPI_SYST_PCFG_ENABLE_PRINTF_API
532#define MIPI_SYST_PCFG_PRINTF_ARGBUF_SIZE 1024
533
534#endif /* #if MIPI_SYST_CONFORMANCE_LEVEL > 20 */
535
536/* @} */
537
548#if MIPI_SYST_CONFORMANCE_LEVEL > 10
552#define MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID
553
557#define MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD
558#undef MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD
566#define MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS
567#undef MIPI_SYST_PCFG_ENABLE_LOCATION_ADDRESS
578#define MIPI_SYST_PCFG_ENABLE_TIMESTAMP
579
580#if defined(_DOXYGEN_) /* only for doxygen, remove the #if to enable */
587#define MIPI_SYST_PCFG_LENGTH_FIELD
588#endif
589
590#endif
591
592#if MIPI_SYST_CONFORMANCE_LEVEL > 20
596#define MIPI_SYST_PCFG_ENABLE_CHECKSUM
597
598#endif /* #if MIPI_SYST_CONFORMANCE_LEVEL */
599
602#include "Platform.h"
603#endif
604#ifdef __cplusplus
605extern "C" {
606#endif
607
608#if defined(MIPI_SYST_PCFG_ENABLE_INLINE)
609#define MIPI_SYST_INLINE static MIPI_SYST_CC_INLINE
610#else
611#define MIPI_SYST_INLINE MIPI_SYST_EXPORT
612#endif
613
618 mipi_syst_u32 systh_version;
620#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA)
621 mipi_syst_inithandle_hook_t systh_inith;
622 mipi_syst_releasehandle_hook_t systh_releaseh;
623#endif
624
625#if MIPI_SYST_CONFORMANCE_LEVEL > 10
626 mipi_syst_msg_write_t systh_writer;
627#endif
628#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA)
629 struct mipi_syst_platform_state systh_platform;
631#endif
632};
633
643#if defined(MIPI_SYST_BIG_ENDIAN)
644 mipi_syst_u32 et_res31 : 1;
645 mipi_syst_u32 et_res30 : 1;
646 mipi_syst_u32 et_subtype : 6;
647 mipi_syst_u32 et_guid : 1;
648 mipi_syst_u32 et_modunit : 11;
649 mipi_syst_u32 et_timestamp : 1;
650 mipi_syst_u32 et_chksum : 1;
651 mipi_syst_u32 et_length : 1;
652 mipi_syst_u32 et_location : 1;
653 mipi_syst_u32 et_res7 : 1;
654 mipi_syst_u32 et_severity : 3;
655 mipi_syst_u32 et_type : 4;
656#else
657 mipi_syst_u32 et_type : 4;
658 mipi_syst_u32 et_severity : 3;
659 mipi_syst_u32 et_res7 : 1;
660 mipi_syst_u32 et_location : 1;
661 mipi_syst_u32 et_length : 1;
662 mipi_syst_u32 et_chksum : 1;
663 mipi_syst_u32 et_timestamp : 1;
664 mipi_syst_u32 et_modunit : 11;
665 mipi_syst_u32 et_guid : 1;
666 mipi_syst_u32 et_subtype : 6;
667 mipi_syst_u32 et_res30 : 1;
668 mipi_syst_u32 et_res31 : 1;
669#endif
670};
671#define _MIPI_SYST_MK_MODUNIT_ORIGIN(m,u) (((u) & 0xF)|(m<<4))
672
686
693 struct {
694#if defined(MIPI_SYST_BIG_ENDIAN)
695 mipi_syst_u16 etls_lineNo;
696 mipi_syst_u16 etls_fileID;
697#else
698 mipi_syst_u16 etls_fileID;
699 mipi_syst_u16 etls_lineNo;
700#endif
701 } etls_source_location;
702
703 mipi_syst_u32 etls_code_location:32;
704};
705
712 struct {
713#if defined(MIPI_SYST_BIG_ENDIAN)
714 mipi_syst_u32 etls_lineNo;
715 mipi_syst_u32 etls_fileID;
716#else
717 mipi_syst_u32 etls_fileID;
718 mipi_syst_u32 etls_lineNo;
719#endif
720 } etls_source_location;
721 mipi_syst_u64 etls_code_location;
722};
723
734 mipi_syst_u8 el_format;
735 union {
738 } el_u;
739};
740
744 mipi_syst_u32 shf_alloc:1;
745};
746
758#if defined(MIPI_SYST_PCFG_ENABLE_ORIGIN_GUID)
760#endif
761
762#if defined(MIPI_SYST_PCFG_ENABLE_LOCATION_RECORD)
763 struct mipi_syst_msglocation systh_location;
764#endif
765
766 mipi_syst_u32 systh_param_count;
767 mipi_syst_u32 systh_param[6];
769#if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_HANDLE_DATA)
772#endif
773};
774
775
776#ifdef __cplusplus
777} /* extern C */
778#endif
779#ifndef MIPI_SYST_API_INCLUDED
780#include "mipi_syst/api.h"
781#endif
782
785typedef enum mipi_syst_severity MIPI_SYST_SEVERITY;
786typedef struct mipi_syst_guid MIPI_SYST_GUID;
789#endif
mipi_syst_u16 unit
Definition: mipi_syst.h:238
mipi_syst_u32 et_timestamp
Definition: mipi_syst.h:663
@ MIPI_SYST_STRING_ASSERT
Definition: mipi_syst.h:147
@ MIPI_SYST_STRING_INVALIDPARAM
Definition: mipi_syst.h:146
@ MIPI_SYST_STRING_FUNCTIONENTER
Definition: mipi_syst.h:144
@ MIPI_SYST_STRING_PRINTF_64
Definition: mipi_syst.h:149
@ MIPI_SYST_STRING_PRINTF_32
Definition: mipi_syst.h:148
@ MIPI_SYST_STRING_GENERIC
Definition: mipi_syst.h:143
@ MIPI_SYST_STRING_FUNCTIONEXIT
Definition: mipi_syst.h:145
@ MIPI_SYST_CLOCK_TRANSPORT_SYNC
Definition: mipi_syst.h:168
mipi_syst_severity
Definition: mipi_syst.h:676
struct mipi_syst_msg_tag systh_tag
Definition: mipi_syst.h:756
mipi_syst_u32 et_modunit
Definition: mipi_syst.h:664
mipi_syst_u64 etls_code_location
Definition: mipi_syst.h:721
mipi_syst_u32 et_guid
Definition: mipi_syst.h:665
@ MIPI_SYST_BUILD_ID_COMPACT32
Definition: mipi_syst.h:173
@ MIPI_SYST_BUILD_ID_LONG
Definition: mipi_syst.h:175
@ MIPI_SYST_BUILD_ID_COMPACT64
Definition: mipi_syst.h:174
struct mipi_syst_platform_handle systh_platform
Definition: mipi_syst.h:770
mipi_syst_u32 et_type
Definition: mipi_syst.h:657
mipi_syst_inithandle_hook_t systh_inith
Definition: mipi_syst.h:621
mipi_syst_u32 et_res7
Definition: mipi_syst.h:659
struct mipi_syst_guid systh_guid
Definition: mipi_syst.h:759
mipi_syst_u8 el_format
Definition: mipi_syst.h:734
mipi_syst_u32 et_length
Definition: mipi_syst.h:661
struct mipi_syst_handle_flags systh_flags
Definition: mipi_syst.h:755
mipi_syst_u32 etls_fileID
Definition: mipi_syst.h:717
mipi_syst_u32 et_chksum
Definition: mipi_syst.h:662
mipi_syst_u32 systh_param_count
Definition: mipi_syst.h:766
mipi_syst_u32 et_subtype
Definition: mipi_syst.h:666
@ MIPI_SYST_CATALOG_ID64_P32
Definition: mipi_syst.h:158
@ MIPI_SYST_CATALOG_ID64_P64
Definition: mipi_syst.h:160
@ MIPI_SYST_CATALOG_ID32_P64
Definition: mipi_syst.h:159
@ MIPI_SYST_CATALOG_ID32_P32
Definition: mipi_syst.h:157
union mipi_syst_msglocation64 loc64
Definition: mipi_syst.h:737
mipi_syst_u32 shf_alloc
Definition: mipi_syst.h:744
mipi_syst_u32 systh_version
Definition: mipi_syst.h:618
mipi_syst_u16 etls_lineNo
Definition: mipi_syst.h:699
mipi_syst_u32 et_location
Definition: mipi_syst.h:660
mipi_syst_msg_write_t systh_writer
Definition: mipi_syst.h:626
@ MIPI_SYST_TYPE_STRING
Definition: mipi_syst.h:131
@ MIPI_SYST_TYPE_SHORT64
Definition: mipi_syst.h:134
@ MIPI_SYST_TYPE_SHORT32
Definition: mipi_syst.h:130
@ MIPI_SYST_TYPE_BUILD
Definition: mipi_syst.h:129
@ MIPI_SYST_TYPE_CLOCK
Definition: mipi_syst.h:135
@ MIPI_SYST_TYPE_RAW
Definition: mipi_syst.h:133
@ MIPI_SYST_TYPE_CATALOG
Definition: mipi_syst.h:132
mipi_syst_u32 et_res31
Definition: mipi_syst.h:668
struct mipi_syst_guid guid
Definition: mipi_syst.h:237
union mipi_syst_msglocation32 loc32
Definition: mipi_syst.h:736
mipi_syst_u32 systh_param[6]
Definition: mipi_syst.h:767
mipi_syst_u32 et_severity
Definition: mipi_syst.h:658
mipi_syst_u32 etls_lineNo
Definition: mipi_syst.h:718
mipi_syst_u16 etls_fileID
Definition: mipi_syst.h:698
struct mipi_syst_header * systh_header
Definition: mipi_syst.h:754
mipi_syst_u32 etls_code_location
Definition: mipi_syst.h:703
mipi_syst_releasehandle_hook_t systh_releaseh
Definition: mipi_syst.h:622
mipi_syst_u32 et_res30
Definition: mipi_syst.h:667
@ MIPI_SYST_SEVERITY_WARNING
Definition: mipi_syst.h:680
@ MIPI_SYST_SEVERITY_FATAL
Definition: mipi_syst.h:678
@ MIPI_SYST_SEVERITY_ERROR
Definition: mipi_syst.h:679
@ MIPI_SYST_SEVERITY_INFO
Definition: mipi_syst.h:681
@ MIPI_SYST_SEVERITY_USER1
Definition: mipi_syst.h:682
@ MIPI_SYST_SEVERITY_MAX
Definition: mipi_syst.h:677
@ MIPI_SYST_SEVERITY_USER2
Definition: mipi_syst.h:683
@ MIPI_SYST_SEVERITY_DEBUG
Definition: mipi_syst.h:684