From f872017d2e677214f67bd85457999c4c3da26dcd Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Wed, 23 Mar 2011 21:02:51 +0100 Subject: [PATCH] hdt: Adding VPD to dump feature --- com32/hdt/{hdt-dump.h => hdt-dump-vpd.c} | 40 ++++++++++++++------------------ com32/hdt/hdt-dump.c | 1 + com32/hdt/hdt-dump.h | 2 ++ 3 files changed, 20 insertions(+), 23 deletions(-) copy com32/hdt/{hdt-dump.h => hdt-dump-vpd.c} (50%) diff --git a/com32/hdt/hdt-dump.h b/com32/hdt/hdt-dump-vpd.c similarity index 50% copy from com32/hdt/hdt-dump.h copy to com32/hdt/hdt-dump-vpd.c index 0f1f8173..9e4a78ee 100644 --- a/com32/hdt/hdt-dump.h +++ b/com32/hdt/hdt-dump-vpd.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 20011 Erwan Velu - All Rights Reserved + * Copyright 2011 Erwan Velu - All Rights Reserved * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -26,28 +26,22 @@ * ----------------------------------------------------------------------- */ -#include -#include -#include -#include -#include -#include #include "hdt-common.h" +#include "hdt-dump.h" -#define add_i(name,value) *item = zzjson_object_append(config, *item, name, zzjson_create_number_i(config, value)) -#define add_s(name,value) *item = zzjson_object_append(config, *item, name, zzjson_create_string(config, value)) -#define add_bool_true(name) *item = zzjson_object_append(config, *item, name, zzjson_create_true(config)) -#define add_bool_false(name) *item = zzjson_object_append(config, *item, name, zzjson_create_false(config)) -#define add_hi(value) add_i(#value,hardware->value) -#define add_hs(value) add_s(#value,(char *)hardware->value) -#define add_b(name,value) if (value==true) {add_bool_true((char *)name);} else {add_bool_false((char *)name);} +void dump_vpd(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) { -extern struct print_buf p_buf; - -void print_and_flush(ZZJSON_CONFIG *config, ZZJSON **item); -int dumpprintf(FILE *p, const char *format, ...); -void flush (char *filename, ZZJSON_CONFIG *config, ZZJSON ** item); - -void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); -void dump_pxe(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); -void dump_syslinux(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); + + *item = zzjson_create_object(config, NULL); /* empty object */ + add_hb(is_vpd_valid); + if (hardware->is_vpd_valid) { + add_hs(vpd.bios_build_id); + add_hs(vpd.bios_release_date); + add_hs(vpd.bios_version); + add_hs(vpd.default_flash_filename); + add_hs(vpd.box_serial_number); + add_hs(vpd.motherboard_serial_number); + add_hs(vpd.machine_type_model); + } + flush("vpd",config,item); +} diff --git a/com32/hdt/hdt-dump.c b/com32/hdt/hdt-dump.c index 429902d6..55ef9070 100644 --- a/com32/hdt/hdt-dump.c +++ b/com32/hdt/hdt-dump.c @@ -117,6 +117,7 @@ void dump(struct s_hardware *hardware) dump_cpu(hardware, &config, &json); dump_pxe(hardware, &config, &json); dump_syslinux(hardware, &config, &json); + dump_vpd(hardware, &config, &json); /* We close & flush the file to send */ cpio_close(upload); diff --git a/com32/hdt/hdt-dump.h b/com32/hdt/hdt-dump.h index 0f1f8173..8a2e4109 100644 --- a/com32/hdt/hdt-dump.h +++ b/com32/hdt/hdt-dump.h @@ -41,6 +41,7 @@ #define add_hi(value) add_i(#value,hardware->value) #define add_hs(value) add_s(#value,(char *)hardware->value) #define add_b(name,value) if (value==true) {add_bool_true((char *)name);} else {add_bool_false((char *)name);} +#define add_hb(value) add_b(#value,hardware->value) extern struct print_buf p_buf; @@ -51,3 +52,4 @@ void flush (char *filename, ZZJSON_CONFIG *config, ZZJSON ** item); void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); void dump_pxe(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); void dump_syslinux(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); +void dump_vpd(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); -- 2.11.4.GIT