1 #ifndef CPER_UTILS_H
2 #define CPER_UTILS_H
3 
4 #define GUID_STRING_LENGTH 48
5 #define TIMESTAMP_LENGTH   26
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 #include <libcper/common-utils.h>
12 #include <libcper/Cper.h>
13 #include <json.h>
14 
15 json_object *
16 cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS *error_status);
17 void ir_generic_error_status_to_cper(
18 	json_object *error_status, EFI_GENERIC_ERROR_STATUS *error_status_cper);
19 json_object *uniform_struct_to_ir(UINT32 *start, int len, const char *names[]);
20 json_object *uniform_struct64_to_ir(UINT64 *start, int len,
21 				    const char *names[]);
22 void ir_to_uniform_struct(json_object *ir, UINT32 *start, int len,
23 			  const char *names[]);
24 void ir_to_uniform_struct64(json_object *ir, UINT64 *start, int len,
25 			    const char *names[]);
26 json_object *integer_to_readable_pair(UINT64 value, int len, const int keys[],
27 				      const char *values[],
28 				      const char *default_value);
29 json_object *integer_to_readable_pair_with_desc(int value, int len,
30 						const int keys[],
31 						const char *values[],
32 						const char *descriptions[],
33 						const char *default_value);
34 UINT64 readable_pair_to_integer(json_object *pair);
35 json_object *bitfield_to_ir(UINT64 bitfield, int num_fields,
36 			    const char *names[]);
37 UINT64 ir_to_bitfield(json_object *ir, int num_fields, const char *names[]);
38 json_object *uint64_array_to_ir_array(UINT64 *array, int len);
39 json_object *revision_to_ir(UINT16 revision);
40 const char *severity_to_string(UINT32 severity);
41 void timestamp_to_string(char *out, int out_len,
42 			 EFI_ERROR_TIME_STAMP *timestamp);
43 void string_to_timestamp(EFI_ERROR_TIME_STAMP *out, const char *timestamp);
44 void guid_to_string(char *out, EFI_GUID *guid);
45 void string_to_guid(EFI_GUID *out, const char *guid);
46 int guid_equal(EFI_GUID *a, EFI_GUID *b);
47 
48 //The available severity types for CPER.
49 extern const char *CPER_SEVERITY_TYPES[4];
50 
51 #ifdef __cplusplus
52 }
53 #endif
54 
55 #endif
56