|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* BIOS Decode
|
|
Packit Service |
e18529 |
*
|
|
Packit Service |
e18529 |
* Copyright (C) 2000-2002 Alan Cox <alan@redhat.com>
|
|
Packit Service |
e18529 |
* Copyright (C) 2002-2017 Jean Delvare <jdelvare@suse.de>
|
|
Packit Service |
e18529 |
*
|
|
Packit Service |
e18529 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
e18529 |
* it under the terms of the GNU General Public License as published by
|
|
Packit Service |
e18529 |
* the Free Software Foundation; either version 2 of the License, or
|
|
Packit Service |
e18529 |
* (at your option) any later version.
|
|
Packit Service |
e18529 |
*
|
|
Packit Service |
e18529 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
e18529 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
e18529 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
e18529 |
* GNU General Public License for more details.
|
|
Packit Service |
e18529 |
*
|
|
Packit Service |
e18529 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
e18529 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
e18529 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
Packit Service |
e18529 |
*
|
|
Packit Service |
e18529 |
* For the avoidance of doubt the "preferred form" of this code is one which
|
|
Packit Service |
e18529 |
* is in an open unpatent encumbered format. Where cryptographic key signing
|
|
Packit Service |
e18529 |
* forms part of the process of creating an executable the information
|
|
Packit Service |
e18529 |
* including keys needed to generate an equivalently functional executable
|
|
Packit Service |
e18529 |
* are deemed to be part of the source code.
|
|
Packit Service |
e18529 |
*
|
|
Packit Service |
e18529 |
* References:
|
|
Packit Service |
e18529 |
* - DMTF "System Management BIOS (SMBIOS) Reference Specification"
|
|
Packit Service |
e18529 |
* Version 3.0.0
|
|
Packit Service |
e18529 |
* http://www.dmtf.org/standards/smbios
|
|
Packit Service |
e18529 |
* - Intel "Preboot Execution Environment (PXE) Specification"
|
|
Packit Service |
e18529 |
* Version 2.1
|
|
Packit Service |
e18529 |
* http://www.intel.com/labs/manage/wfm/wfmspecs.htm
|
|
Packit Service |
e18529 |
* - ACPI "Advanced Configuration and Power Interface Specification"
|
|
Packit Service |
e18529 |
* Revision 2.0
|
|
Packit Service |
e18529 |
* http://www.acpi.info/spec20.htm
|
|
Packit Service |
e18529 |
* - Phoenix "BIOS32 Service Directory"
|
|
Packit Service |
e18529 |
* Revision 0.4
|
|
Packit Service |
e18529 |
* http://www.phoenix.com/en/support/white+papers-specs/
|
|
Packit Service |
e18529 |
* - Microsoft "Plug and Play BIOS Specification"
|
|
Packit Service |
e18529 |
* Version 1.0A
|
|
Packit Service |
e18529 |
* http://www.microsoft.com/hwdev/tech/PnP/
|
|
Packit Service |
e18529 |
* - Microsoft "PCI IRQ Routing Table Specification"
|
|
Packit Service |
e18529 |
* Version 1.0
|
|
Packit Service |
e18529 |
* http://www.microsoft.com/hwdev/archive/BUSBIOS/pciirq.asp
|
|
Packit Service |
e18529 |
* - Compaq "Technical Reference Guide for Compaq Deskpro 4000 and 6000"
|
|
Packit Service |
e18529 |
* First Edition
|
|
Packit Service |
e18529 |
* http://h18000.www1.hp.com/support/techpubs/technical_reference_guides/113a1097.html
|
|
Packit Service |
e18529 |
* - IBM "Using the BIOS Build ID to identify Thinkpad systems"
|
|
Packit Service |
e18529 |
* Revision 2005-09-19
|
|
Packit Service |
e18529 |
* http://www-307.ibm.com/pc/support/site.wss/MIGR-45120.html
|
|
Packit Service |
e18529 |
* - Fujitsu application panel technical details
|
|
Packit Service |
e18529 |
* As of July 23rd, 2004
|
|
Packit Service |
e18529 |
* http://apanel.sourceforge.net/tech.php
|
|
Packit Service |
e18529 |
* - Intel Multiprocessor Specification
|
|
Packit Service |
e18529 |
* Version 1.4
|
|
Packit Service |
e18529 |
* http://www.intel.com/design/archives/processors/pro/docs/242016.htm
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
#include <stdio.h>
|
|
Packit Service |
e18529 |
#include <string.h>
|
|
Packit Service |
e18529 |
#include <stdlib.h>
|
|
Packit Service |
e18529 |
#include <unistd.h>
|
|
Packit Service |
e18529 |
#include <getopt.h>
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
#include "version.h"
|
|
Packit Service |
e18529 |
#include "config.h"
|
|
Packit Service |
e18529 |
#include "types.h"
|
|
Packit Service |
e18529 |
#include "util.h"
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/* Options are global */
|
|
Packit Service |
e18529 |
struct opt
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
const char *devmem;
|
|
Packit Service |
e18529 |
unsigned int flags;
|
|
Packit Service |
e18529 |
unsigned char pir;
|
|
Packit Service |
e18529 |
};
|
|
Packit Service |
e18529 |
static struct opt opt;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
#define FLAG_VERSION (1 << 0)
|
|
Packit Service |
e18529 |
#define FLAG_HELP (1 << 1)
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
#define PIR_SHORT 0
|
|
Packit Service |
e18529 |
#define PIR_FULL 1
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
struct bios_entry {
|
|
Packit Service |
e18529 |
const char *anchor;
|
|
Packit Service |
e18529 |
size_t anchor_len; /* computed */
|
|
Packit Service |
e18529 |
off_t low_address;
|
|
Packit Service |
e18529 |
off_t high_address;
|
|
Packit Service |
e18529 |
size_t (*length)(const u8 *);
|
|
Packit Service |
e18529 |
int (*decode)(const u8*, size_t);
|
|
Packit Service |
e18529 |
};
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* SMBIOS
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t smbios3_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return p[0x06];
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int smbios3_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (len < 0x18 || !checksum(p, p[0x06]))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("SMBIOS %u.%u.%u present.\n",
|
|
Packit Service |
e18529 |
p[0x07], p[0x08], p[0x09]);
|
|
Packit Service |
e18529 |
printf("\tStructure Table Maximum Length: %u bytes\n",
|
|
Packit Service |
e18529 |
DWORD(p + 0x0C));
|
|
Packit Service |
e18529 |
printf("\tStructure Table 64-bit Address: 0x%08X%08X\n",
|
|
Packit Service |
e18529 |
QWORD(p + 0x10).h, QWORD(p + 0x10).l);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t smbios_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return p[0x05] == 0x1E ? 0x1F : p[0x05];
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int smbios_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (len < 0x1F || !checksum(p, p[0x05])
|
|
Packit Service |
e18529 |
|| memcmp("_DMI_", p + 0x10, 5) != 0
|
|
Packit Service |
e18529 |
|| !checksum(p + 0x10, 0x0F))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("SMBIOS %u.%u present.\n",
|
|
Packit Service |
e18529 |
p[0x06], p[0x07]);
|
|
Packit Service |
e18529 |
printf("\tStructure Table Length: %u bytes\n",
|
|
Packit Service |
e18529 |
WORD(p + 0x16));
|
|
Packit Service |
e18529 |
printf("\tStructure Table Address: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 0x18));
|
|
Packit Service |
e18529 |
printf("\tNumber Of Structures: %u\n",
|
|
Packit Service |
e18529 |
WORD(p + 0x1C));
|
|
Packit Service |
e18529 |
printf("\tMaximum Structure Size: %u bytes\n",
|
|
Packit Service |
e18529 |
WORD(p + 0x08));
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t dmi_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
(void) p;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 0x0F;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int dmi_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (len < 0x0F || !checksum(p, len))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("Legacy DMI %u.%u present.\n",
|
|
Packit Service |
e18529 |
p[0x0E]>>4, p[0x0E] & 0x0F);
|
|
Packit Service |
e18529 |
printf("\tStructure Table Length: %u bytes\n",
|
|
Packit Service |
e18529 |
WORD(p + 0x06));
|
|
Packit Service |
e18529 |
printf("\tStructure Table Address: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 0x08));
|
|
Packit Service |
e18529 |
printf("\tNumber Of Structures: %u\n",
|
|
Packit Service |
e18529 |
WORD(p + 0x0C));
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* SYSID
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t sysid_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return WORD(p + 0x08);
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int sysid_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (len < 0x11 || !checksum(p, WORD(p + 0x08)))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("SYSID present.\n");
|
|
Packit Service |
e18529 |
printf("\tRevision: %u\n",
|
|
Packit Service |
e18529 |
p[0x10]);
|
|
Packit Service |
e18529 |
printf("\tStructure Table Address: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 0x0A));
|
|
Packit Service |
e18529 |
printf("\tNumber Of Structures: %u\n",
|
|
Packit Service |
e18529 |
WORD(p + 0x0E));
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* PnP
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t pnp_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return p[0x05];
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static const char *pnp_event_notification(u8 code)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
static const char *notification[] = {
|
|
Packit Service |
e18529 |
"Not Supported", /* 0x0 */
|
|
Packit Service |
e18529 |
"Polling",
|
|
Packit Service |
e18529 |
"Asynchronous",
|
|
Packit Service |
e18529 |
"Unknown" /* 0x3 */
|
|
Packit Service |
e18529 |
};
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return notification[code];
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int pnp_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (len < 0x21 || !checksum(p, p[0x05]))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("PNP BIOS %u.%u present.\n",
|
|
Packit Service |
e18529 |
p[0x04] >> 4, p[0x04] & 0x0F);
|
|
Packit Service |
e18529 |
printf("\tEvent Notification: %s\n",
|
|
Packit Service |
e18529 |
pnp_event_notification(WORD(p + 0x06) & 0x03));
|
|
Packit Service |
e18529 |
if ((WORD(p + 0x06) & 0x03) == 0x01)
|
|
Packit Service |
e18529 |
printf("\tEvent Notification Flag Address: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 0x09));
|
|
Packit Service |
e18529 |
printf("\tReal Mode 16-bit Code Address: %04X:%04X\n",
|
|
Packit Service |
e18529 |
WORD(p + 0x0F), WORD(p + 0x0D));
|
|
Packit Service |
e18529 |
printf("\tReal Mode 16-bit Data Address: %04X:0000\n",
|
|
Packit Service |
e18529 |
WORD(p + 0x1B));
|
|
Packit Service |
e18529 |
printf("\t16-bit Protected Mode Code Address: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 0x13) + WORD(p + 0x11));
|
|
Packit Service |
e18529 |
printf("\t16-bit Protected Mode Data Address: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 0x1D));
|
|
Packit Service |
e18529 |
if (DWORD(p + 0x17) != 0)
|
|
Packit Service |
e18529 |
printf("\tOEM Device Identifier: %c%c%c%02X%02X\n",
|
|
Packit Service |
e18529 |
0x40 + ((p[0x17] >> 2) & 0x1F),
|
|
Packit Service |
e18529 |
0x40 + ((p[0x17] & 0x03) << 3) + ((p[0x18] >> 5) & 0x07),
|
|
Packit Service |
e18529 |
0x40 + (p[0x18] & 0x1F), p[0x19], p[0x20]);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* ACPI
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t acpi_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return p[15] == 2 ? 36 : 20;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static const char *acpi_revision(u8 code)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
switch (code)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
case 0:
|
|
Packit Service |
e18529 |
return " 1.0";
|
|
Packit Service |
e18529 |
case 2:
|
|
Packit Service |
e18529 |
return " 2.0";
|
|
Packit Service |
e18529 |
default:
|
|
Packit Service |
e18529 |
return "";
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int acpi_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (len < 20 || !checksum(p, 20))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("ACPI%s present.\n",
|
|
Packit Service |
e18529 |
acpi_revision(p[15]));
|
|
Packit Service |
e18529 |
printf("\tOEM Identifier: %c%c%c%c%c%c\n",
|
|
Packit Service |
e18529 |
p[9], p[10], p[11], p[12], p[13], p[14]);
|
|
Packit Service |
e18529 |
printf("\tRSD Table 32-bit Address: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 16));
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (len < 36)
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (DWORD(p + 20) > len || !checksum(p, DWORD(p + 20)))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (DWORD(p + 20) < 32) return 1;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("\tXSD Table 64-bit Address: 0x%08X%08X\n",
|
|
Packit Service |
e18529 |
QWORD(p + 24).h, QWORD(p + 24).l);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* Sony
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t sony_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return p[0x05];
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int sony_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (!checksum(p, len))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("Sony system detected.\n");
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* BIOS32
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t bios32_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return p[0x09] << 4;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int bios32_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (len < 0x0A || !checksum(p, p[0x09] << 4))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("BIOS32 Service Directory present.\n");
|
|
Packit Service |
e18529 |
printf("\tRevision: %u\n",
|
|
Packit Service |
e18529 |
p[0x08]);
|
|
Packit Service |
e18529 |
printf("\tCalling Interface Address: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 0x04));
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* PIR
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static void pir_irqs(u16 code)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (code == 0)
|
|
Packit Service |
e18529 |
printf(" None");
|
|
Packit Service |
e18529 |
else
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
u8 i;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
for (i = 0; i < 16; i++)
|
|
Packit Service |
e18529 |
if (code & (1 << i))
|
|
Packit Service |
e18529 |
printf(" %u", i);
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static void pir_slot_number(u8 code)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (code == 0)
|
|
Packit Service |
e18529 |
printf(" on-board");
|
|
Packit Service |
e18529 |
else
|
|
Packit Service |
e18529 |
printf(" slot %u", code);
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t pir_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return WORD(p + 6);
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static void pir_link_bitmap(char letter, const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (p[0] == 0) /* Not connected */
|
|
Packit Service |
e18529 |
return;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("\t\tINT%c#: Link 0x%02x, IRQ Bitmap", letter, p[0]);
|
|
Packit Service |
e18529 |
pir_irqs(WORD(p + 1));
|
|
Packit Service |
e18529 |
printf("\n");
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int pir_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
int i, n;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (len < 32 || !checksum(p, WORD(p + 6)))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("PCI Interrupt Routing %u.%u present.\n",
|
|
Packit Service |
e18529 |
p[5], p[4]);
|
|
Packit Service |
e18529 |
printf("\tRouter Device: %02x:%02x.%1x\n",
|
|
Packit Service |
e18529 |
p[8], p[9]>>3, p[9] & 0x07);
|
|
Packit Service |
e18529 |
printf("\tExclusive IRQs:");
|
|
Packit Service |
e18529 |
pir_irqs(WORD(p + 10));
|
|
Packit Service |
e18529 |
printf("\n");
|
|
Packit Service |
e18529 |
if (DWORD(p + 12) != 0)
|
|
Packit Service |
e18529 |
printf("\tCompatible Router: %04x:%04x\n",
|
|
Packit Service |
e18529 |
WORD(p + 12), WORD(p + 14));
|
|
Packit Service |
e18529 |
if (DWORD(p + 16) != 0)
|
|
Packit Service |
e18529 |
printf("\tMiniport Data: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 16));
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
n = (len - 32) / 16;
|
|
Packit Service |
e18529 |
for (i = 1, p += 32; i <= n; i++, p += 16)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
printf("\tDevice: %02x:%02x,", p[0], p[1] >> 3);
|
|
Packit Service |
e18529 |
pir_slot_number(p[14]);
|
|
Packit Service |
e18529 |
printf("\n");
|
|
Packit Service |
e18529 |
if (opt.pir == PIR_FULL)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
pir_link_bitmap('A', p + 2);
|
|
Packit Service |
e18529 |
pir_link_bitmap('B', p + 5);
|
|
Packit Service |
e18529 |
pir_link_bitmap('C', p + 8);
|
|
Packit Service |
e18529 |
pir_link_bitmap('D', p + 11);
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* Compaq-specific entries
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t compaq_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return p[4] * 10 + 5;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int compaq_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
unsigned int i;
|
|
Packit Service |
e18529 |
(void) len;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("Compaq-specific entries present.\n");
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/* integrity checking (lack of checksum) */
|
|
Packit Service |
e18529 |
for (i = 0; i < p[4]; i++)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* We do not check for truncated entries, because the length
|
|
Packit Service |
e18529 |
* was computed from the number of records in compaq_length
|
|
Packit Service |
e18529 |
* right above, so it can't be wrong.
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
if (p[5 + i * 10] != '$'
|
|
Packit Service |
e18529 |
|| !(p[6 + i * 10] >= 'A' && p[6 + i * 10] <= 'Z')
|
|
Packit Service |
e18529 |
|| !(p[7 + i * 10] >= 'A' && p[7 + i * 10] <= 'Z')
|
|
Packit Service |
e18529 |
|| !(p[8 + i * 10] >= 'A' && p[8 + i * 10] <= 'Z'))
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
printf("\t Abnormal entry! Please report. [%02X %02X "
|
|
Packit Service |
e18529 |
"%02X %02X]\n", p[5 + i * 10], p[6 + i * 10],
|
|
Packit Service |
e18529 |
p[7 + i * 10], p[8 + i * 10]);
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
for (i = 0; i < p[4]; i++)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
printf("\tEntry %u: %c%c%c%c at 0x%08X (%u bytes)\n",
|
|
Packit Service |
e18529 |
i + 1, p[5 + i * 10], p[6 + i * 10], p[7 + i * 10],
|
|
Packit Service |
e18529 |
p[8 + i * 10], DWORD(p + 9 + i * 10),
|
|
Packit Service |
e18529 |
WORD(p + 13 + i * 10));
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* VPD (vital product data, IBM-specific)
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static void vpd_print_entry(const char *name, const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
size_t i;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("\t%s: ", name);
|
|
Packit Service |
e18529 |
for (i = 0; i < len; i++)
|
|
Packit Service |
e18529 |
if (p[i] >= 32 && p[i] < 127)
|
|
Packit Service |
e18529 |
printf("%c", p[i]);
|
|
Packit Service |
e18529 |
printf("\n");
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t vpd_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return p[5];
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int vpd_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (len < 0x30)
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/* XSeries have longer records. */
|
|
Packit Service |
e18529 |
if (!(len >= 0x45 && checksum(p, len))
|
|
Packit Service |
e18529 |
/* Some Netvista seem to work with this. */
|
|
Packit Service |
e18529 |
&& !checksum(p, 0x30)
|
|
Packit Service |
e18529 |
/* The Thinkpad checksum does *not* include the first 13 bytes. */
|
|
Packit Service |
e18529 |
&& !checksum(p + 0x0D, 0x30 - 0x0D))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("VPD present.\n");
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
vpd_print_entry("BIOS Build ID", p + 0x0D, 9);
|
|
Packit Service |
e18529 |
vpd_print_entry("Box Serial Number", p + 0x16, 7);
|
|
Packit Service |
e18529 |
vpd_print_entry("Motherboard Serial Number", p + 0x1D, 11);
|
|
Packit Service |
e18529 |
vpd_print_entry("Machine Type/Model", p + 0x28, 7);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (len < 0x45)
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
vpd_print_entry("BIOS Release Date", p + 0x30, 8);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* Fujitsu application panel
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t fjkeyinf_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
(void) p;
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* We don't know at this point, it's somewhere between 12 and 32.
|
|
Packit Service |
e18529 |
* So we return the max, it shouldn't hurt.
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
return 32;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int fjkeyinf_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
int i;
|
|
Packit Service |
e18529 |
(void) len;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("Fujitsu application panel present.\n");
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
for (i = 0; i < 6; i++)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (*(p + 8 + i * 4) == 0)
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
printf("\tDevice %d: type %u, chip %u", i + 1,
|
|
Packit Service |
e18529 |
*(p + 8 + i * 4), *(p + 8 + i * 4 + 2));
|
|
Packit Service |
e18529 |
if (*(p + 8 + i * 4 + 1)) /* Access method */
|
|
Packit Service |
e18529 |
printf(", SMBus address 0x%x",
|
|
Packit Service |
e18529 |
*(p + 8 + i * 4 + 3) >> 1);
|
|
Packit Service |
e18529 |
printf("\n");
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* Intel Multiprocessor
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static size_t mp_length(const u8 *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
return 16 * p[8];
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static int mp_decode(const u8 *p, size_t len)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (!checksum(p, len))
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("Intel Multiprocessor present.\n");
|
|
Packit Service |
e18529 |
printf("\tSpecification Revision: %s\n",
|
|
Packit Service |
e18529 |
p[9] == 0x01 ? "1.1" : p[9] == 0x04 ? "1.4" : "Invalid");
|
|
Packit Service |
e18529 |
if (p[11])
|
|
Packit Service |
e18529 |
printf("\tDefault Configuration: #%d\n", p[11]);
|
|
Packit Service |
e18529 |
else
|
|
Packit Service |
e18529 |
printf("\tConfiguration Table Address: 0x%08X\n",
|
|
Packit Service |
e18529 |
DWORD(p + 4));
|
|
Packit Service |
e18529 |
printf("\tMode: %s\n", p[12] & (1 << 7) ?
|
|
Packit Service |
e18529 |
"IMCR and PIC" : "Virtual Wire");
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/*
|
|
Packit Service |
e18529 |
* Main
|
|
Packit Service |
e18529 |
*/
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static struct bios_entry bios_entries[] = {
|
|
Packit Service |
e18529 |
{ "_SM3_", 0, 0xF0000, 0xFFFFF, smbios3_length, smbios3_decode },
|
|
Packit Service |
e18529 |
{ "_SM_", 0, 0xF0000, 0xFFFFF, smbios_length, smbios_decode },
|
|
Packit Service |
e18529 |
{ "_DMI_", 0, 0xF0000, 0xFFFFF, dmi_length, dmi_decode },
|
|
Packit Service |
e18529 |
{ "_SYSID_", 0, 0xE0000, 0xFFFFF, sysid_length, sysid_decode },
|
|
Packit Service |
e18529 |
{ "$PnP", 0, 0xF0000, 0xFFFFF, pnp_length, pnp_decode },
|
|
Packit Service |
e18529 |
{ "RSD PTR ", 0, 0xE0000, 0xFFFFF, acpi_length, acpi_decode },
|
|
Packit Service |
e18529 |
{ "$SNY", 0, 0xE0000, 0xFFFFF, sony_length, sony_decode },
|
|
Packit Service |
e18529 |
{ "_32_", 0, 0xE0000, 0xFFFFF, bios32_length, bios32_decode },
|
|
Packit Service |
e18529 |
{ "$PIR", 0, 0xF0000, 0xFFFFF, pir_length, pir_decode },
|
|
Packit Service |
e18529 |
{ "32OS", 0, 0xE0000, 0xFFFFF, compaq_length, compaq_decode },
|
|
Packit Service |
e18529 |
{ "\252\125VPD", 0, 0xF0000, 0xFFFFF, vpd_length, vpd_decode },
|
|
Packit Service |
e18529 |
{ "FJKEYINF", 0, 0xF0000, 0xFFFFF, fjkeyinf_length, fjkeyinf_decode },
|
|
Packit Service |
e18529 |
{ "_MP_", 0, 0xE0000, 0xFFFFF, mp_length, mp_decode },
|
|
Packit Service |
e18529 |
{ NULL, 0, 0, 0, NULL, NULL }
|
|
Packit Service |
e18529 |
};
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/* Believe it or not, this is significantly faster than memcmp */
|
|
Packit Service |
e18529 |
static int anchor_match(const struct bios_entry *entry, const char *p)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
size_t i;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
for (i = 0; i < entry->anchor_len; i++)
|
|
Packit Service |
e18529 |
if (entry->anchor[i] != p[i])
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/* Return -1 on error, 0 on success */
|
|
Packit Service |
e18529 |
static int parse_command_line(int argc, char * const argv[])
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
int option;
|
|
Packit Service |
e18529 |
const char *optstring = "d:hV";
|
|
Packit Service |
e18529 |
struct option longopts[] = {
|
|
Packit Service |
e18529 |
{ "dev-mem", required_argument, NULL, 'd' },
|
|
Packit Service |
e18529 |
{ "pir", required_argument, NULL, 'P' },
|
|
Packit Service |
e18529 |
{ "help", no_argument, NULL, 'h' },
|
|
Packit Service |
e18529 |
{ "version", no_argument, NULL, 'V' },
|
|
Packit Service |
e18529 |
{ NULL, 0, NULL, 0 }
|
|
Packit Service |
e18529 |
};
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
while ((option = getopt_long(argc, argv, optstring, longopts, NULL)) != -1)
|
|
Packit Service |
e18529 |
switch (option)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
case 'd':
|
|
Packit Service |
e18529 |
opt.devmem = optarg;
|
|
Packit Service |
e18529 |
break;
|
|
Packit Service |
e18529 |
case 'P':
|
|
Packit Service |
e18529 |
if (strcmp(optarg, "full") == 0)
|
|
Packit Service |
e18529 |
opt.pir = PIR_FULL;
|
|
Packit Service |
e18529 |
break;
|
|
Packit Service |
e18529 |
case 'h':
|
|
Packit Service |
e18529 |
opt.flags |= FLAG_HELP;
|
|
Packit Service |
e18529 |
break;
|
|
Packit Service |
e18529 |
case 'V':
|
|
Packit Service |
e18529 |
opt.flags |= FLAG_VERSION;
|
|
Packit Service |
e18529 |
break;
|
|
Packit Service |
e18529 |
case '?':
|
|
Packit Service |
e18529 |
return -1;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
static void print_help(void)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
static const char *help =
|
|
Packit Service |
e18529 |
"Usage: biosdecode [OPTIONS]\n"
|
|
Packit Service |
e18529 |
"Options are:\n"
|
|
Packit Service |
e18529 |
" -d, --dev-mem FILE Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"
|
|
Packit Service |
e18529 |
" --pir full Decode the details of the PCI IRQ routing table\n"
|
|
Packit Service |
e18529 |
" -h, --help Display this help text and exit\n"
|
|
Packit Service |
e18529 |
" -V, --version Display the version and exit\n";
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("%s", help);
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
int main(int argc, char * const argv[])
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
u8 *buf;
|
|
Packit Service |
e18529 |
off_t fp;
|
|
Packit Service |
e18529 |
int i;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (sizeof(u8) != 1 || sizeof(u16) != 2 || sizeof(u32) != 4)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
fprintf(stderr, "%s: compiler incompatibility\n", argv[0]);
|
|
Packit Service |
e18529 |
exit(255);
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/* Set default option values */
|
|
Packit Service |
e18529 |
opt.devmem = DEFAULT_MEM_DEV;
|
|
Packit Service |
e18529 |
opt.flags = 0;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (parse_command_line(argc, argv) < 0)
|
|
Packit Service |
e18529 |
exit(2);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (opt.flags & FLAG_HELP)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
print_help();
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (opt.flags & FLAG_VERSION)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
printf("%s\n", VERSION);
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
printf("# biosdecode %s\n", VERSION);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if ((buf = mem_chunk(0xE0000, 0x20000, opt.devmem)) == NULL)
|
|
Packit Service |
e18529 |
exit(1);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
/* Compute anchor lengths once and for all */
|
|
Packit Service |
e18529 |
for (i = 0; bios_entries[i].anchor != NULL; i++)
|
|
Packit Service |
e18529 |
bios_entries[i].anchor_len = strlen(bios_entries[i].anchor);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
for (fp = 0xE0000; fp <= 0xFFFF0; fp += 16)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
u8 *p = buf + fp - 0xE0000;
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
for (i = 0; bios_entries[i].anchor != NULL; i++)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (anchor_match(&bios_entries[i], (char *)p)
|
|
Packit Service |
e18529 |
&& fp >= bios_entries[i].low_address
|
|
Packit Service |
e18529 |
&& fp < bios_entries[i].high_address)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
off_t len = bios_entries[i].length(p);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
if (fp + len - 1 <= bios_entries[i].high_address)
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
if (bios_entries[i].decode(p, len))
|
|
Packit Service |
e18529 |
{
|
|
Packit Service |
e18529 |
fp += (((len - 1) >> 4) << 4);
|
|
Packit Service |
e18529 |
break;
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
}
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
free(buf);
|
|
Packit Service |
e18529 |
|
|
Packit Service |
e18529 |
return 0;
|
|
Packit Service |
e18529 |
}
|