summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dmidecode.c32
-rw-r--r--dmiopt.c11
-rw-r--r--dmiopt.h1
3 files changed, 41 insertions, 3 deletions
diff --git a/dmidecode.c b/dmidecode.c
index 3645fb5..c30824a 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -3877,9 +3877,12 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
if(!(opt.flags & FLAG_QUIET))
{
if(opt.type==NULL)
- printf("%u structures occupying %u bytes.\n"
- "Table at 0x%08X.\n",
- num, len, base);
+ {
+ printf("%u structures occupying %u bytes.\n",
+ num, len);
+ if(!(opt.flags & FLAG_FROM_DUMP))
+ printf("Table at 0x%08X.\n", base);
+ }
printf("\n");
}
@@ -4138,6 +4141,29 @@ int main(int argc, char * const argv[])
if(!(opt.flags & FLAG_QUIET))
printf("# dmidecode %s\n", VERSION);
+ /* Read from dump if so instructed */
+ if(opt.flags & FLAG_FROM_DUMP)
+ {
+ printf("Reading SMBIOS/DMI data from file %s.\n", opt.dumpfile);
+ if((buf=mem_chunk(0, 0x20, opt.dumpfile))==NULL)
+ {
+ ret=1;
+ goto exit_free;
+ }
+
+ if(memcmp(buf, "_SM_", 4)==0)
+ {
+ if(smbios_decode(buf, opt.dumpfile))
+ found++;
+ }
+ else if(memcmp(buf, "_DMI_", 5)==0)
+ {
+ if (legacy_decode(buf, opt.dumpfile))
+ found++;
+ }
+ goto done;
+ }
+
/* First try EFI (ia64, Intel-based Mac) */
efi=address_from_efi(&fp);
switch(efi)
diff --git a/dmiopt.c b/dmiopt.c
index b76b8fc..5d5cad1 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -224,6 +224,7 @@ int parse_command_line(int argc, char * const argv[])
{ "type", required_argument, NULL, 't' },
{ "dump", no_argument, NULL, 'u' },
{ "dump-bin", required_argument, NULL, 'B' },
+ { "from-dump", required_argument, NULL, 'F' },
{ "version", no_argument, NULL, 'V' },
{ 0, 0, 0, 0 }
};
@@ -235,6 +236,10 @@ int parse_command_line(int argc, char * const argv[])
opt.flags|=FLAG_DUMP_BIN;
opt.dumpfile=optarg;
break;
+ case 'F':
+ opt.flags|=FLAG_FROM_DUMP;
+ opt.dumpfile=optarg;
+ break;
case 'd':
opt.devmem=optarg;
break;
@@ -297,6 +302,11 @@ int parse_command_line(int argc, char * const argv[])
fprintf(stderr, "Options --dump-bin, --string and --type are mutually exclusive\n");
return -1;
}
+ if((opt.flags & FLAG_FROM_DUMP) && (opt.flags & FLAG_DUMP_BIN))
+ {
+ fprintf(stderr, "Options --from-dump and --dump-bin are mutually exclusive\n");
+ return -1;
+ }
return 0;
}
@@ -313,6 +323,7 @@ void print_help(void)
" -t, --type TYPE Only display the entries of given type\n"
" -u, --dump Do not decode the entries\n"
" --dump-bin FILE Dump the DMI data to a binary file\n"
+ " --from-dump FILE Read the DMI data from a binary file\n"
" -V, --version Display the version and exit\n";
printf("%s", help);
diff --git a/dmiopt.h b/dmiopt.h
index 47ae7aa..ac0f897 100644
--- a/dmiopt.h
+++ b/dmiopt.h
@@ -43,6 +43,7 @@ extern struct opt opt;
#define FLAG_DUMP (1<<2)
#define FLAG_QUIET (1<<3)
#define FLAG_DUMP_BIN (1<<4)
+#define FLAG_FROM_DUMP (1<<5)
int parse_command_line(int argc, char * const argv[]);
void print_help(void);