2 * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 FILE_LICENCE ( GPL2_OR_LATER );
26 #include <ipxe/uaccess.h>
27 #include <ipxe/smbios.h>
33 * System Management BIOS
40 * @v smbios SMBIOS entry point descriptor structure to fill in
41 * @ret rc Return status code
43 static int bios_find_smbios ( struct smbios *smbios ) {
45 struct smbios_entry entry;
46 uint8_t bytes[256]; /* 256 is maximum length possible */
48 static unsigned int offset = 0;
53 /* Try to find SMBIOS */
54 for ( ; offset < 0x10000 ; offset += 0x10 ) {
56 /* Read start of header and verify signature */
57 copy_from_real ( &u.entry, BIOS_SEG, offset,
59 if ( u.entry.signature != SMBIOS_SIGNATURE )
62 /* Read whole header and verify checksum */
64 copy_from_real ( &u.bytes, BIOS_SEG, offset, len );
65 for ( i = 0 , sum = 0 ; i < len ; i++ ) {
69 DBG ( "SMBIOS at %04x:%04x has bad checksum %02x\n",
70 BIOS_SEG, offset, sum );
74 /* Fill result structure */
75 DBG ( "Found SMBIOS v%d.%d entry point at %04x:%04x\n",
76 u.entry.major, u.entry.minor, BIOS_SEG, offset );
77 smbios->address = phys_to_user ( u.entry.smbios_address );
78 smbios->len = u.entry.smbios_len;
79 smbios->count = u.entry.smbios_count;
83 DBG ( "No SMBIOS found\n" );
87 PROVIDE_SMBIOS ( pcbios, find_smbios, bios_find_smbios );