smbios.c revision 199767f8919635c4928607450d9e0abb932109ce
/*-
* Copyright (c) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
__FBSDID("$FreeBSD$");
#include <stand.h>
#include <bootstrap.h>
#ifdef EFI
/* In EFI, we don't need PTOV(). */
#else
#include "btxv86.h"
#endif
#include "smbios.h"
/*
* Detect SMBIOS and export information about the SMBIOS into the
* environment.
*
* System Management BIOS Reference Specification, v2.6 Final
*/
/*
* 2.1.1 SMBIOS Structure Table Entry Point
*
* "On non-EFI systems, the SMBIOS Entry Point structure, described below, can
* be located by application software by searching for the anchor-string on
* paragraph (16-byte) boundaries within the physical memory address range
* 000F0000h to 000FFFFFh. This entry point encapsulates an intermediate anchor
* string that is used by some existing DMI browsers."
*/
#define SMBIOS_START 0xf0000
#define SMBIOS_LENGTH 0x10000
#define SMBIOS_STEP 0x10
#define SMBIOS_SIG "_SM_"
#define SMBIOS_DMI_SIG "_DMI_"
struct smbios_attr {
int probed;
int major;
int minor;
int ver;
const char* bios_vendor;
const char* maker;
const char* product;
};
static struct smbios_attr smbios;
static uint8_t
{
int i;
return (sum);
}
static caddr_t
{
/* Search on 16-byte boundaries. */
return (cp);
return (NULL);
}
static const char*
{
int i, idx;
if (idx != 0) {
for (i = 1; i < idx; i++)
return cp;
}
return (NULL);
}
static void
{
const char* val;
}
#ifdef SMBIOS_SERIAL_NUMBERS
#define UUID_SIZE 16
static void
{
char uuid[37];
UUID_TYPE n;
if (zeros == 0 && n == 0)
ones++;
else if (ones == 0 && n == 1)
zeros++;
else
break;
}
/*
* 3.3.2.1 System UUID
*
* "Although RFC 4122 recommends network byte order for all
* fields, the PC industry (including the ACPI, UEFI, and
* Microsoft specifications) has consistently used
* little-endian byte encoding for the first three fields:
* time_low, time_mid, time_hi_and_version. The same encoding,
* also known as wire format, should also be used for the
* SMBIOS representation of the UUID."
*
* Note: We use network byte order for backward compatibility
* unless SMBIOS version is 2.6+ or little-endian is forced.
*/
#if defined(SMBIOS_LITTLE_ENDIAN_UUID)
#elif defined(SMBIOS_NETWORK_ENDIAN_UUID)
#else
#endif
if (byteorder != LITTLE_ENDIAN) {
} else {
}
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
}
}
#endif
static caddr_t
{
switch(type) {
case 0: /* 3.3.1 BIOS Information (Type 0) */
break;
case 1: /* 3.3.2 System Information (Type 1) */
#ifdef SMBIOS_SERIAL_NUMBERS
#endif
break;
case 2: /* 3.3.3 Base Board (or Module) Information (Type 2) */
#ifdef SMBIOS_SERIAL_NUMBERS
#endif
break;
case 3: /* 3.3.4 System Enclosure or Chassis (Type 3) */
#ifdef SMBIOS_SERIAL_NUMBERS
#endif
break;
case 4: /* 3.3.5 Processor Information (Type 4) */
/*
* Offset 18h: Processor Status
*
* Bit 7 Reserved, must be 0
* Bit 6 CPU Socket Populated
* 1 - CPU Socket Populated
* 0 - CPU Socket Unpopulated
* Bit 5:3 Reserved, must be zero
* Bit 2:0 CPU Status
* 0h - Unknown
* 1h - CPU Enabled
* 2h - CPU Disabled by User via BIOS Setup
* 3h - CPU Disabled by BIOS (POST Error)
* 4h - CPU is Idle, waiting to be enabled
* 5-6h - Reserved
* 7h - Other
*/
if ((proc & 0x40) != 0)
break;
case 6: /* 3.3.7 Memory Module Information (Type 6, Obsolete) */
/*
* Offset 0Ah: Enabled Size
*
* Bit 7 Bank connection
* 1 - Double-bank connection
* 0 - Single-bank connection
* Bit 6:0 Size (n), where 2**n is the size in MB
* 7Dh - Not determinable (Installed Size only)
* 7Eh - Module is installed, but no memory
* has been enabled
* 7Fh - Not installed
*/
break;
case 17: /* 3.3.18 Memory Device (Type 17) */
/*
* Offset 0Ch: Size
*
* Bit 15 Granularity
* 1 - Value is in kilobytes units
* 0 - Value is in megabytes units
* Bit 14:0 Size
*/
break;
default: /* skip other types */
break;
}
/* Find structure terminator. */
while (SMBIOS_GET16(cp, 0) != 0)
cp++;
return (cp + 2);
}
static caddr_t
smbios_find_struct(int type)
{
size_t i;
return (NULL);
return dmi;
/* Find structure terminator. */
while (SMBIOS_GET16(dmi, 0) != 0)
dmi++;
dmi += 2;
}
return (NULL);
}
static void
{
return;
/* Search signatures and validate checksums. */
return;
}
}
/* Get system information from SMBIOS */
}
}
}
void
{
char buf[16];
size_t i;
return;
}
if (smbios.enabled_sockets > 0) {
}
if (smbios.populated_sockets > 0) {
}
}
static int
{
}
int
const char* product)
{
/* XXXRP currently, only called from non-EFI. */
}