Пример #1
0
static void
smbios_setuuid(const char *name, const caddr_t addr, const int ver)
{
    char		uuid[37];
    int		byteorder, i, ones, zeros;
    UUID_TYPE	n;
    uint32_t	f1;
    uint16_t	f2, f3;

    for (i = 0, ones = 0, zeros = 0; i < UUID_SIZE; i += UUID_STEP) {
        n = UUID_GET(addr, i) + 1;
        if (zeros == 0 && n == 0)
            ones++;
        else if (ones == 0 && n == 1)
            zeros++;
        else
            break;
    }

    if (ones != UUID_ALL_BITS && zeros != UUID_ALL_BITS) {
        /*
         * 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)
        byteorder = LITTLE_ENDIAN;
#elif defined(SMBIOS_NETWORK_ENDIAN_UUID)
        byteorder = BIG_ENDIAN;
#else
        byteorder = ver < 0x0206 ? BIG_ENDIAN : LITTLE_ENDIAN;
#endif
        if (byteorder != LITTLE_ENDIAN) {
            f1 = ntohl(SMBIOS_GET32(addr, 0));
            f2 = ntohs(SMBIOS_GET16(addr, 4));
            f3 = ntohs(SMBIOS_GET16(addr, 6));
        } else {
            f1 = le32toh(SMBIOS_GET32(addr, 0));
            f2 = le16toh(SMBIOS_GET16(addr, 4));
            f3 = le16toh(SMBIOS_GET16(addr, 6));
        }
        sprintf(uuid,
                "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
                f1, f2, f3, SMBIOS_GET8(addr, 8), SMBIOS_GET8(addr, 9),
                SMBIOS_GET8(addr, 10), SMBIOS_GET8(addr, 11),
                SMBIOS_GET8(addr, 12), SMBIOS_GET8(addr, 13),
                SMBIOS_GET8(addr, 14), SMBIOS_GET8(addr, 15));
        setenv(name, uuid, 1);
    }
}
Пример #2
0
void
smbios_detect(void)
{
	char            buf[16];
	caddr_t         addr, dmi, smbios;
	size_t          count, length;
	uint32_t        paddr;
	int             i, major, minor, ver;
	
	/* Search signatures and validate checksums. */
	smbios = smbios_sigsearch(PTOV(SMBIOS_START), SMBIOS_LENGTH);
	if (smbios == NULL)
		return;
	
	length = SMBIOS_GET16(smbios, 0x16);    /* Structure Table Length */
	paddr = SMBIOS_GET32(smbios, 0x18);     /* Structure Table Address */
	count = SMBIOS_GET16(smbios, 0x1c);     /* No of SMBIOS Structures */
	ver = SMBIOS_GET8(smbios, 0x1e);        /* SMBIOS BCD Revision */
	
	if (ver != 0) {
		major = ver >> 4;
		minor = ver & 0x0f;
		if (major > 9 || minor > 9)
			ver = 0;
	}
Пример #3
0
static void
smbios_probe(const caddr_t addr)
{
    caddr_t		saddr, info;
    uintptr_t	paddr;

    if (smbios.probed)
        return;
    smbios.probed = 1;

    /* Search signatures and validate checksums. */
    saddr = smbios_sigsearch(addr ? addr : PTOV(SMBIOS_START),
                             SMBIOS_LENGTH);
    if (saddr == NULL)
        return;

    smbios.length = SMBIOS_GET16(saddr, 0x16);	/* Structure Table Length */
    paddr = SMBIOS_GET32(saddr, 0x18);		/* Structure Table Address */
    smbios.count = SMBIOS_GET16(saddr, 0x1c);	/* No of SMBIOS Structures */
    smbios.ver = SMBIOS_GET8(saddr, 0x1e);		/* SMBIOS BCD Revision */

    if (smbios.ver != 0) {
        smbios.major = smbios.ver >> 4;
        smbios.minor = smbios.ver & 0x0f;
        if (smbios.major > 9 || smbios.minor > 9)
            smbios.ver = 0;
    }