1 /** @file
2   EFI Driver Diagnostics Protocol
3 
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7 **/
8 
9 #ifndef __EFI_DRIVER_DIAGNOSTICS_H__
10 #define __EFI_DRIVER_DIAGNOSTICS_H__
11 
12 ///
13 /// The global ID for the Driver Diagnostics Protocol as defined in EFI 1.1.
14 ///
15 #define EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID \
16   { \
17     0x0784924f, 0xe296, 0x11d4, {0x9a, 0x49, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
18   }
19 
20 typedef struct _EFI_DRIVER_DIAGNOSTICS_PROTOCOL EFI_DRIVER_DIAGNOSTICS_PROTOCOL;
21 
22 typedef enum {
23   ///
24   /// Performs standard diagnostics on the controller.
25   ///
26   EfiDriverDiagnosticTypeStandard = 0,
27   ///
28   /// This is an optional diagnostic type that performs diagnostics on the controller that may
29   /// take an extended amount of time to execute.
30   ///
31   EfiDriverDiagnosticTypeExtended = 1,
32   ///
33   /// This is an optional diagnostic type that performs diagnostics on the controller that are
34   /// suitable for a manufacturing and test environment.
35   ///
36   EfiDriverDiagnosticTypeManufacturing = 2,
37   ///
38   /// This is an optional diagnostic type that would only be used in the situation where an
39   /// EFI_NOT_READY had been returned by a previous call to RunDiagnostics()
40   /// and there is a desire to cancel the current running diagnostics operation.
41   ///
42   EfiDriverDiagnosticTypeCancel = 3,
43   EfiDriverDiagnosticTypeMaximum
44 } EFI_DRIVER_DIAGNOSTIC_TYPE;
45 
46 /**
47   Runs diagnostics on a controller.
48 
49   @param  This             A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOL instance.
50   @param  ControllerHandle The handle of the controller to run diagnostics on.
51   @param  ChildHandle      The handle of the child controller to run diagnostics on
52                            This is an optional parameter that may be NULL.  It will
53                            be NULL for device drivers.  It will also be NULL for a
54                            bus drivers that wish to run diagnostics on the bus
55                            controller.  It will not be NULL for a bus driver that
56                            wishes to run diagnostics on one of its child controllers.
57   @param  DiagnosticType   Indicates type of diagnostics to perform on the controller
58                            specified by ControllerHandle and ChildHandle.   See
59                            "Related Definitions" for the list of supported types.
60   @param  Language         A pointer to a three character ISO 639-2 language
61                            identifier.  This is the language in which the optional
62                            error message should be returned in Buffer, and it must
63                            match one of the languages specified in SupportedLanguages.
64                            The number of languages supported by a driver is up to
65                            the driver writer.
66   @param  ErrorType        A GUID that defines the format of the data returned in Buffer.
67   @param  BufferSize       The size, in bytes, of the data returned in Buffer.
68   @param  Buffer           A buffer that contains a Null-terminated string
69                            plus some additional data whose format is defined by
70                            ErrorType.  Buffer is allocated by this function with
71                            AllocatePool(), and it is the caller's responsibility
72                            to free it with a call to FreePool().
73 
74   @retval EFI_SUCCESS           The controller specified by ControllerHandle and
75                                 ChildHandle passed the diagnostic.
76   @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
77   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid EFI_HANDLE.
78   @retval EFI_INVALID_PARAMETER Language is NULL.
79   @retval EFI_INVALID_PARAMETER ErrorType is NULL.
80   @retval EFI_INVALID_PARAMETER BufferType is NULL.
81   @retval EFI_INVALID_PARAMETER Buffer is NULL.
82   @retval EFI_UNSUPPORTED       The driver specified by This does not support
83                                 running diagnostics for the controller specified
84                                 by ControllerHandle and ChildHandle.
85   @retval EFI_UNSUPPORTED       The driver specified by This does not support the
86                                 type of diagnostic specified by DiagnosticType.
87   @retval EFI_UNSUPPORTED       The driver specified by This does not support the
88                                 language specified by Language.
89   @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to complete
90                                 the diagnostics.
91   @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to return
92                                 the status information in ErrorType, BufferSize,
93                                 and Buffer.
94   @retval EFI_DEVICE_ERROR      The controller specified by ControllerHandle and
95                                 ChildHandle did not pass the diagnostic.
96 
97 **/
98 typedef
99 EFI_STATUS
100 (EFIAPI *EFI_DRIVER_DIAGNOSTICS_RUN_DIAGNOSTICS)(
101   IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL                        *This,
102   IN  EFI_HANDLE                                            ControllerHandle,
103   IN  EFI_HANDLE                                            ChildHandle  OPTIONAL,
104   IN  EFI_DRIVER_DIAGNOSTIC_TYPE                            DiagnosticType,
105   IN  CHAR8                                                 *Language,
106   OUT EFI_GUID                                              **ErrorType,
107   OUT UINTN                                                 *BufferSize,
108   OUT CHAR16                                                **Buffer
109   );
110 
111 ///
112 /// Used to perform diagnostics on a controller that an EFI Driver is managing.
113 ///
114 struct _EFI_DRIVER_DIAGNOSTICS_PROTOCOL {
115   EFI_DRIVER_DIAGNOSTICS_RUN_DIAGNOSTICS    RunDiagnostics;
116   ///
117   /// A Null-terminated ASCII string that contains one or more ISO 639-2
118   /// language codes.  This is the list of language codes that this protocol supports.
119   ///
120   CHAR8                                     *SupportedLanguages;
121 };
122 
123 extern EFI_GUID  gEfiDriverDiagnosticsProtocolGuid;
124 
125 #endif
126