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., 675 Mass Ave, Cambridge, MA 02139, USA.
19 FILE_LICENCE ( GPL2_OR_LATER
);
25 #include <gpxe/uaccess.h>
26 #include <gpxe/smbios.h>
32 * System Management BIOS
39 * @v smbios SMBIOS entry point descriptor structure to fill in
40 * @ret rc Return status code
42 static int bios_find_smbios ( struct smbios
*smbios
) {
44 struct smbios_entry entry
;
45 uint8_t bytes
[256]; /* 256 is maximum length possible */
47 static unsigned int offset
= 0;
52 /* Try to find SMBIOS */
53 for ( ; offset
< 0x10000 ; offset
+= 0x10 ) {
55 /* Read start of header and verify signature */
56 copy_from_real ( &u
.entry
, BIOS_SEG
, offset
,
58 if ( u
.entry
.signature
!= SMBIOS_SIGNATURE
)
61 /* Read whole header and verify checksum */
63 copy_from_real ( &u
.bytes
, BIOS_SEG
, offset
, len
);
64 for ( i
= 0 , sum
= 0 ; i
< len
; i
++ ) {
68 DBG ( "SMBIOS at %04x:%04x has bad checksum %02x\n",
69 BIOS_SEG
, offset
, sum
);
73 /* Fill result structure */
74 DBG ( "Found SMBIOS v%d.%d entry point at %04x:%04x\n",
75 u
.entry
.major
, u
.entry
.minor
, BIOS_SEG
, offset
);
76 smbios
->address
= phys_to_user ( u
.entry
.smbios_address
);
77 smbios
->len
= u
.entry
.smbios_len
;
78 smbios
->count
= u
.entry
.smbios_count
;
82 DBG ( "No SMBIOS found\n" );
86 PROVIDE_SMBIOS ( pcbios
, find_smbios
, bios_find_smbios
);