11b0b00e3SLawrence Tang #ifndef CPER_UTILS_H 21b0b00e3SLawrence Tang #define CPER_UTILS_H 31b0b00e3SLawrence Tang 4f8fc7052SJohn Chung #define GUID_STRING_LENGTH 48 51b0b00e3SLawrence Tang #define TIMESTAMP_LENGTH 24 61b0b00e3SLawrence Tang 7aacf0e26SLawrence Tang #include "common-utils.h" 8f8fc7052SJohn Chung #include <json.h> 9aacf0e26SLawrence Tang 10f8fc7052SJohn Chung json_object * 11f8fc7052SJohn Chung cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS *error_status); 12f8fc7052SJohn Chung void ir_generic_error_status_to_cper( 13f8fc7052SJohn Chung json_object *error_status, EFI_GENERIC_ERROR_STATUS *error_status_cper); 147f21db6cSLawrence Tang json_object *uniform_struct_to_ir(UINT32 *start, int len, const char *names[]); 15f8fc7052SJohn Chung json_object *uniform_struct64_to_ir(UINT64 *start, int len, 16f8fc7052SJohn Chung const char *names[]); 17f8fc7052SJohn Chung void ir_to_uniform_struct(json_object *ir, UINT32 *start, int len, 18f8fc7052SJohn Chung const char *names[]); 19f8fc7052SJohn Chung void ir_to_uniform_struct64(json_object *ir, UINT64 *start, int len, 20f8fc7052SJohn Chung const char *names[]); 21*b35d957eSEd Tanous json_object *integer_to_readable_pair(UINT64 value, int len, const int keys[], 22f8fc7052SJohn Chung const char *values[], 23f8fc7052SJohn Chung const char *default_value); 24*b35d957eSEd Tanous json_object *integer_to_readable_pair_with_desc(int value, int len, 25*b35d957eSEd Tanous const int keys[], 26f8fc7052SJohn Chung const char *values[], 27f8fc7052SJohn Chung const char *descriptions[], 28f8fc7052SJohn Chung const char *default_value); 29b44314c7SLawrence Tang UINT64 readable_pair_to_integer(json_object *pair); 30f8fc7052SJohn Chung json_object *bitfield_to_ir(UINT64 bitfield, int num_fields, 31f8fc7052SJohn Chung const char *names[]); 32b44314c7SLawrence Tang UINT64 ir_to_bitfield(json_object *ir, int num_fields, const char *names[]); 33e18aaee9SLawrence Tang json_object *uint64_array_to_ir_array(UINT64 *array, int len); 341b0b00e3SLawrence Tang json_object *revision_to_ir(UINT16 revision); 3502c801a5SLawrence Tang const char *severity_to_string(UINT32 severity); 36b44314c7SLawrence Tang void timestamp_to_string(char *out, EFI_ERROR_TIME_STAMP *timestamp); 37b44314c7SLawrence Tang void string_to_timestamp(EFI_ERROR_TIME_STAMP *out, const char *timestamp); 381b0b00e3SLawrence Tang void guid_to_string(char *out, EFI_GUID *guid); 39b44314c7SLawrence Tang void string_to_guid(EFI_GUID *out, const char *guid); 401b0b00e3SLawrence Tang int guid_equal(EFI_GUID *a, EFI_GUID *b); 411b0b00e3SLawrence Tang 421b0b00e3SLawrence Tang //The available severity types for CPER. 431b0b00e3SLawrence Tang extern const char *CPER_SEVERITY_TYPES[4]; 441b0b00e3SLawrence Tang 451b0b00e3SLawrence Tang #endif 46