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