Partial reformat to kernel code style.
diff --git a/sections/cper-section-dmar-generic.c b/sections/cper-section-dmar-generic.c
index faeefa8..420dd8d 100644
--- a/sections/cper-section-dmar-generic.c
+++ b/sections/cper-section-dmar-generic.c
@@ -11,67 +11,84 @@
#include "cper-section-dmar-generic.h"
//Converts a single generic DMAr CPER section into JSON IR.
-json_object* cper_section_dmar_generic_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor)
+json_object *
+cper_section_dmar_generic_to_ir(void *section,
+ EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
{
- EFI_DMAR_GENERIC_ERROR_DATA* firmware_error = (EFI_DMAR_GENERIC_ERROR_DATA*)section;
- json_object* section_ir = json_object_new_object();
+ EFI_DMAR_GENERIC_ERROR_DATA *firmware_error =
+ (EFI_DMAR_GENERIC_ERROR_DATA *)section;
+ json_object *section_ir = json_object_new_object();
- //Requester ID, segment.
- json_object_object_add(section_ir, "requesterID", json_object_new_int(firmware_error->RequesterId));
- json_object_object_add(section_ir, "segmentNumber", json_object_new_int(firmware_error->SegmentNumber));
+ //Requester ID, segment.
+ json_object_object_add(
+ section_ir, "requesterID",
+ json_object_new_int(firmware_error->RequesterId));
+ json_object_object_add(
+ section_ir, "segmentNumber",
+ json_object_new_int(firmware_error->SegmentNumber));
- //Fault reason.
- json_object* fault_reason = integer_to_readable_pair_with_desc(firmware_error->FaultReason, 11,
- DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_KEYS,
- DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_VALUES,
- DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_DESCRIPTIONS,
- "Unknown (Reserved)");
- json_object_object_add(section_ir, "faultReason", fault_reason);
+ //Fault reason.
+ json_object *fault_reason = integer_to_readable_pair_with_desc(
+ firmware_error->FaultReason, 11,
+ DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_KEYS,
+ DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_VALUES,
+ DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_DESCRIPTIONS,
+ "Unknown (Reserved)");
+ json_object_object_add(section_ir, "faultReason", fault_reason);
- //Access type.
- json_object* access_type = integer_to_readable_pair(firmware_error->AccessType, 2,
- DMAR_GENERIC_ERROR_ACCESS_TYPES_KEYS,
- DMAR_GENERIC_ERROR_ACCESS_TYPES_VALUES,
- "Unknown (Reserved)");
- json_object_object_add(section_ir, "accessType", access_type);
+ //Access type.
+ json_object *access_type = integer_to_readable_pair(
+ firmware_error->AccessType, 2,
+ DMAR_GENERIC_ERROR_ACCESS_TYPES_KEYS,
+ DMAR_GENERIC_ERROR_ACCESS_TYPES_VALUES, "Unknown (Reserved)");
+ json_object_object_add(section_ir, "accessType", access_type);
- //Address type.
- json_object* address_type = integer_to_readable_pair(firmware_error->AddressType, 2,
- DMAR_GENERIC_ERROR_ADDRESS_TYPES_KEYS,
- DMAR_GENERIC_ERROR_ADDRESS_TYPES_VALUES,
- "Unknown (Reserved)");
- json_object_object_add(section_ir, "addressType", address_type);
+ //Address type.
+ json_object *address_type = integer_to_readable_pair(
+ firmware_error->AddressType, 2,
+ DMAR_GENERIC_ERROR_ADDRESS_TYPES_KEYS,
+ DMAR_GENERIC_ERROR_ADDRESS_TYPES_VALUES, "Unknown (Reserved)");
+ json_object_object_add(section_ir, "addressType", address_type);
- //Architecture type.
- json_object* arch_type = integer_to_readable_pair(firmware_error->ArchType, 2,
- DMAR_GENERIC_ERROR_ARCH_TYPES_KEYS,
- DMAR_GENERIC_ERROR_ARCH_TYPES_VALUES,
- "Unknown (Reserved)");
- json_object_object_add(section_ir, "architectureType", arch_type);
+ //Architecture type.
+ json_object *arch_type = integer_to_readable_pair(
+ firmware_error->ArchType, 2, DMAR_GENERIC_ERROR_ARCH_TYPES_KEYS,
+ DMAR_GENERIC_ERROR_ARCH_TYPES_VALUES, "Unknown (Reserved)");
+ json_object_object_add(section_ir, "architectureType", arch_type);
- //Device address.
- json_object_object_add(section_ir, "deviceAddress", json_object_new_uint64(firmware_error->DeviceAddr));
-
- return section_ir;
+ //Device address.
+ json_object_object_add(
+ section_ir, "deviceAddress",
+ json_object_new_uint64(firmware_error->DeviceAddr));
+
+ return section_ir;
}
//Converts a single generic DMAR CPER-JSON section into CPER binary, outputting to the given stream.
-void ir_section_dmar_generic_to_cper(json_object* section, FILE* out)
+void ir_section_dmar_generic_to_cper(json_object *section, FILE *out)
{
- EFI_DMAR_GENERIC_ERROR_DATA* section_cper =
- (EFI_DMAR_GENERIC_ERROR_DATA*)calloc(1, sizeof(EFI_DMAR_GENERIC_ERROR_DATA));
+ EFI_DMAR_GENERIC_ERROR_DATA *section_cper =
+ (EFI_DMAR_GENERIC_ERROR_DATA *)calloc(
+ 1, sizeof(EFI_DMAR_GENERIC_ERROR_DATA));
- //Record fields.
- section_cper->RequesterId = (UINT16)json_object_get_int(json_object_object_get(section, "requesterID"));
- section_cper->SegmentNumber = (UINT16)json_object_get_int(json_object_object_get(section, "segmentNumber"));
- section_cper->FaultReason = (UINT8)readable_pair_to_integer(json_object_object_get(section, "faultReason"));
- section_cper->AccessType = (UINT8)readable_pair_to_integer(json_object_object_get(section, "accessType"));
- section_cper->AddressType = (UINT8)readable_pair_to_integer(json_object_object_get(section, "addressType"));
- section_cper->ArchType = (UINT8)readable_pair_to_integer(json_object_object_get(section, "architectureType"));
- section_cper->DeviceAddr = json_object_get_uint64(json_object_object_get(section, "deviceAddress"));
+ //Record fields.
+ section_cper->RequesterId = (UINT16)json_object_get_int(
+ json_object_object_get(section, "requesterID"));
+ section_cper->SegmentNumber = (UINT16)json_object_get_int(
+ json_object_object_get(section, "segmentNumber"));
+ section_cper->FaultReason = (UINT8)readable_pair_to_integer(
+ json_object_object_get(section, "faultReason"));
+ section_cper->AccessType = (UINT8)readable_pair_to_integer(
+ json_object_object_get(section, "accessType"));
+ section_cper->AddressType = (UINT8)readable_pair_to_integer(
+ json_object_object_get(section, "addressType"));
+ section_cper->ArchType = (UINT8)readable_pair_to_integer(
+ json_object_object_get(section, "architectureType"));
+ section_cper->DeviceAddr = json_object_get_uint64(
+ json_object_object_get(section, "deviceAddress"));
- //Write to stream, free resources.
- fwrite(section_cper, sizeof(EFI_DMAR_GENERIC_ERROR_DATA), 1, out);
- fflush(out);
- free(section_cper);
+ //Write to stream, free resources.
+ fwrite(section_cper, sizeof(EFI_DMAR_GENERIC_ERROR_DATA), 1, out);
+ fflush(out);
+ free(section_cper);
}
\ No newline at end of file