blob: cea6e0a78bd32024b8c7fa922b979670d5032259 [file] [log] [blame]
Lawrence Tang1b0b00e2022-07-05 10:33:10 +01001#ifndef CPER_UTILS_H
2#define CPER_UTILS_H
3
4#define GUID_STRING_LENGTH 30
5#define TIMESTAMP_LENGTH 24
6
Lawrence Tanga0865e32022-07-06 11:59:52 +01007json_object* cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS* error_status);
Lawrence Tang3b7f45b2022-07-14 14:14:30 +01008void ir_generic_error_status_to_cper(json_object* error_status, EFI_GENERIC_ERROR_STATUS* error_status_cper);
Lawrence Tang7f21db62022-07-06 11:09:39 +01009json_object* uniform_struct_to_ir(UINT32* start, int len, const char* names[]);
10json_object* uniform_struct64_to_ir(UINT64* start, int len, const char* names[]);
Lawrence Tang71570a22022-07-14 11:45:28 +010011void ir_to_uniform_struct(json_object* ir, UINT32* start, int len, const char* names[]);
12void ir_to_uniform_struct64(json_object* ir, UINT64* start, int len, const char* names[]);
Lawrence Tang3c878352022-07-08 14:04:50 +010013json_object* integer_to_readable_pair(UINT64 value, int len, int keys[], const char* values[], const char* default_value);
Lawrence Tang7f21db62022-07-06 11:09:39 +010014json_object* integer_to_readable_pair_with_desc(int value, int len, int keys[], const char* values[], const char* descriptions[], const char* default_value);
Lawrence Tangb44314c2022-07-13 11:45:22 +010015UINT64 readable_pair_to_integer(json_object* pair);
Lawrence Tang3d0e4f22022-07-05 17:17:41 +010016json_object* bitfield_to_ir(UINT64 bitfield, int num_fields, const char* names[]);
Lawrence Tangb44314c2022-07-13 11:45:22 +010017UINT64 ir_to_bitfield(json_object* ir, int num_fields, const char* names[]);
Lawrence Tange18aaee2022-07-07 09:01:30 +010018json_object* uint64_array_to_ir_array(UINT64* array, int len);
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010019json_object* revision_to_ir(UINT16 revision);
Lawrence Tang02c801a2022-07-18 14:43:52 +010020const char* severity_to_string(UINT32 severity);
Lawrence Tangb44314c2022-07-13 11:45:22 +010021void timestamp_to_string(char* out, EFI_ERROR_TIME_STAMP* timestamp);
22void string_to_timestamp(EFI_ERROR_TIME_STAMP* out, const char* timestamp);
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010023void guid_to_string(char* out, EFI_GUID* guid);
Lawrence Tangb44314c2022-07-13 11:45:22 +010024void string_to_guid(EFI_GUID* out, const char* guid);
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010025int guid_equal(EFI_GUID* a, EFI_GUID* b);
Lawrence Tang4dbe3d72022-07-06 13:51:01 +010026int bcd_to_int(UINT8 bcd);
Lawrence Tang3b7f45b2022-07-14 14:14:30 +010027UINT8 int_to_bcd(int value);
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010028
29//The available severity types for CPER.
30extern const char* CPER_SEVERITY_TYPES[4];
31
32#endif