aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2011-04-03 20:59:34 +0200
committerErwan Velu <erwanaliasr1@gmail.com>2011-04-03 20:59:34 +0200
commitb0ca086f7b98cdb92355c7adfddd3d976b7c94fc (patch)
treeed4f0b2387fe214eb53d3b52faae3d2d8981288e /com32/hdt
parent9ca3c9cc9eeb578b60c4d27746dc4e7447face0c (diff)
downloadsyslinux-b0ca086f7b98cdb92355c7adfddd3d976b7c94fc.tar.gz
syslinux-b0ca086f7b98cdb92355c7adfddd3d976b7c94fc.tar.xz
syslinux-b0ca086f7b98cdb92355c7adfddd3d976b7c94fc.zip
hdt: Making dumping code easier to use
A set of CREATE_NEW_OBJECT / FLUSH is enough for a simple dump.
Diffstat (limited to 'com32/hdt')
-rw-r--r--com32/hdt/hdt-dump-cpu.c6
-rw-r--r--com32/hdt/hdt-dump-disks.c7
-rw-r--r--com32/hdt/hdt-dump-dmi.c3
-rw-r--r--com32/hdt/hdt-dump-memory.c83
-rw-r--r--com32/hdt/hdt-dump-pci.c14
-rw-r--r--com32/hdt/hdt-dump-pxe.c5
-rw-r--r--com32/hdt/hdt-dump-syslinux.c5
-rw-r--r--com32/hdt/hdt-dump-vesa.c8
-rw-r--r--com32/hdt/hdt-dump-vpd.c6
9 files changed, 71 insertions, 66 deletions
diff --git a/com32/hdt/hdt-dump-cpu.c b/com32/hdt/hdt-dump-cpu.c
index dc58a6f8..33d561c8 100644
--- a/com32/hdt/hdt-dump-cpu.c
+++ b/com32/hdt/hdt-dump-cpu.c
@@ -31,7 +31,7 @@
void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
- *item = zzjson_create_object(config, NULL); /* empty object */
+ CREATE_NEW_OBJECT;
add_hs(cpu.vendor);
add_hs(cpu.model);
add_hi(cpu.vendor_id);
@@ -48,6 +48,6 @@ void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item)
snprintf(temp,sizeof(temp),"cpu.flags.%s",cpu_flags_names[i]);
add_b(temp,get_cpu_flag_value_from_name(&hardware->cpu,cpu_flags_names[i]));
}
-
- flush("cpu",config,item);
+ FLUSH_OBJECT;
+ to_cpio("cpu");
}
diff --git a/com32/hdt/hdt-dump-disks.c b/com32/hdt/hdt-dump-disks.c
index a8e856ff..ed2aea36 100644
--- a/com32/hdt/hdt-dump-disks.c
+++ b/com32/hdt/hdt-dump-disks.c
@@ -123,7 +123,7 @@ void dump_disks(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **ite
for (int drive = 0x80; drive < 0xff; drive++) {
if (hardware->disk_info[drive - 0x80].cbios) {
if (found==false) {
- *item = zzjson_create_object(config, NULL); /* empty object */
+ CREATE_NEW_OBJECT;
add_b("disks->is_valid",true);
found=true;
}
@@ -132,8 +132,9 @@ void dump_disks(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **ite
}
if (found==false) {
- *item = zzjson_create_object(config, NULL); /* empty object */
+ CREATE_NEW_OBJECT;
add_b("disks->is_valid",false);
+ FLUSH_OBJECT;
}
- flush("disks",config,item);
+ to_cpio("disks");
}
diff --git a/com32/hdt/hdt-dump-dmi.c b/com32/hdt/hdt-dump-dmi.c
index 8df9e61e..6e5c1ce8 100644
--- a/com32/hdt/hdt-dump-dmi.c
+++ b/com32/hdt/hdt-dump-dmi.c
@@ -420,6 +420,7 @@ void dump_dmi(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item)
add_hb(is_dmi_valid);
if (hardware->is_dmi_valid == false) {
+ FLUSH_OBJECT;
goto exit;
} else {
char buffer[8]={0};
@@ -442,5 +443,5 @@ void dump_dmi(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item)
dump_oem_strings(hardware,config,item);
dump_hardware_security(hardware,config,item);
exit:
- flush("dmi",config,item);
+ to_cpio("dmi");
}
diff --git a/com32/hdt/hdt-dump-memory.c b/com32/hdt/hdt-dump-memory.c
index 54823542..5095d3c2 100644
--- a/com32/hdt/hdt-dump-memory.c
+++ b/com32/hdt/hdt-dump-memory.c
@@ -34,41 +34,38 @@ void dump_88(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item)
(void) hardware;
int mem_size = 0;
+ CREATE_NEW_OBJECT;
if (detect_memory_88(&mem_size)) {
- APPEND_ARRAY
- add_as("memory.error","8800h memory configuration is invalid")
- END_OF_APPEND;
+ add_s("memory.error","8800h memory configuration is invalid");
+ FLUSH_OBJECT
return;
}
- APPEND_ARRAY
- add_as("dmi.item","memory via 88")
- add_ai("memory.size (KiB)", mem_size)
- add_ai("memory.size (MiB)", mem_size >> 10)
- END_OF_APPEND;
-
+ add_s("dmi.item","memory via 88");
+ add_i("memory.size (KiB)", mem_size);
+ add_i("memory.size (MiB)", mem_size >> 10);
+ FLUSH_OBJECT;
}
void dump_e801(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
(void) hardware;
int mem_low, mem_high = 0;
+ CREATE_NEW_OBJECT;
if (detect_memory_e801(&mem_low,&mem_high)) {
- APPEND_ARRAY
- add_as("memory.error","e801 memory configuration is invalid")
- END_OF_APPEND;
+ add_s("memory.error","e801 memory configuration is invalid");
+ FLUSH_OBJECT;
return;
}
- APPEND_ARRAY
- add_as("dmi.item","memory via e801")
- add_ai("memory.total.size (KiB)", mem_low + (mem_high << 6))
- add_ai("memory.total.size (MiB)", (mem_low >> 10) + (mem_high >> 4))
- add_ai("memory.low.size (KiB)", mem_low )
- add_ai("memory.low.size (MiB)", mem_low >> 10)
- add_ai("memory.high.size (KiB)", mem_high << 6)
- add_ai("memory.high.size (MiB)", mem_high >> 4)
- END_OF_APPEND;
+ add_s("dmi.item","memory via e801");
+ add_i("memory.total.size (KiB)", mem_low + (mem_high << 6));
+ add_i("memory.total.size (MiB)", (mem_low >> 10) + (mem_high >> 4));
+ add_i("memory.low.size (KiB)", mem_low );
+ add_i("memory.low.size (MiB)", mem_low >> 10);
+ add_i("memory.high.size (KiB)", mem_high << 6);
+ add_i("memory.high.size (MiB)", mem_high >> 4);
+ FLUSH_OBJECT;
}
void dump_e820(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
@@ -82,12 +79,12 @@ void dump_e820(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item
detect_memory_e820(map, E820MAX, &count);
memsize = memsize_e820(map, count);
-
- APPEND_ARRAY
- add_as("dmi.item","memory via e820")
- add_ai("memory.total.size (KiB)", memsize)
- add_ai("memory.total.size (MiB)", (memsize + (1 << 9)) >> 10)
- END_OF_APPEND;
+
+ CREATE_NEW_OBJECT;
+ add_s("dmi.item","memory via e820");
+ add_i("memory.total.size (KiB)", memsize);
+ add_i("memory.total.size (MiB)", (memsize + (1 << 9)) >> 10);
+ FLUSH_OBJECT;
for (int i = 0; i < count; i++) {
get_type(map[i].type, type, sizeof(type));
@@ -97,12 +94,12 @@ void dump_e820(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item
snprintf(begin,sizeof(begin),"0x%016llx",map[i].addr);
snprintf(size,sizeof(size),"0x%016llx",map[i].size);
snprintf(end,sizeof(end),"0x%016llx",map[i].addr+map[i].size);
- CREATE_TEMP_OBJECT
- add_ts("memory.segment.start",begin);
- add_ts("memory.segment.size ",size);
- add_ts("memory.segment.end ",end);
- add_ts("memory.segment.type ",remove_spaces(type));
- APPEND_TEMP_OBJECT_ARRAY;
+ CREATE_NEW_OBJECT;
+ add_s("memory.segment.start",begin);
+ add_s("memory.segment.size ",size);
+ add_s("memory.segment.end ",end);
+ add_s("memory.segment.type ",remove_spaces(type));
+ FLUSH_OBJECT;
}
int nr = sanitize_e820_map(map, nm, count);
@@ -114,23 +111,23 @@ void dump_e820(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item
snprintf(begin,sizeof(begin),"0x%016llx",nm[i].addr);
snprintf(size,sizeof(size),"0x%016llx",nm[i].size);
snprintf(end,sizeof(end),"0x%016llx",nm[i].addr+nm[i].size);
- CREATE_TEMP_OBJECT
- add_ts("sanitized_memory.segment.start",begin);
- add_ts("sanitized_memory.segment.size ",size);
- add_ts("sanitized_memory.segment.end ",end);
- add_ts("sanitized_memory.segment.type ",remove_spaces(type));
- APPEND_TEMP_OBJECT_ARRAY;
+ CREATE_NEW_OBJECT;
+ add_s("sanitized_memory.segment.start",begin);
+ add_s("sanitized_memory.segment.size ",size);
+ add_s("sanitized_memory.segment.end ",end);
+ add_s("sanitized_memory.segment.type ",remove_spaces(type));
+ FLUSH_OBJECT;
}
}
void dump_memory(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
- CREATE_ARRAY
- add_as("Memory configuration","true")
- END_OF_ARRAY;
+ CREATE_NEW_OBJECT;
+ add_s("Memory configuration","true");
+ FLUSH_OBJECT;
dump_88(hardware,config,item);
dump_e801(hardware,config,item);
dump_e820(hardware,config,item);
- flush("memory",config,item);
+ to_cpio("memory");
}
diff --git a/com32/hdt/hdt-dump-pci.c b/com32/hdt/hdt-dump-pci.c
index 9d89f3ad..b1f18fdf 100644
--- a/com32/hdt/hdt-dump-pci.c
+++ b/com32/hdt/hdt-dump-pci.c
@@ -54,10 +54,11 @@ void dump_pci(struct s_hardware *hardware, ZZJSON_CONFIG * config,
nomodulesfile = nomodulespcimap && nomodulesalias;
- *item = zzjson_create_object(config, NULL); /* empty object */
+ CREATE_NEW_OBJECT;
add_i("pci_device.count", hardware->nb_pci_devices);
+ FLUSH_OBJECT;
/* For every detected pci device, compute its submenu */
for_each_pci_func(pci_device, hardware->pci_domain) {
if (pci_device == NULL)
@@ -69,9 +70,7 @@ void dump_pci(struct s_hardware *hardware, ZZJSON_CONFIG * config,
char c[10] = { 0 };
char r[10] = { 0 };
- zzjson_print(config, *item);
- zzjson_free(config, *item);
- *item = zzjson_create_object(config, NULL); /* empty object */
+ CREATE_NEW_OBJECT;
bus = __pci_bus;
slot = __pci_slot;
func = __pci_func;
@@ -112,8 +111,8 @@ void dump_pci(struct s_hardware *hardware, ZZJSON_CONFIG * config,
add_s("pci_device.product_id", p);
add_s("pci_device.sub_vendor_id", sv);
add_s("pci_device.sub_product_id", sp);
-// add_s("pci_device.class_id", c);
-// add_s("pci_device.revision", r);
+ add_s("pci_device.class_id", c);
+ add_s("pci_device.revision", r);
if ((pci_device->dev_info->irq > 0)
&& (pci_device->dev_info->irq < 255))
add_i("pci_device.irq", pci_device->dev_info->irq);
@@ -131,6 +130,7 @@ void dump_pci(struct s_hardware *hardware, ZZJSON_CONFIG * config,
}
}
i++;
+ FLUSH_OBJECT;
}
- flush("pci", config, item);
+ to_cpio("pci");
}
diff --git a/com32/hdt/hdt-dump-pxe.c b/com32/hdt/hdt-dump-pxe.c
index 2cd214be..6f4f511a 100644
--- a/com32/hdt/hdt-dump-pxe.c
+++ b/com32/hdt/hdt-dump-pxe.c
@@ -33,7 +33,7 @@
void dump_pxe(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
- *item = zzjson_create_object(config, NULL); /* empty object */
+ CREATE_NEW_OBJECT;
add_hb(is_pxe_valid);
if (hardware->is_pxe_valid) {
char buffer[32] = {0};
@@ -76,5 +76,6 @@ void dump_pxe(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item)
add_s("pxe.ipaddr",ip);
add_b("gpxe_detected",is_gpxe());
}
- flush("pxe",config,item);
+ FLUSH_OBJECT;
+ to_cpio("pxe");
}
diff --git a/com32/hdt/hdt-dump-syslinux.c b/com32/hdt/hdt-dump-syslinux.c
index 843ebafc..7cef925f 100644
--- a/com32/hdt/hdt-dump-syslinux.c
+++ b/com32/hdt/hdt-dump-syslinux.c
@@ -32,11 +32,12 @@
void dump_syslinux(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
- *item = zzjson_create_object(config, NULL); /* empty object */
+ CREATE_NEW_OBJECT;
add_hs(syslinux_fs);
add_hs(sv->version_string);
add_hi(sv->version);
add_hi(sv->max_api);
add_hs(sv->copyright_string);
- flush("syslinux",config,item);
+ FLUSH_OBJECT
+ to_cpio("syslinux");
}
diff --git a/com32/hdt/hdt-dump-vesa.c b/com32/hdt/hdt-dump-vesa.c
index ddf096fa..97ff9fc2 100644
--- a/com32/hdt/hdt-dump-vesa.c
+++ b/com32/hdt/hdt-dump-vesa.c
@@ -37,6 +37,7 @@ void dump_vesa(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item
if (hardware->is_vesa_valid) {
char buffer[64]={0};
snprintf(buffer,sizeof(buffer),"%d.%d", hardware->vesa.major_version, hardware->vesa.minor_version);
+ printf("buffer='%s'\n",buffer);
add_s("vesa.version",buffer);
add_hs(vesa.vendor);
add_hs(vesa.product);
@@ -46,11 +47,11 @@ void dump_vesa(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item
snprintf(buffer,sizeof(buffer),"%d KB",hardware->vesa.total_memory*64);
add_s("vesa.memory",buffer);
add_i("vesa.modes",hardware->vesa.vmi_count);
+ FLUSH_OBJECT;
for (int i = 0; i < hardware->vesa.vmi_count; i++) {
struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi;
if ((mi->h_res == 0) || (mi->v_res == 0))
continue;
- FLUSH_OBJECT;
CREATE_NEW_OBJECT;
memset(buffer,0,sizeof(buffer));
snprintf(buffer,sizeof(buffer),"0x%04x",hardware->vesa.vmi[i].mode + 0x200);
@@ -58,7 +59,10 @@ void dump_vesa(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item
add_i("vesa.hres",mi->h_res);
add_i("vesa.vres",mi->v_res);
add_i("vesa.bpp",mi->bpp);
+ FLUSH_OBJECT;
}
+ } else {
+ FLUSH_OBJECT;
}
- flush("vesa",config,item);
+ to_cpio("vesa");
}
diff --git a/com32/hdt/hdt-dump-vpd.c b/com32/hdt/hdt-dump-vpd.c
index 9e4a78ee..36451c8a 100644
--- a/com32/hdt/hdt-dump-vpd.c
+++ b/com32/hdt/hdt-dump-vpd.c
@@ -31,8 +31,7 @@
void dump_vpd(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
-
- *item = zzjson_create_object(config, NULL); /* empty object */
+ CREATE_NEW_OBJECT;
add_hb(is_vpd_valid);
if (hardware->is_vpd_valid) {
add_hs(vpd.bios_build_id);
@@ -43,5 +42,6 @@ void dump_vpd(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item)
add_hs(vpd.motherboard_serial_number);
add_hs(vpd.machine_type_model);
}
- flush("vpd",config,item);
+ FLUSH_OBJECT;
+ to_cpio("vpd");
}