blob: d7c8d5c625a511c81b5018d65926ad074f48612d [file] [log] [blame]
Lawrence Tang7f21db62022-07-06 11:09:39 +01001/**
2 * Describes functions for converting memory error CPER sections from binary and JSON format
3 * into an intermediate format.
4 *
5 * Author: Lawrence.Tang@arm.com
6 **/
7#include <stdio.h>
8#include "json.h"
9#include "../edk/Cper.h"
10#include "../cper-utils.h"
11#include "cper-section-memory.h"
12
13//Converts a single memory error CPER section into JSON IR.
14json_object* cper_section_memory_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
15{
16 EFI_PLATFORM_MEMORY_ERROR_DATA* memory_error = (EFI_PLATFORM_MEMORY_ERROR_DATA*)section;
17 json_object* section_ir = json_object_new_object();
18
19 //Validation bitfield.
20 json_object* validation = bitfield_to_ir(memory_error->ValidFields, 22, MEMORY_ERROR_VALID_BITFIELD_NAMES);
21 json_object_object_add(section_ir, "validationBits", validation);
22
23 //Error status.
24 json_object* error_status = json_object_new_object();
25 json_object_object_add(error_status, "errorType", integer_to_readable_pair_with_desc(memory_error->ErrorStatus.Type, 18,
26 MEMORY_ERROR_ERROR_TYPES_KEYS,
27 MEMORY_ERROR_ERROR_TYPES_VALUES,
28 MEMORY_ERROR_ERROR_TYPES_DESCRIPTIONS,
29 "Unknown (Reserved)"));
30}