blob: 9ab7a5a2200e11b5d759b3dbf016f2d175e9f7e1 [file] [log] [blame]
Lawrence Tang1b0b00e2022-07-05 10:33:10 +01001#ifndef CPER_UTILS_H
2#define CPER_UTILS_H
3
John Chungf8fc7052024-05-03 20:05:29 +08004#define GUID_STRING_LENGTH 48
5#define TIMESTAMP_LENGTH 24
Lawrence Tang1b0b00e2022-07-05 10:33:10 +01006
Lawrence Tangaacf0e22022-07-20 13:28:52 +01007#include "common-utils.h"
John Chungf8fc7052024-05-03 20:05:29 +08008#include <json.h>
Lawrence Tangaacf0e22022-07-20 13:28:52 +01009
John Chungf8fc7052024-05-03 20:05:29 +080010json_object *
11cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS *error_status);
12void ir_generic_error_status_to_cper(
13 json_object *error_status, EFI_GENERIC_ERROR_STATUS *error_status_cper);
14json_object *uniform_struct_to_ir(UINT32 *start, int len, const char *names[]);
15json_object *uniform_struct64_to_ir(UINT64 *start, int len,
16 const char *names[]);
17void ir_to_uniform_struct(json_object *ir, UINT32 *start, int len,
18 const char *names[]);
19void ir_to_uniform_struct64(json_object *ir, UINT64 *start, int len,
20 const char *names[]);
21json_object *integer_to_readable_pair(UINT64 value, int len, int keys[],
22 const char *values[],
23 const char *default_value);
24json_object *integer_to_readable_pair_with_desc(int value, int len, int keys[],
25 const char *values[],
26 const char *descriptions[],
27 const char *default_value);
28UINT64 readable_pair_to_integer(json_object *pair);
29json_object *bitfield_to_ir(UINT64 bitfield, int num_fields,
30 const char *names[]);
31UINT64 ir_to_bitfield(json_object *ir, int num_fields, const char *names[]);
32json_object *uint64_array_to_ir_array(UINT64 *array, int len);
33json_object *revision_to_ir(UINT16 revision);
34const char *severity_to_string(UINT32 severity);
35void timestamp_to_string(char *out, EFI_ERROR_TIME_STAMP *timestamp);
36void string_to_timestamp(EFI_ERROR_TIME_STAMP *out, const char *timestamp);
37void guid_to_string(char *out, EFI_GUID *guid);
38void string_to_guid(EFI_GUID *out, const char *guid);
39int guid_equal(EFI_GUID *a, EFI_GUID *b);
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010040
41//The available severity types for CPER.
John Chungf8fc7052024-05-03 20:05:29 +080042extern const char *CPER_SEVERITY_TYPES[4];
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010043
John Chungf8fc7052024-05-03 20:05:29 +080044#endif