|
@@ -183,6 +183,77 @@ const char * efi_guid_ntoa ( EFI_GUID *guid ) {
|
183
|
183
|
return uuid_ntoa ( &u.uuid );
|
184
|
184
|
}
|
185
|
185
|
|
|
186
|
+/**
|
|
187
|
+ * Name protocol open attributes
|
|
188
|
+ *
|
|
189
|
+ * @v attributes Protocol open attributes
|
|
190
|
+ * @ret name Protocol open attributes name
|
|
191
|
+ *
|
|
192
|
+ * Returns a (static) string with characters for each set bit
|
|
193
|
+ * corresponding to BY_(H)ANDLE_PROTOCOL, (G)ET_PROTOCOL,
|
|
194
|
+ * (T)EST_PROTOCOL, BY_(C)HILD_CONTROLLER, BY_(D)RIVER, and
|
|
195
|
+ * E(X)CLUSIVE.
|
|
196
|
+ */
|
|
197
|
+static const char * efi_open_attributes_name ( unsigned int attributes ) {
|
|
198
|
+ static char attribute_chars[] = "HGTCDX";
|
|
199
|
+ static char name[ sizeof ( attribute_chars ) ];
|
|
200
|
+ char *tmp = name;
|
|
201
|
+ unsigned int i;
|
|
202
|
+
|
|
203
|
+ for ( i = 0 ; i < ( sizeof ( attribute_chars ) - 1 ) ; i++ ) {
|
|
204
|
+ if ( attributes & ( 1 << i ) )
|
|
205
|
+ *(tmp++) = attribute_chars[i];
|
|
206
|
+ }
|
|
207
|
+ *tmp = '\0';
|
|
208
|
+
|
|
209
|
+ return name;
|
|
210
|
+}
|
|
211
|
+
|
|
212
|
+/**
|
|
213
|
+ * Print list of openers of a given protocol on a given handle
|
|
214
|
+ *
|
|
215
|
+ * @v handle EFI handle
|
|
216
|
+ * @v protocol Protocol GUID
|
|
217
|
+ */
|
|
218
|
+void dbg_efi_openers ( EFI_HANDLE handle, EFI_GUID *protocol ) {
|
|
219
|
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
|
220
|
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers;
|
|
221
|
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener;
|
|
222
|
+ UINTN count;
|
|
223
|
+ unsigned int i;
|
|
224
|
+ EFI_STATUS efirc;
|
|
225
|
+ int rc;
|
|
226
|
+
|
|
227
|
+ /* Retrieve list of openers */
|
|
228
|
+ if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
|
|
229
|
+ &count ) ) != 0 ) {
|
|
230
|
+ rc = -EEFI ( efirc );
|
|
231
|
+ printf ( "EFI could not retrieve openers for %s on %p: %s\n",
|
|
232
|
+ efi_guid_ntoa ( protocol ), handle, strerror ( rc ) );
|
|
233
|
+ return;
|
|
234
|
+ }
|
|
235
|
+
|
|
236
|
+ /* Dump list of openers */
|
|
237
|
+ for ( i = 0 ; i < count ; i++ ) {
|
|
238
|
+ opener = &openers[i];
|
|
239
|
+ printf ( "HANDLE %p %s %s opened %dx (%s)",
|
|
240
|
+ handle, efi_handle_name ( handle ),
|
|
241
|
+ efi_guid_ntoa ( protocol ), opener->OpenCount,
|
|
242
|
+ efi_open_attributes_name ( opener->Attributes ) );
|
|
243
|
+ printf ( " by %p %s", opener->AgentHandle,
|
|
244
|
+ efi_handle_name ( opener->AgentHandle ) );
|
|
245
|
+ if ( opener->ControllerHandle == handle ) {
|
|
246
|
+ printf ( "\n" );
|
|
247
|
+ } else {
|
|
248
|
+ printf ( " for %p %s\n", opener->ControllerHandle,
|
|
249
|
+ efi_handle_name ( opener->ControllerHandle ) );
|
|
250
|
+ }
|
|
251
|
+ }
|
|
252
|
+
|
|
253
|
+ /* Free list */
|
|
254
|
+ bs->FreePool ( openers );
|
|
255
|
+}
|
|
256
|
+
|
186
|
257
|
/**
|
187
|
258
|
* Print list of protocol handlers attached to a handle
|
188
|
259
|
*
|
|
@@ -190,7 +261,8 @@ const char * efi_guid_ntoa ( EFI_GUID *guid ) {
|
190
|
261
|
*/
|
191
|
262
|
void dbg_efi_protocols ( EFI_HANDLE handle ) {
|
192
|
263
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
193
|
|
- EFI_GUID **protocols;
|
|
264
|
+ EFI_GUID **protocols;
|
|
265
|
+ EFI_GUID *protocol;
|
194
|
266
|
UINTN count;
|
195
|
267
|
unsigned int i;
|
196
|
268
|
EFI_STATUS efirc;
|
|
@@ -206,8 +278,13 @@ void dbg_efi_protocols ( EFI_HANDLE handle ) {
|
206
|
278
|
}
|
207
|
279
|
|
208
|
280
|
/* Dump list of protocols */
|
209
|
|
- for ( i = 0 ; i < count ; i++ )
|
210
|
|
- printf ( "%s\n", efi_guid_ntoa ( protocols[i] ) );
|
|
281
|
+ for ( i = 0 ; i < count ; i++ ) {
|
|
282
|
+ protocol = protocols[i];
|
|
283
|
+ printf ( "HANDLE %p %s %s supported\n",
|
|
284
|
+ handle, efi_handle_name ( handle ),
|
|
285
|
+ efi_guid_ntoa ( protocol ) );
|
|
286
|
+ dbg_efi_openers ( handle, protocol );
|
|
287
|
+ }
|
211
|
288
|
|
212
|
289
|
/* Free list */
|
213
|
290
|
bs->FreePool ( protocols );
|