iPXE
efiprefix.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Michael Brown <mbrown@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., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER );
21 
22 #include <stdlib.h>
23 #include <errno.h>
24 #include <ipxe/device.h>
25 #include <ipxe/efi/efi.h>
26 #include <ipxe/efi/efi_driver.h>
27 #include <ipxe/efi/efi_snp.h>
28 #include <ipxe/efi/efi_autoboot.h>
29 #include <ipxe/efi/efi_watchdog.h>
30 #include <ipxe/efi/efi_blacklist.h>
31 
32 /**
33  * EFI entry point
34  *
35  * @v image_handle Image handle
36  * @v systab System table
37  * @ret efirc EFI return status code
38  */
40  EFI_SYSTEM_TABLE *systab ) {
41  EFI_STATUS efirc;
42  int rc;
43 
44  /* Initialise EFI environment */
45  if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 )
46  goto err_init;
47 
48  /* Record autoboot device (if any) */
50 
51  /* Claim SNP devices for use by iPXE */
52  efi_snp_claim();
53 
54  /* Start watchdog holdoff timer */
56 
57  /* Call to main() */
58  if ( ( rc = main() ) != 0 ) {
59  efirc = EFIRC ( rc );
60  goto err_main;
61  }
62 
63  err_main:
66  efi_loaded_image->Unload ( image_handle );
68  err_init:
69  return efirc;
70 }
71 
72 /**
73  * Probe EFI root bus
74  *
75  * @v rootdev EFI root device
76  */
77 static int efi_probe ( struct root_device *rootdev __unused ) {
78 
79  /* Unloaded any blacklisted drivers */
81 
82  /* Connect our drivers */
83  return efi_driver_connect_all();
84 }
85 
86 /**
87  * Remove EFI root bus
88  *
89  * @v rootdev EFI root device
90  */
91 static void efi_remove ( struct root_device *rootdev __unused ) {
92 
93  /* Disconnect our drivers */
95 }
96 
97 /** EFI root device driver */
98 static struct root_driver efi_root_driver = {
99  .probe = efi_probe,
100  .remove = efi_remove,
101 };
102 
103 /** EFI root device */
104 struct root_device efi_root_device __root_device = {
105  .dev = { .name = "EFI" },
106  .driver = &efi_root_driver,
107 };
int efi_driver_connect_all(void)
Connect EFI driver to all possible devices.
Definition: efi_driver.c:551
EFI_LOADED_IMAGE_PROTOCOL * efi_loaded_image
Loaded image protocol for this image.
Definition: efi_init.c:33
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
EFI driver interface.
Error codes.
static void efi_remove(struct root_device *rootdev __unused)
Remove EFI root bus.
Definition: efiprefix.c:91
struct root_device efi_root_device __root_device
EFI root device.
Definition: efiprefix.c:104
char name[40]
Name.
Definition: device.h:75
FILE_LICENCE(GPL2_OR_LATER)
A root device.
Definition: device.h:94
static void efi_snp_claim(void)
Claim network devices for use by iPXE.
Definition: efi_snp.h:88
struct device dev
Device chain.
Definition: device.h:99
void efi_set_autoboot(void)
Identify autoboot device.
Definition: efi_autoboot.c:41
void efi_driver_reconnect_all(void)
Reconnect original EFI drivers to all possible devices.
Definition: efi_driver.c:573
EFI driver blacklist.
static void efi_watchdog_start(void)
Start EFI watchdog holdoff timer.
Definition: efi_watchdog.h:17
static struct root_driver efi_root_driver
EFI root device driver.
Definition: efiprefix.c:98
static void efi_watchdog_stop(void)
Stop EFI watchdog holdoff timer.
Definition: efi_watchdog.h:26
#define EFIAPI
EFI autoboot device.
EFI_IMAGE_UNLOAD Unload
Definition: LoadedImage.h:79
EFI watchdog holdoff timer.
void efi_driver_disconnect_all(void)
Disconnect EFI driver from all possible devices.
Definition: efi_driver.c:562
A root device driver.
Definition: device.h:107
static void efi_snp_release(void)
Release network devices for use via SNP.
Definition: efi_snp.h:96
EFI System Table.
Definition: UefiSpec.h:1949
int(* probe)(struct root_device *rootdev)
Add root device.
Definition: device.h:116
EFI API.
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
EFI_STATUS EFIAPI _efi_start(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
EFI entry point.
Definition: efiprefix.c:39
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
Device model.
EFI_STATUS efi_init(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
Initialise EFI environment.
Definition: efi_init.c:97
static int efi_probe(struct root_device *rootdev __unused)
Probe EFI root bus.
Definition: efiprefix.c:77
iPXE EFI SNP interface
__asmcall int main(void)
Main entry point.
Definition: main.c:28
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:149
Definition: efi.h:55
void efi_unload_blacklist(void)
Unload any blacklisted drivers.