1e42fb487SThu Nguyen #ifndef CPER_UTILS_H
2e42fb487SThu Nguyen #define CPER_UTILS_H
3e42fb487SThu Nguyen 
4e42fb487SThu Nguyen #define GUID_STRING_LENGTH 48
5*13f099ffSEd Tanous #define TIMESTAMP_LENGTH   26
6e42fb487SThu Nguyen 
7e42fb487SThu Nguyen #ifdef __cplusplus
8e42fb487SThu Nguyen extern "C" {
9e42fb487SThu Nguyen #endif
10e42fb487SThu Nguyen 
11e42fb487SThu Nguyen #include <libcper/common-utils.h>
12e42fb487SThu Nguyen #include <libcper/Cper.h>
13e42fb487SThu Nguyen #include <json.h>
14e42fb487SThu Nguyen 
15e42fb487SThu Nguyen json_object *
16e42fb487SThu Nguyen cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS *error_status);
17e42fb487SThu Nguyen void ir_generic_error_status_to_cper(
18e42fb487SThu Nguyen 	json_object *error_status, EFI_GENERIC_ERROR_STATUS *error_status_cper);
19e42fb487SThu Nguyen json_object *uniform_struct_to_ir(UINT32 *start, int len, const char *names[]);
20e42fb487SThu Nguyen json_object *uniform_struct64_to_ir(UINT64 *start, int len,
21e42fb487SThu Nguyen 				    const char *names[]);
22e42fb487SThu Nguyen void ir_to_uniform_struct(json_object *ir, UINT32 *start, int len,
23e42fb487SThu Nguyen 			  const char *names[]);
24e42fb487SThu Nguyen void ir_to_uniform_struct64(json_object *ir, UINT64 *start, int len,
25e42fb487SThu Nguyen 			    const char *names[]);
26e42fb487SThu Nguyen json_object *integer_to_readable_pair(UINT64 value, int len, const int keys[],
27e42fb487SThu Nguyen 				      const char *values[],
28e42fb487SThu Nguyen 				      const char *default_value);
29e42fb487SThu Nguyen json_object *integer_to_readable_pair_with_desc(int value, int len,
30e42fb487SThu Nguyen 						const int keys[],
31e42fb487SThu Nguyen 						const char *values[],
32e42fb487SThu Nguyen 						const char *descriptions[],
33e42fb487SThu Nguyen 						const char *default_value);
34e42fb487SThu Nguyen UINT64 readable_pair_to_integer(json_object *pair);
35e42fb487SThu Nguyen json_object *bitfield_to_ir(UINT64 bitfield, int num_fields,
36e42fb487SThu Nguyen 			    const char *names[]);
37e42fb487SThu Nguyen UINT64 ir_to_bitfield(json_object *ir, int num_fields, const char *names[]);
38e42fb487SThu Nguyen json_object *uint64_array_to_ir_array(UINT64 *array, int len);
39e42fb487SThu Nguyen json_object *revision_to_ir(UINT16 revision);
40e42fb487SThu Nguyen const char *severity_to_string(UINT32 severity);
41*13f099ffSEd Tanous void timestamp_to_string(char *out, int out_len,
42*13f099ffSEd Tanous 			 EFI_ERROR_TIME_STAMP *timestamp);
43e42fb487SThu Nguyen void string_to_timestamp(EFI_ERROR_TIME_STAMP *out, const char *timestamp);
44e42fb487SThu Nguyen void guid_to_string(char *out, EFI_GUID *guid);
45e42fb487SThu Nguyen void string_to_guid(EFI_GUID *out, const char *guid);
46e42fb487SThu Nguyen int guid_equal(EFI_GUID *a, EFI_GUID *b);
47e42fb487SThu Nguyen 
48e42fb487SThu Nguyen //The available severity types for CPER.
49e42fb487SThu Nguyen extern const char *CPER_SEVERITY_TYPES[4];
50e42fb487SThu Nguyen 
51e42fb487SThu Nguyen #ifdef __cplusplus
52e42fb487SThu Nguyen }
53e42fb487SThu Nguyen #endif
54e42fb487SThu Nguyen 
55e42fb487SThu Nguyen #endif
56