(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) {
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));
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);
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");
}
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)
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;
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);
}
}
i++;
+ FLUSH_OBJECT;
}
- flush("pci", config, item);
+ to_cpio("pci");
}
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);
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);
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");
}