2 * Copyright (C) 2008 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.
20 #include <gpxe/efi/efi.h>
21 #include <gpxe/uuid.h>
23 /** Image handle passed to entry point */
24 EFI_HANDLE efi_image_handle;
26 /** System table passed to entry point */
27 EFI_SYSTEM_TABLE *efi_systab;
29 /** Declared used EFI protocols */
30 static struct efi_protocol efi_protocols[0] \
31 __table_start ( struct efi_protocol, efi_protocols );
32 static struct efi_protocol efi_protocols_end[0] \
33 __table_end ( struct efi_protocol, efi_protocols );
38 * @v image_handle Image handle
39 * @v systab System table
40 * @ret efirc EFI return status code
42 EFI_STATUS EFIAPI efi_entry ( EFI_HANDLE image_handle,
43 EFI_SYSTEM_TABLE *systab ) {
44 EFI_BOOT_SERVICES *bs;
45 struct efi_protocol *prot;
48 /* Store image handle and system table pointer for future use */
49 efi_image_handle = image_handle;
54 return EFI_NOT_AVAILABLE_YET;
55 if ( ! systab->ConOut )
56 return EFI_NOT_AVAILABLE_YET;
57 if ( ! systab->BootServices ) {
58 DBGC ( systab, "EFI provided no BootServices entry point\n" );
59 return EFI_NOT_AVAILABLE_YET;
61 if ( ! systab->RuntimeServices ) {
62 DBGC ( systab, "EFI provided no RuntimeServices entry "
64 return EFI_NOT_AVAILABLE_YET;
66 DBGC ( systab, "EFI handle %p systab %p\n", image_handle, systab );
68 /* Look up required protocols */
69 bs = systab->BootServices;
70 for ( prot = efi_protocols ; prot < efi_protocols_end ; prot++ ) {
71 if ( ( efirc = bs->LocateProtocol ( &prot->u.guid, NULL,
72 prot->protocol ) ) != 0 ) {
73 DBGC ( systab, "EFI does not provide protocol %s\n",
74 uuid_ntoa ( &prot->u.uuid ) );
77 DBGC ( systab, "EFI protocol %s is at %p\n",
78 uuid_ntoa ( &prot->u.uuid ), *(prot->protocol) );
82 return RC_TO_EFIRC ( main () );