blob: e4c14a1f18761517c06a52b1f84e0d7a74f25ba9 [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
Karthik Rajagopalan255bd812024-09-06 14:36:34 -07007#ifdef __cplusplus
8extern "C" {
9#endif
10
Lawrence Tangaacf0e22022-07-20 13:28:52 +010011#include "common-utils.h"
John Chungf8fc7052024-05-03 20:05:29 +080012#include <json.h>
Lawrence Tangaacf0e22022-07-20 13:28:52 +010013
John Chungf8fc7052024-05-03 20:05:29 +080014json_object *
15cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS *error_status);
16void ir_generic_error_status_to_cper(
17 json_object *error_status, EFI_GENERIC_ERROR_STATUS *error_status_cper);
18json_object *uniform_struct_to_ir(UINT32 *start, int len, const char *names[]);
19json_object *uniform_struct64_to_ir(UINT64 *start, int len,
20 const char *names[]);
21void ir_to_uniform_struct(json_object *ir, UINT32 *start, int len,
22 const char *names[]);
23void ir_to_uniform_struct64(json_object *ir, UINT64 *start, int len,
24 const char *names[]);
Ed Tanousb35d9572024-06-18 13:17:22 -070025json_object *integer_to_readable_pair(UINT64 value, int len, const int keys[],
John Chungf8fc7052024-05-03 20:05:29 +080026 const char *values[],
27 const char *default_value);
Ed Tanousb35d9572024-06-18 13:17:22 -070028json_object *integer_to_readable_pair_with_desc(int value, int len,
29 const int keys[],
John Chungf8fc7052024-05-03 20:05:29 +080030 const char *values[],
31 const char *descriptions[],
32 const char *default_value);
33UINT64 readable_pair_to_integer(json_object *pair);
34json_object *bitfield_to_ir(UINT64 bitfield, int num_fields,
35 const char *names[]);
36UINT64 ir_to_bitfield(json_object *ir, int num_fields, const char *names[]);
37json_object *uint64_array_to_ir_array(UINT64 *array, int len);
38json_object *revision_to_ir(UINT16 revision);
39const char *severity_to_string(UINT32 severity);
40void timestamp_to_string(char *out, EFI_ERROR_TIME_STAMP *timestamp);
41void string_to_timestamp(EFI_ERROR_TIME_STAMP *out, const char *timestamp);
42void guid_to_string(char *out, EFI_GUID *guid);
43void string_to_guid(EFI_GUID *out, const char *guid);
44int guid_equal(EFI_GUID *a, EFI_GUID *b);
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010045
46//The available severity types for CPER.
John Chungf8fc7052024-05-03 20:05:29 +080047extern const char *CPER_SEVERITY_TYPES[4];
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010048
Karthik Rajagopalan255bd812024-09-06 14:36:34 -070049#ifdef __cplusplus
50}
51#endif
52
John Chungf8fc7052024-05-03 20:05:29 +080053#endif