iPXE
efi_smbios.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  */
00019 
00020 FILE_LICENCE ( GPL2_OR_LATER );
00021 
00022 #include <errno.h>
00023 #include <ipxe/smbios.h>
00024 #include <ipxe/efi/efi.h>
00025 #include <ipxe/efi/Guid/SmBios.h>
00026 
00027 /** @file
00028  *
00029  * iPXE SMBIOS API for EFI
00030  *
00031  */
00032 
00033 /** SMBIOS configuration table */
00034 static struct smbios_entry *smbios_entry;
00035 EFI_USE_TABLE ( SMBIOS_TABLE, &smbios_entry, 0 );
00036 
00037 /**
00038  * Find SMBIOS
00039  *
00040  * @v smbios            SMBIOS entry point descriptor structure to fill in
00041  * @ret rc              Return status code
00042  */
00043 static int efi_find_smbios ( struct smbios *smbios ) {
00044 
00045         if ( ! smbios_entry ) {
00046                 DBG ( "No SMBIOS table provided\n" );
00047                 return -ENODEV;
00048         }
00049 
00050         if ( smbios_entry->signature != SMBIOS_SIGNATURE ) {
00051                 DBG ( "Invalid SMBIOS signature\n" );
00052                 return -ENODEV;
00053         }
00054 
00055         smbios->address = phys_to_user ( smbios_entry->smbios_address );
00056         smbios->len = smbios_entry->smbios_len;
00057         smbios->count = smbios_entry->smbios_count;
00058         smbios->version =
00059                 SMBIOS_VERSION ( smbios_entry->major, smbios_entry->minor );
00060         DBG ( "Found SMBIOS v%d.%d entry point at %p (%x+%zx)\n",
00061               smbios_entry->major, smbios_entry->minor, smbios_entry,
00062               smbios_entry->smbios_address, smbios->len );
00063 
00064         return 0;
00065 }
00066 
00067 PROVIDE_SMBIOS ( efi, find_smbios, efi_find_smbios );