blob: 18f1e0f2002dc5913dd1cc4805cc04705ab43281 [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 Tangaacf0e22022-07-20 13:28:52 +01007#include "common-utils.h"
8
Lawrence Tanga0865e32022-07-06 11:59:52 +01009json_object* cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS* error_status);
Lawrence Tang3b7f45b2022-07-14 14:14:30 +010010void ir_generic_error_status_to_cper(json_object* error_status, EFI_GENERIC_ERROR_STATUS* error_status_cper);
Lawrence Tang7f21db62022-07-06 11:09:39 +010011json_object* uniform_struct_to_ir(UINT32* start, int len, const char* names[]);
12json_object* uniform_struct64_to_ir(UINT64* start, int len, const char* names[]);
Lawrence Tang71570a22022-07-14 11:45:28 +010013void ir_to_uniform_struct(json_object* ir, UINT32* start, int len, const char* names[]);
14void ir_to_uniform_struct64(json_object* ir, UINT64* start, int len, const char* names[]);
Lawrence Tang3c878352022-07-08 14:04:50 +010015json_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 +010016json_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 +010017UINT64 readable_pair_to_integer(json_object* pair);
Lawrence Tang3d0e4f22022-07-05 17:17:41 +010018json_object* bitfield_to_ir(UINT64 bitfield, int num_fields, const char* names[]);
Lawrence Tangb44314c2022-07-13 11:45:22 +010019UINT64 ir_to_bitfield(json_object* ir, int num_fields, const char* names[]);
Lawrence Tange18aaee2022-07-07 09:01:30 +010020json_object* uint64_array_to_ir_array(UINT64* array, int len);
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010021json_object* revision_to_ir(UINT16 revision);
Lawrence Tang02c801a2022-07-18 14:43:52 +010022const char* severity_to_string(UINT32 severity);
Lawrence Tangb44314c2022-07-13 11:45:22 +010023void timestamp_to_string(char* out, EFI_ERROR_TIME_STAMP* timestamp);
24void string_to_timestamp(EFI_ERROR_TIME_STAMP* out, const char* timestamp);
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010025void guid_to_string(char* out, EFI_GUID* guid);
Lawrence Tangb44314c2022-07-13 11:45:22 +010026void string_to_guid(EFI_GUID* out, const char* guid);
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010027int guid_equal(EFI_GUID* a, EFI_GUID* b);
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