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 #include <stdbool.h> 15 16 typedef enum { UINT_8T, UINT_16T, UINT_32T, UINT_64T } IntType; 17 18 typedef struct { 19 IntType size; 20 union { 21 UINT8 ui8; 22 UINT16 ui16; 23 UINT32 ui32; 24 UINT64 ui64; 25 } value; 26 } ValidationTypes; 27 28 json_object * 29 cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS *error_status); 30 void ir_generic_error_status_to_cper( 31 json_object *error_status, EFI_GENERIC_ERROR_STATUS *error_status_cper); 32 json_object *uniform_struct_to_ir(UINT32 *start, int len, const char *names[]); 33 json_object *uniform_struct64_to_ir(UINT64 *start, int len, 34 const char *names[]); 35 void ir_to_uniform_struct(json_object *ir, UINT32 *start, int len, 36 const char *names[]); 37 void ir_to_uniform_struct64(json_object *ir, UINT64 *start, int len, 38 const char *names[]); 39 json_object *integer_to_readable_pair(UINT64 value, int len, const int keys[], 40 const char *values[], 41 const char *default_value); 42 json_object *integer_to_readable_pair_with_desc(int value, int len, 43 const int keys[], 44 const char *values[], 45 const char *descriptions[], 46 const char *default_value); 47 UINT64 readable_pair_to_integer(json_object *pair); 48 json_object *bitfield_to_ir(UINT64 bitfield, int num_fields, 49 const char *names[]); 50 UINT64 ir_to_bitfield(json_object *ir, int num_fields, const char *names[]); 51 bool isvalid_prop_to_ir(ValidationTypes *val, int vbit_idx); 52 void add_to_valid_bitfield(ValidationTypes *val, int vbit_idx); 53 void print_val(ValidationTypes *val); 54 json_object *uint64_array_to_ir_array(UINT64 *array, int len); 55 json_object *revision_to_ir(UINT16 revision); 56 const char *severity_to_string(UINT32 severity); 57 void timestamp_to_string(char *out, int out_len, 58 EFI_ERROR_TIME_STAMP *timestamp); 59 void string_to_timestamp(EFI_ERROR_TIME_STAMP *out, const char *timestamp); 60 void guid_to_string(char *out, EFI_GUID *guid); 61 void string_to_guid(EFI_GUID *out, const char *guid); 62 int guid_equal(EFI_GUID *a, EFI_GUID *b); 63 64 //The available severity types for CPER. 65 extern const char *CPER_SEVERITY_TYPES[4]; 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 #endif 72