summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--biosdecode.c257
-rw-r--r--dmidecode.c1610
-rw-r--r--dmioem.c39
-rw-r--r--dmiopt.c112
-rw-r--r--dmiopt.h14
-rw-r--r--ownership.c82
-rw-r--r--types.h16
-rw-r--r--util.c58
-rw-r--r--vpddecode.c90
-rw-r--r--vpdopt.c36
-rw-r--r--vpdopt.h10
11 files changed, 1168 insertions, 1156 deletions
diff --git a/biosdecode.c b/biosdecode.c
index 185c39d..602d0a7 100644
--- a/biosdecode.c
+++ b/biosdecode.c
@@ -68,13 +68,13 @@
/* Options are global */
struct opt
{
- const char* devmem;
+ const char *devmem;
unsigned int flags;
};
static struct opt opt;
-#define FLAG_VERSION (1<<0)
-#define FLAG_HELP (1<<1)
+#define FLAG_VERSION (1 << 0)
+#define FLAG_HELP (1 << 1)
struct bios_entry {
const char *anchor;
@@ -92,14 +92,14 @@ struct bios_entry {
static size_t smbios_length(const u8 *p)
{
- return(p[0x05]==0x1E?0x1F:p[0x05]);
+ return p[0x05] == 0x1E ? 0x1F : p[0x05];
}
static int smbios_decode(const u8 *p, size_t len)
{
- if(len<0x1F || !checksum(p, p[0x05])
- || memcmp("_DMI_", p+0x10, 5)!=0
- || !checksum(p+0x10, 0x0F))
+ if (len < 0x1F || !checksum(p, p[0x05])
+ || memcmp("_DMI_", p + 0x10, 5) != 0
+ || !checksum(p + 0x10, 0x0F))
return 0;
printf("SMBIOS %u.%u present.\n",
@@ -107,11 +107,11 @@ static int smbios_decode(const u8 *p, size_t len)
printf("\tStructure Table Length: %u bytes\n",
WORD(p+0x16));
printf("\tStructure Table Address: 0x%08X\n",
- DWORD(p+0x18));
+ DWORD(p + 0x18));
printf("\tNumber Of Structures: %u\n",
- WORD(p+0x1C));
+ WORD(p + 0x1C));
printf("\tMaximum Structure Size: %u bytes\n",
- WORD(p+0x08));
+ WORD(p + 0x08));
return 1;
}
@@ -120,22 +120,22 @@ static size_t dmi_length(const u8 *p)
{
(void) p;
- return(0x0F);
+ return 0x0F;
}
static int dmi_decode(const u8 *p, size_t len)
{
- if(len<0x0F || !checksum(p, len))
+ if (len < 0x0F || !checksum(p, len))
return 0;
printf("Legacy DMI %u.%u present.\n",
- p[0x0E]>>4, p[0x0E]&0x0F);
+ p[0x0E]>>4, p[0x0E] & 0x0F);
printf("\tStructure Table Length: %u bytes\n",
- WORD(p+0x06));
+ WORD(p + 0x06));
printf("\tStructure Table Address: 0x%08X\n",
- DWORD(p+0x08));
+ DWORD(p + 0x08));
printf("\tNumber Of Structures: %u\n",
- WORD(p+0x0C));
+ WORD(p + 0x0C));
return 1;
}
@@ -146,21 +146,21 @@ static int dmi_decode(const u8 *p, size_t len)
static size_t sysid_length(const u8 *p)
{
- return WORD(p+0x08);
+ return WORD(p + 0x08);
}
static int sysid_decode(const u8 *p, size_t len)
{
- if(len<0x11 || !checksum(p, WORD(p+0x08)))
+ if (len < 0x11 || !checksum(p, WORD(p + 0x08)))
return 0;
printf("SYSID present.\n");
printf("\tRevision: %u\n",
p[0x10]);
printf("\tStructure Table Address: 0x%08X\n",
- DWORD(p+0x0A));
+ DWORD(p + 0x0A));
printf("\tNumber Of Structures: %u\n",
- WORD(p+0x0E));
+ WORD(p + 0x0E));
return 1;
}
@@ -171,7 +171,7 @@ static int sysid_decode(const u8 *p, size_t len)
static size_t pnp_length(const u8 *p)
{
- return(p[0x05]);
+ return p[0x05];
}
static const char *pnp_event_notification(u8 code)
@@ -188,29 +188,29 @@ static const char *pnp_event_notification(u8 code)
static int pnp_decode(const u8 *p, size_t len)
{
- if(len<0x21 || !checksum(p, p[0x05]))
+ if (len < 0x21 || !checksum(p, p[0x05]))
return 0;
printf("PNP BIOS %u.%u present.\n",
- p[0x04]>>4, p[0x04]&0x0F);
+ p[0x04]>>4, p[0x04] & 0x0F);
printf("\tEvent Notification: %s\n",
- pnp_event_notification(WORD(p+0x06)&0x03));
- if((WORD(p+0x06)&0x03)==0x01)
+ pnp_event_notification(WORD(p + 0x06) & 0x03));
+ if ((WORD(p+0x06)&0x03)==0x01)
printf("\tEvent Notification Flag Address: 0x%08X\n",
- DWORD(p+0x09));
+ DWORD(p + 0x09));
printf("\tReal Mode 16-bit Code Address: %04X:%04X\n",
- WORD(p+0x0F), WORD(p+0x0D));
+ WORD(p + 0x0F), WORD(p + 0x0D));
printf("\tReal Mode 16-bit Data Address: %04X:0000\n",
- WORD(p+0x1B));
+ WORD(p + 0x1B));
printf("\t16-bit Protected Mode Code Address: 0x%08X\n",
- DWORD(p+0x13)+WORD(p+0x11));
+ DWORD(p + 0x13) + WORD(p + 0x11));
printf("\t16-bit Protected Mode Data Address: 0x%08X\n",
- DWORD(p+0x1D));
- if(DWORD(p+0x17)!=0)
+ DWORD(p + 0x1D));
+ if (DWORD(p + 0x17)!=0)
printf("\tOEM Device Identifier: %c%c%c%02X%02X\n",
- 0x40+((p[0x17]>>2)&0x1F),
- 0x40+((p[0x17]&0x03)<<3)+((p[0x18]>>5)&0x07),
- 0x40+(p[0x18]&0x1F), p[0x19], p[0x20]);
+ 0x40 + ((p[0x17] >> 2) & 0x1F),
+ 0x40 + ((p[0x17] & 0x03) << 3) + ((p[0x18] >> 5) & 0x07),
+ 0x40 + (p[0x18] & 0x1F), p[0x19], p[0x20]);
return 1;
}
@@ -221,12 +221,12 @@ static int pnp_decode(const u8 *p, size_t len)
static size_t acpi_length(const u8 *p)
{
- return(p[15]==2?36:20);
+ return p[15] == 2 ? 36 : 20;
}
static const char *acpi_revision(u8 code)
{
- switch(code)
+ switch (code)
{
case 0:
return " 1.0";
@@ -239,7 +239,7 @@ static const char *acpi_revision(u8 code)
static int acpi_decode(const u8 *p, size_t len)
{
- if(len<20 || !checksum(p, 20))
+ if (len < 20 || !checksum(p, 20))
return 0;
printf("ACPI%s present.\n",
@@ -247,18 +247,18 @@ static int acpi_decode(const u8 *p, size_t len)
printf("\tOEM Identifier: %c%c%c%c%c%c\n",
p[9], p[10], p[11], p[12], p[13], p[14]);
printf("\tRSD Table 32-bit Address: 0x%08X\n",
- DWORD(p+16));
+ DWORD(p + 16));
- if(len<36)
+ if (len < 36)
return 1;
- if(DWORD(p+20)>len || !checksum(p, DWORD(p+20)))
+ if (DWORD(p + 20) > len || !checksum(p, DWORD(p + 20)))
return 0;
- if(DWORD(p+20)<32) return 1;
+ if (DWORD(p + 20) < 32) return 1;
printf("\tXSD Table 64-bit Address: 0x%08X%08X\n",
- QWORD(p+24).h, QWORD(p+24).l);
+ QWORD(p + 24).h, QWORD(p + 24).l);
return 1;
}
@@ -269,12 +269,12 @@ static int acpi_decode(const u8 *p, size_t len)
static size_t sony_length(const u8 *p)
{
- return(p[0x05]);
+ return p[0x05];
}
static int sony_decode(const u8 *p, size_t len)
{
- if(!checksum(p, len))
+ if (!checksum(p, len))
return 0;
printf("Sony system detected.\n");
@@ -288,19 +288,19 @@ static int sony_decode(const u8 *p, size_t len)
static size_t bios32_length(const u8 *p)
{
- return p[0x09]<<4;
+ return p[0x09] << 4;
}
static int bios32_decode(const u8 *p, size_t len)
{
- if(len<0x0A || !checksum(p, p[0x09]<<4))
+ if (len < 0x0A || !checksum(p, p[0x09] << 4))
return 0;
printf("BIOS32 Service Directory present.\n");
printf("\tRevision: %u\n",
p[0x08]);
printf("\tCalling Interface Address: 0x%08X\n",
- DWORD(p+0x04));
+ DWORD(p + 0x04));
return 1;
}
@@ -311,21 +311,21 @@ static int bios32_decode(const u8 *p, size_t len)
static void pir_irqs(u16 code)
{
- if(code==0)
+ if (code == 0)
printf(" None");
else
{
u8 i;
- for(i=0; i<16; i++)
- if(code&(1<<i))
+ for (i = 0; i < 16; i++)
+ if (code & (1 << i))
printf(" %u", i);
}
}
static void pir_slot_number(u8 code)
{
- if(code==0)
+ if (code == 0)
printf(" on-board");
else
printf(" slot number %u", code);
@@ -333,61 +333,61 @@ static void pir_slot_number(u8 code)
static size_t pir_length(const u8 *p)
{
- return WORD(p+6);
+ return WORD(p + 6);
}
static int pir_decode(const u8 *p, size_t len)
{
int i;
- if(len<32 || !checksum(p, WORD(p+6)))
+ if (len < 32 || !checksum(p, WORD(p + 6)))
return 0;
printf("PCI Interrupt Routing %u.%u present.\n",
p[5], p[4]);
printf("\tRouter ID: %02x:%02x.%1x\n",
- p[8], p[9]>>3, p[9]&0x07);
+ p[8], p[9]>>3, p[9] & 0x07);
printf("\tExclusive IRQs:");
- pir_irqs(WORD(p+10));
+ pir_irqs(WORD(p + 10));
printf("\n");
- if(DWORD(p+12)!=0)
+ if (DWORD(p + 12) != 0)
printf("\tCompatible Router: %04x:%04x\n",
- WORD(p+12), WORD(p+14));
- if(DWORD(p+16)!=0)
+ WORD(p + 12), WORD(p + 14));
+ if (DWORD(p + 16) != 0)
printf("\tMiniport Data: 0x%08X\n",
- DWORD(p+16));
+ DWORD(p + 16));
- for(i=1; i<=(WORD(p+6)-32)/16; i++)
+ for (i = 1; i <= (WORD(p + 6) - 32) / 16; i++)
{
printf("\tSlot Entry %u: ID %02x:%02x,",
- i, p[(i+1)*16], p[(i+1)*16+1]>>3);
- pir_slot_number(p[(i+1)*16+14]);
+ i, p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
+ pir_slot_number(p[(i + 1) * 16 + 14]);
printf("\n");
/* printf("\tSlot Entry %u\n", i);
printf("\t\tID: %02x:%02x\n",
- p[(i+1)*16], p[(i+1)*16+1]>>3);
+ p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
printf("\t\tLink Value for INTA#: %u\n",
- p[(i+1)*16+2]);
+ p[(i + 1) * 16 + 2]);
printf("\t\tIRQ Bitmap for INTA#:");
- pir_irqs(WORD(p+(i+1)*16+3));
+ pir_irqs(WORD(p + (i + 1) * 16 + 3));
printf("\n");
printf("\t\tLink Value for INTB#: %u\n",
- p[(i+1)*16+5]);
+ p[(i + 1) * 16 + 5]);
printf("\t\tIRQ Bitmap for INTB#:");
- pir_irqs(WORD(p+(i+1)*16+6));
+ pir_irqs(WORD(p + (i + 1) * 16 + 6));
printf("\n");
printf("\t\tLink Value for INTC#: %u\n",
- p[(i+1)*16+8]);
+ p[(i + 1) * 16 + 8]);
printf("\t\tIRQ Bitmap for INTC#:");
- pir_irqs(WORD(p+(i+1)*16+9));
+ pir_irqs(WORD(p + (i + 1) * 16 + 9));
printf("\n");
printf("\t\tLink Value for INTD#: %u\n",
- p[(i+1)*16+11]);
+ p[(i + 1) * 16 + 11]);
printf("\t\tIRQ Bitmap for INTD#:");
- pir_irqs(WORD(p+(i+1)*16+12));
+ pir_irqs(WORD(p + (i + 1) * 16 + 12));
printf("\n");
printf("\t\tSlot Number:");
- pir_slot_number(p[(i+1)*16+14]);
+ pir_slot_number(p[(i + 1) * 16 + 14]);
printf("\n");*/
}
@@ -400,7 +400,7 @@ static int pir_decode(const u8 *p, size_t len)
static size_t compaq_length(const u8 *p)
{
- return (p[4]*10+5);
+ return p[4] * 10 + 5;
}
static int compaq_decode(const u8 *p, size_t len)
@@ -411,29 +411,31 @@ static int compaq_decode(const u8 *p, size_t len)
printf("Compaq-specific entries present.\n");
/* integrity checking (lack of checksum) */
- for(i=0; i<p[4]; i++)
+ for (i = 0; i < p[4]; i++)
{
/*
* We do not check for truncated entries, because the length
* was computed from the number of records in compaq_length
* right above, so it can't be wrong.
*/
- if(p[5+i*10]!='$' || !(p[6+i*10]>='A' && p[6+i*10]<='Z')
- || !(p[7+i*10]>='A' && p[7+i*10]<='Z')
- || !(p[8+i*10]>='A' && p[8+i*10]<='Z'))
+ if (p[5 + i * 10] != '$'
+ || !(p[6 + i * 10] >= 'A' && p[6 + i * 10] <= 'Z')
+ || !(p[7 + i * 10] >= 'A' && p[7 + i * 10] <= 'Z')
+ || !(p[8 + i * 10] >= 'A' && p[8 + i * 10] <= 'Z'))
{
printf("\t Abnormal entry! Please report. [%02X %02X "
- "%02X %02X]\n", p[5+i*10], p[6+i*10],
- p[7+i*10], p[8+i*10]);
+ "%02X %02X]\n", p[5 + i * 10], p[6 + i * 10],
+ p[7 + i * 10], p[8 + i * 10]);
return 0;
}
}
- for(i=0; i<p[4]; i++)
+ for (i = 0; i < p[4]; i++)
{
printf("\tEntry %u: %c%c%c%c at 0x%08X (%u bytes)\n",
- i+1, p[5+i*10], p[6+i*10], p[7+i*10], p[8+i*10],
- DWORD(p+9+i*10), WORD(p+13+i*10));
+ i + 1, p[5 + i * 10], p[6 + i * 10], p[7 + i * 10],
+ p[8 + i * 10], DWORD(p + 9 + i * 10),
+ WORD(p + 13 + i * 10));
}
return 1;
@@ -448,41 +450,41 @@ static void vpd_print_entry(const char *name, const u8 *p, size_t len)
size_t i;
printf("\t%s: ", name);
- for(i=0; i<len; i++)
- if(p[i]>=32 && p[i]<127)
+ for (i = 0; i < len; i++)
+ if (p[i] >= 32 && p[i] < 127)
printf("%c", p[i]);
printf("\n");
}
static size_t vpd_length(const u8 *p)
{
- return (p[5]);
+ return p[5];
}
static int vpd_decode(const u8 *p, size_t len)
{
- if(len<0x30)
+ if (len < 0x30)
return 0;
/* XSeries have longer records. */
- if(!(len>=0x45 && checksum(p, len))
+ if (!(len >= 0x45 && checksum(p, len))
/* Some Netvista seem to work with this. */
- && !checksum(p, 0x30)
+ && !checksum(p, 0x30)
/* The Thinkpad checksum does *not* include the first 13 bytes. */
- && !checksum(p+0x0D, 0x30-0x0D))
+ && !checksum(p + 0x0D, 0x30 - 0x0D))
return 0;
printf("VPD present.\n");
- vpd_print_entry("BIOS Build ID", p+0x0D, 9);
- vpd_print_entry("Box Serial Number", p+0x16, 7);
- vpd_print_entry("Motherboard Serial Number", p+0x1D, 11);
- vpd_print_entry("Machine Type/Model", p+0x28, 7);
+ vpd_print_entry("BIOS Build ID", p + 0x0D, 9);
+ vpd_print_entry("Box Serial Number", p + 0x16, 7);
+ vpd_print_entry("Motherboard Serial Number", p + 0x1D, 11);
+ vpd_print_entry("Machine Type/Model", p + 0x28, 7);
- if(len<0x45)
+ if (len < 0x45)
return 1;
- vpd_print_entry("BIOS Release Date", p+0x30, 8);
+ vpd_print_entry("BIOS Release Date", p + 0x30, 8);
return 1;
}
@@ -510,12 +512,13 @@ static int fjkeyinf_decode(const u8 *p, size_t len)
for (i = 0; i < 6; i++)
{
- if (*(p+8+i*4)==0)
+ if (*(p + 8 + i * 4)==0)
return 1;
- printf("\tDevice %d: type %u, chip %u", i+1,
- *(p+8+i*4), *(p+8+i*4+2));
+ printf("\tDevice %d: type %u, chip %u", i + 1,
+ *(p + 8 + i * 4), *(p + 8 + i * 4 + 2));
if (*(p+8+i*4+1)) /* Access method */
- printf(", SMBus address 0x%x", *(p+8+i*4+3) >> 1);
+ printf(", SMBus address 0x%x",
+ *(p + 8 + i * 4 + 3) >> 1);
printf("\n");
}
@@ -526,7 +529,7 @@ static int fjkeyinf_decode(const u8 *p, size_t len)
* Main
*/
-static struct bios_entry bios_entries[]={
+static struct bios_entry bios_entries[] = {
{ "_SM_", 0, 0xF0000, 0xFFFFF, smbios_length, smbios_decode },
{ "_DMI_", 0, 0xF0000, 0xFFFFF, dmi_length, dmi_decode },
{ "_SYSID_", 0, 0xE0000, 0xFFFFF, sysid_length, sysid_decode },
@@ -546,8 +549,8 @@ static inline int anchor_match(const struct bios_entry *entry, const char *p)
{
size_t i;
- for(i=0; i<entry->anchor_len; i++)
- if(entry->anchor[i]!=p[i])
+ for (i = 0; i < entry->anchor_len; i++)
+ if (entry->anchor[i] != p[i])
return 0;
return 1;
@@ -558,24 +561,24 @@ static int parse_command_line(int argc, char * const argv[])
{
int option;
const char *optstring = "d:hV";
- struct option longopts[]={
+ struct option longopts[] = {
{ "dev-mem", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ 0, 0, 0, 0 }
};
- while((option=getopt_long(argc, argv, optstring, longopts, NULL))!=-1)
- switch(option)
+ while ((option = getopt_long(argc, argv, optstring, longopts, NULL)) != -1)
+ switch (option)
{
case 'd':
- opt.devmem=optarg;
+ opt.devmem = optarg;
break;
case 'h':
- opt.flags|=FLAG_HELP;
+ opt.flags |= FLAG_HELP;
break;
case 'V':
- opt.flags|=FLAG_VERSION;
+ opt.flags |= FLAG_VERSION;
break;
case '?':
return -1;
@@ -586,7 +589,7 @@ static int parse_command_line(int argc, char * const argv[])
static void print_help(void)
{
- static const char *help=
+ static const char *help =
"Usage: biosdecode [OPTIONS]\n"
"Options are:\n"
" -d, --dev-mem FILE Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"
@@ -602,26 +605,26 @@ int main(int argc, char * const argv[])
off_t fp;
int i;
- if(sizeof(u8)!=1 || sizeof(u16)!=2 || sizeof(u32)!=4)
+ if (sizeof(u8) != 1 || sizeof(u16) != 2 || sizeof(u32) != 4)
{
fprintf(stderr, "%s: compiler incompatibility\n", argv[0]);
exit(255);
}
/* Set default option values */
- opt.devmem=DEFAULT_MEM_DEV;
- opt.flags=0;
+ opt.devmem = DEFAULT_MEM_DEV;
+ opt.flags = 0;
- if(parse_command_line(argc, argv)<0)
+ if (parse_command_line(argc, argv) < 0)
exit(2);
- if(opt.flags & FLAG_HELP)
+ if (opt.flags & FLAG_HELP)
{
print_help();
return 0;
}
- if(opt.flags & FLAG_VERSION)
+ if (opt.flags & FLAG_VERSION)
{
printf("%s\n", VERSION);
return 0;
@@ -629,30 +632,30 @@ int main(int argc, char * const argv[])
printf("# biosdecode %s\n", VERSION);
- if((buf=mem_chunk(0xE0000, 0x20000, opt.devmem))==NULL)
+ if ((buf = mem_chunk(0xE0000, 0x20000, opt.devmem)) == NULL)
exit(1);
/* Compute anchor lengths once and for all */
- for(i=0; bios_entries[i].anchor!=NULL; i++)
+ for (i = 0; bios_entries[i].anchor != NULL; i++)
bios_entries[i].anchor_len = strlen(bios_entries[i].anchor);
- for(fp=0xE0000; fp<=0xFFFF0; fp+=16)
+ for (fp = 0xE0000; fp <= 0xFFFF0; fp += 16)
{
- u8 *p=buf+fp-0xE0000;
+ u8 *p = buf + fp - 0xE0000;
- for(i=0; bios_entries[i].anchor!=NULL; i++)
+ for (i = 0; bios_entries[i].anchor != NULL; i++)
{
- if(anchor_match(&bios_entries[i], (char *)p)
- && fp>=bios_entries[i].low_address
- && fp<bios_entries[i].high_address)
+ if (anchor_match(&bios_entries[i], (char *)p)
+ && fp >= bios_entries[i].low_address
+ && fp < bios_entries[i].high_address)
{
- off_t len=bios_entries[i].length(p);
+ off_t len = bios_entries[i].length(p);
- if(fp+len-1<=bios_entries[i].high_address)
+ if (fp + len - 1 <= bios_entries[i].high_address)
{
- if(bios_entries[i].decode(p, len))
+ if (bios_entries[i].decode(p, len))
{
- fp+=(((len-1)>>4)<<4);
+ fp += (((len - 1) >> 4) << 4);
break;
}
}
diff --git a/dmidecode.c b/dmidecode.c
index d9850cd..f1d6521 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -69,35 +69,35 @@ static const char *bad_index = "<BAD INDEX>";
const char *dmi_string(struct dmi_header *dm, u8 s)
{
- char *bp=(char *)dm->data;
+ char *bp = (char *)dm->data;
size_t i, len;
- if(s==0)
+ if (s == 0)
return "Not Specified";
- bp+=dm->length;
- while(s>1 && *bp)
+ bp += dm->length;
+ while (s > 1 && *bp)
{
- bp+=strlen(bp);
+ bp += strlen(bp);
bp++;
s--;
}
- if(!*bp)
+ if (!*bp)
return bad_index;
/* ASCII filtering */
- len=strlen(bp);
- for(i=0; i<len; i++)
- if(bp[i]<32 || bp[i]==127)
- bp[i]='.';
+ len = strlen(bp);
+ for (i = 0; i < len; i++)
+ if (bp[i] < 32 || bp[i] == 127)
+ bp[i] = '.';
return bp;
}
static const char *dmi_smbios_structure_type(u8 code)
{
- static const char *type[]={
+ static const char *type[] = {
"BIOS", /* 0 */
"System",
"Base Board",
@@ -140,16 +140,16 @@ static const char *dmi_smbios_structure_type(u8 code)
"Power Supply" /* 39 */
};
- if(code<=39)
- return(type[code]);
+ if (code <= 39)
+ return type[code];
return out_of_spec;
}
static int dmi_bcd_range(u8 value, u8 low, u8 high)
{
- if(value>0x99 || (value&0x0F)>0x09)
+ if (value > 0x99 || (value & 0x0F) > 0x09)
return 0;
- if(value<low || value>high)
+ if (value < low || value > high)
return 0;
return 1;
}
@@ -160,29 +160,30 @@ static void dmi_dump(struct dmi_header *h, const char *prefix)
const char *s;
printf("%sHeader and Data:\n", prefix);
- for(row=0; row<((h->length-1)>>4)+1; row++)
+ for (row = 0; row < ((h->length - 1) >> 4) + 1; row++)
{
printf("%s\t", prefix);
- for(i=0; i<16 && i<h->length-(row<<4); i++)
- printf("%s%02X", i?" ":"", (h->data)[(row<<4)+i]);
+ for (i = 0; i < 16 && i < h->length - (row << 4); i++)
+ printf("%s%02X", i ? " " : "",
+ (h->data)[(row << 4) + i]);
printf("\n");
}
- if((h->data)[h->length] || (h->data)[h->length+1])
+ if ((h->data)[h->length] || (h->data)[h->length + 1])
{
printf("%sStrings:\n", prefix);
- i=1;
- while((s=dmi_string(h, i++))!=bad_index)
+ i = 1;
+ while ((s = dmi_string(h, i++)) != bad_index)
{
- if(opt.flags & FLAG_DUMP)
+ if (opt.flags & FLAG_DUMP)
{
- int j, l = strlen(s)+1;
- for(row=0; row<((l-1)>>4)+1; row++)
+ int j, l = strlen(s) + 1;
+ for (row = 0; row < ((l - 1) >> 4) + 1; row++)
{
printf("%s\t", prefix);
- for(j=0; j<16 && j<l-(row<<4); j++)
- printf("%s%02X", j?" ":"",
- s[(row<<4)+j]);
+ for (j = 0; j < 16 && j < l - (row << 4); j++)
+ printf("%s%02X", j ? " " : "",
+ s[(row << 4) + j]);
printf("\n");
}
printf("%s\t\"%s\"\n", prefix, s);
@@ -199,16 +200,16 @@ static void dmi_dump(struct dmi_header *h, const char *prefix)
static void dmi_bios_runtime_size(u32 code)
{
- if(code&0x000003FF)
+ if (code & 0x000003FF)
printf(" %u bytes", code);
else
- printf(" %u kB", code>>10);
+ printf(" %u kB", code >> 10);
}
static void dmi_bios_characteristics(u64 code, const char *prefix)
{
/* 3.3.1.1 */
- static const char *characteristics[]={
+ static const char *characteristics[] = {
"BIOS characteristics not supported", /* 3 */
"ISA is supported",
"MCA is supported",
@@ -244,23 +245,23 @@ static void dmi_bios_characteristics(u64 code, const char *prefix)
/*
* This isn't very clear what this bit is supposed to mean
*/
- if(code.l&(1<<3))
+ if (code.l & (1<<3))
{
printf("%s%s\n",
prefix, characteristics[0]);
return;
}
- for(i=4; i<=31; i++)
- if(code.l&(1<<i))
+ for (i = 4; i <= 31; i++)
+ if (code.l & (1 << i))
printf("%s%s\n",
- prefix, characteristics[i-3]);
+ prefix, characteristics[i - 3]);
}
static void dmi_bios_characteristics_x1(u8 code, const char *prefix)
{
/* 3.3.1.2.1 */
- static const char *characteristics[]={
+ static const char *characteristics[] = {
"ACPI is supported", /* 0 */
"USB legacy is supported",
"AGP is supported",
@@ -272,8 +273,8 @@ static void dmi_bios_characteristics_x1(u8 code, const char *prefix)
};
int i;
- for(i=0; i<=7; i++)
- if(code&(1<<i))
+ for (i = 0; i <= 7; i++)
+ if (code & (1 << i))
printf("%s%s\n",
prefix, characteristics[i]);
}
@@ -281,15 +282,15 @@ static void dmi_bios_characteristics_x1(u8 code, const char *prefix)
static void dmi_bios_characteristics_x2(u8 code, const char *prefix)
{
/* 3.3.1.2.2 */
- static const char *characteristics[]={
+ static const char *characteristics[] = {
"BIOS boot specification is supported", /* 0 */
"Function key-initiated network boot is supported",
"Targeted content distribution is supported" /* 2 */
};
int i;
- for(i=0; i<=2; i++)
- if(code&(1<<i))
+ for (i = 0; i <= 2; i++)
+ if (code & (1 << i))
printf("%s%s\n",
prefix, characteristics[i]);
}
@@ -300,21 +301,21 @@ static void dmi_bios_characteristics_x2(u8 code, const char *prefix)
void dmi_system_uuid(u8 *p)
{
- int only0xFF=1, only0x00=1;
+ int only0xFF = 1, only0x00 = 1;
int i;
- for(i=0; i<16 && (only0x00 || only0xFF); i++)
+ for (i = 0; i < 16 && (only0x00 || only0xFF); i++)
{
- if(p[i]!=0x00) only0x00=0;
- if(p[i]!=0xFF) only0xFF=0;
+ if (p[i] != 0x00) only0x00 = 0;
+ if (p[i] != 0xFF) only0xFF = 0;
}
- if(only0xFF)
+ if (only0xFF)
{
printf("Not Present");
return;
}
- if(only0x00)
+ if (only0x00)
{
printf("Not Settable");
return;
@@ -328,7 +329,7 @@ void dmi_system_uuid(u8 *p)
static const char *dmi_system_wake_up_type(u8 code)
{
/* 3.3.2.1 */
- static const char *type[]={
+ static const char *type[] = {
"Reserved", /* 0x00 */
"Other",
"Unknown",
@@ -340,7 +341,7 @@ static const char *dmi_system_wake_up_type(u8 code)
"AC Power Restored" /* 0x08 */
};
- if(code<=0x08)
+ if (code <= 0x08)
return type[code];
return out_of_spec;
}
@@ -352,7 +353,7 @@ static const char *dmi_system_wake_up_type(u8 code)
static void dmi_base_board_features(u8 code, const char *prefix)
{
/* 3.3.3.1 */
- static const char *features[]={
+ static const char *features[] = {
"Board is a hosting board", /* 0 */
"Board requires at least one daughter board",
"Board is removable",
@@ -360,15 +361,15 @@ static void dmi_base_board_features(u8 code, const char *prefix)
"Board is hot swappable" /* 4 */
};
- if((code&0x1F)==0)
+ if ((code & 0x1F) == 0)
printf(" None\n");
else
{
int i;
printf("\n");
- for(i=0; i<=4; i++)
- if(code&(1<<i))
+ for (i = 0; i <= 4; i++)
+ if (code & (1 << i))
printf("%s%s\n",
prefix, features[i]);
}
@@ -377,7 +378,7 @@ static void dmi_base_board_features(u8 code, const char *prefix)
static const char *dmi_base_board_type(u8 code)
{
/* 3.3.3.2 */
- static const char *type[]={
+ static const char *type[] = {
"Unknown", /* 0x01 */
"Other",
"Server Blade",
@@ -393,8 +394,8 @@ static const char *dmi_base_board_type(u8 code)
"Interconnect Board" /* 0x0D */
};
- if(code>=0x01 && code<=0x0D)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x0D)
+ return type[code - 0x01];
return out_of_spec;
}
@@ -404,9 +405,9 @@ static void dmi_base_board_handles(u8 count, u8 *p, const char *prefix)
printf("%sContained Object Handles: %u\n",
prefix, count);
- for(i=0; i<count; i++)
+ for (i = 0; i < count; i++)
printf("%s\t0x%04X\n",
- prefix, WORD(p+sizeof(u16)*i));
+ prefix, WORD(p + sizeof(u16) * i));
}
/*
@@ -416,7 +417,7 @@ static void dmi_base_board_handles(u8 count, u8 *p, const char *prefix)
const char *dmi_chassis_type(u8 code)
{
/* 3.3.4.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Desktop",
@@ -446,14 +447,14 @@ const char *dmi_chassis_type(u8 code)
"AdvancedTCA" /* 0x1B */
};
- if(code>=0x01 && code<=0x1B)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x1B)
+ return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_chassis_lock(u8 code)
{
- static const char *lock[]={
+ static const char *lock[] = {
"Not Present", /* 0x00 */
"Present" /* 0x01 */
};
@@ -464,7 +465,7 @@ static const char *dmi_chassis_lock(u8 code)
static const char *dmi_chassis_state(u8 code)
{
/* 3.3.4.2 */
- static const char *state[]={
+ static const char *state[] = {
"Other", /* 0x01 */
"Unknown",
"Safe", /* master.mif says OK */
@@ -473,15 +474,15 @@ static const char *dmi_chassis_state(u8 code)
"Non-recoverable" /* 0x06 */
};
- if(code>=0x01 && code<=0x06)
- return(state[code-0x01]);
+ if (code >= 0x01 && code <= 0x06)
+ return state[code - 0x01];
return out_of_spec;
}
static const char *dmi_chassis_security_status(u8 code)
{
/* 3.3.4.3 */
- static const char *status[]={
+ static const char *status[] = {
"Other", /* 0x01 */
"Unknown",
"None",
@@ -489,14 +490,14 @@ static const char *dmi_chassis_security_status(u8 code)
"External Interface Enabled" /* 0x05 */
};
- if(code>=0x01 && code<=0x05)
- return(status[code-0x01]);
+ if (code >= 0x01 && code <= 0x05)
+ return status[code - 0x01];
return out_of_spec;
}
static void dmi_chassis_height(u8 code)
{
- if(code==0x00)
+ if (code == 0x00)
printf(" Unspecified");
else
printf(" %u U", code);
@@ -504,7 +505,7 @@ static void dmi_chassis_height(u8 code)
static void dmi_chassis_power_cords(u8 code)
{
- if(code==0x00)
+ if (code == 0x00)
printf(" Unspecified");
else
printf(" %u", code);
@@ -516,18 +517,18 @@ static void dmi_chassis_elements(u8 count, u8 len, u8 *p, const char *prefix)
printf("%sContained Elements: %u\n",
prefix, count);
- for(i=0; i<count; i++)
+ for (i = 0; i < count; i++)
{
- if(len>=0x03)
+ if (len >= 0x03)
{
printf("%s\t%s (",
- prefix, p[i*len]&0x80?
- dmi_smbios_structure_type(p[i*len]&0x7F):
- dmi_base_board_type(p[i*len]&0x7F));
- if(p[1+i*len]==p[2+i*len])
- printf("%u", p[1+i*len]);
+ prefix, p[i * len] & 0x80 ?
+ dmi_smbios_structure_type(p[i * len] & 0x7F) :
+ dmi_base_board_type(p[i * len] & 0x7F));
+ if (p[1 + i * len] == p[2 + i * len])
+ printf("%u", p[1 + i * len]);
else
- printf("%u-%u", p[1+i*len], p[2+i*len]);
+ printf("%u-%u", p[1 + i * len], p[2 + i * len]);
printf(")\n");
}
}
@@ -540,7 +541,7 @@ static void dmi_chassis_elements(u8 count, u8 len, u8 *p, const char *prefix)
static const char *dmi_processor_type(u8 code)
{
/* 3.3.5.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Central Processor",
@@ -549,15 +550,15 @@ static const char *dmi_processor_type(u8 code)
"Video Processor" /* 0x06 */
};
- if(code>=0x01 && code<=0x06)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x06)
+ return type[code - 0x01];
return out_of_spec;
}
const char *dmi_processor_family(u8 code)
{
/* 3.3.5.2 */
- static const char *family[256]={
+ static const char *family[256] = {
NULL, /* 0x00 */
"Other",
"Unknown",
@@ -817,7 +818,7 @@ const char *dmi_processor_family(u8 code)
/* master.mif has values beyond that, but they can't be used for DMI */
};
- if(family[code]!=NULL)
+ if (family[code] != NULL)
return family[code];
return out_of_spec;
}
@@ -825,7 +826,7 @@ const char *dmi_processor_family(u8 code)
static void dmi_processor_id(u8 type, u8 *p, const char *version, const char *prefix)
{
/* Intel AP-485 revision 31, table 3-4 */
- static const char *flags[32]={
+ static const char *flags[32] = {
"FPU (Floating-point unit on-chip)", /* 0 */
"VME (Virtual mode extension)",
"DE (Debugging extension)",
@@ -865,7 +866,7 @@ static void dmi_processor_id(u8 type, u8 *p, const char *version, const char *pr
* DMI doesn't support this yet.
*/
u32 eax, edx;
- int sig=0;
+ int sig = 0;
/*
* This might help learn about new processors supporting the
@@ -874,92 +875,96 @@ static void dmi_processor_id(u8 type, u8 *p, const char *version, const char *pr
printf("%sID: %02X %02X %02X %02X %02X %02X %02X %02X\n",
prefix, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
- if(type==0x05) /* 80386 */
+ if (type == 0x05) /* 80386 */
{
- u16 dx=WORD(p);
+ u16 dx = WORD(p);
/*
* 80386 have a different signature.
*/
printf("%sSignature: Type %u, Family %u, Major Stepping %u, Minor Stepping %u\n",
- prefix, dx>>12, (dx>>8)&0xF, (dx>>4)&0xF, dx&0xF);
+ prefix, dx >> 12, (dx >> 8) & 0xF,
+ (dx >> 4) & 0xF, dx & 0xF);
return;
}
- if(type==0x06) /* 80486 */
+ if (type == 0x06) /* 80486 */
{
- u16 dx=WORD(p);
+ u16 dx = WORD(p);
/*
* Not all 80486 CPU support the CPUID instruction, we have to find
* wether the one we have here does or not. Note that this trick
* works only because we know that 80486 must be little-endian.
*/
- if((dx&0x0F00)==0x0400
- && ((dx&0x00F0)==0x0040 || (dx&0x00F0)>=0x0070)
- && ((dx&0x000F)>=0x0003))
- sig=1;
+ if ((dx & 0x0F00) == 0x0400
+ && ((dx & 0x00F0) == 0x0040 || (dx & 0x00F0) >= 0x0070)
+ && ((dx & 0x000F) >= 0x0003))
+ sig = 1;
else
{
printf("%sSignature: Type %u, Family %u, Model %u, Stepping %u\n",
- prefix, (dx>>12)&0x3, (dx>>8)&0xF, (dx>>4)&0xF, dx&0xF);
+ prefix, (dx >> 12) & 0x3, (dx >> 8) & 0xF,
+ (dx >> 4) & 0xF, dx & 0xF);
return;
}
}
- else if((type>=0x0B && type<=0x13) /* Intel, Cyrix */
- || (type>=0xB0 && type<=0xB3) /* Intel */
- || type==0xB5 /* Intel */
- || (type>=0xB9 && type<=0xBC)) /* Intel */
- sig=1;
- else if((type>=0x18 && type<=0x1D) /* AMD */
- || type==0x1F /* AMD */
- || (type>=0xB6 && type<=0xB7) /* AMD */
- || (type>=0x83 && type<=0x88)) /* AMD */
- sig=2;
- else if(type==0x01 || type==0x02)
+ else if ((type >= 0x0B && type <= 0x13) /* Intel, Cyrix */
+ || (type >= 0xB0 && type <= 0xB3) /* Intel */
+ || type == 0xB5 /* Intel */
+ || (type >= 0xB9 && type <= 0xBC)) /* Intel */
+ sig = 1;
+ else if ((type >= 0x18 && type <= 0x1D) /* AMD */
+ || type == 0x1F /* AMD */
+ || (type >= 0xB6 && type <= 0xB7) /* AMD */
+ || (type >= 0x83 && type <= 0x88)) /* AMD */
+ sig = 2;
+ else if (type == 0x01 || type == 0x02)
{
/*
* Some X86-class CPU have family "Other" or "Unknown". In this case,
* we use the version string to determine if they are known to
* support the CPUID instruction.
*/
- if(strncmp(version, "Pentium III MMX", 15)==0)
- sig=1;
- else if(strncmp(version, "AMD Athlon(TM)", 14)==0
- || strncmp(version, "AMD Opteron(tm)", 15)==0)
- sig=2;
+ if (strncmp(version, "Pentium III MMX", 15) == 0)
+ sig = 1;
+ else if (strncmp(version, "AMD Athlon(TM)", 14) == 0
+ || strncmp(version, "AMD Opteron(tm)", 15) == 0)
+ sig = 2;
else
return;
}
else /* not X86-class */
return;
- eax=DWORD(p);
- edx=DWORD(p+4);
- switch(sig)
+ eax = DWORD(p);
+ edx = DWORD(p + 4);
+ switch (sig)
{
case 1: /* Intel */
printf("%sSignature: Type %u, Family %u, Model %u, Stepping %u\n",
- prefix, (eax>>12)&0x3, ((eax>>20)&0xFF)+((eax>>8)&0x0F),
- ((eax>>12)&0xF0)+((eax>>4)&0x0F), eax&0xF);
+ prefix, (eax >> 12) & 0x3,
+ ((eax >> 20) & 0xFF) + ((eax >> 8) & 0x0F),
+ ((eax >> 12) & 0xF0) + ((eax >> 4) & 0x0F),
+ eax & 0xF);
break;
case 2: /* AMD */
printf("%sSignature: Family %u, Model %u, Stepping %u\n",
prefix,
- ((eax>>8)&0xF)+(((eax>>8)&0xF)==0xF?(eax>>20)&0xFF:0),
- ((eax>>4)&0xF)|(((eax>>8)&0xF)==0xF?(eax>>12)&0xF0:0),
+ ((eax >> 8) & 0xF) + (((eax >> 8) & 0xF) == 0xF ? (eax >> 20) & 0xFF : 0),
+ ((eax >> 4) & 0xF) | (((eax >> 8) & 0xF) == 0xF ? (eax >> 12) & 0xF0 : 0),
eax&0xF);
break;
}
- edx=DWORD(p+4);
+ edx = DWORD(p + 4);
printf("%sFlags:", prefix);
- if((edx&0xFFEFFBFF)==0)
+ if ((edx & 0xFFEFFBFF) == 0)
printf(" None\n");
else
{
int i;
printf("\n");
- for(i=0; i<=31; i++)
- if(flags[i]!=NULL && edx&(1<<i))
+ for (i = 0; i <= 31; i++)
+ if (flags[i] != NULL && edx & (1 << i))
printf("%s\t%s\n", prefix, flags[i]);
}
}
@@ -967,21 +972,21 @@ static void dmi_processor_id(u8 type, u8 *p, const char *version, const char *pr
static void dmi_processor_voltage(u8 code)
{
/* 3.3.5.4 */
- static const char *voltage[]={
+ static const char *voltage[] = {
"5.0 V", /* 0 */
"3.3 V",
"2.9 V" /* 2 */
};
int i;
- if(code&0x80)
- printf(" %.1f V", (float)(code&0x7f)/10);
+ if (code & 0x80)
+ printf(" %.1f V", (float)(code & 0x7f) / 10);
else
{
- for(i=0; i<=2; i++)
- if(code&(1<<i))
+ for (i = 0; i <= 2; i++)
+ if (code & (1 << i))
printf(" %s", voltage[i]);
- if(code==0x00)
+ if (code == 0x00)
printf(" Unknown");
}
}
@@ -990,7 +995,7 @@ void dmi_processor_frequency(u8 *p)
{
u16 code = WORD(p);
- if(code)
+ if (code)
printf("%u MHz", code);
else
printf("Unknown");
@@ -998,7 +1003,7 @@ void dmi_processor_frequency(u8 *p)
static const char *dmi_processor_status(u8 code)
{
- static const char *status[]={
+ static const char *status[] = {
"Unknown", /* 0x00 */
"Enabled",
"Disabled By User",
@@ -1007,9 +1012,9 @@ static const char *dmi_processor_status(u8 code)
"Other" /* 0x07 */
};
- if(code<=0x04)
+ if (code <= 0x04)
return status[code];
- if(code==0x07)
+ if (code == 0x07)
return status[0x05];
return out_of_spec;
}
@@ -1017,7 +1022,7 @@ static const char *dmi_processor_status(u8 code)
static const char *dmi_processor_upgrade(u8 code)
{
/* 3.3.5.5 */
- static const char *upgrade[]={
+ static const char *upgrade[] = {
"Other", /* 0x01 */
"Unknown",
"Daughter Board",
@@ -1041,16 +1046,16 @@ static const char *dmi_processor_upgrade(u8 code)
"Socket LGA775" /* 0x15 */
};
- if(code>=0x01 && code<=0x15)
- return upgrade[code-0x01];
+ if (code >= 0x01 && code <= 0x15)
+ return upgrade[code - 0x01];
return out_of_spec;
}
static void dmi_processor_cache(u16 code, const char *level, u16 ver)
{
- if(code==0xFFFF)
+ if (code == 0xFFFF)
{
- if(ver>=0x0203)
+ if (ver >= 0x0203)
printf(" Not Provided");
else
printf(" No %s Cache", level);
@@ -1062,20 +1067,20 @@ static void dmi_processor_cache(u16 code, const char *level, u16 ver)
static void dmi_processor_characteristics(u16 code, const char *prefix)
{
/* 3.3.5.9 */
- static const char *characteristics[]={
+ static const char *characteristics[] = {
"64-bit capable" /* 2 */
};
- if((code&0x0004)==0)
+ if ((code & 0x0004) == 0)
printf(" None\n");
else
{
int i;
printf("\n");
- for(i=2; i<=2; i++)
- if(code&(1<<i))
- printf("%s%s\n", prefix, characteristics[i-2]);
+ for (i = 2; i <= 2; i++)
+ if (code & (1 << i))
+ printf("%s%s\n", prefix, characteristics[i - 2]);
}
}
@@ -1086,7 +1091,7 @@ static void dmi_processor_characteristics(u16 code, const char *prefix)
static const char *dmi_memory_controller_ed_method(u8 code)
{
/* 3.3.6.1 */
- static const char *method[]={
+ static const char *method[] = {
"Other", /* 0x01 */
"Unknown",
"None",
@@ -1097,15 +1102,15 @@ static const char *dmi_memory_controller_ed_method(u8 code)
"CRC" /* 0x08 */
};
- if(code>=0x01 && code<=0x08)
- return(method[code-0x01]);
+ if (code >= 0x01 && code <= 0x08)
+ return method[code - 0x01];
return out_of_spec;
}
static void dmi_memory_controller_ec_capabilities(u8 code, const char *prefix)
{
/* 3.3.6.2 */
- static const char *capabilities[]={
+ static const char *capabilities[] = {
"Other", /* 0 */
"Unknown",
"None",
@@ -1114,23 +1119,23 @@ static void dmi_memory_controller_ec_capabilities(u8 code, const char *prefix)
"Error Scrubbing" /* 5 */
};
- if((code&0x3F)==0)
+ if ((code & 0x3F) == 0)
printf(" None\n");
else
{
int i;
printf("\n");
- for(i=0; i<=5; i++)
- if(code&(1<<i))
+ for (i = 0; i <= 5; i++)
+ if (code & (1 << i))
printf("%s%s\n", prefix, capabilities[i]);
}
}
-static const char* dmi_memory_controller_interleave(u8 code)
+static const char *dmi_memory_controller_interleave(u8 code)
{
/* 3.3.6.3 */
- static const char *interleave[]={
+ static const char *interleave[] = {
"Other", /* 0x01 */
"Unknown",
"One-way Interleave",
@@ -1140,15 +1145,15 @@ static const char* dmi_memory_controller_interleave(u8 code)
"Sixteen-way Interleave" /* 0x07 */
};
- if(code>=0x01 && code<=0x07)
- return(interleave[code-0x01]);
- return(out_of_spec);
+ if (code >= 0x01 && code <= 0x07)
+ return interleave[code - 0x01];
+ return out_of_spec;
}
static void dmi_memory_controller_speeds(u16 code, const char *prefix)
{
/* 3.3.6.4 */
- const char *speeds[]={
+ const char *speeds[] = {
"Other", /* 0 */
"Unknown",
"70 ns",
@@ -1156,15 +1161,15 @@ static void dmi_memory_controller_speeds(u16 code, const char *prefix)
"50 ns" /* 4 */
};
- if((code&0x001F)==0)
+ if ((code & 0x001F) == 0)
printf(" None\n");
else
{
int i;
printf("\n");
- for(i=0; i<=4; i++)
- if(code&(1<<i))
+ for (i = 0; i <= 4; i++)
+ if (code & (1 << i))
printf("%s%s\n", prefix, speeds[i]);
}
}
@@ -1175,9 +1180,9 @@ static void dmi_memory_controller_slots(u8 count, u8 *p, const char *prefix)
printf("%sAssociated Memory Slots: %u\n",
prefix, count);
- for(i=0; i<count; i++)
+ for (i = 0; i < count; i++)
printf("%s\t0x%04X\n",
- prefix, WORD(p+sizeof(u16)*i));
+ prefix, WORD(p + sizeof(u16) * i));
}
/*
@@ -1187,7 +1192,7 @@ static void dmi_memory_controller_slots(u8 count, u8 *p, const char *prefix)
static void dmi_memory_module_types(u16 code, const char *sep)
{
/* 3.3.7.1 */
- static const char *types[]={
+ static const char *types[] = {
"Other", /* 0 */
"Unknown",
"Standard",
@@ -1201,34 +1206,34 @@ static void dmi_memory_module_types(u16 code, const char *sep)
"SDRAM" /* 10 */
};
- if((code&0x07FF)==0)
+ if ((code & 0x07FF) == 0)
printf(" None");
else
{
int i;
- for(i=0; i<=10; i++)
- if(code&(1<<i))
+ for (i = 0; i <= 10; i++)
+ if (code & (1 << i))
printf("%s%s", sep, types[i]);
}
}
static void dmi_memory_module_connections(u8 code)
{
- if(code==0xFF)
+ if (code == 0xFF)
printf(" None");
else
{
- if((code&0xF0)!=0xF0)
- printf(" %u", code>>4);
- if((code&0x0F)!=0x0F)
- printf(" %u", code&0x0F);
+ if ((code & 0xF0) != 0xF0)
+ printf(" %u", code >> 4);
+ if ((code & 0x0F) != 0x0F)
+ printf(" %u", code & 0x0F);
}
}
static void dmi_memory_module_speed(u8 code)
{
- if(code==0)
+ if (code == 0)
printf(" Unknown");
else
printf(" %u ns", code);
@@ -1237,7 +1242,7 @@ static void dmi_memory_module_speed(u8 code)
static void dmi_memory_module_size(u8 code)
{
/* 3.3.7.2 */
- switch(code&0x7F)
+ switch (code & 0x7F)
{
case 0x7D:
printf(" Not Determinable");
@@ -1249,10 +1254,10 @@ static void dmi_memory_module_size(u8 code)
printf(" Not Installed");
return;
default:
- printf(" %u MB", 1<<(code&0x7F));
+ printf(" %u MB", 1 << (code & 0x7F));
}
- if(code&0x80)
+ if (code & 0x80)
printf(" (Double-bank Connection)");
else
printf(" (Single-bank Connection)");
@@ -1260,14 +1265,14 @@ static void dmi_memory_module_size(u8 code)
static void dmi_memory_module_error(u8 code, const char *prefix)
{
- if(code&(1<<2))
+ if (code & (1 << 2))
printf(" See Event Log\n");
else
- { if((code&0x03)==0)
+ { if ((code & 0x03) == 0)
printf(" OK\n");
- if(code&(1<<0))
+ if (code & (1 << 0))
printf("%sUncorrectable Errors\n", prefix);
- if(code&(1<<1))
+ if (code & (1 << 1))
printf("%sCorrectable Errors\n", prefix);
}
}
@@ -1278,7 +1283,7 @@ static void dmi_memory_module_error(u8 code, const char *prefix)
static const char *dmi_cache_mode(u8 code)
{
- static const char *mode[]={
+ static const char *mode[] = {
"Write Through", /* 0x00 */
"Write Back",
"Varies With Memory Address",
@@ -1290,22 +1295,22 @@ static const char *dmi_cache_mode(u8 code)
static const char *dmi_cache_location(u8 code)
{
- static const char *location[4]={
+ static const char *location[4] = {
"Internal", /* 0x00 */
"External",
NULL, /* 0x02 */
"Unknown" /* 0x03 */
};
- if(location[code]!=NULL)
+ if (location[code] != NULL)
return location[code];
return out_of_spec;
}
static void dmi_cache_size(u16 code)
{
- if(code&0x8000)
- printf(" %u kB", (code&0x7FFF)<<6);
+ if (code & 0x8000)
+ printf(" %u kB", (code & 0x7FFF) << 6);
else
printf(" %u kB", code);
}
@@ -1313,7 +1318,7 @@ static void dmi_cache_size(u16 code)
static void dmi_cache_types(u16 code, const char *sep)
{
/* 3.3.8.2 */
- static const char *types[]={
+ static const char *types[] = {
"Other", /* 0 */
"Unknown",
"Non-burst",
@@ -1323,14 +1328,14 @@ static void dmi_cache_types(u16 code, const char *sep)
"Asynchronous" /* 6 */
};
- if((code&0x007F)==0)
+ if ((code & 0x007F) == 0)
printf(" None");
else
{
int i;
- for(i=0; i<=6; i++)
- if(code&(1<<i))
+ for (i = 0; i <= 6; i++)
+ if (code & (1 << i))
printf("%s%s", sep, types[i]);
}
}
@@ -1338,7 +1343,7 @@ static void dmi_cache_types(u16 code, const char *sep)
static const char *dmi_cache_ec_type(u8 code)
{
/* 3.3.8.3 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"None",
@@ -1347,15 +1352,15 @@ static const char *dmi_cache_ec_type(u8 code)
"Multi-bit ECC" /* 0x06 */
};
- if(code>=0x01 && code<=0x06)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x06)
+ return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_cache_type(u8 code)
{
/* 3.3.8.4 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Instruction",
@@ -1363,15 +1368,15 @@ static const char *dmi_cache_type(u8 code)
"Unified" /* 0x05 */
};
- if(code>=0x01 && code<=0x05)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x05)
+ return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_cache_associativity(u8 code)
{
/* 3.3.8.5 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Direct Mapped",
@@ -1382,8 +1387,8 @@ static const char *dmi_cache_associativity(u8 code)
"16-way Set-associative" /* 0x08 */
};
- if(code>=0x01 && code<=0x08)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x08)
+ return type[code - 0x01];
return out_of_spec;
}
@@ -1394,7 +1399,7 @@ static const char *dmi_cache_associativity(u8 code)
static const char *dmi_port_connector_type(u8 code)
{
/* 3.3.9.2 */
- static const char *type[]={
+ static const char *type[] = {
"None", /* 0x00 */
"Centronics",
"Mini Centronics",
@@ -1431,7 +1436,7 @@ static const char *dmi_port_connector_type(u8 code)
"IEEE 1394",
"SAS/SATA Plug Receptacle" /* 0x22 */
};
- static const char *type_0xA0[]={
+ static const char *type_0xA0[] = {
"PC-98", /* 0xA0 */
"PC-98 Hireso",
"PC-H98",
@@ -1439,11 +1444,11 @@ static const char *dmi_port_connector_type(u8 code)
"PC-98 Full" /* 0xA4 */
};
- if(code<=0x22)
+ if (code <= 0x22)
return type[code];
- if(code>=0xA0 && code<=0xA4)
- return type_0xA0[code-0xA0];
- if(code==0xFF)
+ if (code >= 0xA0 && code <= 0xA4)
+ return type_0xA0[code - 0xA0];
+ if (code == 0xFF)
return "Other";
return out_of_spec;
}
@@ -1451,7 +1456,7 @@ static const char *dmi_port_connector_type(u8 code)
static const char *dmi_port_type(u8 code)
{
/* 3.3.9.3 */
- static const char *type[]={
+ static const char *type[] = {
"None", /* 0x00 */
"Parallel Port XT/AT Compatible",
"Parallel Port PS/2",
@@ -1487,16 +1492,16 @@ static const char *dmi_port_type(u8 code)
"SATA",
"SAS" /* 0x21 */
};
- static const char *type_0xA0[]={
+ static const char *type_0xA0[] = {
"8251 Compatible", /* 0xA0 */
"8251 FIFO Compatible" /* 0xA1 */
};
- if(code<=0x21)
+ if (code <= 0x21)
return type[code];
- if(code>=0xA0 && code<=0xA1)
- return type_0xA0[code-0xA0];
- if(code==0xFF)
+ if (code >= 0xA0 && code <= 0xA1)
+ return type_0xA0[code - 0xA0];
+ if (code == 0xFF)
return "Other";
return out_of_spec;
}
@@ -1508,7 +1513,7 @@ static const char *dmi_port_type(u8 code)
static const char *dmi_slot_type(u8 code)
{
/* 3.3.10.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"ISA",
@@ -1529,7 +1534,7 @@ static const char *dmi_slot_type(u8 code)
"PCI-X",
"AGP 8x" /* 0x13 */
};
- static const char *type_0xA0[]={
+ static const char *type_0xA0[] = {
"PC-98/C20", /* 0xA0 */
"PC-98/C24",
"PC-98/E",
@@ -1538,17 +1543,17 @@ static const char *dmi_slot_type(u8 code)
"PCI Express" /* 0xA5 */
};
- if(code>=0x01 && code<=0x13)
- return type[code-0x01];
- if(code>=0xA0 && code<=0xA5)
- return type_0xA0[code-0xA0];
+ if (code >= 0x01 && code <= 0x13)
+ return type[code - 0x01];
+ if (code >= 0xA0 && code <= 0xA5)
+ return type_0xA0[code - 0xA0];
return out_of_spec;
}
static const char *dmi_slot_bus_width(u8 code)
{
/* 3.3.10.2 */
- static const char *width[]={
+ static const char *width[] = {
"", /* 0x01, "Other" */
"", /* "Unknown" */
"8-bit ",
@@ -1565,45 +1570,45 @@ static const char *dmi_slot_bus_width(u8 code)
"x32 " /* 0x0E */
};
- if(code>=0x01 && code<=0x0E)
- return width[code-0x01];
+ if (code >= 0x01 && code <= 0x0E)
+ return width[code - 0x01];
return out_of_spec;
}
static const char *dmi_slot_current_usage(u8 code)
{
/* 3.3.10.3 */
- static const char *usage[]={
+ static const char *usage[] = {
"Other", /* 0x01 */
"Unknown",
"Available",
"In Use" /* 0x04 */
};
- if(code>=0x01 && code<=0x04)
- return usage[code-0x01];
+ if (code >= 0x01 && code <= 0x04)
+ return usage[code - 0x01];
return out_of_spec;
}
static const char *dmi_slot_length(u8 code)
{
/* 3.3.1O.4 */
- static const char *length[]={
+ static const char *length[] = {
"Other", /* 0x01 */
"Unknown",
"Short",
"Long" /* 0x04 */
};
- if(code>=0x01 && code<=0x04)
- return length[code-0x01];
+ if (code >= 0x01 && code <= 0x04)
+ return length[code - 0x01];
return out_of_spec;
}
static void dmi_slot_id(u8 code1, u8 code2, u8 type, const char *prefix)
{
/* 3.3.10.5 */
- switch(type)
+ switch (type)
{
case 0x04: /* MCA */
printf("%sID: %u\n", prefix, code1);
@@ -1630,7 +1635,7 @@ static void dmi_slot_id(u8 code1, u8 code2, u8 type, const char *prefix)
static void dmi_slot_characteristics(u8 code1, u8 code2, const char *prefix)
{
/* 3.3.10.6 */
- static const char *characteristics1[]={
+ static const char *characteristics1[] = {
"5.0 V is provided", /* 1 */
"3.3 V is provided",
"Opening is shared",
@@ -1640,26 +1645,26 @@ static void dmi_slot_characteristics(u8 code1, u8 code2, const char *prefix)
"Modem ring resume is supported" /* 7 */
};
/* 3.3.10.7 */
- static const char *characteristics2[]={
+ static const char *characteristics2[] = {
"PME signal is supported", /* 0 */
"Hot-plug devices are supported",
"SMBus signal is supported" /* 2 */
};
- if(code1&(1<<0))
+ if (code1 & (1 << 0))
printf(" Unknown\n");
- else if((code1&0xFE)==0 && (code2&0x07)==0)
+ else if ((code1 & 0xFE) == 0 && (code2 & 0x07) == 0)
printf(" None\n");
else
{
int i;
printf("\n");
- for(i=1; i<=7; i++)
- if(code1&(1<<i))
- printf("%s%s\n", prefix, characteristics1[i-1]);
- for(i=0; i<=2; i++)
- if(code2&(1<<i))
+ for (i = 1; i <= 7; i++)
+ if (code1 & (1 << i))
+ printf("%s%s\n", prefix, characteristics1[i - 1]);
+ for (i = 0; i <= 2; i++)
+ if (code2 & (1 << i))
printf("%s%s\n", prefix, characteristics2[i]);
}
}
@@ -1671,7 +1676,7 @@ static void dmi_slot_characteristics(u8 code1, u8 code2, const char *prefix)
static const char *dmi_on_board_devices_type(u8 code)
{
/* 3.3.11.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Video",
@@ -1684,31 +1689,31 @@ static const char *dmi_on_board_devices_type(u8 code)
"SAS Controller" /* 0x0A */
};
- if(code>=0x01 && code<=0x0A)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x0A)
+ return type[code - 0x01];
return out_of_spec;
}
static void dmi_on_board_devices(struct dmi_header *h, const char *prefix)
{
- u8 *p=h->data+4;
- u8 count=(h->length-0x04)/2;
+ u8 *p = h->data + 4;
+ u8 count = (h->length - 0x04) / 2;
int i;
- for(i=0; i<count; i++)
+ for (i = 0; i < count; i++)
{
- if(count==1)
+ if (count == 1)
printf("%sOn Board Device Information\n",
prefix);
else
printf("%sOn Board Device %d Information\n",
- prefix, i+1);
+ prefix, i + 1);
printf("%s\tType: %s\n",
- prefix, dmi_on_board_devices_type(p[2*i]&0x7F));
+ prefix, dmi_on_board_devices_type(p[2 * i] & 0x7F));
printf("%s\tStatus: %s\n",
- prefix, p[2*i]&0x80?"Enabled":"Disabled");
+ prefix, p[2 * i] & 0x80 ? "Enabled" : "Disabled");
printf("%s\tDescription: %s\n",
- prefix, dmi_string(h, p[2*i+1]));
+ prefix, dmi_string(h, p[2 * i + 1]));
}
}
@@ -1718,11 +1723,11 @@ static void dmi_on_board_devices(struct dmi_header *h, const char *prefix)
static void dmi_oem_strings(struct dmi_header *h, const char *prefix)
{
- u8 *p=h->data+4;
- u8 count=p[0x00];
+ u8 *p = h->data + 4;
+ u8 count = p[0x00];
int i;
- for(i=1; i<=count; i++)
+ for (i = 1; i <= count; i++)
printf("%sString %d: %s\n",
prefix, i, dmi_string(h, i));
}
@@ -1733,11 +1738,11 @@ static void dmi_oem_strings(struct dmi_header *h, const char *prefix)
static void dmi_system_configuration_options(struct dmi_header *h, const char *prefix)
{
- u8 *p=h->data+4;
- u8 count=p[0x00];
+ u8 *p = h->data + 4;
+ u8 count = p[0x00];
int i;
- for(i=1; i<=count; i++)
+ for (i = 1; i <= count; i++)
printf("%sOption %d: %s\n",
prefix, i, dmi_string(h, i));
}
@@ -1748,11 +1753,11 @@ static void dmi_system_configuration_options(struct dmi_header *h, const char *p
static void dmi_bios_languages(struct dmi_header *h, const char *prefix)
{
- u8 *p=h->data+4;
+ u8 *p = h->data + 4;
u8 count=p[0x00];
int i;
- for(i=1; i<=count; i++)
+ for (i = 1; i <= count; i++)
printf("%s%s\n",
prefix, dmi_string(h, i));
}
@@ -1765,11 +1770,11 @@ static void dmi_group_associations_items(u8 count, u8 *p, const char *prefix)
{
int i;
- for(i=0; i<count; i++)
+ for (i = 0; i < count; i++)
{
printf("%s0x%04X (%s)\n",
- prefix, WORD(p+3*i+1),
- dmi_smbios_structure_type(p[3*i]));
+ prefix, WORD(p + 3 * i + 1),
+ dmi_smbios_structure_type(p[3 * i]));
}
}
@@ -1779,7 +1784,7 @@ static void dmi_group_associations_items(u8 count, u8 *p, const char *prefix)
static const char *dmi_event_log_method(u8 code)
{
- static const char *method[]={
+ static const char *method[] = {
"Indexed I/O, one 8-bit index port, one 8-bit data port", /* 0x00 */
"Indexed I/O, two 8-bit index ports, one 8-bit data port",
"Indexed I/O, one 16-bit index port, one 8-bit data port",
@@ -1787,37 +1792,37 @@ static const char *dmi_event_log_method(u8 code)
"General-purpose non-volatile data functions" /* 0x04 */
};
- if(code<=0x04)
+ if (code <= 0x04)
return method[code];
- if(code>=0x80)
+ if (code >= 0x80)
return "OEM-specific";
return out_of_spec;
}
static void dmi_event_log_status(u8 code)
{
- static const char *valid[]={
+ static const char *valid[] = {
"Invalid", /* 0 */
"Valid" /* 1 */
};
- static const char *full[]={
+ static const char *full[] = {
"Not Full", /* 0 */
"Full" /* 1 */
};
printf(" %s, %s",
- valid[(code>>0)&1], full[(code>>1)&1]);
+ valid[(code >> 0) & 1], full[(code >> 1) & 1]);
}
static void dmi_event_log_address(u8 method, u8 *p)
{
/* 3.3.16.3 */
- switch(method)
+ switch (method)
{
case 0x00:
case 0x01:
case 0x02:
- printf(" Index 0x%04X, Data 0x%04X", WORD(p), WORD(p+2));
+ printf(" Index 0x%04X, Data 0x%04X", WORD(p), WORD(p + 2));
break;
case 0x03:
printf(" 0x%08X", DWORD(p));
@@ -1832,14 +1837,14 @@ static void dmi_event_log_address(u8 method, u8 *p)
static const char *dmi_event_log_header_type(u8 code)
{
- static const char *type[]={
+ static const char *type[] = {
"No Header", /* 0x00 */
"Type 1" /* 0x01 */
};
- if(code<=0x01)
+ if (code <= 0x01)
return type[code];
- if(code>=0x80)
+ if (code >= 0x80)
return "OEM-specific";
return out_of_spec;
}
@@ -1847,7 +1852,7 @@ static const char *dmi_event_log_header_type(u8 code)
static const char *dmi_event_log_descriptor_type(u8 code)
{
/* 3.3.16.6.1 */
- static const char *type[]={
+ static const char *type[] = {
NULL, /* 0x00 */
"Single-bit ECC memory error",
"Multi-bit ECC memory error",
@@ -1874,11 +1879,11 @@ static const char *dmi_event_log_descriptor_type(u8 code)
"System boot" /* 0x17 */
};
- if(code<=0x17 && type[code]!=NULL)
+ if (code <= 0x17 && type[code] != NULL)
return type[code];
- if(code>=0x80 && code<=0xFE)
+ if (code >= 0x80 && code <= 0xFE)
return "OEM-specific";
- if(code==0xFF)
+ if (code == 0xFF)
return "End of log";
return out_of_spec;
}
@@ -1886,7 +1891,7 @@ static const char *dmi_event_log_descriptor_type(u8 code)
static const char *dmi_event_log_descriptor_format(u8 code)
{
/* 3.3.16.6.2 */
- static const char *format[]={
+ static const char *format[] = {
"None", /* 0x00 */
"Handle",
"Multiple-event",
@@ -1896,9 +1901,9 @@ static const char *dmi_event_log_descriptor_format(u8 code)
"Multiple-event system management" /* 0x06 */
};
- if(code<=0x06)
+ if (code <= 0x06)
return format[code];
- if(code>=0x80)
+ if (code >= 0x80)
return "OEM-specific";
return out_of_spec;
}
@@ -1908,14 +1913,14 @@ static void dmi_event_log_descriptors(u8 count, u8 len, u8 *p, const char *prefi
/* 3.3.16.1 */
int i;
- for(i=0; i<count; i++)
+ for (i = 0; i < count; i++)
{
- if(len>=0x02)
+ if (len >= 0x02)
{
printf("%sDescriptor %u: %s\n",
- prefix, i+1, dmi_event_log_descriptor_type(p[i*len]));
+ prefix, i + 1, dmi_event_log_descriptor_type(p[i * len]));
printf("%sData Format %u: %s\n",
- prefix, i+1, dmi_event_log_descriptor_format(p[i*len+1]));
+ prefix, i + 1, dmi_event_log_descriptor_format(p[i * len + 1]));
}
}
}
@@ -1927,7 +1932,7 @@ static void dmi_event_log_descriptors(u8 count, u8 len, u8 *p, const char *prefi
static const char *dmi_memory_array_location(u8 code)
{
/* 3.3.17.1 */
- static const char *location[]={
+ static const char *location[] = {
"Other", /* 0x01 */
"Unknown",
"System Board Or Motherboard",
@@ -1939,7 +1944,7 @@ static const char *dmi_memory_array_location(u8 code)
"Proprietary Add-on Card",
"NuBus" /* 0x0A, master.mif says 16 */
};
- static const char *location_0xA0[]={
+ static const char *location_0xA0[] = {
"PC-98/C20 Add-on Card", /* 0xA0 */
"PC-98/C24 Add-on Card",
"PC-98/E Add-on Card",
@@ -1947,17 +1952,17 @@ static const char *dmi_memory_array_location(u8 code)
"PC-98/Card Slot Add-on Card" /* 0xA4, from master.mif */
};
- if(code>=0x01 && code<=0x0A)
- return location[code-0x01];
- if(code>=0xA0 && code<=0xA4)
- return location_0xA0[code-0xA0];
+ if (code >= 0x01 && code <= 0x0A)
+ return location[code - 0x01];
+ if (code >= 0xA0 && code <= 0xA4)
+ return location_0xA0[code - 0xA0];
return out_of_spec;
}
static const char *dmi_memory_array_use(u8 code)
{
/* 3.3.17.2 */
- static const char *use[]={
+ static const char *use[] = {
"Other", /* 0x01 */
"Unknown",
"System Memory",
@@ -1967,15 +1972,15 @@ static const char *dmi_memory_array_use(u8 code)
"Cache Memory" /* 0x07 */
};
- if(code>=0x01 && code<=0x07)
- return use[code-0x01];
+ if (code >= 0x01 && code <= 0x07)
+ return use[code - 0x01];
return out_of_spec;
}
static const char *dmi_memory_array_ec_type(u8 code)
{
/* 3.3.17.3 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"None",
@@ -1985,21 +1990,21 @@ static const char *dmi_memory_array_ec_type(u8 code)
"CRC" /* 0x07 */
};
- if(code>=0x01 && code<=0x07)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x07)
+ return type[code - 0x01];
return out_of_spec;
}
static void dmi_memory_array_capacity(u32 code)
{
- if(code==0x8000000)
+ if (code == 0x8000000)
printf(" Unknown");
else
{
- if((code&0x000FFFFF)==0)
- printf(" %u GB", code>>20);
- else if((code&0x000003FF)==0)
- printf(" %u MB", code>>10);
+ if ((code & 0x000FFFFF) == 0)
+ printf(" %u GB", code >> 20);
+ else if ((code & 0x000003FF)==0)
+ printf(" %u MB", code >> 10);
else
printf(" %u kB", code);
}
@@ -2007,9 +2012,9 @@ static void dmi_memory_array_capacity(u32 code)
static void dmi_memory_array_error_handle(u16 code)
{
- if(code==0xFFFE)
+ if (code == 0xFFFE)
printf(" Not Provided");
- else if(code==0xFFFF)
+ else if (code == 0xFFFF)
printf(" No Error");
else
printf(" 0x%04X", code);
@@ -2024,7 +2029,7 @@ static void dmi_memory_device_width(u16 code)
/*
* If no memory module is present, width may be 0
*/
- if(code==0xFFFF || code==0)
+ if (code == 0xFFFF || code == 0)
printf(" Unknown");
else
printf(" %u bits", code);
@@ -2032,14 +2037,14 @@ static void dmi_memory_device_width(u16 code)
static void dmi_memory_device_size(u16 code)
{
- if(code==0)
+ if (code == 0)
printf(" No Module Installed");
- else if(code==0xFFFF)
+ else if (code == 0xFFFF)
printf(" Unknown");
else
{
- if(code&0x8000)
- printf(" %u kB", code&0x7FFF);
+ if (code & 0x8000)
+ printf(" %u kB", code & 0x7FFF);
else
printf(" %u MB", code);
}
@@ -2048,7 +2053,7 @@ static void dmi_memory_device_size(u16 code)
static const char *dmi_memory_device_form_factor(u8 code)
{
/* 3.3.18.1 */
- static const char *form_factor[]={
+ static const char *form_factor[] = {
"Other", /* 0x01 */
"Unknown",
"SIMM",
@@ -2066,16 +2071,16 @@ static const char *dmi_memory_device_form_factor(u8 code)
"FB-DIMM" /* 0x0F */
};
- if(code>=0x01 && code<=0x0F)
- return form_factor[code-0x01];
+ if (code >= 0x01 && code <= 0x0F)
+ return form_factor[code - 0x01];
return out_of_spec;
}
static void dmi_memory_device_set(u8 code)
{
- if(code==0)
+ if (code == 0)
printf(" None");
- else if(code==0xFF)
+ else if (code == 0xFF)
printf(" Unknown");
else
printf(" %u", code);
@@ -2084,7 +2089,7 @@ static void dmi_memory_device_set(u8 code)
static const char *dmi_memory_device_type(u8 code)
{
/* 3.3.18.2 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"DRAM",
@@ -2107,15 +2112,15 @@ static const char *dmi_memory_device_type(u8 code)
"DDR2 FB-DIMM" /* 0x14 */
};
- if(code>=0x01 && code<=0x14)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x14)
+ return type[code - 0x01];
return out_of_spec;
}
static void dmi_memory_device_type_detail(u16 code)
{
/* 3.3.18.3 */
- static const char *detail[]={
+ static const char *detail[] = {
"Other", /* 1 */
"Unknown",
"Fast-paged",
@@ -2130,24 +2135,24 @@ static void dmi_memory_device_type_detail(u16 code)
"Non-Volatile" /* 12 */
};
- if((code&0x1FFE)==0)
+ if ((code & 0x1FFE) == 0)
printf(" None");
else
{
int i;
- for(i=1; i<=12; i++)
- if(code&(1<<i))
- printf(" %s", detail[i-1]);
+ for (i = 1; i <= 12; i++)
+ if (code & (1 << i))
+ printf(" %s", detail[i - 1]);
}
}
static void dmi_memory_device_speed(u16 code)
{
- if(code==0)
+ if (code == 0)
printf(" Unknown");
else
- printf(" %u MHz (%.1f ns)", code, (float)1000/code);
+ printf(" %u MHz (%.1f ns)", code, (float)1000 / code);
}
/*
@@ -2157,7 +2162,7 @@ static void dmi_memory_device_speed(u16 code)
static const char *dmi_memory_error_type(u8 code)
{
/* 3.3.19.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"OK",
@@ -2174,30 +2179,30 @@ static const char *dmi_memory_error_type(u8 code)
"Uncorrectable Error" /* 0x0E */
};
- if(code>=0x01 && code<=0x0E)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x0E)
+ return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_memory_error_granularity(u8 code)
{
/* 3.3.19.2 */
- static const char *granularity[]={
+ static const char *granularity[] = {
"Other", /* 0x01 */
"Unknown",
"Device Level",
"Memory Partition Level" /* 0x04 */
};
- if(code>=0x01 && code<=0x04)
- return granularity[code-0x01];
+ if (code >= 0x01 && code <= 0x04)
+ return granularity[code - 0x01];
return out_of_spec;
}
static const char *dmi_memory_error_operation(u8 code)
{
/* 3.3.19.3 */
- static const char *operation[]={
+ static const char *operation[] = {
"Other", /* 0x01 */
"Unknown",
"Read",
@@ -2205,14 +2210,14 @@ static const char *dmi_memory_error_operation(u8 code)
"Partial Write" /* 0x05 */
};
- if(code>=0x01 && code<=0x05)
- return operation[code-0x01];
+ if (code >= 0x01 && code <= 0x05)
+ return operation[code - 0x01];
return out_of_spec;
}
static void dmi_memory_error_syndrome(u32 code)
{
- if(code==0x00000000)
+ if (code == 0x00000000)
printf(" Unknown");
else
printf(" 0x%08X", code);
@@ -2220,7 +2225,7 @@ static void dmi_memory_error_syndrome(u32 code)
static void dmi_32bit_memory_error_address(u32 code)
{
- if(code==0x80000000)
+ if (code == 0x80000000)
printf(" Unknown");
else
printf(" 0x%08X", code);
@@ -2232,12 +2237,12 @@ static void dmi_32bit_memory_error_address(u32 code)
static void dmi_mapped_address_size(u32 code)
{
- if(code==0)
+ if (code == 0)
printf(" Invalid");
- else if((code&0x000FFFFF)==0)
- printf(" %u GB", code>>20);
- else if((code&0x000003FF)==0)
- printf(" %u MB", code>>10);
+ else if ((code & 0x000FFFFF) == 0)
+ printf(" %u GB", code >> 20);
+ else if ((code & 0x000003FF) == 0)
+ printf(" %u MB", code >> 10);
else
printf(" %u kB", code);
}
@@ -2248,9 +2253,9 @@ static void dmi_mapped_address_size(u32 code)
static void dmi_mapped_address_row_position(u8 code)
{
- if(code==0)
+ if (code == 0)
printf(" %s", out_of_spec);
- else if(code==0xFF)
+ else if (code == 0xFF)
printf(" Unknown");
else
printf(" %u", code);
@@ -2258,10 +2263,10 @@ static void dmi_mapped_address_row_position(u8 code)
static void dmi_mapped_address_interleave_position(u8 code, const char *prefix)
{
- if(code!=0)
+ if (code != 0)
{
printf("%sInterleave Position:", prefix);
- if(code==0xFF)
+ if (code == 0xFF)
printf(" Unknown");
else
printf(" %u", code);
@@ -2271,10 +2276,10 @@ static void dmi_mapped_address_interleave_position(u8 code, const char *prefix)
static void dmi_mapped_address_interleaved_data_depth(u8 code, const char *prefix)
{
- if(code!=0)
+ if (code != 0)
{
printf("%sInterleaved Data Depth:", prefix);
- if(code==0xFF)
+ if (code == 0xFF)
printf(" Unknown");
else
printf(" %u", code);
@@ -2289,7 +2294,7 @@ static void dmi_mapped_address_interleaved_data_depth(u8 code, const char *prefi
static const char *dmi_pointing_device_type(u8 code)
{
/* 3.3.22.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Mouse",
@@ -2301,15 +2306,15 @@ static const char *dmi_pointing_device_type(u8 code)
"Optical Sensor" /* 0x09 */
};
- if(code>=0x01 && code<=0x09)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x09)
+ return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_pointing_device_interface(u8 code)
{
/* 3.3.22.2 */
- static const char *interface[]={
+ static const char *interface[] = {
"Other", /* 0x01 */
"Unknown",
"Serial",
@@ -2319,16 +2324,16 @@ static const char *dmi_pointing_device_interface(u8 code)
"Bus Mouse",
"ADB (Apple Desktop Bus)" /* 0x08 */
};
- static const char *interface_0xA0[]={
+ static const char *interface_0xA0[] = {
"Bus Mouse DB-9", /* 0xA0 */
"Bus Mouse Micro DIN",
"USB" /* 0xA2 */
};
- if(code>=0x01 && code<=0x08)
- return interface[code-0x01];
- if(code>=0xA0 && code<=0xA2)
- return interface_0xA0[code-0xA0];
+ if (code >= 0x01 && code <= 0x08)
+ return interface[code - 0x01];
+ if (code >= 0xA0 && code <= 0xA2)
+ return interface_0xA0[code - 0xA0];
return out_of_spec;
}
@@ -2339,7 +2344,7 @@ static const char *dmi_pointing_device_interface(u8 code)
static const char *dmi_battery_chemistry(u8 code)
{
/* 3.3.23.1 */
- static const char *chemistry[]={
+ static const char *chemistry[] = {
"Other", /* 0x01 */
"Unknown",
"Lead Acid",
@@ -2350,22 +2355,22 @@ static const char *dmi_battery_chemistry(u8 code)
"Lithium Polymer" /* 0x08 */
};
- if(code>=0x01 && code<=0x08)
- return chemistry[code-0x01];
+ if (code >= 0x01 && code <= 0x08)
+ return chemistry[code - 0x01];
return out_of_spec;
}
static void dmi_battery_capacity(u16 code, u8 multiplier)
{
- if(code==0)
+ if (code == 0)
printf(" Unknown");
else
- printf(" %u mWh", code*multiplier);
+ printf(" %u mWh", code * multiplier);
}
static void dmi_battery_voltage(u16 code)
{
- if(code==0)
+ if (code == 0)
printf(" Unknown");
else
printf(" %u mV", code);
@@ -2373,7 +2378,7 @@ static void dmi_battery_voltage(u16 code)
static void dmi_battery_maximum_error(u8 code)
{
- if(code==0xFF)
+ if (code == 0xFF)
printf(" Unknown");
else
printf(" %u%%", code);
@@ -2385,20 +2390,20 @@ static void dmi_battery_maximum_error(u8 code)
static const char *dmi_system_reset_boot_option(u8 code)
{
- static const char *option[]={
+ static const char *option[] = {
"Operating System", /* 0x1 */
"System Utilities",
"Do Not Reboot" /* 0x3 */
};
- if(code>=0x1)
- return option[code-0x1];
+ if (code >= 0x1)
+ return option[code - 0x1];
return out_of_spec;
}
static void dmi_system_reset_count(u16 code)
{
- if(code==0xFFFF)
+ if (code == 0xFFFF)
printf(" Unknown");
else
printf(" %u", code);
@@ -2406,7 +2411,7 @@ static void dmi_system_reset_count(u16 code)
static void dmi_system_reset_timer(u16 code)
{
- if(code==0xFFFF)
+ if (code == 0xFFFF)
printf(" Unknown");
else
printf(" %u min", code);
@@ -2418,7 +2423,7 @@ static void dmi_system_reset_timer(u16 code)
static const char *dmi_hardware_security_status(u8 code)
{
- static const char *status[]={
+ static const char *status[] = {
"Disabled", /* 0x00 */
"Enabled",
"Not Implemented",
@@ -2435,23 +2440,23 @@ static const char *dmi_hardware_security_status(u8 code)
static void dmi_power_controls_power_on(u8 *p)
{
/* 3.3.26.1 */
- if(dmi_bcd_range(p[0], 0x01, 0x12))
+ if (dmi_bcd_range(p[0], 0x01, 0x12))
printf(" %02X", p[0]);
else
printf(" *");
- if(dmi_bcd_range(p[1], 0x01, 0x31))
+ if (dmi_bcd_range(p[1], 0x01, 0x31))
printf("-%02X", p[1]);
else
printf("-*");
- if(dmi_bcd_range(p[2], 0x00, 0x23))
+ if (dmi_bcd_range(p[2], 0x00, 0x23))
printf(" %02X", p[2]);
else
printf(" *");
- if(dmi_bcd_range(p[3], 0x00, 0x59))
+ if (dmi_bcd_range(p[3], 0x00, 0x59))
printf(":%02X", p[3]);
else
printf(":*");
- if(dmi_bcd_range(p[4], 0x00, 0x59))
+ if (dmi_bcd_range(p[4], 0x00, 0x59))
printf(":%02X", p[4]);
else
printf(":*");
@@ -2464,7 +2469,7 @@ static void dmi_power_controls_power_on(u8 *p)
static const char *dmi_voltage_probe_location(u8 code)
{
/* 3.3.27.1 */
- static const char *location[]={
+ static const char *location[] = {
"Other", /* 0x01 */
"Unknown",
"Processor",
@@ -2478,15 +2483,15 @@ static const char *dmi_voltage_probe_location(u8 code)
"Add-in Card" /* 0x0B */
};
- if(code>=0x01 && code<=0x0B)
- return location[code-0x01];
+ if (code >= 0x01 && code <= 0x0B)
+ return location[code - 0x01];
return out_of_spec;
}
static const char *dmi_probe_status(u8 code)
{
/* 3.3.27.1 */
- static const char *status[]={
+ static const char *status[] = {
"Other", /* 0x01 */
"Unknown",
"OK",
@@ -2495,33 +2500,33 @@ static const char *dmi_probe_status(u8 code)
"Non-recoverable" /* 0x06 */
};
- if(code>=0x01 && code<=0x06)
- return status[code-0x01];
+ if (code >= 0x01 && code <= 0x06)
+ return status[code - 0x01];
return out_of_spec;
}
static void dmi_voltage_probe_value(u16 code)
{
- if(code==0x8000)
+ if (code == 0x8000)
printf(" Unknown");
else
- printf(" %.3f V", (float)(i16)code/1000);
+ printf(" %.3f V", (float)(i16)code / 1000);
}
static void dmi_voltage_probe_resolution(u16 code)
{
- if(code==0x8000)
+ if (code == 0x8000)
printf(" Unknown");
else
- printf(" %.1f mV", (float)code/10);
+ printf(" %.1f mV", (float)code / 10);
}
static void dmi_probe_accuracy(u16 code)
{
- if(code==0x8000)
+ if (code == 0x8000)
printf(" Unknown");
else
- printf(" %.2f%%", (float)code/100);
+ printf(" %.2f%%", (float)code / 100);
}
/*
@@ -2531,7 +2536,7 @@ static void dmi_probe_accuracy(u16 code)
static const char *dmi_cooling_device_type(u8 code)
{
/* 3.3.28.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Fan",
@@ -2542,21 +2547,21 @@ static const char *dmi_cooling_device_type(u8 code)
"Heat Pipe",
"Integrated Refrigeration" /* 0x09 */
};
- static const char *type_0x10[]={
+ static const char *type_0x10[] = {
"Active Cooling", /* 0x10, master.mif says 32 */
"Passive Cooling" /* 0x11, master.mif says 33 */
};
- if(code>=0x01 && code<=0x09)
- return type[code-0x01];
- if(code>=0x10 && code<=0x11)
- return type_0x10[code-0x10];
+ if (code >= 0x01 && code <= 0x09)
+ return type[code - 0x01];
+ if (code >= 0x10 && code <= 0x11)
+ return type_0x10[code - 0x10];
return out_of_spec;
}
static void dmi_cooling_device_speed(u16 code)
{
- if(code==0x8000)
+ if (code == 0x8000)
printf(" Unknown Or Non-rotating");
else
printf(" %u rpm", code);
@@ -2569,7 +2574,7 @@ static void dmi_cooling_device_speed(u16 code)
static const char *dmi_temperature_probe_location(u8 code)
{
/* 3.3.29.1 */
- static const char *location[]={
+ static const char *location[] = {
"Other", /* 0x01 */
"Unknown",
"Processor",
@@ -2587,25 +2592,25 @@ static const char *dmi_temperature_probe_location(u8 code)
"Drive Back Plane" /* 0x0F */
};
- if(code>=0x01 && code<=0x0F)
- return location[code-0x01];
+ if (code >= 0x01 && code <= 0x0F)
+ return location[code - 0x01];
return out_of_spec;
}
static void dmi_temperature_probe_value(u16 code)
{
- if(code==0x8000)
+ if (code == 0x8000)
printf(" Unknown");
else
- printf(" %.1f deg C", (float)(i16)code/10);
+ printf(" %.1f deg C", (float)(i16)code / 10);
}
static void dmi_temperature_probe_resolution(u16 code)
{
- if(code==0x8000)
+ if (code == 0x8000)
printf(" Unknown");
else
- printf(" %.3f deg C", (float)code/1000);
+ printf(" %.3f deg C", (float)code / 1000);
}
/*
@@ -2614,18 +2619,18 @@ static void dmi_temperature_probe_resolution(u16 code)
static void dmi_current_probe_value(u16 code)
{
- if(code==0x8000)
+ if (code == 0x8000)
printf(" Unknown");
else
- printf(" %.3f A", (float)(i16)code/1000);
+ printf(" %.3f A", (float)(i16)code / 1000);
}
static void dmi_current_probe_resolution(u16 code)
{
- if(code==0x8000)
+ if (code == 0x8000)
printf(" Unknown");
else
- printf(" %.1f mA", (float)code/10);
+ printf(" %.1f mA", (float)code / 10);
}
/*
@@ -2634,7 +2639,7 @@ static void dmi_current_probe_resolution(u16 code)
static const char *dmi_system_boot_status(u8 code)
{
- static const char *status[]={
+ static const char *status[] = {
"No errors detected", /* 0 */
"No bootable media",
"Operating system failed to load",
@@ -2646,11 +2651,11 @@ static const char *dmi_system_boot_status(u8 code)
"System watchdog timer expired" /* 8 */
};
- if(code<=8)
+ if (code <= 8)
return status[code];
- if(code>=128 && code<=191)
+ if (code >= 128 && code <= 191)
return "OEM-specific";
- if(code>=192)
+ if (code >= 192)
return "Product-specific";
return out_of_spec;
}
@@ -2661,7 +2666,7 @@ static const char *dmi_system_boot_status(u8 code)
static void dmi_64bit_memory_error_address(u64 code)
{
- if(code.h==0x80000000 && code.l==0x00000000)
+ if (code.h == 0x80000000 && code.l == 0x00000000)
printf(" Unknown");
else
printf(" 0x%08X%08X", code.h, code.l);
@@ -2674,7 +2679,7 @@ static void dmi_64bit_memory_error_address(u64 code)
static const char *dmi_management_device_type(u8 code)
{
/* 3.3.35.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"LM75",
@@ -2690,15 +2695,15 @@ static const char *dmi_management_device_type(u8 code)
"HT82H791" /* 0x0D */
};
- if(code>=0x01 && code<=0x0D)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x0D)
+ return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_management_device_address_type(u8 code)
{
/* 3.3.35.2 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"I/O Port",
@@ -2706,8 +2711,8 @@ static const char *dmi_management_device_address_type(u8 code)
"SMBus" /* 0x05 */
};
- if(code>=0x01 && code<=0x05)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x05)
+ return type[code - 0x01];
return out_of_spec;
}
@@ -2718,15 +2723,15 @@ static const char *dmi_management_device_address_type(u8 code)
static const char *dmi_memory_channel_type(u8 code)
{
/* 3.3.38.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"RamBus",
"SyncLink" /* 0x04 */
};
- if(code>=0x01 && code<=0x04)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x04)
+ return type[code - 0x01];
return out_of_spec;
}
@@ -2734,13 +2739,13 @@ static void dmi_memory_channel_devices(u8 count, u8 *p, const char *prefix)
{
int i;
- for(i=1; i<=count; i++)
+ for (i = 1; i <= count; i++)
{
printf("%sDevice %u Load: %u\n",
- prefix, i, p[3*i]);
- if(!(opt.flags & FLAG_QUIET))
+ prefix, i, p[3 * i]);
+ if (!(opt.flags & FLAG_QUIET))
printf("%sDevice %u Handle: 0x%04X\n",
- prefix, i, WORD(p+3*i+1));
+ prefix, i, WORD(p + 3 * i + 1));
}
}
@@ -2751,7 +2756,7 @@ static void dmi_memory_channel_devices(u8 count, u8 *p, const char *prefix)
static const char *dmi_ipmi_interface_type(u8 code)
{
/* 3.3.39.1 and IPMI 2.0, appendix C1, table C1-2 */
- static const char *type[]={
+ static const char *type[] = {
"Unknown", /* 0x00 */
"KCS (Keyboard Control Style)",
"SMIC (Server Management Interface Chip)",
@@ -2759,35 +2764,35 @@ static const char *dmi_ipmi_interface_type(u8 code)
"SSIF (SMBus System Interface)" /* 0x04 */
};
- if(code<=0x04)
+ if (code <= 0x04)
return type[code];
return out_of_spec;
}
static void dmi_ipmi_base_address(u8 type, u8 *p, u8 lsb)
{
- if(type==0x04) /* SSIF */
+ if (type == 0x04) /* SSIF */
{
- printf("0x%02X (SMBus)", (*p)>>1);
+ printf("0x%02X (SMBus)", (*p) >> 1);
}
else
{
- u64 address=QWORD(p);
- printf("0x%08X%08X (%s)", address.h, (address.l&~1)|lsb,
- address.l&1?"I/O":"Memory-mapped");
+ u64 address = QWORD(p);
+ printf("0x%08X%08X (%s)", address.h, (address.l & ~1) | lsb,
+ address.l & 1 ? "I/O" : "Memory-mapped");
}
}
static const char *dmi_ipmi_register_spacing(u8 code)
{
/* IPMI 2.0, appendix C1, table C1-1 */
- static const char *spacing[]={
+ static const char *spacing[] = {
"Successive Byte Boundaries", /* 0x00 */
"32-bit Boundaries",
"16-byte Boundaries" /* 0x02 */
};
- if(code<=0x02)
+ if (code <= 0x02)
return spacing[code];
return out_of_spec;
}
@@ -2798,16 +2803,16 @@ static const char *dmi_ipmi_register_spacing(u8 code)
static void dmi_power_supply_power(u16 code)
{
- if(code==0x8000)
+ if (code == 0x8000)
printf(" Unknown");
else
- printf(" %.3f W", (float)code/1000);
+ printf(" %.3f W", (float)code / 1000);
}
static const char *dmi_power_supply_type(u8 code)
{
/* 3.3.40.1 */
- static const char *type[]={
+ static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Linear",
@@ -2818,15 +2823,15 @@ static const char *dmi_power_supply_type(u8 code)
"Regulator" /* 0x08 */
};
- if(code>=0x01 && code<=0x08)
- return type[code-0x01];
+ if (code >= 0x01 && code <= 0x08)
+ return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_power_supply_status(u8 code)
{
/* 3.3.40.1 */
- static const char *status[]={
+ static const char *status[] = {
"Other", /* 0x01 */
"Unknown",
"OK",
@@ -2834,15 +2839,15 @@ static const char *dmi_power_supply_status(u8 code)
"Critical" /* 0x05 */
};
- if(code>=0x01 && code<=0x05)
- return status[code-0x01];
+ if (code >= 0x01 && code <= 0x05)
+ return status[code - 0x01];
return out_of_spec;
}
static const char *dmi_power_supply_range_switching(u8 code)
{
/* 3.3.40.1 */
- static const char *switching[]={
+ static const char *switching[] = {
"Other", /* 0x01 */
"Unknown",
"Manual",
@@ -2851,8 +2856,8 @@ static const char *dmi_power_supply_range_switching(u8 code)
"N/A" /* 0x06 */
};
- if(code>=0x01 && code<=0x06)
- return switching[code-0x01];
+ if (code >= 0x01 && code <= 0x06)
+ return switching[code - 0x01];
return out_of_spec;
}
@@ -2867,11 +2872,11 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
/*
* Note: DMI types 37 and 39 are untested
*/
- switch(h->type)
+ switch (h->type)
{
case 0: /* 3.3.1 BIOS Information */
printf("BIOS Information\n");
- if(h->length<0x12) break;
+ if (h->length < 0x12) break;
printf("\tVendor: %s\n",
dmi_string(h, data[0x04]));
printf("\tVersion: %s\n",
@@ -2883,34 +2888,34 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
* there is no BIOS. Skip the base address and the
* runtime size in this case.
*/
- if(WORD(data+0x06)!=0)
+ if (WORD(data + 0x06) != 0)
{
printf("\tAddress: 0x%04X0\n",
- WORD(data+0x06));
+ WORD(data + 0x06));
printf("\tRuntime Size:");
- dmi_bios_runtime_size((0x10000-WORD(data+0x06))<<4);
+ dmi_bios_runtime_size((0x10000 - WORD(data + 0x06)) << 4);
printf("\n");
}
printf("\tROM Size: %u kB\n",
- (data[0x09]+1)<<6);
+ (data[0x09] + 1) << 6);
printf("\tCharacteristics:\n");
- dmi_bios_characteristics(QWORD(data+0x0A), "\t\t");
- if(h->length<0x13) break;
+ dmi_bios_characteristics(QWORD(data + 0x0A), "\t\t");
+ if (h->length < 0x13) break;
dmi_bios_characteristics_x1(data[0x12], "\t\t");
- if(h->length<0x14) break;
+ if (h->length < 0x14) break;
dmi_bios_characteristics_x2(data[0x13], "\t\t");
- if(h->length<0x18) break;
- if(data[0x14]!=0xFF && data[0x15]!=0xFF)
+ if (h->length < 0x18) break;
+ if (data[0x14] != 0xFF && data[0x15] != 0xFF)
printf("\tBIOS Revision: %u.%u\n",
data[0x14], data[0x15]);
- if(data[0x16]!=0xFF && data[0x17]!=0xFF)
+ if (data[0x16] != 0xFF && data[0x17] != 0xFF)
printf("\tFirmware Revision: %u.%u\n",
data[0x16], data[0x17]);
break;
case 1: /* 3.3.2 System Information */
printf("System Information\n");
- if(h->length<0x08) break;
+ if (h->length < 0x08) break;
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x04]));
printf("\tProduct Name: %s\n",
@@ -2919,13 +2924,13 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
dmi_string(h, data[0x06]));
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x07]));
- if(h->length<0x19) break;
+ if (h->length < 0x19) break;
printf("\tUUID: ");
- dmi_system_uuid(data+0x08);
+ dmi_system_uuid(data + 0x08);
printf("\n");
printf("\tWake-up Type: %s\n",
dmi_system_wake_up_type(data[0x18]));
- if(h->length<0x1B) break;
+ if (h->length < 0x1B) break;
printf("\tSKU Number: %s\n",
dmi_string(h, data[0x19]));
printf("\tFamily: %s\n",
@@ -2934,7 +2939,7 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 2: /* 3.3.3 Base Board Information */
printf("Base Board Information\n");
- if(h->length<0x08) break;
+ if (h->length < 0x08) break;
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x04]));
printf("\tProduct Name: %s\n",
@@ -2943,39 +2948,39 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
dmi_string(h, data[0x06]));
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x07]));
- if(h->length<0x0F) break;
+ if (h->length < 0x0F) break;
printf("\tAsset Tag: %s\n",
dmi_string(h, data[0x08]));
printf("\tFeatures:");
dmi_base_board_features(data[0x09], "\t\t");
printf("\tLocation In Chassis: %s\n",
dmi_string(h, data[0x0A]));
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
printf("\tChassis Handle: 0x%04X\n",
- WORD(data+0x0B));
+ WORD(data + 0x0B));
printf("\tType: %s\n",
dmi_base_board_type(data[0x0D]));
- if(h->length<0x0F+data[0x0E]*sizeof(u16)) break;
- if(!(opt.flags & FLAG_QUIET))
- dmi_base_board_handles(data[0x0E], data+0x0F, "\t");
+ if (h->length < 0x0F + data[0x0E] * sizeof(u16)) break;
+ if (!(opt.flags & FLAG_QUIET))
+ dmi_base_board_handles(data[0x0E], data + 0x0F, "\t");
break;
case 3: /* 3.3.4 Chassis Information */
printf("Chassis Information\n");
- if(h->length<0x09) break;
+ if (h->length < 0x09) break;
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x04]));
printf("\tType: %s\n",
- dmi_chassis_type(data[0x05]&0x7F));
+ dmi_chassis_type(data[0x05] & 0x7F));
printf("\tLock: %s\n",
- dmi_chassis_lock(data[0x05]>>7));
+ dmi_chassis_lock(data[0x05] >> 7));
printf("\tVersion: %s\n",
dmi_string(h, data[0x06]));
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x07]));
printf("\tAsset Tag: %s\n",
dmi_string(h, data[0x08]));
- if(h->length<0x0D) break;
+ if (h->length < 0x0D) break;
printf("\tBoot-up State: %s\n",
dmi_chassis_state(data[0x09]));
printf("\tPower Supply State: %s\n",
@@ -2984,23 +2989,23 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
dmi_chassis_state(data[0x0B]));
printf("\tSecurity Status: %s\n",
dmi_chassis_security_status(data[0x0C]));
- if(h->length<0x11) break;
+ if (h->length < 0x11) break;
printf("\tOEM Information: 0x%08X\n",
- DWORD(data+0x0D));
- if(h->length<0x15) break;
+ DWORD(data + 0x0D));
+ if (h->length < 0x15) break;
printf("\tHeight:");
dmi_chassis_height(data[0x11]);
printf("\n");
printf("\tNumber Of Power Cords:");
dmi_chassis_power_cords(data[0x12]);
printf("\n");
- if(h->length<0x15+data[0x13]*data[0x14]) break;
- dmi_chassis_elements(data[0x13], data[0x14], data+0x15, "\t");
+ if (h->length < 0x15 + data[0x13] * data[0x14]) break;
+ dmi_chassis_elements(data[0x13], data[0x14], data + 0x15, "\t");
break;
case 4: /* 3.3.5 Processor Information */
printf("Processor Information\n");
- if(h->length<0x1A) break;
+ if (h->length < 0x1A) break;
printf("\tSocket Designation: %s\n",
dmi_string(h, data[0x04]));
printf("\tType: %s\n",
@@ -3009,62 +3014,62 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
dmi_processor_family(data[0x06]));
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x07]));
- dmi_processor_id(data[0x06], data+8, dmi_string(h, data[0x10]), "\t");
+ dmi_processor_id(data[0x06], data + 8, dmi_string(h, data[0x10]), "\t");
printf("\tVersion: %s\n",
dmi_string(h, data[0x10]));
printf("\tVoltage:");
dmi_processor_voltage(data[0x11]);
printf("\n");
printf("\tExternal Clock: ");
- dmi_processor_frequency(data+0x12);
+ dmi_processor_frequency(data + 0x12);
printf("\n");
printf("\tMax Speed: ");
- dmi_processor_frequency(data+0x14);
+ dmi_processor_frequency(data + 0x14);
printf("\n");
printf("\tCurrent Speed: ");
- dmi_processor_frequency(data+0x16);
+ dmi_processor_frequency(data + 0x16);
printf("\n");
- if(data[0x18]&(1<<6))
+ if (data[0x18]&(1<<6))
printf("\tStatus: Populated, %s\n",
- dmi_processor_status(data[0x18]&0x07));
+ dmi_processor_status(data[0x18] & 0x07));
else
printf("\tStatus: Unpopulated\n");
printf("\tUpgrade: %s\n",
dmi_processor_upgrade(data[0x19]));
- if(h->length<0x20) break;
- if(!(opt.flags & FLAG_QUIET))
+ if (h->length < 0x20) break;
+ if (!(opt.flags & FLAG_QUIET))
{
printf("\tL1 Cache Handle:");
- dmi_processor_cache(WORD(data+0x1A), "L1", ver);
+ dmi_processor_cache(WORD(data + 0x1A), "L1", ver);
printf("\n");
printf("\tL2 Cache Handle:");
- dmi_processor_cache(WORD(data+0x1C), "L2", ver);
+ dmi_processor_cache(WORD(data + 0x1C), "L2", ver);
printf("\n");
printf("\tL3 Cache Handle:");
- dmi_processor_cache(WORD(data+0x1E), "L3", ver);
+ dmi_processor_cache(WORD(data + 0x1E), "L3", ver);
printf("\n");
}
- if(h->length<0x23) break;
+ if (h->length < 0x23) break;
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x20]));
printf("\tAsset Tag: %s\n",
dmi_string(h, data[0x21]));
printf("\tPart Number: %s\n",
dmi_string(h, data[0x22]));
- if(h->length<0x28) break;
- if(data[0x23]!=0)
+ if (h->length < 0x28) break;
+ if (data[0x23] != 0)
printf("\tCore Count: %u\n", data[0x23]);
- if(data[0x24]!=0)
+ if (data[0x24] != 0)
printf("\tCore Enabled: %u\n", data[0x24]);
- if(data[0x25]!=0)
+ if (data[0x25] != 0)
printf("\tThread Count: %u\n", data[0x25]);
printf("\tCharacteristics:");
- dmi_processor_characteristics(WORD(data+0x26), "\t\t");
+ dmi_processor_characteristics(WORD(data + 0x26), "\t\t");
break;
case 5: /* 3.3.6 Memory Controller Information */
printf("Memory Controller Information\n");
- if(h->length<0x0F) break;
+ if (h->length < 0x0F) break;
printf("\tError Detecting Method: %s\n",
dmi_memory_controller_ed_method(data[0x04]));
printf("\tError Correcting Capabilities:");
@@ -3074,27 +3079,27 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
printf("\tCurrent Interleave: %s\n",
dmi_memory_controller_interleave(data[0x07]));
printf("\tMaximum Memory Module Size: %u MB\n",
- 1<<data[0x08]);
+ 1 << data[0x08]);
printf("\tMaximum Total Memory Size: %u MB\n",
- data[0x0E]*(1<<data[0x08]));
+ data[0x0E] * (1 << data[0x08]));
printf("\tSupported Speeds:");
- dmi_memory_controller_speeds(WORD(data+0x09), "\t\t");
+ dmi_memory_controller_speeds(WORD(data + 0x09), "\t\t");
printf("\tSupported Memory Types:");
- dmi_memory_module_types(WORD(data+0x0B), "\n\t\t");
+ dmi_memory_module_types(WORD(data + 0x0B), "\n\t\t");
printf("\n");
printf("\tMemory Module Voltage:");
dmi_processor_voltage(data[0x0D]);
printf("\n");
- if(h->length<0x0F+data[0x0E]*sizeof(u16)) break;
- dmi_memory_controller_slots(data[0x0E], data+0x0F, "\t");
- if(h->length<0x10+data[0x0E]*sizeof(u16)) break;
+ if (h->length < 0x0F + data[0x0E] * sizeof(u16)) break;
+ dmi_memory_controller_slots(data[0x0E], data + 0x0F, "\t");
+ if (h->length < 0x10 + data[0x0E] * sizeof(u16)) break;
printf("\tEnabled Error Correcting Capabilities:");
- dmi_memory_controller_ec_capabilities(data[0x0F+data[0x0E]*sizeof(u16)], "\t\t");
+ dmi_memory_controller_ec_capabilities(data[0x0F + data[0x0E] * sizeof(u16)], "\t\t");
break;
case 6: /* 3.3.7 Memory Module Information */
printf("Memory Module Information\n");
- if(h->length<0x0C) break;
+ if (h->length < 0x0C) break;
printf("\tSocket Designation: %s\n",
dmi_string(h, data[0x04]));
printf("\tBank Connections:");
@@ -3104,7 +3109,7 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
dmi_memory_module_speed(data[0x06]);
printf("\n");
printf("\tType:");
- dmi_memory_module_types(WORD(data+0x07), " ");
+ dmi_memory_module_types(WORD(data + 0x07), " ");
printf("\n");
printf("\tInstalled Size:");
dmi_memory_module_size(data[0x09]);
@@ -3118,30 +3123,30 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 7: /* 3.3.8 Cache Information */
printf("Cache Information\n");
- if(h->length<0x0F) break;
+ if (h->length < 0x0F) break;
printf("\tSocket Designation: %s\n",
dmi_string(h, data[0x04]));
printf("\tConfiguration: %s, %s, Level %u\n",
- WORD(data+0x05)&0x0080?"Enabled":"Disabled",
- WORD(data+0x05)&0x0008?"Socketed":"Not Socketed",
- (WORD(data+0x05)&0x0007)+1);
+ WORD(data + 0x05) & 0x0080 ? "Enabled" : "Disabled",
+ WORD(data + 0x05) & 0x0008 ? "Socketed" : "Not Socketed",
+ (WORD(data + 0x05) & 0x0007) + 1);
printf("\tOperational Mode: %s\n",
- dmi_cache_mode((WORD(data+0x05)>>8)&0x0003));
+ dmi_cache_mode((WORD(data + 0x05) >> 8) & 0x0003));
printf("\tLocation: %s\n",
- dmi_cache_location((WORD(data+0x05)>>5)&0x0003));
+ dmi_cache_location((WORD(data + 0x05) >> 5) & 0x0003));
printf("\tInstalled Size:");
- dmi_cache_size(WORD(data+0x09));
+ dmi_cache_size(WORD(data + 0x09));
printf("\n");
printf("\tMaximum Size:");
- dmi_cache_size(WORD(data+0x07));
+ dmi_cache_size(WORD(data + 0x07));
printf("\n");
printf("\tSupported SRAM Types:");
- dmi_cache_types(WORD(data+0x0B), "\n\t\t");
+ dmi_cache_types(WORD(data + 0x0B), "\n\t\t");
printf("\n");
printf("\tInstalled SRAM Type:");
- dmi_cache_types(WORD(data+0x0D), " ");
+ dmi_cache_types(WORD(data + 0x0D), " ");
printf("\n");
- if(h->length<0x13) break;
+ if (h->length < 0x13) break;
printf("\tSpeed:");
dmi_memory_module_speed(data[0x0F]);
printf("\n");
@@ -3155,22 +3160,22 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 8: /* 3.3.9 Port Connector Information */
printf("Port Connector Information\n");
- if(h->length<0x09) break;
+ if (h->length < 0x09) break;
printf("\tInternal Reference Designator: %s\n",
- dmi_string(h, data[0x04]));
+ dmi_string(h, data[0x04]));
printf("\tInternal Connector Type: %s\n",
- dmi_port_connector_type(data[0x05]));
+ dmi_port_connector_type(data[0x05]));
printf("\tExternal Reference Designator: %s\n",
- dmi_string(h, data[0x06]));
+ dmi_string(h, data[0x06]));
printf("\tExternal Connector Type: %s\n",
- dmi_port_connector_type(data[0x07]));
+ dmi_port_connector_type(data[0x07]));
printf("\tPort Type: %s\n",
- dmi_port_type(data[0x08]));
+ dmi_port_type(data[0x08]));
break;
case 9: /* 3.3.10 System Slots */
printf("System Slot Information\n");
- if(h->length<0x0C) break;
+ if (h->length < 0x0C) break;
printf("\tDesignation: %s\n",
dmi_string(h, data[0x04]));
printf("\tType: %s%s\n",
@@ -3182,7 +3187,7 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
dmi_slot_length(data[0x08]));
dmi_slot_id(data[0x09], data[0x0A], data[0x05], "\t");
printf("\tCharacteristics:");
- if(h->length<0x0D)
+ if (h->length < 0x0D)
dmi_slot_characteristics(data[0x0B], 0x00, "\t\t");
else
dmi_slot_characteristics(data[0x0B], data[0x0C], "\t\t");
@@ -3194,19 +3199,19 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 11: /* 3.3.12 OEM Strings */
printf("OEM Strings\n");
- if(h->length<0x05) break;
+ if (h->length < 0x05) break;
dmi_oem_strings(h, "\t");
break;
case 12: /* 3.3.13 System Configuration Options */
printf("System Configuration Options\n");
- if(h->length<0x05) break;
+ if (h->length < 0x05) break;
dmi_system_configuration_options(h, "\t");
break;
case 13: /* 3.3.14 BIOS Language Information */
printf("BIOS Language Information\n");
- if(h->length<0x16) break;
+ if (h->length < 0x16) break;
printf("\tInstallable Languages: %u\n", data[0x04]);
dmi_bios_languages(h, "\t\t");
printf("\tCurrently Installed Language: %s\n",
@@ -3215,49 +3220,49 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 14: /* 3.3.15 Group Associations */
printf("Group Associations\n");
- if(h->length<0x05) break;
+ if (h->length < 0x05) break;
printf("\tName: %s\n",
dmi_string(h, data[0x04]));
printf("\tItems: %u\n",
- (h->length-0x05)/3);
- dmi_group_associations_items((h->length-0x05)/3, data+0x05, "\t\t");
+ (h->length - 0x05) / 3);
+ dmi_group_associations_items((h->length - 0x05) / 3, data + 0x05, "\t\t");
break;
case 15: /* 3.3.16 System Event Log */
printf("System Event Log\n");
- if(h->length<0x14) break;
+ if (h->length < 0x14) break;
printf("\tArea Length: %u bytes\n",
- WORD(data+0x04));
+ WORD(data + 0x04));
printf("\tHeader Start Offset: 0x%04X\n",
- WORD(data+0x06));
- if(WORD(data+0x08)-WORD(data+0x06))
+ WORD(data + 0x06));
+ if (WORD(data + 0x08) - WORD(data + 0x06))
printf("\tHeader Length: %u byte%s\n",
- WORD(data+0x08)-WORD(data+0x06),
- WORD(data+0x08)-WORD(data+0x06)>1?"s":"");
+ WORD(data + 0x08) - WORD(data + 0x06),
+ WORD(data + 0x08) - WORD(data + 0x06) > 1 ? "s" : "");
printf("\tData Start Offset: 0x%04X\n",
- WORD(data+0x08));
+ WORD(data + 0x08));
printf("\tAccess Method: %s\n",
dmi_event_log_method(data[0x0A]));
printf("\tAccess Address:");
- dmi_event_log_address(data[0x0A], data+0x10);
+ dmi_event_log_address(data[0x0A], data + 0x10);
printf("\n");
printf("\tStatus:");
dmi_event_log_status(data[0x0B]);
printf("\n");
printf("\tChange Token: 0x%08X\n",
- DWORD(data+0x0C));
- if(h->length<0x17) break;
+ DWORD(data + 0x0C));
+ if (h->length < 0x17) break;
printf("\tHeader Format: %s\n",
dmi_event_log_header_type(data[0x14]));
printf("\tSupported Log Type Descriptors: %u\n",
data[0x15]);
- if(h->length<0x17+data[0x15]*data[0x16]) break;
- dmi_event_log_descriptors(data[0x15], data[0x16], data+0x17, "\t");
+ if (h->length < 0x17 + data[0x15] * data[0x16]) break;
+ dmi_event_log_descriptors(data[0x15], data[0x16], data + 0x17, "\t");
break;
case 16: /* 3.3.17 Physical Memory Array */
printf("Physical Memory Array\n");
- if(h->length<0x0F) break;
+ if (h->length < 0x0F) break;
printf("\tLocation: %s\n",
dmi_memory_array_location(data[0x04]));
printf("\tUse: %s\n",
@@ -3265,37 +3270,37 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
printf("\tError Correction Type: %s\n",
dmi_memory_array_ec_type(data[0x06]));
printf("\tMaximum Capacity:");
- dmi_memory_array_capacity(DWORD(data+0x07));
+ dmi_memory_array_capacity(DWORD(data + 0x07));
printf("\n");
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
{
printf("\tError Information Handle:");
- dmi_memory_array_error_handle(WORD(data+0x0B));
+ dmi_memory_array_error_handle(WORD(data + 0x0B));
printf("\n");
}
printf("\tNumber Of Devices: %u\n",
- WORD(data+0x0D));
+ WORD(data + 0x0D));
break;
case 17: /* 3.3.18 Memory Device */
printf("Memory Device\n");
- if(h->length<0x15) break;
- if(!(opt.flags & FLAG_QUIET))
+ if (h->length < 0x15) break;
+ if (!(opt.flags & FLAG_QUIET))
{
printf("\tArray Handle: 0x%04X\n",
- WORD(data+0x04));
+ WORD(data + 0x04));
printf("\tError Information Handle:");
- dmi_memory_array_error_handle(WORD(data+0x06));
+ dmi_memory_array_error_handle(WORD(data + 0x06));
printf("\n");
}
printf("\tTotal Width:");
- dmi_memory_device_width(WORD(data+0x08));
+ dmi_memory_device_width(WORD(data + 0x08));
printf("\n");
printf("\tData Width:");
- dmi_memory_device_width(WORD(data+0x0A));
+ dmi_memory_device_width(WORD(data + 0x0A));
printf("\n");
printf("\tSize:");
- dmi_memory_device_size(WORD(data+0x0C));
+ dmi_memory_device_size(WORD(data + 0x0C));
printf("\n");
printf("\tForm Factor: %s\n",
dmi_memory_device_form_factor(data[0x0E]));
@@ -3309,13 +3314,13 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
printf("\tType: %s\n",
dmi_memory_device_type(data[0x12]));
printf("\tType Detail:");
- dmi_memory_device_type_detail(WORD(data+0x13));
+ dmi_memory_device_type_detail(WORD(data + 0x13));
printf("\n");
- if(h->length<0x17) break;
+ if (h->length < 0x17) break;
printf("\tSpeed:");
- dmi_memory_device_speed(WORD(data+0x15));
+ dmi_memory_device_speed(WORD(data + 0x15));
printf("\n");
- if(h->length<0x1B) break;
+ if (h->length < 0x1B) break;
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x17]));
printf("\tSerial Number: %s\n",
@@ -3328,7 +3333,7 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 18: /* 3.3.19 32-bit Memory Error Information */
printf("32-bit Memory Error Information\n");
- if(h->length<0x17) break;
+ if (h->length < 0x17) break;
printf("\tType: %s\n",
dmi_memory_error_type(data[0x04]));
printf("\tGranularity: %s\n",
@@ -3336,52 +3341,52 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
printf("\tOperation: %s\n",
dmi_memory_error_operation(data[0x06]));
printf("\tVendor Syndrome:");
- dmi_memory_error_syndrome(DWORD(data+0x07));
+ dmi_memory_error_syndrome(DWORD(data + 0x07));
printf("\n");
printf("\tMemory Array Address:");
- dmi_32bit_memory_error_address(DWORD(data+0x0B));
+ dmi_32bit_memory_error_address(DWORD(data + 0x0B));
printf("\n");
printf("\tDevice Address:");
- dmi_32bit_memory_error_address(DWORD(data+0x0F));
+ dmi_32bit_memory_error_address(DWORD(data + 0x0F));
printf("\n");
printf("\tResolution:");
- dmi_32bit_memory_error_address(DWORD(data+0x13));
+ dmi_32bit_memory_error_address(DWORD(data + 0x13));
printf("\n");
break;
case 19: /* 3.3.20 Memory Array Mapped Address */
printf("Memory Array Mapped Address\n");
- if(h->length<0x0F) break;
+ if (h->length < 0x0F) break;
printf("\tStarting Address: 0x%08X%03X\n",
- DWORD(data+0x04)>>2, (DWORD(data+0x04)&0x3)<<10);
+ DWORD(data + 0x04) >> 2, (DWORD(data + 0x04) & 0x3) << 10);
printf("\tEnding Address: 0x%08X%03X\n",
- DWORD(data+0x08)>>2, ((DWORD(data+0x08)&0x3)<<10)+0x3FF);
+ DWORD(data + 0x08) >> 2, ((DWORD(data + 0x08) & 0x3) << 10) + 0x3FF);
printf("\tRange Size:");
- dmi_mapped_address_size(DWORD(data+0x08)-DWORD(data+0x04)+1);
+ dmi_mapped_address_size(DWORD(data + 0x08) - DWORD(data + 0x04) + 1);
printf("\n");
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
printf("\tPhysical Array Handle: 0x%04X\n",
- WORD(data+0x0C));
+ WORD(data + 0x0C));
printf("\tPartition Width: %u\n",
data[0x0F]);
break;
case 20: /* 3.3.21 Memory Device Mapped Address */
printf("Memory Device Mapped Address\n");
- if(h->length<0x13) break;
+ if (h->length < 0x13) break;
printf("\tStarting Address: 0x%08X%03X\n",
- DWORD(data+0x04)>>2, (DWORD(data+0x04)&0x3)<<10);
+ DWORD(data + 0x04) >> 2, (DWORD(data + 0x04) & 0x3) << 10);
printf("\tEnding Address: 0x%08X%03X\n",
- DWORD(data+0x08)>>2, ((DWORD(data+0x08)&0x3)<<10)+0x3FF);
+ DWORD(data + 0x08) >> 2, ((DWORD(data + 0x08) & 0x3) << 10) + 0x3FF);
printf("\tRange Size:");
- dmi_mapped_address_size(DWORD(data+0x08)-DWORD(data+0x04)+1);
+ dmi_mapped_address_size(DWORD(data + 0x08) - DWORD(data + 0x04) + 1);
printf("\n");
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
{
printf("\tPhysical Device Handle: 0x%04X\n",
- WORD(data+0x0C));
+ WORD(data + 0x0C));
printf("\tMemory Array Mapped Address Handle: 0x%04X\n",
- WORD(data+0x0E));
+ WORD(data + 0x0E));
}
printf("\tPartition Row Position:");
dmi_mapped_address_row_position(data[0x10]);
@@ -3392,7 +3397,7 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 21: /* 3.3.22 Built-in Pointing Device */
printf("Built-in Pointing Device\n");
- if(h->length<0x07) break;
+ if (h->length < 0x07) break;
printf("\tType: %s\n",
dmi_pointing_device_type(data[0x04]));
printf("\tInterface: %s\n",
@@ -3403,219 +3408,220 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 22: /* 3.3.23 Portable Battery */
printf("Portable Battery\n");
- if(h->length<0x10) break;
+ if (h->length < 0x10) break;
printf("\tLocation: %s\n",
dmi_string(h, data[0x04]));
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x05]));
- if(data[0x06] || h->length<0x1A)
+ if (data[0x06] || h->length < 0x1A)
printf("\tManufacture Date: %s\n",
dmi_string(h, data[0x06]));
- if(data[0x07] || h->length<0x1A)
+ if (data[0x07] || h->length < 0x1A)
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x07]));
printf("\tName: %s\n",
dmi_string(h, data[0x08]));
- if(data[0x09]!=0x02 || h->length<0x1A)
+ if (data[0x09] != 0x02 || h->length < 0x1A)
printf("\tChemistry: %s\n",
dmi_battery_chemistry(data[0x09]));
printf("\tDesign Capacity:");
- if(h->length<0x1A)
- dmi_battery_capacity(WORD(data+0x0A), 1);
+ if (h->length < 0x1A)
+ dmi_battery_capacity(WORD(data + 0x0A), 1);
else
- dmi_battery_capacity(WORD(data+0x0A), data[0x15]);
+ dmi_battery_capacity(WORD(data + 0x0A), data[0x15]);
printf("\n");
printf("\tDesign Voltage:");
- dmi_battery_voltage(WORD(data+0x0C));
+ dmi_battery_voltage(WORD(data + 0x0C));
printf("\n");
printf("\tSBDS Version: %s\n",
dmi_string(h, data[0x0E]));
printf("\tMaximum Error:");
dmi_battery_maximum_error(data[0x0F]);
printf("\n");
- if(h->length<0x1A) break;
- if(data[0x07]==0)
+ if (h->length < 0x1A) break;
+ if (data[0x07] == 0)
printf("\tSBDS Serial Number: %04X\n",
- WORD(data+0x10));
- if(data[0x06]==0)
+ WORD(data + 0x10));
+ if (data[0x06] == 0)
printf("\tSBDS Manufacture Date: %u-%02u-%02u\n",
- 1980+(WORD(data+0x12)>>9), (WORD(data+0x12)>>5)&0x0F,
- WORD(data+0x12)&0x1F);
- if(data[0x09]==0x02)
+ 1980 + (WORD(data + 0x12) >> 9),
+ (WORD(data + 0x12) >> 5) & 0x0F,
+ WORD(data + 0x12) & 0x1F);
+ if (data[0x09] == 0x02)
printf("\tSBDS Chemistry: %s\n",
dmi_string(h, data[0x14]));
printf("\tOEM-specific Information: 0x%08X\n",
- DWORD(data+0x16));
+ DWORD(data + 0x16));
break;
case 23: /* 3.3.24 System Reset */
printf("System Reset\n");
- if(h->length<0x0D) break;
+ if (h->length < 0x0D) break;
printf("\tStatus: %s\n",
- data[0x04]&(1<<0)?"Enabled":"Disabled");
+ data[0x04] & (1 << 0) ? "Enabled" : "Disabled");
printf("\tWatchdog Timer: %s\n",
- data[0x04]&(1<<5)?"Present":"Not Present");
- if(!(data[0x04]&(1<<5)))
+ data[0x04] & (1 << 5) ? "Present" : "Not Present");
+ if (!(data[0x04] & (1 << 5)))
break;
printf("\tBoot Option: %s\n",
- dmi_system_reset_boot_option((data[0x04]>>1)&0x3));
+ dmi_system_reset_boot_option((data[0x04] >> 1) & 0x3));
printf("\tBoot Option On Limit: %s\n",
- dmi_system_reset_boot_option((data[0x04]>>3)&0x3));
+ dmi_system_reset_boot_option((data[0x04] >> 3) & 0x3));
printf("\tReset Count:");
- dmi_system_reset_count(WORD(data+0x05));
+ dmi_system_reset_count(WORD(data + 0x05));
printf("\n");
printf("\tReset Limit:");
- dmi_system_reset_count(WORD(data+0x07));
+ dmi_system_reset_count(WORD(data + 0x07));
printf("\n");
printf("\tTimer Interval:");
- dmi_system_reset_timer(WORD(data+0x09));
+ dmi_system_reset_timer(WORD(data + 0x09));
printf("\n");
printf("\tTimeout:");
- dmi_system_reset_timer(WORD(data+0x0B));
+ dmi_system_reset_timer(WORD(data + 0x0B));
printf("\n");
break;
case 24: /* 3.3.25 Hardware Security */
printf("Hardware Security\n");
- if(h->length<0x05) break;
+ if (h->length < 0x05) break;
printf("\tPower-On Password Status: %s\n",
- dmi_hardware_security_status(data[0x04]>>6));
+ dmi_hardware_security_status(data[0x04] >> 6));
printf("\tKeyboard Password Status: %s\n",
- dmi_hardware_security_status((data[0x04]>>4)&0x3));
+ dmi_hardware_security_status((data[0x04] >> 4) & 0x3));
printf("\tAdministrator Password Status: %s\n",
- dmi_hardware_security_status((data[0x04]>>2)&0x3));
+ dmi_hardware_security_status((data[0x04] >> 2) & 0x3));
printf("\tFront Panel Reset Status: %s\n",
- dmi_hardware_security_status(data[0x04]&0x3));
+ dmi_hardware_security_status(data[0x04] & 0x3));
break;
case 25: /* 3.3.26 System Power Controls */
printf("\tSystem Power Controls\n");
- if(h->length<0x09) break;
+ if (h->length < 0x09) break;
printf("\tNext Scheduled Power-on:");
- dmi_power_controls_power_on(data+0x04);
+ dmi_power_controls_power_on(data + 0x04);
printf("\n");
break;
case 26: /* 3.3.27 Voltage Probe */
printf("Voltage Probe\n");
- if(h->length<0x14) break;
+ if (h->length < 0x14) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
printf("\tLocation: %s\n",
- dmi_voltage_probe_location(data[0x05]&0x1f));
+ dmi_voltage_probe_location(data[0x05] & 0x1f));
printf("\tStatus: %s\n",
- dmi_probe_status(data[0x05]>>5));
+ dmi_probe_status(data[0x05] >> 5));
printf("\tMaximum Value:");
- dmi_voltage_probe_value(WORD(data+0x06));
+ dmi_voltage_probe_value(WORD(data + 0x06));
printf("\n");
printf("\tMinimum Value:");
- dmi_voltage_probe_value(WORD(data+0x08));
+ dmi_voltage_probe_value(WORD(data + 0x08));
printf("\n");
printf("\tResolution:");
- dmi_voltage_probe_resolution(WORD(data+0x0A));
+ dmi_voltage_probe_resolution(WORD(data + 0x0A));
printf("\n");
printf("\tTolerance:");
- dmi_voltage_probe_value(WORD(data+0x0C));
+ dmi_voltage_probe_value(WORD(data + 0x0C));
printf("\n");
printf("\tAccuracy:");
- dmi_probe_accuracy(WORD(data+0x0E));
+ dmi_probe_accuracy(WORD(data + 0x0E));
printf("\n");
printf("\tOEM-specific Information: 0x%08X\n",
- DWORD(data+0x10));
- if(h->length<0x16) break;
+ DWORD(data + 0x10));
+ if (h->length < 0x16) break;
printf("\tNominal Value:");
- dmi_voltage_probe_value(WORD(data+0x14));
+ dmi_voltage_probe_value(WORD(data + 0x14));
printf("\n");
break;
case 27: /* 3.3.28 Cooling Device */
printf("Cooling Device\n");
- if(h->length<0x0C) break;
- if(!(opt.flags & FLAG_QUIET) && WORD(data+0x04)!=0xFFFF)
+ if (h->length < 0x0C) break;
+ if (!(opt.flags & FLAG_QUIET) && WORD(data + 0x04)!=0xFFFF)
printf("\tTemperature Probe Handle: 0x%04X\n",
- WORD(data+0x04));
+ WORD(data + 0x04));
printf("\tType: %s\n",
- dmi_cooling_device_type(data[0x06]&0x1f));
+ dmi_cooling_device_type(data[0x06] & 0x1f));
printf("\tStatus: %s\n",
- dmi_probe_status(data[0x06]>>5));
- if(data[0x07]!=0x00)
+ dmi_probe_status(data[0x06] >> 5));
+ if (data[0x07] != 0x00)
printf("\tCooling Unit Group: %u\n",
data[0x07]);
printf("\tOEM-specific Information: 0x%08X\n",
- DWORD(data+0x08));
- if(h->length<0x0E) break;
+ DWORD(data + 0x08));
+ if (h->length < 0x0E) break;
printf("\tNominal Speed:");
- dmi_cooling_device_speed(WORD(data+0x0C));
+ dmi_cooling_device_speed(WORD(data + 0x0C));
printf("\n");
break;
case 28: /* 3.3.29 Temperature Probe */
printf("Temperature Probe\n");
- if(h->length<0x14) break;
+ if (h->length < 0x14) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
printf("\tLocation: %s\n",
- dmi_temperature_probe_location(data[0x05]&0x1F));
+ dmi_temperature_probe_location(data[0x05] & 0x1F));
printf("\tStatus: %s\n",
- dmi_probe_status(data[0x05]>>5));
+ dmi_probe_status(data[0x05] >> 5));
printf("\tMaximum Value:");
- dmi_temperature_probe_value(WORD(data+0x06));
+ dmi_temperature_probe_value(WORD(data + 0x06));
printf("\n");
printf("\tMinimum Value:");
- dmi_temperature_probe_value(WORD(data+0x08));
+ dmi_temperature_probe_value(WORD(data + 0x08));
printf("\n");
printf("\tResolution:");
- dmi_temperature_probe_resolution(WORD(data+0x0A));
+ dmi_temperature_probe_resolution(WORD(data + 0x0A));
printf("\n");
printf("\tTolerance:");
- dmi_temperature_probe_value(WORD(data+0x0C));
+ dmi_temperature_probe_value(WORD(data + 0x0C));
printf("\n");
printf("\tAccuracy:");
- dmi_probe_accuracy(WORD(data+0x0E));
+ dmi_probe_accuracy(WORD(data + 0x0E));
printf("\n");
printf("\tOEM-specific Information: 0x%08X\n",
- DWORD(data+0x10));
- if(h->length<0x16) break;
+ DWORD(data + 0x10));
+ if (h->length < 0x16) break;
printf("\tNominal Value:");
- dmi_temperature_probe_value(WORD(data+0x14));
+ dmi_temperature_probe_value(WORD(data + 0x14));
printf("\n");
break;
case 29: /* 3.3.30 Electrical Current Probe */
printf("Electrical Current Probe\n");
- if(h->length<0x14) break;
+ if (h->length < 0x14) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
printf("\tLocation: %s\n",
- dmi_voltage_probe_location(data[5]&0x1F));
+ dmi_voltage_probe_location(data[5] & 0x1F));
printf("\tStatus: %s\n",
- dmi_probe_status(data[0x05]>>5));
+ dmi_probe_status(data[0x05] >> 5));
printf("\tMaximum Value:");
- dmi_current_probe_value(WORD(data+0x06));
+ dmi_current_probe_value(WORD(data + 0x06));
printf("\n");
printf("\tMinimum Value:");
- dmi_current_probe_value(WORD(data+0x08));
+ dmi_current_probe_value(WORD(data + 0x08));
printf("\n");
printf("\tResolution:");
- dmi_current_probe_resolution(WORD(data+0x0A));
+ dmi_current_probe_resolution(WORD(data + 0x0A));
printf("\n");
printf("\tTolerance:");
- dmi_current_probe_value(WORD(data+0x0C));
+ dmi_current_probe_value(WORD(data + 0x0C));
printf("\n");
printf("\tAccuracy:");
- dmi_probe_accuracy(WORD(data+0x0E));
+ dmi_probe_accuracy(WORD(data + 0x0E));
printf("\n");
printf("\tOEM-specific Information: 0x%08X\n",
- DWORD(data+0x10));
- if(h->length<0x16) break;
+ DWORD(data + 0x10));
+ if (h->length < 0x16) break;
printf("\tNominal Value:");
- dmi_current_probe_value(WORD(data+0x14));
+ dmi_current_probe_value(WORD(data + 0x14));
printf("\n");
break;
case 30: /* 3.3.31 Out-of-band Remote Access */
printf("Out-of-band Remote Access\n");
- if(h->length<0x06) break;
+ if (h->length < 0x06) break;
printf("\tManufacturer Name: %s\n",
dmi_string(h, data[0x04]));
printf("\tInbound Connection: %s\n",
@@ -3630,13 +3636,13 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 32: /* 3.3.33 System Boot Information */
printf("System Boot Information\n");
- if(h->length<0x0B) break;
+ if (h->length < 0x0B) break;
printf("\tStatus: %s\n",
dmi_system_boot_status(data[0x0A]));
break;
case 33: /* 3.3.34 64-bit Memory Error Information */
- if(h->length<0x1F) break;
+ if (h->length < 0x1F) break;
printf("64-bit Memory Error Information\n");
printf("\tType: %s\n",
dmi_memory_error_type(data[0x04]));
@@ -3645,83 +3651,83 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
printf("\tOperation: %s\n",
dmi_memory_error_operation(data[0x06]));
printf("\tVendor Syndrome:");
- dmi_memory_error_syndrome(DWORD(data+0x07));
+ dmi_memory_error_syndrome(DWORD(data + 0x07));
printf("\n");
printf("\tMemory Array Address:");
- dmi_64bit_memory_error_address(QWORD(data+0x0B));
+ dmi_64bit_memory_error_address(QWORD(data + 0x0B));
printf("\n");
printf("\tDevice Address:");
- dmi_64bit_memory_error_address(QWORD(data+0x13));
+ dmi_64bit_memory_error_address(QWORD(data + 0x13));
printf("\n");
printf("\tResolution:");
- dmi_32bit_memory_error_address(DWORD(data+0x1B));
+ dmi_32bit_memory_error_address(DWORD(data + 0x1B));
printf("\n");
break;
case 34: /* 3.3.35 Management Device */
printf("Management Device\n");
- if(h->length<0x0B) break;
+ if (h->length < 0x0B) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
printf("\tType: %s\n",
dmi_management_device_type(data[0x05]));
printf("\tAddress: 0x%08X\n",
- DWORD(data+0x06));
+ DWORD(data + 0x06));
printf("\tAddress Type: %s\n",
dmi_management_device_address_type(data[0x0A]));
break;
case 35: /* 3.3.36 Management Device Component */
printf("Management Device Component\n");
- if(h->length<0x0B) break;
+ if (h->length < 0x0B) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
{
printf("\tManagement Device Handle: 0x%04X\n",
- WORD(data+0x05));
+ WORD(data + 0x05));
printf("\tComponent Handle: 0x%04X\n",
- WORD(data+0x07));
- if(WORD(data+0x09)!=0xFFFF)
+ WORD(data + 0x07));
+ if (WORD(data + 0x09) != 0xFFFF)
printf("\tThreshold Handle: 0x%04X\n",
- WORD(data+0x09));
+ WORD(data + 0x09));
}
break;
case 36: /* 3.3.37 Management Device Threshold Data */
printf("Management Device Threshold Data\n");
- if(h->length<0x10) break;
- if(WORD(data+0x04)!=0x8000)
+ if (h->length < 0x10) break;
+ if (WORD(data + 0x04) != 0x8000)
printf("\tLower Non-critical Threshold: %d\n",
- (i16)WORD(data+0x04));
- if(WORD(data+0x06)!=0x8000)
+ (i16)WORD(data + 0x04));
+ if (WORD(data + 0x06) != 0x8000)
printf("\tUpper Non-critical Threshold: %d\n",
- (i16)WORD(data+0x06));
- if(WORD(data+0x08)!=0x8000)
+ (i16)WORD(data + 0x06));
+ if (WORD(data + 0x08) != 0x8000)
printf("\tLower Critical Threshold: %d\n",
- (i16)WORD(data+0x08));
- if(WORD(data+0x0A)!=0x8000)
+ (i16)WORD(data + 0x08));
+ if (WORD(data + 0x0A) != 0x8000)
printf("\tUpper Critical Threshold: %d\n",
- (i16)WORD(data+0x0A));
- if(WORD(data+0x0C)!=0x8000)
+ (i16)WORD(data + 0x0A));
+ if (WORD(data + 0x0C) != 0x8000)
printf("\tLower Non-recoverable Threshold: %d\n",
- (i16)WORD(data+0x0C));
- if(WORD(data+0x0E)!=0x8000)
+ (i16)WORD(data + 0x0C));
+ if (WORD(data + 0x0E) != 0x8000)
printf("\tUpper Non-recoverable Threshold: %d\n",
- (i16)WORD(data+0x0E));
+ (i16)WORD(data + 0x0E));
break;
case 37: /* 3.3.38 Memory Channel */
printf("Memory Channel\n");
- if(h->length<0x07) break;
+ if (h->length < 0x07) break;
printf("\tType: %s\n",
dmi_memory_channel_type(data[0x04]));
printf("\tMaximal Load: %u\n",
data[0x05]);
printf("\tDevices: %u\n",
data[0x06]);
- if(h->length<0x07+3*data[0x06]) break;
- dmi_memory_channel_devices(data[0x06], data+0x07, "\t");
+ if (h->length < 0x07 + 3 * data[0x06]) break;
+ dmi_memory_channel_devices(data[0x06], data + 0x07, "\t");
break;
case 38: /* 3.3.39 IPMI Device Information */
@@ -3730,36 +3736,36 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
* the IPMI specification.
*/
printf("IPMI Device Information\n");
- if(h->length<0x10) break;
+ if (h->length < 0x10) break;
printf("\tInterface Type: %s\n",
dmi_ipmi_interface_type(data[0x04]));
printf("\tSpecification Version: %u.%u\n",
- data[0x05]>>4, data[0x05]&0x0F);
+ data[0x05] >> 4, data[0x05] & 0x0F);
printf("\tI2C Slave Address: 0x%02x\n",
- data[0x06]>>1);
- if(data[0x07]!=0xFF)
+ data[0x06] >> 1);
+ if (data[0x07] != 0xFF)
printf("\tNV Storage Device Address: %u\n",
data[0x07]);
else
printf("\tNV Storage Device: Not Present\n");
printf("\tBase Address: ");
- dmi_ipmi_base_address(data[0x04], data+0x08,
- h->length<0x12?0:(data[0x10]>>5)&1);
+ dmi_ipmi_base_address(data[0x04], data + 0x08,
+ h->length < 0x12 ? 0 : (data[0x10] >> 5) & 1);
printf("\n");
- if(h->length<0x12) break;
- if(data[0x04]!=0x04)
+ if (h->length < 0x12) break;
+ if (data[0x04] != 0x04)
{
printf("\tRegister Spacing: %s\n",
- dmi_ipmi_register_spacing(data[0x10]>>6));
- if(data[0x10]&(1<<3))
+ dmi_ipmi_register_spacing(data[0x10] >> 6));
+ if (data[0x10] & (1 << 3))
{
printf("\tInterrupt Polarity: %s\n",
- data[0x10]&(1<<1)?"Active High":"Active Low");
+ data[0x10] & (1 << 1) ? "Active High" : "Active Low");
printf("\tInterrupt Trigger Mode: %s\n",
- data[0x10]&(1<<0)?"Level":"Edge");
+ data[0x10] & (1 << 0) ? "Level" : "Edge");
}
}
- if(data[0x11]!=0x00)
+ if (data[0x11] != 0x00)
{
printf("\tInterrupt Number: %x\n",
data[0x11]);
@@ -3768,8 +3774,8 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
case 39: /* 3.3.40 System Power Supply */
printf("System Power Supply\n");
- if(h->length<0x10) break;
- if(data[0x04]!=0x00)
+ if (h->length < 0x10) break;
+ if (data[0x04] != 0x00)
printf("\tPower Unit Group: %u\n",
data[0x04]);
printf("\tLocation: %s\n",
@@ -3787,35 +3793,35 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
printf("\tRevision: %s\n",
dmi_string(h, data[0x0B]));
printf("\tMax Power Capacity:");
- dmi_power_supply_power(WORD(data+0x0C));
+ dmi_power_supply_power(WORD(data + 0x0C));
printf("\n");
printf("\tStatus:");
- if(WORD(data+0x0E)&(1<<1))
+ if (WORD(data + 0x0E) & (1 << 1))
printf(" Present, %s",
- dmi_power_supply_status((WORD(data+0x0E)>>7)&0x07));
+ dmi_power_supply_status((WORD(data + 0x0E) >> 7) & 0x07));
else
printf(" Not Present");
printf("\n");
printf("\tType: %s\n",
- dmi_power_supply_type((WORD(data+0x0E)>>10)&0x0F));
+ dmi_power_supply_type((WORD(data + 0x0E) >> 10) & 0x0F));
printf("\tInput Voltage Range Switching: %s\n",
- dmi_power_supply_range_switching((WORD(data+0x0E)>>3)&0x0F));
+ dmi_power_supply_range_switching((WORD(data + 0x0E) >> 3) & 0x0F));
printf("\tPlugged: %s\n",
- WORD(data+0x0E)&(1<<2)?"No":"Yes");
+ WORD(data + 0x0E) & (1 << 2) ? "No" : "Yes");
printf("\tHot Replaceable: %s\n",
- WORD(data+0x0E)&(1<<0)?"Yes":"No");
- if(h->length<0x16) break;
- if(!(opt.flags & FLAG_QUIET))
+ WORD(data + 0x0E) & (1 << 0) ? "Yes" : "No");
+ if (h->length < 0x16) break;
+ if (!(opt.flags & FLAG_QUIET))
{
- if(WORD(data+0x10)!=0xFFFF)
+ if (WORD(data + 0x10) != 0xFFFF)
printf("\tInput Voltage Probe Handle: 0x%04X\n",
- WORD(data+0x10));
- if(WORD(data+0x12)!=0xFFFF)
+ WORD(data + 0x10));
+ if (WORD(data + 0x12) != 0xFFFF)
printf("\tCooling Device Handle: 0x%04X\n",
- WORD(data+0x12));
- if(WORD(data+0x14)!=0xFFFF)
+ WORD(data + 0x12));
+ if (WORD(data + 0x14) != 0xFFFF)
printf("\tInput Current Probe Handle: 0x%04X\n",
- WORD(data+0x14));
+ WORD(data + 0x14));
}
break;
@@ -3828,12 +3834,12 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
break;
default:
- if(dmi_decode_oem(h))
+ if (dmi_decode_oem(h))
break;
- if(opt.flags & FLAG_QUIET)
+ if (opt.flags & FLAG_QUIET)
return;
printf("%s Type\n",
- h->type>=128?"OEM-specific":"Unknown");
+ h->type >= 128 ? "OEM-specific" : "Unknown");
dmi_dump(h, "\t");
}
printf("\n");
@@ -3841,17 +3847,17 @@ static void dmi_decode(struct dmi_header *h, u16 ver)
static void to_dmi_header(struct dmi_header *h, u8 *data)
{
- h->type=data[0];
- h->length=data[1];
- h->handle=WORD(data+2);
- h->data=data;
+ h->type = data[0];
+ h->length = data[1];
+ h->handle = WORD(data + 2);
+ h->data = data;
}
static void dmi_table_dump(u32 base, u16 len, const char *devmem)
{
u8 *buf;
- if((buf=mem_chunk(base, len, devmem))==NULL)
+ if ((buf = mem_chunk(base, len, devmem)) == NULL)
{
fprintf(stderr, "Failed to read table, sorry.\n");
return;
@@ -3866,27 +3872,27 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
{
u8 *buf;
u8 *data;
- int i=0;
+ int i = 0;
- if(opt.flags & FLAG_DUMP_BIN)
+ if (opt.flags & FLAG_DUMP_BIN)
{
dmi_table_dump(base, len, devmem);
return;
}
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
{
- if(opt.type==NULL)
+ if (opt.type == NULL)
{
printf("%u structures occupying %u bytes.\n",
num, len);
- if(!(opt.flags & FLAG_FROM_DUMP))
+ if (!(opt.flags & FLAG_FROM_DUMP))
printf("Table at 0x%08X.\n", base);
}
printf("\n");
}
- if((buf=mem_chunk(base, len, devmem))==NULL)
+ if ((buf = mem_chunk(base, len, devmem)) == NULL)
{
fprintf(stderr, "Table is unreachable, sorry."
#ifndef USE_MMAP
@@ -3896,16 +3902,16 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
return;
}
- data=buf;
- while(i<num && data+4<=buf+len) /* 4 is the length of an SMBIOS structure header */
+ data = buf;
+ while (i < num && data+4 <= buf + len) /* 4 is the length of an SMBIOS structure header */
{
u8 *next;
struct dmi_header h;
int display;
to_dmi_header(&h, data);
- display=((opt.type==NULL || opt.type[h.type])
- && !((opt.flags & FLAG_QUIET) && (h.type>39 && h.type<=127))
+ display = ((opt.type == NULL || opt.type[h.type])
+ && !((opt.flags & FLAG_QUIET) && (h.type > 39 && h.type <= 127))
&& !opt.string);
/*
@@ -3914,7 +3920,7 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
* Better stop at this point, and let the user know his/her
* table is broken.
*/
- if(h.length<4)
+ if (h.length < 4)
{
printf("Invalid entry length (%u). DMI table is "
"broken! Stop.\n\n", (unsigned int)h.length);
@@ -3923,27 +3929,27 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
}
/* In quiet mode, stop decoding at end of table marker */
- if((opt.flags & FLAG_QUIET) && h.type==127)
+ if ((opt.flags & FLAG_QUIET) && h.type == 127)
break;
- if(display && !(opt.flags & FLAG_QUIET))
+ if (display && !(opt.flags & FLAG_QUIET))
printf("Handle 0x%04X, DMI type %d, %d bytes\n",
h.handle, h.type, h.length);
/* assign vendor for vendor-specific decodes later */
- if(h.type==0 && h.length>=5)
+ if (h.type == 0 && h.length >= 5)
dmi_set_vendor(dmi_string(&h, data[0x04]));
/* look for the next handle */
- next=data+h.length;
- while(next-buf+1<len && (next[0]!=0 || next[1]!=0))
+ next = data + h.length;
+ while (next - buf + 1 < len && (next[0] != 0 || next[1] != 0))
next++;
- next+=2;
- if(display)
+ next += 2;
+ if (display)
{
- if(next-buf<=len)
+ if (next - buf <= len)
{
- if(opt.flags & FLAG_DUMP)
+ if (opt.flags & FLAG_DUMP)
{
dmi_dump(&h, "\t");
printf("\n");
@@ -3951,36 +3957,36 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
else
dmi_decode(&h, ver);
}
- else if(!(opt.flags & FLAG_QUIET))
+ else if (!(opt.flags & FLAG_QUIET))
printf("\t<TRUNCATED>\n\n");
}
- else if(opt.string!=NULL
- && opt.string->type==h.type
- && opt.string->offset<h.length)
+ else if (opt.string != NULL
+ && opt.string->type == h.type
+ && opt.string->offset < h.length)
{
- if (opt.string->lookup!=NULL)
+ if (opt.string->lookup != NULL)
printf("%s\n", opt.string->lookup(data[opt.string->offset]));
- else if (opt.string->print!=NULL) {
- opt.string->print(data+opt.string->offset);
+ else if (opt.string->print != NULL) {
+ opt.string->print(data + opt.string->offset);
printf("\n");
}
else
printf("%s\n", dmi_string(&h, data[opt.string->offset]));
}
- data=next;
+ data = next;
i++;
}
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
{
- if(i!=num)
+ if (i != num)
printf("Wrong DMI structures count: %d announced, "
"only %d decoded.\n", num, i);
- if(data-buf!=len)
+ if (data - buf != len)
printf("Wrong DMI structures length: %d bytes "
"announced, structures occupy %d bytes.\n",
- len, (unsigned int)(data-buf));
+ len, (unsigned int)(data - buf));
}
free(buf);
@@ -3994,33 +4000,33 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
*/
static void overwrite_dmi_address(u8 *buf)
{
- buf[0x05]+=buf[0x08]+buf[0x09]+buf[0x0A]+buf[0x0B]-32;
- buf[0x08]=32;
- buf[0x09]=0;
- buf[0x0A]=0;
- buf[0x0B]=0;
+ buf[0x05] += buf[0x08] + buf[0x09] + buf[0x0A] + buf[0x0B] - 32;
+ buf[0x08] = 32;
+ buf[0x09] = 0;
+ buf[0x0A] = 0;
+ buf[0x0B] = 0;
}
static int smbios_decode(u8 *buf, const char *devmem)
{
- if(!checksum(buf, buf[0x05])
- || memcmp(buf+0x10, "_DMI_", 5)!=0
- || !checksum(buf+0x10, 0x0F))
+ if (!checksum(buf, buf[0x05])
+ || memcmp(buf + 0x10, "_DMI_", 5) != 0
+ || !checksum(buf + 0x10, 0x0F))
return 0;
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
printf("SMBIOS %u.%u present.\n",
buf[0x06], buf[0x07]);
- dmi_table(DWORD(buf+0x18), WORD(buf+0x16), WORD(buf+0x1C),
- (buf[0x06]<<8)+buf[0x07], devmem);
+ dmi_table(DWORD(buf + 0x18), WORD(buf + 0x16), WORD(buf + 0x1C),
+ (buf[0x06] << 8) + buf[0x07], devmem);
- if(opt.flags & FLAG_DUMP_BIN)
+ if (opt.flags & FLAG_DUMP_BIN)
{
u8 crafted[32];
memcpy(crafted, buf, 32);
- overwrite_dmi_address(crafted+0x10);
+ overwrite_dmi_address(crafted + 0x10);
printf("# Writing %d bytes to %s.\n", crafted[0x05], opt.dumpfile);
write_dump(0, crafted[0x05], crafted, opt.dumpfile);
@@ -4031,17 +4037,17 @@ static int smbios_decode(u8 *buf, const char *devmem)
static int legacy_decode(u8 *buf, const char *devmem)
{
- if(!checksum(buf, 0x0F))
+ if (!checksum(buf, 0x0F))
return 0;
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
printf("Legacy DMI %u.%u present.\n",
- buf[0x0E]>>4, buf[0x0E]&0x0F);
+ buf[0x0E] >> 4, buf[0x0E] & 0x0F);
- dmi_table(DWORD(buf+0x08), WORD(buf+0x06), WORD(buf+0x0C),
- ((buf[0x0E]&0xF0)<<4)+(buf[0x0E]&0x0F), devmem);
+ dmi_table(DWORD(buf + 0x08), WORD(buf + 0x06), WORD(buf + 0x0C),
+ ((buf[0x0E] & 0xF0) << 4) + (buf[0x0E] & 0x0F), devmem);
- if(opt.flags & FLAG_DUMP_BIN)
+ if (opt.flags & FLAG_DUMP_BIN)
{
u8 crafted[16];
@@ -4067,98 +4073,98 @@ static int address_from_efi(size_t *address)
char linebuf[64];
int ret;
- *address=0; /* Prevent compiler warning */
+ *address = 0; /* Prevent compiler warning */
/*
* Linux up to 2.6.6: /proc/efi/systab
* Linux 2.6.7 and up: /sys/firmware/efi/systab
*/
- if((efi_systab=fopen(filename="/sys/firmware/efi/systab", "r"))==NULL
- && (efi_systab=fopen(filename="/proc/efi/systab", "r"))==NULL)
+ if ((efi_systab = fopen(filename="/sys/firmware/efi/systab", "r")) == NULL
+ && (efi_systab = fopen(filename="/proc/efi/systab", "r")) == NULL)
{
/* No EFI interface, fallback to memory scan */
return EFI_NOT_FOUND;
}
- ret=EFI_NO_SMBIOS;
- while((fgets(linebuf, sizeof(linebuf)-1, efi_systab))!=NULL)
+ ret = EFI_NO_SMBIOS;
+ while ((fgets(linebuf, sizeof(linebuf) - 1, efi_systab)) != NULL)
{
- char *addrp=strchr(linebuf, '=');
- *(addrp++)='\0';
- if(strcmp(linebuf, "SMBIOS")==0)
+ char *addrp = strchr(linebuf, '=');
+ *(addrp++) = '\0';
+ if (strcmp(linebuf, "SMBIOS") == 0)
{
- *address=strtoul(addrp, NULL, 0);
- if(!(opt.flags & FLAG_QUIET))
+ *address = strtoul(addrp, NULL, 0);
+ if (!(opt.flags & FLAG_QUIET))
printf("# SMBIOS entry point at 0x%08lx\n",
(unsigned long)*address);
- ret=0;
+ ret = 0;
break;
}
}
- if(fclose(efi_systab)!=0)
+ if (fclose(efi_systab) != 0)
perror(filename);
- if(ret==EFI_NO_SMBIOS)
+ if (ret == EFI_NO_SMBIOS)
fprintf(stderr, "%s: SMBIOS entry point missing\n", filename);
return ret;
}
int main(int argc, char * const argv[])
{
- int ret=0; /* Returned value */
- int found=0;
+ int ret = 0; /* Returned value */
+ int found = 0;
size_t fp;
int efi;
u8 *buf;
- if(sizeof(u8)!=1 || sizeof(u16)!=2 || sizeof(u32)!=4 || '\0'!=0)
+ if (sizeof(u8) != 1 || sizeof(u16) != 2 || sizeof(u32) != 4 || '\0' != 0)
{
fprintf(stderr, "%s: compiler incompatibility\n", argv[0]);
exit(255);
}
/* Set default option values */
- opt.devmem=DEFAULT_MEM_DEV;
- opt.flags=0;
+ opt.devmem = DEFAULT_MEM_DEV;
+ opt.flags = 0;
- if(parse_command_line(argc, argv)<0)
+ if (parse_command_line(argc, argv)<0)
{
- ret=2;
+ ret = 2;
goto exit_free;
}
- if(opt.flags & FLAG_HELP)
+ if (opt.flags & FLAG_HELP)
{
print_help();
goto exit_free;
}
- if(opt.flags & FLAG_VERSION)
+ if (opt.flags & FLAG_VERSION)
{
printf("%s\n", VERSION);
goto exit_free;
}
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
printf("# dmidecode %s\n", VERSION);
/* Read from dump if so instructed */
- if(opt.flags & FLAG_FROM_DUMP)
+ if (opt.flags & FLAG_FROM_DUMP)
{
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
printf("Reading SMBIOS/DMI data from file %s.\n",
opt.dumpfile);
- if((buf=mem_chunk(0, 0x20, opt.dumpfile))==NULL)
+ if ((buf = mem_chunk(0, 0x20, opt.dumpfile)) == NULL)
{
- ret=1;
+ ret = 1;
goto exit_free;
}
- if(memcmp(buf, "_SM_", 4)==0)
+ if (memcmp(buf, "_SM_", 4)==0)
{
- if(smbios_decode(buf, opt.dumpfile))
+ if (smbios_decode(buf, opt.dumpfile))
found++;
}
- else if(memcmp(buf, "_DMI_", 5)==0)
+ else if (memcmp(buf, "_DMI_", 5)==0)
{
if (legacy_decode(buf, opt.dumpfile))
found++;
@@ -4168,7 +4174,7 @@ int main(int argc, char * const argv[])
/* First try EFI (ia64, Intel-based Mac) */
efi=address_from_efi(&fp);
- switch(efi)
+ switch (efi)
{
case EFI_NOT_FOUND:
goto memory_scan;
@@ -4177,43 +4183,43 @@ int main(int argc, char * const argv[])
goto exit_free;
}
- if((buf=mem_chunk(fp, 0x20, opt.devmem))==NULL)
+ if ((buf = mem_chunk(fp, 0x20, opt.devmem)) == NULL)
{
- ret=1;
+ ret = 1;
goto exit_free;
}
- if(smbios_decode(buf, opt.devmem))
+ if (smbios_decode(buf, opt.devmem))
found++;
goto done;
memory_scan:
/* Fallback to memory scan (x86, x86_64) */
- if((buf=mem_chunk(0xF0000, 0x10000, opt.devmem))==NULL)
+ if ((buf = mem_chunk(0xF0000, 0x10000, opt.devmem)) == NULL)
{
- ret=1;
+ ret = 1;
goto exit_free;
}
- for(fp=0; fp<=0xFFF0; fp+=16)
+ for (fp = 0; fp <= 0xFFF0; fp += 16)
{
- if(memcmp(buf+fp, "_SM_", 4)==0 && fp<=0xFFE0)
+ if (memcmp(buf + fp, "_SM_", 4) == 0 && fp <= 0xFFE0)
{
- if(smbios_decode(buf+fp, opt.devmem))
+ if (smbios_decode(buf+fp, opt.devmem))
{
found++;
- fp+=16;
+ fp += 16;
}
}
- else if(memcmp(buf+fp, "_DMI_", 5)==0)
+ else if (memcmp(buf + fp, "_DMI_", 5)==0)
{
- if (legacy_decode(buf+fp, opt.devmem))
+ if (legacy_decode(buf + fp, opt.devmem))
found++;
}
}
done:
- if(!found && !(opt.flags & FLAG_QUIET))
+ if (!found && !(opt.flags & FLAG_QUIET))
printf("# No SMBIOS nor DMI entry point found, sorry.\n");
free(buf);
diff --git a/dmioem.c b/dmioem.c
index 22690c0..cf684df 100644
--- a/dmioem.c
+++ b/dmioem.c
@@ -32,7 +32,7 @@
enum DMI_VENDORS { VENDOR_UNKNOWN, VENDOR_HP };
-static enum DMI_VENDORS dmi_vendor=VENDOR_UNKNOWN;
+static enum DMI_VENDORS dmi_vendor = VENDOR_UNKNOWN;
/*
* Remember the system vendor for later use. We only actually store the
@@ -41,8 +41,8 @@ static enum DMI_VENDORS dmi_vendor=VENDOR_UNKNOWN;
*/
void dmi_set_vendor(const char *s)
{
- if(strcmp(s, "HP")==0)
- dmi_vendor=VENDOR_HP;
+ if (strcmp(s, "HP") == 0)
+ dmi_vendor = VENDOR_HP;
}
/*
@@ -53,17 +53,17 @@ void dmi_set_vendor(const char *s)
static int dmi_decode_hp(struct dmi_header *h)
{
- u8 *data=h->data;
+ u8 *data = h->data;
int nic, ptr;
- switch(h->type)
+ switch (h->type)
{
case 204:
/*
* Vendor Specific: HP ProLiant System/Rack Locator
*/
printf("HP ProLiant System/Rack Locator\n");
- if(h->length<0x0B) break;
+ if (h->length < 0x0B) break;
printf("\tRack Name: %s\n", dmi_string(h, data[0x04]));
printf("\tEnclosure Name: %s\n", dmi_string(h, data[0x05]));
printf("\tEnclosure Model: %s\n", dmi_string(h, data[0x06]));
@@ -81,28 +81,29 @@ static int dmi_decode_hp(struct dmi_header *h)
* This prints the BIOS NIC number,
* PCI bus/device/function, and MAC address
*/
- printf(h->type==221?
- "HP BIOS iSCSI NIC PCI and MAC Information\n":
+ printf(h->type == 221 ?
+ "HP BIOS iSCSI NIC PCI and MAC Information\n" :
"HP BIOS NIC PCI and MAC Information\n");
- nic=1;
- ptr=4;
- while(h->length>=ptr+8)
+ nic = 1;
+ ptr = 4;
+ while (h->length >= ptr + 8)
{
- if(data[ptr]==0x00 && data[ptr+1]==0x00)
+ if (data[ptr] == 0x00 && data[ptr + 1] == 0x00)
printf("\tNIC %d: Disabled\n", nic);
- else if(data[ptr]==0xFF && data[ptr+1]==0xFF)
+ else if (data[ptr] == 0xFF && data[ptr + 1] == 0xFF)
printf("\tNIC %d: Not Installed\n", nic);
else
{
printf("\tNIC %d: PCI device %02x:%02x.%x, "
"MAC address %02X:%02X:%02X:%02X:%02X:%02X\n",
- nic, data[ptr+1], data[ptr]>>3, data[ptr]&7,
- data[ptr+2], data[ptr+3],
- data[ptr+4], data[ptr+5],
- data[ptr+6], data[ptr+7]);
+ nic, data[ptr + 1],
+ data[ptr] >> 3, data[ptr] & 7,
+ data[ptr + 2], data[ptr + 3],
+ data[ptr + 4], data[ptr + 5],
+ data[ptr + 6], data[ptr + 7]);
}
nic++;
- ptr+=8;
+ ptr += 8;
}
break;
@@ -118,7 +119,7 @@ static int dmi_decode_hp(struct dmi_header *h)
*/
int dmi_decode_oem(struct dmi_header *h)
{
- switch(dmi_vendor)
+ switch (dmi_vendor)
{
case VENDOR_HP:
return dmi_decode_hp(h);
diff --git a/dmiopt.c b/dmiopt.c
index 4b35666..a01e5da 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -45,17 +45,17 @@ struct type_keyword
const u8 *type;
};
-static const u8 opt_type_bios[]={ 0, 13, 255 };
-static const u8 opt_type_system[]={ 1, 12, 15, 23, 32, 255 };
-static const u8 opt_type_baseboard[]={ 2, 10, 255 };
-static const u8 opt_type_chassis[]={ 3, 255 };
-static const u8 opt_type_processor[]={ 4, 255 };
-static const u8 opt_type_memory[]={ 5, 6, 16, 17, 255 };
-static const u8 opt_type_cache[]={ 7, 255 };
-static const u8 opt_type_connector[]={ 8, 255 };
-static const u8 opt_type_slot[]={ 9, 255 };
-
-static const struct type_keyword opt_type_keyword[]={
+static const u8 opt_type_bios[] = { 0, 13, 255 };
+static const u8 opt_type_system[] = { 1, 12, 15, 23, 32, 255 };
+static const u8 opt_type_baseboard[] = { 2, 10, 255 };
+static const u8 opt_type_chassis[] = { 3, 255 };
+static const u8 opt_type_processor[] = { 4, 255 };
+static const u8 opt_type_memory[] = { 5, 6, 16, 17, 255 };
+static const u8 opt_type_cache[] = { 7, 255 };
+static const u8 opt_type_connector[] = { 8, 255 };
+static const u8 opt_type_slot[] = { 9, 255 };
+
+static const struct type_keyword opt_type_keyword[] = {
{ "bios", opt_type_bios },
{ "system", opt_type_system },
{ "baseboard", opt_type_baseboard },
@@ -72,7 +72,7 @@ static void print_opt_type_list(void)
unsigned int i;
fprintf(stderr, "Valid type keywords are:\n");
- for(i=0; i<ARRAY_SIZE(opt_type_keyword); i++)
+ for (i = 0; i < ARRAY_SIZE(opt_type_keyword); i++)
{
fprintf(stderr, " %s\n", opt_type_keyword[i].keyword);
}
@@ -83,10 +83,10 @@ static u8 *parse_opt_type(u8 *p, const char *arg)
unsigned int i;
/* Allocate memory on first call only */
- if(p==NULL)
+ if (p == NULL)
{
- p=(u8 *)calloc(256, sizeof(u8));
- if(p==NULL)
+ p = (u8 *)calloc(256, sizeof(u8));
+ if (p == NULL)
{
perror("calloc");
return NULL;
@@ -94,39 +94,39 @@ static u8 *parse_opt_type(u8 *p, const char *arg)
}
/* First try as a keyword */
- for(i=0; i<ARRAY_SIZE(opt_type_keyword); i++)
+ for (i = 0; i < ARRAY_SIZE(opt_type_keyword); i++)
{
- if(!strcasecmp(arg, opt_type_keyword[i].keyword))
+ if (!strcasecmp(arg, opt_type_keyword[i].keyword))
{
- int j=0;
- while(opt_type_keyword[i].type[j]!=255)
- p[opt_type_keyword[i].type[j++]]=1;
+ int j = 0;
+ while (opt_type_keyword[i].type[j] != 255)
+ p[opt_type_keyword[i].type[j++]] = 1;
goto found;
}
}
/* Else try as a number */
- while(*arg!='\0')
+ while (*arg != '\0')
{
unsigned long val;
char *next;
- val=strtoul(arg, &next, 0);
- if(next==arg)
+ val = strtoul(arg, &next, 0);
+ if (next == arg)
{
fprintf(stderr, "Invalid type keyword: %s\n", arg);
print_opt_type_list();
goto exit_free;
}
- if(val>0xff)
+ if (val > 0xff)
{
fprintf(stderr, "Invalid type number: %lu\n", val);
goto exit_free;
}
- p[val]=1;
- arg=next;
- while(*arg==',' || *arg==' ')
+ p[val] = 1;
+ arg = next;
+ while (*arg == ',' || *arg == ' ')
arg++;
}
@@ -146,7 +146,7 @@ exit_free:
/* This lookup table could admittedly be reworked for improved performance.
Due to the low count of items in there at the moment, it did not seem
worth the additional code complexity though. */
-static const struct string_keyword opt_string_keyword[]={
+static const struct string_keyword opt_string_keyword[] = {
{ "bios-vendor", 0, 0x04, NULL, NULL },
{ "bios-version", 0, 0x05, NULL, NULL },
{ "bios-release-date", 0, 0x08, NULL, NULL },
@@ -176,7 +176,7 @@ static void print_opt_string_list(void)
unsigned int i;
fprintf(stderr, "Valid string keywords are:\n");
- for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++)
+ for (i = 0; i<ARRAY_SIZE(opt_string_keyword); i++)
{
fprintf(stderr, " %s\n", opt_string_keyword[i].keyword);
}
@@ -186,17 +186,17 @@ static int parse_opt_string(const char *arg)
{
unsigned int i;
- if(opt.string)
+ if (opt.string)
{
fprintf(stderr, "Only one string can be specified\n");
return -1;
}
- for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++)
+ for (i = 0; i < ARRAY_SIZE(opt_string_keyword); i++)
{
- if(!strcasecmp(arg, opt_string_keyword[i].keyword))
+ if (!strcasecmp(arg, opt_string_keyword[i].keyword))
{
- opt.string=&opt_string_keyword[i];
+ opt.string = &opt_string_keyword[i];
return 0;
}
}
@@ -216,7 +216,7 @@ int parse_command_line(int argc, char * const argv[])
{
int option;
const char *optstring = "d:hqs:t:uV";
- struct option longopts[]={
+ struct option longopts[] = {
{ "dev-mem", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "quiet", no_argument, NULL, 'q' },
@@ -229,44 +229,44 @@ int parse_command_line(int argc, char * const argv[])
{ 0, 0, 0, 0 }
};
- while((option=getopt_long(argc, argv, optstring, longopts, NULL))!=-1)
- switch(option)
+ while ((option = getopt_long(argc, argv, optstring, longopts, NULL)) != -1)
+ switch (option)
{
case 'B':
- opt.flags|=FLAG_DUMP_BIN;
- opt.dumpfile=optarg;
+ opt.flags |= FLAG_DUMP_BIN;
+ opt.dumpfile = optarg;
break;
case 'F':
- opt.flags|=FLAG_FROM_DUMP;
- opt.dumpfile=optarg;
+ opt.flags |= FLAG_FROM_DUMP;
+ opt.dumpfile = optarg;
break;
case 'd':
- opt.devmem=optarg;
+ opt.devmem = optarg;
break;
case 'h':
- opt.flags|=FLAG_HELP;
+ opt.flags |= FLAG_HELP;
break;
case 'q':
- opt.flags|=FLAG_QUIET;
+ opt.flags |= FLAG_QUIET;
break;
case 's':
- if(parse_opt_string(optarg)<0)
+ if (parse_opt_string(optarg) < 0)
return -1;
- opt.flags|=FLAG_QUIET;
+ opt.flags |= FLAG_QUIET;
break;
case 't':
- opt.type=parse_opt_type(opt.type, optarg);
- if(opt.type==NULL)
+ opt.type = parse_opt_type(opt.type, optarg);
+ if (opt.type == NULL)
return -1;
break;
case 'u':
- opt.flags|=FLAG_DUMP;
+ opt.flags |= FLAG_DUMP;
break;
case 'V':
- opt.flags|=FLAG_VERSION;
+ opt.flags |= FLAG_VERSION;
break;
case '?':
- switch(optopt)
+ switch (optopt)
{
case 's':
fprintf(stderr, "String keyword expected\n");
@@ -281,16 +281,16 @@ int parse_command_line(int argc, char * const argv[])
}
/* Check for mutually exclusive output format options */
- if((opt.string!=NULL)+(opt.type!=NULL)
- +!!(opt.flags & FLAG_DUMP)+!!(opt.flags & FLAG_DUMP_BIN)>1)
+ if ((opt.string != NULL) + (opt.type != NULL)
+ + !!(opt.flags & FLAG_DUMP) + !!(opt.flags & FLAG_DUMP_BIN) > 1)
{
fprintf(stderr, "Options --string, --type, --dump and --dump-bin are mutually exclusive\n");
return -1;
}
- if(opt.flags & (FLAG_DUMP | FLAG_DUMP_BIN))
- opt.flags&=~FLAG_QUIET;
+ if (opt.flags & (FLAG_DUMP | FLAG_DUMP_BIN))
+ opt.flags &= ~FLAG_QUIET;
- if((opt.flags & FLAG_FROM_DUMP) && (opt.flags & FLAG_DUMP_BIN))
+ 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;
@@ -301,7 +301,7 @@ int parse_command_line(int argc, char * const argv[])
void print_help(void)
{
- static const char *help=
+ static const char *help =
"Usage: dmidecode [OPTIONS]\n"
"Options are:\n"
" -d, --dev-mem FILE Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"
diff --git a/dmiopt.h b/dmiopt.h
index ac0f897..e821509 100644
--- a/dmiopt.h
+++ b/dmiopt.h
@@ -30,7 +30,7 @@ struct string_keyword
struct opt
{
- const char* devmem;
+ const char *devmem;
unsigned int flags;
u8 *type;
const struct string_keyword *string;
@@ -38,12 +38,12 @@ struct opt
};
extern struct opt opt;
-#define FLAG_VERSION (1<<0)
-#define FLAG_HELP (1<<1)
-#define FLAG_DUMP (1<<2)
-#define FLAG_QUIET (1<<3)
-#define FLAG_DUMP_BIN (1<<4)
-#define FLAG_FROM_DUMP (1<<5)
+#define FLAG_VERSION (1 << 0)
+#define FLAG_HELP (1 << 1)
+#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);
diff --git a/ownership.c b/ownership.c
index 8dfb461..901cbf4 100644
--- a/ownership.c
+++ b/ownership.c
@@ -43,13 +43,13 @@
/* Options are global */
struct opt
{
- const char* devmem;
+ const char *devmem;
unsigned int flags;
};
static struct opt opt;
-#define FLAG_VERSION (1<<0)
-#define FLAG_HELP (1<<1)
+#define FLAG_VERSION (1 << 0)
+#define FLAG_HELP (1 << 1)
static void ownership(u32 base, const char *pname, const char *devmem)
{
@@ -57,25 +57,25 @@ static void ownership(u32 base, const char *pname, const char *devmem)
int i;
/* read the ownership tag */
- if((buf=mem_chunk(base, 0x51, devmem))==NULL)
+ if ((buf = mem_chunk(base, 0x51, devmem)) == NULL)
{
perror(pname);
return;
}
/* chop the trailing garbage */
- i=0x4f;
- while(i>=0 && (buf[i]==0x20 || buf[i]==0x00))
+ i = 0x4f;
+ while (i >= 0 && (buf[i] == 0x20 || buf[i] == 0x00))
i--;
- buf[i+1]='\0';
+ buf[i + 1] = '\0';
/* filter and print */
- if(i>=0)
+ if (i >= 0)
{
- for(; i>=0; i--)
+ for (; i >= 0; i--)
{
- if(buf[i]<32 || (buf[i]>=127 && buf[i]<160))
- buf[i]='?';
+ if (buf[i] < 32 || (buf[i] >= 127 && buf[i] < 160))
+ buf[i] = '?';
}
printf("%s\n", (char *)buf);
}
@@ -88,22 +88,24 @@ static u32 decode(const u8 *p)
int i;
/* integrity checking (lack of checksum) */
- for(i=0; i<p[4]; i++)
+ for (i = 0; i < p[4]; i++)
{
- if(p[5+i*10]!='$' || !(p[6+i*10]>='A' && p[6+i*10]<='Z')
- || !(p[7+i*10]>='A' && p[7+i*10]<='Z')
- || !(p[8+i*10]>='A' && p[8+i*10]<='Z'))
+ if (p[5 + i * 10] != '$'
+ || !(p[6 + i * 10] >= 'A' && p[6 + i * 10] <= 'Z')
+ || !(p[7 + i * 10] >= 'A' && p[7 + i * 10] <= 'Z')
+ || !(p[8 + i * 10] >= 'A' && p[8 + i * 10] <= 'Z'))
{
printf("\t Abnormal Entry! Please report. [%02x %02x %02x %02x]\n",
- p[5+i*10], p[6+i*10], p[7+i*10], p[8+i*10]);
+ p[5 + i * 10], p[6 + i * 10],
+ p[7 + i * 10], p[8 + i * 10]);
return 0;
}
}
/* search for the right entry */
- for(i=0; i<p[4]; i++)
- if(memcmp(p+5+i*10, "$ERB", 4)==0)
- return DWORD(p+9+i*10);
+ for (i = 0; i < p[4]; i++)
+ if (memcmp(p + 5 + i * 10, "$ERB", 4) == 0)
+ return DWORD(p + 9 + i * 10);
return 0;
}
@@ -120,17 +122,17 @@ static int parse_command_line(int argc, char * const argv[])
{ 0, 0, 0, 0 }
};
- while((option=getopt_long(argc, argv, optstring, longopts, NULL))!=-1)
- switch(option)
+ while ((option = getopt_long(argc, argv, optstring, longopts, NULL)) != -1)
+ switch (option)
{
case 'd':
- opt.devmem=optarg;
+ opt.devmem = optarg;
break;
case 'h':
- opt.flags|=FLAG_HELP;
+ opt.flags |= FLAG_HELP;
break;
case 'V':
- opt.flags|=FLAG_VERSION;
+ opt.flags |= FLAG_VERSION;
break;
case '?':
return -1;
@@ -141,7 +143,7 @@ static int parse_command_line(int argc, char * const argv[])
static void print_help(void)
{
- static const char *help=
+ static const char *help =
"Usage: ownership [OPTIONS]\n"
"Options are:\n"
" -d, --dev-mem FILE Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"
@@ -155,51 +157,51 @@ int main(int argc, char * const argv[])
{
u8 *buf;
off_t fp;
- int ok=0;
+ int ok = 0;
- if(sizeof(u8)!=1 || sizeof(u32)!=4)
+ if (sizeof(u8) != 1 || sizeof(u32) != 4)
{
fprintf(stderr, "%s: compiler incompatibility\n", argv[0]);
exit(255);
}
/* Set default option values */
- opt.devmem=DEFAULT_MEM_DEV;
- opt.flags=0;
+ opt.devmem = DEFAULT_MEM_DEV;
+ opt.flags = 0;
- if(parse_command_line(argc, argv)<0)
+ if (parse_command_line(argc, argv)<0)
exit(2);
- if(opt.flags & FLAG_HELP)
+ if (opt.flags & FLAG_HELP)
{
print_help();
return 0;
}
- if(opt.flags & FLAG_VERSION)
+ if (opt.flags & FLAG_VERSION)
{
printf("%s\n", VERSION);
return 0;
}
- if((buf=mem_chunk(0xE0000, 0x20000, opt.devmem))==NULL)
+ if ((buf = mem_chunk(0xE0000, 0x20000, opt.devmem)) == NULL)
exit(1);
- for(fp=0; !ok && fp<=0x1FFF0; fp+=16)
+ for (fp = 0; !ok && fp <= 0x1FFF0; fp += 16)
{
- u8 *p=buf+fp;
+ u8 *p = buf + fp;
- if(memcmp((char *)p, "32OS", 4)==0)
+ if (memcmp((char *)p, "32OS", 4) == 0)
{
- off_t len=p[4]*10+5;
+ off_t len = p[4] * 10 + 5;
- if(fp+len-1<=0x1FFFF)
+ if (fp + len - 1 <= 0x1FFFF)
{
u32 base;
- if((base=decode(p)))
+ if ((base = decode(p)))
{
- ok=1;
+ ok = 1;
ownership(base, argv[0], opt.devmem);
}
}
diff --git a/types.h b/types.h
index fd008b8..19d803d 100644
--- a/types.h
+++ b/types.h
@@ -36,8 +36,8 @@ static inline u64 U64(u32 low, u32 high)
{
u64 self;
- self.l=low;
- self.h=high;
+ self.l = low;
+ self.h = high;
return self;
}
@@ -45,13 +45,13 @@ static inline u64 U64(u32 low, u32 high)
#ifdef ALIGNMENT_WORKAROUND
# ifdef BIGENDIAN
-# define WORD(x) (u16)((x)[1]+((x)[0]<<8))
-# define DWORD(x) (u32)((x)[3]+((x)[2]<<8)+((x)[1]<<16)+((x)[0]<<24))
-# define QWORD(x) (U64(DWORD(x+4), DWORD(x)))
+# define WORD(x) (u16)((x)[1] + ((x)[0] << 8))
+# define DWORD(x) (u32)((x)[3] + ((x)[2] << 8) + ((x)[1] << 16) + ((x)[0] << 24))
+# define QWORD(x) (U64(DWORD(x + 4), DWORD(x)))
# else /* BIGENDIAN */
-# define WORD(x) (u16)((x)[0]+((x)[1]<<8))
-# define DWORD(x) (u32)((x)[0]+((x)[1]<<8)+((x)[2]<<16)+((x)[3]<<24))
-# define QWORD(x) (U64(DWORD(x), DWORD(x+4)))
+# define WORD(x) (u16)((x)[0] + ((x)[1] << 8))
+# define DWORD(x) (u32)((x)[0] + ((x)[1] << 8) + ((x)[2] << 16) + ((x)[3] << 24))
+# define QWORD(x) (U64(DWORD(x), DWORD(x + 4)))
# endif /* BIGENDIAN */
#else /* ALIGNMENT_WORKAROUND */
#define WORD(x) (u16)(*(const u16 *)(x))
diff --git a/util.c b/util.c
index 241de10..dfdc028 100644
--- a/util.c
+++ b/util.c
@@ -50,15 +50,15 @@
#ifndef USE_MMAP
static int myread(int fd, u8 *buf, size_t count, const char *prefix)
{
- ssize_t r=1;
- size_t r2=0;
+ ssize_t r = 1;
+ size_t r2 = 0;
- while(r2!=count && r!=0)
+ while (r2 != count && r != 0)
{
- r=read(fd, buf+r2, count-r2);
- if(r==-1)
+ r = read(fd, buf + r2, count - r2);
+ if (r == -1)
{
- if(errno!=EINTR)
+ if (errno != EINTR)
{
close(fd);
perror(prefix);
@@ -66,10 +66,10 @@ static int myread(int fd, u8 *buf, size_t count, const char *prefix)
}
}
else
- r2+=r;
+ r2 += r;
}
- if(r2!=count)
+ if (r2 != count)
{
close(fd);
fprintf(stderr, "%s: Unexpected end of file\n", prefix);
@@ -82,12 +82,12 @@ static int myread(int fd, u8 *buf, size_t count, const char *prefix)
int checksum(const u8 *buf, size_t len)
{
- u8 sum=0;
+ u8 sum = 0;
size_t a;
- for(a=0; a<len; a++)
- sum+=buf[a];
- return (sum==0);
+ for (a = 0; a < len; a++)
+ sum += buf[a];
+ return (sum == 0);
}
/*
@@ -103,13 +103,13 @@ void *mem_chunk(size_t base, size_t len, const char *devmem)
void *mmp;
#endif
- if((fd=open(devmem, O_RDONLY))==-1)
+ if ((fd = open(devmem, O_RDONLY)) == -1)
{
perror(devmem);
return NULL;
}
- if((p=malloc(len))==NULL)
+ if ((p = malloc(len)) == NULL)
{
perror("malloc");
return NULL;
@@ -117,17 +117,17 @@ void *mem_chunk(size_t base, size_t len, const char *devmem)
#ifdef USE_MMAP
#ifdef _SC_PAGESIZE
- mmoffset=base%sysconf(_SC_PAGESIZE);
+ mmoffset = base % sysconf(_SC_PAGESIZE);
#else
- mmoffset=base%getpagesize();
+ mmoffset = base % getpagesize();
#endif /* _SC_PAGESIZE */
/*
* Please note that we don't use mmap() for performance reasons here,
* but to workaround problems many people encountered when trying
* to read from /dev/mem using regular read() calls.
*/
- mmp=mmap(0, mmoffset+len, PROT_READ, MAP_SHARED, fd, base-mmoffset);
- if(mmp==MAP_FAILED)
+ mmp = mmap(0, mmoffset + len, PROT_READ, MAP_SHARED, fd, base - mmoffset);
+ if (mmp == MAP_FAILED)
{
fprintf(stderr, "%s: ", devmem);
perror("mmap");
@@ -135,15 +135,15 @@ void *mem_chunk(size_t base, size_t len, const char *devmem)
return NULL;
}
- memcpy(p, (u8 *)mmp+mmoffset, len);
+ memcpy(p, (u8 *)mmp + mmoffset, len);
- if(munmap(mmp, mmoffset+len)==-1)
+ if (munmap(mmp, mmoffset + len) == -1)
{
fprintf(stderr, "%s: ", devmem);
perror("munmap");
}
#else /* USE_MMAP */
- if(lseek(fd, base, SEEK_SET)==-1)
+ if (lseek(fd, base, SEEK_SET) == -1)
{
fprintf(stderr, "%s: ", devmem);
perror("lseek");
@@ -151,14 +151,14 @@ void *mem_chunk(size_t base, size_t len, const char *devmem)
return NULL;
}
- if(myread(fd, p, len, devmem)==-1)
+ if (myread(fd, p, len, devmem) == -1)
{
free(p);
return NULL;
}
#endif /* USE_MMAP */
- if(close(fd)==-1)
+ if (close(fd) == -1)
perror(devmem);
return p;
@@ -169,30 +169,30 @@ int write_dump(size_t base, size_t len, const void *data, const char *dumpfile)
FILE *f;
f=fopen(dumpfile, "r+b");
- if(!f && errno==ENOENT)
- f=fopen(dumpfile, "wb");
- if(!f)
+ if (!f && errno == ENOENT)
+ f = fopen(dumpfile, "wb");
+ if (!f)
{
fprintf(stderr, "%s: ", dumpfile);
perror("fopen");
return -1;
}
- if(fseek(f, base, SEEK_SET)!=0)
+ if (fseek(f, base, SEEK_SET) != 0)
{
fprintf(stderr, "%s: ", dumpfile);
perror("fseek");
goto err_close;
}
- if(fwrite(data, len, 1, f)!=1)
+ if (fwrite(data, len, 1, f) != 1)
{
fprintf(stderr, "%s: ", dumpfile);
perror("fwrite");
goto err_close;
}
- if(fclose(f))
+ if (fclose(f))
{
fprintf(stderr, "%s: ", dumpfile);
perror("fclose");
diff --git a/vpddecode.c b/vpddecode.c
index d090c74..18727a8 100644
--- a/vpddecode.c
+++ b/vpddecode.c
@@ -48,14 +48,14 @@ static void print_entry(const char *name, const u8 *p, size_t len)
{
size_t i;
- if(name!=NULL)
+ if (name != NULL)
printf("%s: ", name);
- for(i=0; i<len; i++)
+ for (i = 0; i < len; i++)
{
/* ASCII filtering */
- if(p[i]>=32 && p[i]<127)
+ if (p[i] >= 32 && p[i] < 127)
printf("%c", p[i]);
- else if(p[i]!=0)
+ else if (p[i] != 0)
printf(".");
}
printf("\n");
@@ -65,66 +65,66 @@ static void dump(const u8 *p, u8 len)
{
int done, i, min;
- for(done=0; done<len; done+=16)
+ for (done = 0; done < len; done += 16)
{
printf("%02X:", done);
- min=(len-done<16)?len-done:16;
+ min = (len - done < 16) ? len - done : 16;
/* As hexadecimal first */
- for(i=0; i<min; i++)
- printf(" %02X", p[done+i]);
- for(; i<16; i++) /* Complete line if needed */
+ for (i = 0; i < min; i++)
+ printf(" %02X", p[done + i]);
+ for (; i < 16; i++) /* Complete line if needed */
printf(" ");
printf(" ");
/* And now as text, with ASCII filtering */
- for(i=0; i<min; i++)
- printf("%c", (p[done+i]>=32 && p[done+i]<127)?
- p[done+i]:'.');
+ for (i = 0; i < min; i++)
+ printf("%c", (p[done + i] >= 32 && p[done + i] < 127) ?
+ p[done + i] : '.');
printf("\n");
}
}
static int decode(const u8 *p)
{
- if(p[5]<0x30)
+ if (p[5] < 0x30)
return 0;
/* XSeries have longer records, exact length seems to vary. */
- if(!(p[5]>=0x45 && checksum(p, p[5]))
+ if (!(p[5] >= 0x45 && checksum(p, p[5]))
/* Some Netvista seem to work with this. */
- && !(checksum(p, 0x30))
+ && !(checksum(p, 0x30))
/* The Thinkpad/Thinkcentre checksum does *not* include the first
13 bytes. */
- && !(checksum(p+0x0D, 0x30-0x0D)))
+ && !(checksum(p + 0x0D, 0x30 - 0x0D)))
{
/* A few systems have a bad checksum (xSeries 325, 330, 335
and 345 with early BIOS) but the record is otherwise
valid. */
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
printf("# Bad checksum!\n");
}
- if(opt.string!=NULL)
+ if (opt.string != NULL)
{
- if(opt.string->offset+opt.string->len<p[5])
- print_entry(NULL, p+opt.string->offset,
+ if (opt.string->offset + opt.string->len < p[5])
+ print_entry(NULL, p + opt.string->offset,
opt.string->len);
return 1;
}
- print_entry("BIOS Build ID", p+0x0D, 9);
- print_entry("Box Serial Number", p+0x16, 7);
- print_entry("Motherboard Serial Number", p+0x1D, 11);
- print_entry("Machine Type/Model", p+0x28, 7);
+ print_entry("BIOS Build ID", p + 0x0D, 9);
+ print_entry("Box Serial Number", p + 0x16, 7);
+ print_entry("Motherboard Serial Number", p + 0x1D, 11);
+ print_entry("Machine Type/Model", p + 0x28, 7);
- if(p[5]<0x44)
+ if (p[5] < 0x44)
return 1;
- print_entry("BIOS Release Date", p+0x30, 8);
- print_entry("Default Flash Image File Name", p+0x38, 12);
+ print_entry("BIOS Release Date", p + 0x30, 8);
+ print_entry("Default Flash Image File Name", p + 0x38, 12);
- if(p[5]>=0x46 && p[0x44]!=0x00)
+ if (p[5] >= 0x46 && p[0x44] != 0x00)
{
printf("%s: %u\n", "BIOS Revision", p[0x44]);
}
@@ -138,55 +138,55 @@ int main(int argc, char * const argv[])
int found=0;
unsigned int fp;
- if(sizeof(u8)!=1)
+ if (sizeof(u8) != 1)
{
fprintf(stderr, "%s: compiler incompatibility\n", argv[0]);
exit(255);
}
/* Set default option values */
- opt.devmem=DEFAULT_MEM_DEV;
- opt.flags=0;
+ opt.devmem = DEFAULT_MEM_DEV;
+ opt.flags = 0;
- if(parse_command_line(argc, argv)<0)
+ if (parse_command_line(argc, argv)<0)
exit(2);
- if(opt.flags & FLAG_HELP)
+ if (opt.flags & FLAG_HELP)
{
print_help();
return 0;
}
- if(opt.flags & FLAG_VERSION)
+ if (opt.flags & FLAG_VERSION)
{
printf("%s\n", VERSION);
return 0;
}
- if(!(opt.flags & FLAG_QUIET))
+ if (!(opt.flags & FLAG_QUIET))
printf("# vpddecode %s\n", VERSION);
- if((buf=mem_chunk(0xF0000, 0x10000, opt.devmem))==NULL)
+ if ((buf = mem_chunk(0xF0000, 0x10000, opt.devmem)) == NULL)
exit(1);
- for(fp=0; fp<=0xFFF0; fp+=4)
+ for (fp = 0; fp <= 0xFFF0; fp += 4)
{
- u8 *p=buf+fp;
+ u8 *p = buf + fp;
- if(memcmp((char *)p, "\252\125VPD", 5)==0
- && fp+p[5]-1<=0xFFFF)
+ if (memcmp((char *)p, "\252\125VPD", 5) == 0
+ && fp + p[5] - 1 <= 0xFFFF)
{
- if(fp%16 && !(opt.flags & FLAG_QUIET))
+ if (fp % 16 && !(opt.flags & FLAG_QUIET))
printf("# Unaligned address (%#x)\n",
- 0xf0000+fp);
- if(opt.flags & FLAG_DUMP)
+ 0xf0000 + fp);
+ if (opt.flags & FLAG_DUMP)
{
dump(p, p[5]);
found++;
}
else
{
- if(decode(p))
+ if (decode(p))
found++;
}
}
@@ -194,7 +194,7 @@ int main(int argc, char * const argv[])
free(buf);
- if(!found && !(opt.flags && FLAG_QUIET))
+ if (!found && !(opt.flags && FLAG_QUIET))
printf("# No VPD structure found, sorry.\n");
return 0;
diff --git a/vpdopt.c b/vpdopt.c
index 11cbcb8..021ade2 100644
--- a/vpdopt.c
+++ b/vpdopt.c
@@ -40,7 +40,7 @@ struct opt opt;
/* This lookup table could admittedly be reworked for improved performance.
Due to the low count of items in there at the moment, it did not seem
worth the additional code complexity though. */
-static const struct string_keyword opt_string_keyword[]={
+static const struct string_keyword opt_string_keyword[] = {
{ "bios-build-id", 0x0D, 9 },
{ "box-serial-number", 0x16, 7 },
{ "motherboard-serial-number", 0x1D, 11 },
@@ -53,7 +53,7 @@ static void print_opt_string_list(void)
unsigned int i;
fprintf(stderr, "Valid string keywords are:\n");
- for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++)
+ for (i = 0; i < ARRAY_SIZE(opt_string_keyword); i++)
{
fprintf(stderr, " %s\n", opt_string_keyword[i].keyword);
}
@@ -63,17 +63,17 @@ static int parse_opt_string(const char *arg)
{
unsigned int i;
- if(opt.string)
+ if (opt.string)
{
fprintf(stderr, "Only one string can be specified\n");
return -1;
}
- for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++)
+ for (i = 0; i<ARRAY_SIZE(opt_string_keyword); i++)
{
- if(!strcasecmp(arg, opt_string_keyword[i].keyword))
+ if (!strcasecmp(arg, opt_string_keyword[i].keyword))
{
- opt.string=&opt_string_keyword[i];
+ opt.string = &opt_string_keyword[i];
return 0;
}
}
@@ -93,7 +93,7 @@ int parse_command_line(int argc, char * const argv[])
{
int option;
const char *optstring = "d:hs:uV";
- struct option longopts[]={
+ struct option longopts[] = {
{ "dev-mem", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "string", required_argument, NULL, 's' },
@@ -102,28 +102,28 @@ int parse_command_line(int argc, char * const argv[])
{ 0, 0, 0, 0 }
};
- while((option=getopt_long(argc, argv, optstring, longopts, NULL))!=-1)
- switch(option)
+ while ((option = getopt_long(argc, argv, optstring, longopts, NULL)) != -1)
+ switch (option)
{
case 'd':
- opt.devmem=optarg;
+ opt.devmem = optarg;
break;
case 'h':
- opt.flags|=FLAG_HELP;
+ opt.flags |= FLAG_HELP;
break;
case 's':
- if(parse_opt_string(optarg)<0)
+ if (parse_opt_string(optarg) < 0)
return -1;
- opt.flags|=FLAG_QUIET;
+ opt.flags |= FLAG_QUIET;
break;
case 'u':
- opt.flags|=FLAG_DUMP;
+ opt.flags |= FLAG_DUMP;
break;
case 'V':
- opt.flags|=FLAG_VERSION;
+ opt.flags |= FLAG_VERSION;
break;
case '?':
- switch(optopt)
+ switch (optopt)
{
case 's':
fprintf(stderr, "String keyword expected\n");
@@ -133,7 +133,7 @@ int parse_command_line(int argc, char * const argv[])
return -1;
}
- if((opt.flags & FLAG_DUMP) && opt.string!=NULL)
+ if ((opt.flags & FLAG_DUMP) && opt.string != NULL)
{
fprintf(stderr, "Options --string and --dump are mutually exclusive\n");
return -1;
@@ -144,7 +144,7 @@ int parse_command_line(int argc, char * const argv[])
void print_help(void)
{
- static const char *help=
+ static const char *help =
"Usage: vpddecode [OPTIONS]\n"
"Options are:\n"
" -d, --dev-mem FILE Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"
diff --git a/vpdopt.h b/vpdopt.h
index 205b272..fceb552 100644
--- a/vpdopt.h
+++ b/vpdopt.h
@@ -30,16 +30,16 @@ struct string_keyword
struct opt
{
- const char* devmem;
+ const char *devmem;
unsigned int flags;
const struct string_keyword *string;
};
extern struct opt opt;
-#define FLAG_VERSION (1<<0)
-#define FLAG_HELP (1<<1)
-#define FLAG_DUMP (1<<2)
-#define FLAG_QUIET (1<<3)
+#define FLAG_VERSION (1 << 0)
+#define FLAG_HELP (1 << 1)
+#define FLAG_DUMP (1 << 2)
+#define FLAG_QUIET (1 << 3)
int parse_command_line(int argc, char * const argv[]);
void print_help(void);