1 /* 2 * Copyright (C) 2008 Michael Brown <mbrown (at) fensystems.co.uk>. 3 * 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. 8 * 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. 13 * 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. 17 */ 18 19 FILE_LICENCE ( GPL2_OR_LATER ); 20 21 #include <errno.h> 22 #include <gpxe/smbios.h> 23 #include <gpxe/efi/efi.h> 24 #include <gpxe/efi/Guid/SmBios.h> 25 26 /** @file 27 * 28 * gPXE SMBIOS API for EFI 29 * 30 */ 31 32 /** SMBIOS configuration table */ 33 static struct smbios_entry *smbios_entry; 34 EFI_USE_TABLE ( EFI_SMBIOS_TABLE, &smbios_entry, 0 ); 35 36 /** 37 * Find SMBIOS 38 * 39 * @v smbios SMBIOS entry point descriptor structure to fill in 40 * @ret rc Return status code 41 */ 42 static int efi_find_smbios ( struct smbios *smbios ) { 43 44 if ( ! smbios_entry ) { 45 DBG ( "No SMBIOS table provided\n" ); 46 return -ENODEV; 47 } 48 49 if ( smbios_entry->signature != SMBIOS_SIGNATURE ) { 50 DBG ( "Invalid SMBIOS signature\n" ); 51 return -ENODEV; 52 } 53 54 smbios->address = phys_to_user ( smbios_entry->smbios_address ); 55 smbios->len = smbios_entry->smbios_len; 56 smbios->count = smbios_entry->smbios_count; 57 DBG ( "Found SMBIOS v%d.%d entry point at %p (%x+%zx)\n", 58 smbios_entry->major, smbios_entry->minor, smbios_entry, 59 smbios_entry->smbios_address, smbios->len ); 60 61 return 0; 62 } 63 64 PROVIDE_SMBIOS ( efi, find_smbios, efi_find_smbios ); 65