|
@@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
22
|
22
|
#include <string.h>
|
23
|
23
|
#include <ipxe/efi/efi.h>
|
24
|
24
|
#include <ipxe/efi/Protocol/LoadedImage.h>
|
|
25
|
+#include <ipxe/efi/Protocol/DevicePath.h>
|
25
|
26
|
#include <ipxe/uuid.h>
|
26
|
27
|
#include <ipxe/init.h>
|
27
|
28
|
|
|
@@ -31,6 +32,9 @@ EFI_HANDLE efi_image_handle;
|
31
|
32
|
/** Loaded image protocol for this image */
|
32
|
33
|
EFI_LOADED_IMAGE_PROTOCOL *efi_loaded_image;
|
33
|
34
|
|
|
35
|
+/** Loaded image protocol device path for this image */
|
|
36
|
+EFI_DEVICE_PATH_PROTOCOL *efi_loaded_image_path;
|
|
37
|
+
|
34
|
38
|
/** System table passed to entry point */
|
35
|
39
|
EFI_SYSTEM_TABLE *efi_systab;
|
36
|
40
|
|
|
@@ -38,6 +42,10 @@ EFI_SYSTEM_TABLE *efi_systab;
|
38
|
42
|
static EFI_GUID efi_loaded_image_protocol_guid
|
39
|
43
|
= EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
40
|
44
|
|
|
45
|
+/** EFI loaded image device path protocol GUID */
|
|
46
|
+static EFI_GUID efi_loaded_image_device_path_protocol_guid
|
|
47
|
+ = EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID;
|
|
48
|
+
|
41
|
49
|
/** Event used to signal shutdown */
|
42
|
50
|
static EFI_EVENT efi_shutdown_event;
|
43
|
51
|
|
|
@@ -83,8 +91,9 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
|
83
|
91
|
EFI_BOOT_SERVICES *bs;
|
84
|
92
|
struct efi_protocol *prot;
|
85
|
93
|
struct efi_config_table *tab;
|
86
|
|
- EFI_STATUS efirc;
|
87
|
94
|
void *loaded_image;
|
|
95
|
+ void *loaded_image_path;
|
|
96
|
+ EFI_STATUS efirc;
|
88
|
97
|
|
89
|
98
|
/* Store image handle and system table pointer for future use */
|
90
|
99
|
efi_image_handle = image_handle;
|
|
@@ -105,19 +114,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
|
105
|
114
|
return EFI_NOT_AVAILABLE_YET;
|
106
|
115
|
}
|
107
|
116
|
DBGC ( systab, "EFI handle %p systab %p\n", image_handle, systab );
|
108
|
|
-
|
109
|
117
|
bs = systab->BootServices;
|
110
|
|
- efirc = bs->OpenProtocol ( image_handle,
|
111
|
|
- &efi_loaded_image_protocol_guid,
|
112
|
|
- &loaded_image, image_handle, NULL,
|
113
|
|
- EFI_OPEN_PROTOCOL_GET_PROTOCOL );
|
114
|
|
- if ( efirc ) {
|
115
|
|
- DBGC ( systab, "Could not get loaded image protocol" );
|
116
|
|
- return efirc;
|
117
|
|
- }
|
118
|
|
-
|
119
|
|
- efi_loaded_image = loaded_image;
|
120
|
|
- DBG ( "Image base address = %p\n", efi_loaded_image->ImageBase );
|
121
|
118
|
|
122
|
119
|
/* Look up used protocols */
|
123
|
120
|
for_each_table_entry ( prot, EFI_PROTOCOLS ) {
|
|
@@ -147,6 +144,33 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
|
147
|
144
|
}
|
148
|
145
|
}
|
149
|
146
|
|
|
147
|
+ /* Get loaded image protocol */
|
|
148
|
+ if ( ( efirc = bs->OpenProtocol ( image_handle,
|
|
149
|
+ &efi_loaded_image_protocol_guid,
|
|
150
|
+ &loaded_image, image_handle, NULL,
|
|
151
|
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
|
152
|
+ DBGC ( systab, "EFI could not get loaded image protocol: %s",
|
|
153
|
+ efi_strerror ( efirc ) );
|
|
154
|
+ return efirc;
|
|
155
|
+ }
|
|
156
|
+ efi_loaded_image = loaded_image;
|
|
157
|
+ DBGC ( systab, "EFI image base address %p\n",
|
|
158
|
+ efi_loaded_image->ImageBase );
|
|
159
|
+
|
|
160
|
+ /* Get loaded image device path protocol */
|
|
161
|
+ if ( ( efirc = bs->OpenProtocol ( image_handle,
|
|
162
|
+ &efi_loaded_image_device_path_protocol_guid,
|
|
163
|
+ &loaded_image_path, image_handle, NULL,
|
|
164
|
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
|
165
|
+ DBGC ( systab, "EFI could not get loaded image device path "
|
|
166
|
+ "protocol: %s", efi_strerror ( efirc ) );
|
|
167
|
+ return efirc;
|
|
168
|
+ }
|
|
169
|
+ efi_loaded_image_path = loaded_image_path;
|
|
170
|
+ DBGC ( systab, "EFI image device path " );
|
|
171
|
+ DBGC_EFI_DEVPATH ( systab, efi_loaded_image_path );
|
|
172
|
+ DBGC ( systab, "\n" );
|
|
173
|
+
|
150
|
174
|
/* EFI is perfectly capable of gracefully shutting down any
|
151
|
175
|
* loaded devices if it decides to fall back to a legacy boot.
|
152
|
176
|
* For no particularly comprehensible reason, it doesn't
|