Add untested IA32/x64 log support.
diff --git a/cper-utils.c b/cper-utils.c
index b76ca0f..61a796a 100644
--- a/cper-utils.c
+++ b/cper-utils.c
@@ -19,7 +19,7 @@
json_object_object_add(result, "value", json_object_new_int(value));
//Search for human readable name, add.
- char* name = default_value;
+ const char* name = default_value;
for (int i=0; i<len; i++)
{
if (keys[i] == value)
@@ -30,6 +30,43 @@
return result;
}
+//Converts the given uint8 bitfield to IR, assuming bit 0 starts on the left.
+json_object* bitfield8_to_ir(UINT8 bitfield, int num_fields, const char* names[])
+{
+ json_object* result = json_object_new_object();
+ for (int i=0; i<num_fields; i++)
+ {
+ json_object_object_add(result, names[i], json_object_new_boolean((bitfield >> (7 - i)) & 0b1));
+ }
+
+ return result;
+}
+
+//Converts the given bitfield to IR, assuming bit 0 starts on the left.
+json_object* bitfield_to_ir(UINT32 bitfield, int num_fields, const char* names[])
+{
+ json_object* result = json_object_new_object();
+ for (int i=0; i<num_fields; i++)
+ {
+ json_object_object_add(result, names[i], json_object_new_boolean((bitfield >> (31 - i)) & 0b1));
+ }
+
+ return result;
+}
+
+//Converts the given 64 bit bitfield to IR, assuming bit 0 starts on the left.
+json_object* bitfield64_to_ir(UINT64 bitfield, int num_fields, const char* names[])
+{
+ json_object* result = json_object_new_object();
+ for (int i=0; i<num_fields; i++)
+ {
+ json_object_object_add(result, names[i], json_object_new_boolean((bitfield >> (63 - i)) & 0b1));
+ }
+
+ return result;
+}
+
+
//Converts a single UINT16 revision number into JSON IR representation.
json_object* revision_to_ir(UINT16 revision)
{