Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[efi] Use EFI-native mechanism for accessing SMBIOS table
EFI provides a copy of the SMBIOS table accessible via the EFI system
table, which we should use instead of manually scanning through the
F000:0000 segment.
  • Loading branch information
Michael Brown committed Dec 4, 2008
1 parent 045a227 commit 29480dd
Show file tree
Hide file tree
Showing 15 changed files with 376 additions and 180 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Expand Up @@ -58,7 +58,7 @@ SRCDIRS += drivers/block
SRCDIRS += drivers/nvs
SRCDIRS += drivers/bitbash
SRCDIRS += drivers/infiniband
SRCDIRS += interface/pxe interface/efi
SRCDIRS += interface/pxe interface/efi interface/smbios
SRCDIRS += tests
SRCDIRS += crypto crypto/axtls crypto/matrixssl
SRCDIRS += hci hci/commands hci/tui
Expand Down
3 changes: 1 addition & 2 deletions src/arch/i386/include/bits/errfile.h
Expand Up @@ -9,10 +9,9 @@
#define ERRFILE_memtop_umalloc ( ERRFILE_ARCH | ERRFILE_CORE | 0x00000000 )
#define ERRFILE_memmap ( ERRFILE_ARCH | ERRFILE_CORE | 0x00010000 )
#define ERRFILE_pnpbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00020000 )
#define ERRFILE_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
#define ERRFILE_bios_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
#define ERRFILE_biosint ( ERRFILE_ARCH | ERRFILE_CORE | 0x00040000 )
#define ERRFILE_int13 ( ERRFILE_ARCH | ERRFILE_CORE | 0x00050000 )
#define ERRFILE_smbios_settings ( ERRFILE_ARCH | ERRFILE_CORE | 0x00060000 )

#define ERRFILE_bootsector ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
#define ERRFILE_bzimage ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
Expand Down
12 changes: 12 additions & 0 deletions src/arch/i386/include/bits/smbios.h
@@ -0,0 +1,12 @@
#ifndef _BITS_SMBIOS_H
#define _BITS_SMBIOS_H

/** @file
*
* i386-specific SMBIOS API implementations
*
*/

#include <gpxe/bios_smbios.h>

#endif /* _BITS_SMBIOS_H */
16 changes: 16 additions & 0 deletions src/arch/i386/include/gpxe/bios_smbios.h
@@ -0,0 +1,16 @@
#ifndef _GPXE_BIOS_SMBIOS_H
#define _GPXE_BIOS_SMBIOS_H

/** @file
*
* Standard PC-BIOS SMBIOS interface
*
*/

#ifdef SMBIOS_PCBIOS
#define SMBIOS_PREFIX_pcbios
#else
#define SMBIOS_PREFIX_pcbios __pcbios_
#endif

#endif /* _GPXE_BIOS_SMBIOS_H */
60 changes: 0 additions & 60 deletions src/arch/i386/include/smbios.h

This file was deleted.

84 changes: 84 additions & 0 deletions src/arch/i386/interface/pcbios/bios_smbios.c
@@ -0,0 +1,84 @@
/*
* Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <gpxe/uaccess.h>
#include <gpxe/smbios.h>
#include <realmode.h>
#include <pnpbios.h>

/** @file
*
* System Management BIOS
*
*/

/**
* Find SMBIOS
*
* @v smbios SMBIOS entry point descriptor structure to fill in
* @ret rc Return status code
*/
static int bios_find_smbios ( struct smbios *smbios ) {
union {
struct smbios_entry entry;
uint8_t bytes[256]; /* 256 is maximum length possible */
} u;
static unsigned int offset = 0;
size_t len;
unsigned int i;
uint8_t sum;

/* Try to find SMBIOS */
for ( ; offset < 0x10000 ; offset += 0x10 ) {

/* Read start of header and verify signature */
copy_from_real ( &u.entry, BIOS_SEG, offset,
sizeof ( u.entry ));
if ( u.entry.signature != SMBIOS_SIGNATURE )
continue;

/* Read whole header and verify checksum */
len = u.entry.len;
copy_from_real ( &u.bytes, BIOS_SEG, offset, len );
for ( i = 0 , sum = 0 ; i < len ; i++ ) {
sum += u.bytes[i];
}
if ( sum != 0 ) {
DBG ( "SMBIOS at %04x:%04x has bad checksum %02x\n",
BIOS_SEG, offset, sum );
continue;
}

/* Fill result structure */
DBG ( "Found SMBIOS v%d.%d entry point at %04x:%04x\n",
u.entry.major, u.entry.minor, BIOS_SEG, offset );
smbios->address = phys_to_user ( u.entry.smbios_address );
smbios->len = u.entry.smbios_len;
smbios->count = u.entry.smbios_count;
return 0;
}

DBG ( "No SMBIOS found\n" );
return -ENODEV;
}

PROVIDE_SMBIOS ( pcbios, find_smbios, bios_find_smbios );
1 change: 1 addition & 0 deletions src/config/defaults/efi.h
Expand Up @@ -14,6 +14,7 @@
#define TIMER_EFI
#define NAP_EFIX86
#define UMALLOC_EFI
#define SMBIOS_EFI

#define IMAGE_EFI /* EFI image support */

Expand Down
1 change: 1 addition & 0 deletions src/config/defaults/pcbios.h
Expand Up @@ -14,6 +14,7 @@
#define CONSOLE_PCBIOS
#define NAP_PCBIOS
#define UMALLOC_MEMTOP
#define SMBIOS_PCBIOS

#define IMAGE_ELF /* ELF image support */
#define IMAGE_MULTIBOOT /* MultiBoot image support */
Expand Down
34 changes: 34 additions & 0 deletions src/include/gpxe/efi/Guid/SmBios.h
@@ -0,0 +1,34 @@
/** @file
GUIDs used to locate the SMBIOS tables in the UEFI 2.0 system table.
This GUID in the system table is the only legal way to search for and
locate the SMBIOS tables. Do not search the 0xF0000 segment to find SMBIOS
tables.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@par Revision Reference:
GUIDs defined in UEFI 2.0 spec.
**/

#ifndef __SMBIOS_GUID_H__
#define __SMBIOS_GUID_H__

#define EFI_SMBIOS_TABLE_GUID \
{ \
0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
}

#define SMBIOS_TABLE_GUID EFI_SMBIOS_TABLE_GUID

extern EFI_GUID gEfiSmbiosTableGuid;

#endif
16 changes: 16 additions & 0 deletions src/include/gpxe/efi/efi_smbios.h
@@ -0,0 +1,16 @@
#ifndef _GPXE_EFI_SMBIOS_H
#define _GPXE_EFI_SMBIOS_H

/** @file
*
* gPXE SMBIOS API for EFI
*
*/

#ifdef SMBIOS_EFI
#define SMBIOS_PREFIX_efi
#else
#define SMBIOS_PREFIX_efi __efi_
#endif

#endif /* _GPXE_EFI_SMBIOS_H */
3 changes: 3 additions & 0 deletions src/include/gpxe/errfile.h
Expand Up @@ -164,6 +164,9 @@
#define ERRFILE_iscsiboot ( ERRFILE_OTHER | 0x000f0000 )
#define ERRFILE_efi_pci ( ERRFILE_OTHER | 0x00100000 )
#define ERRFILE_efi_snp ( ERRFILE_OTHER | 0x00110000 )
#define ERRFILE_smbios ( ERRFILE_OTHER | 0x00120000 )
#define ERRFILE_smbios_settings ( ERRFILE_OTHER | 0x00130000 )
#define ERRFILE_efi_smbios ( ERRFILE_OTHER | 0x00140000 )

/** @} */

Expand Down

0 comments on commit 29480dd

Please sign in to comment.