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