]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/UefiLib.h
Remove prefix EFI_ from some TPL macros reference in some comments
[mirror_edk2.git] / MdePkg / Include / Library / UefiLib.h
index 428235cbf23640a4406100614c0089a224743eae..7b247e063cd9c865d02e5fe68820cad3bb7bba5f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   MDE UEFI library functions and macros\r
 \r
-  Copyright (c) 2006, Intel Corporation                                                         \r
+  Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
   All rights reserved. This program and the accompanying materials                          \r
   are licensed and made available under the terms and conditions of the BSD License         \r
   which accompanies this distribution.  The full text of the license may be found at        \r
 #ifndef __UEFI_LIB_H__\r
 #define __UEFI_LIB_H__\r
 \r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/DriverConfiguration.h>\r
+#include <Protocol/ComponentName.h>\r
+#include <Protocol/ComponentName2.h>\r
+#include <Protocol/DriverDiagnostics.h>\r
+#include <Protocol/DriverDiagnostics2.h>\r
+\r
 //\r
 // Unicode String Table\r
 //\r
@@ -84,7 +91,7 @@ EfiCreateProtocolNotifyEvent(
   IN  EFI_TPL           NotifyTpl,\r
   IN  EFI_EVENT_NOTIFY  NotifyFunction,\r
   IN  VOID              *NotifyContext,  OPTIONAL\r
-  OUT VOID              *Registration\r
+  OUT VOID              **Registration\r
   );\r
 \r
 /**\r
@@ -109,7 +116,7 @@ EfiNamedEventListen (
   IN EFI_TPL           NotifyTpl,\r
   IN EFI_EVENT_NOTIFY  NotifyFunction,\r
   IN CONST VOID        *NotifyContext,  OPTIONAL\r
-  OUT VOID             *Registration    OPTIONAL\r
+  OUT VOID             *Registration OPTIONAL\r
   );\r
 \r
 /**\r
@@ -128,6 +135,26 @@ EfiNamedEventSignal (
   IN CONST EFI_GUID  *Name\r
   );\r
 \r
+/** \r
+  Returns the current TPL.\r
+\r
+  This function returns the current TPL.  There is no EFI service to directly \r
+  retrieve the current TPL. Instead, the RaiseTPL() function is used to raise \r
+  the TPL to TPL_HIGH_LEVEL.  This will return the current TPL.  The TPL level \r
+  can then immediately be restored back to the current TPL level with a call \r
+  to RestoreTPL().\r
+\r
+  @param  VOID\r
+\r
+  @retvale EFI_TPL              The current TPL.\r
+\r
+**/\r
+EFI_TPL\r
+EFIAPI\r
+EfiGetCurrentTpl (\r
+  VOID\r
+  );\r
+\r
 /**\r
   This function initializes a basic mutual exclusion lock to the released state \r
   and returns the lock.  Each lock provides mutual exclusion access at its task \r
@@ -160,7 +187,7 @@ EfiInitializeLock (
 \r
 **/\r
 #define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \\r
-  {Priority, EFI_TPL_APPLICATION, EfiLockReleased }\r
+  {Priority, TPL_APPLICATION, EfiLockReleased }\r
 \r
 \r
 /**\r
@@ -189,7 +216,7 @@ EfiInitializeLock (
 \r
 \r
 /**\r
-  This function raises the system¡¯s current task priority level to the task \r
+  This function raises the system's current task priority level to the task \r
   priority level of the mutual exclusion lock.  Then, it places the lock in the \r
   acquired state.\r
 \r
@@ -203,7 +230,7 @@ EfiAcquireLock (
   );\r
 \r
 /**\r
-  This function raises the system¡¯s current task priority level to the task \r
+  This function raises the system's current task priority level to the task \r
   priority level of the mutual exclusion lock.  Then, it attempts to place the \r
   lock in the acquired state.\r
 \r
@@ -221,7 +248,7 @@ EfiAcquireLockOrFail (
 \r
 /**\r
   This function transitions a mutual exclusion lock from the acquired state to \r
-  the released state, and restores the system¡¯s task priority level to its \r
+  the released state, and restores the system's task priority level to its \r
   previous level.\r
 \r
   @param  Lock  A pointer to the lock to release.\r
@@ -233,6 +260,64 @@ EfiReleaseLock (
   IN EFI_LOCK  *Lock\r
   );\r
 \r
+/**
+  Tests whether a controller handle is being managed by a specific driver.
+
+  This function tests whether the driver specified by DriverBindingHandle is\r
+  currently managing the controller specified by ControllerHandle.  This test\r
+  is performed by evaluating if the the protocol specified by ProtocolGuid is\r
+  present on ControllerHandle and is was opened by DriverBindingHandle with an\r
+  attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r
+  If ProtocolGuid is NULL, then ASSERT().\r
+
+  @param  ControllerHandle     A handle for a controller to test.
+  @param  DriverBindingHandle  Specifies the driver binding handle for the
+                               driver.
+  @param  ProtocolGuid         Specifies the protocol that the driver specified
+                               by DriverBindingHandle opens in its Start()
+                               function.
+
+  @retval EFI_SUCCESS          ControllerHandle is managed by the driver
+                               specifed by DriverBindingHandle.
+  @retval EFI_UNSUPPORTED      ControllerHandle is not managed by the driver
+                               specifed by DriverBindingHandle.
+
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiTestManagedDevice (\r
+  IN CONST EFI_HANDLE       ControllerHandle,\r
+  IN CONST EFI_HANDLE       DriverBindingHandle,\r
+  IN CONST EFI_GUID         *ProtocolGuid\r
+  );\r
+\r
+/**
+  Tests whether a child handle is a child device of the controller.
+
+  This function tests whether ChildHandle is one of the children of\r
+  ControllerHandle.  This test is performed by checking to see if the protocol\r
+  specified by ProtocolGuid is present on ControllerHandle and opened by\r
+  ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  If ProtocolGuid is NULL, then ASSERT().\r
+
+  @param  ControllerHandle     A handle for a (parent) controller to test. 
+  @param  ChildHandle          A child handle to test.
+  @param  ConsumsedGuid        Supplies the protocol that the child controller
+                               opens on its parent controller. 
+
+  @retval EFI_SUCCESS          ChildHandle is a child of the ControllerHandle.
+  @retval EFI_UNSUPPORTED      ChildHandle is not a child of the
+                               ControllerHandle.
+
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiTestChildHandle (\r
+  IN CONST EFI_HANDLE       ControllerHandle,\r
+  IN CONST EFI_HANDLE       ChildHandle,\r
+  IN CONST EFI_GUID         *ProtocolGuid\r
+  );\r
+\r
 /**\r
   This function looks up a Unicode string in UnicodeStringTable.  If Language is \r
   a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable\r
@@ -400,7 +485,7 @@ EfiSignalEventLegacyBoot (
   This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
   added and now it's possible to not voilate the UEFI specification by \r
   declaring a GUID for the legacy boot event class. This library supports\r
-  the R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to \r
+  the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r
   work both ways.\r
 \r
   @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
@@ -450,7 +535,7 @@ EfiCreateEventLegacyBootEx (
   This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
   added and now it's possible to not voilate the UEFI specification and use \r
   the ready to boot event class defined in UEFI 2.0. This library supports\r
-  the R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to \r
+  the EDK/EFI 1.10 form and EDKII/UEFI 2.0 form and allows common code to \r
   work both ways.\r
 \r
   @param  LegacyBootEvent   Returns the EFI event returned from gBS->CreateEvent(Ex).\r
@@ -499,7 +584,7 @@ EfiCreateEventReadyToBootEx (
   Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
   so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
   the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
+  device path is defined for Tiano extensions of device path. If the code \r
   is compiled to conform with the UEFI 2.0 specification use the new device path\r
   else use the old form for backwards compatability.\r
 \r
@@ -520,7 +605,7 @@ EfiInitializeFwVolDevicepathNode (
   Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
   so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
   the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
+  device path is defined for Tiano extensions of device path. If the code \r
   is compiled to conform with the UEFI 2.0 specification use the new device path\r
   else use the old form for backwards compatability. The return value to this\r
   function points to a location in FvDevicePathNode and it does not allocate\r
@@ -538,5 +623,217 @@ EfiGetNameGuidFromFwVolDevicePathNode (
   IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode\r
   );\r
 \r
+/** \r
+  Prints a formatted Unicode string to the console output device specified by \r
+  ConOut defined in the EFI_SYSTEM_TABLE.\r
+\r
+  This function prints a formatted Unicode string to the console output device \r
+  specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode \r
+  characters that printed to ConOut.  If the length of the formatted Unicode \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
+\r
+  @param Format   Null-terminated Unicode format string.\r
+  @param ...      VARARG list consumed to process Format.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+Print (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  );\r
+\r
+/** \r
+  Prints a formatted Unicode string to the console output device specified by \r
+  StdErr defined in the EFI_SYSTEM_TABLE.\r
+\r
+  This function prints a formatted Unicode string to the console output device \r
+  specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode \r
+  characters that printed to StdErr.  If the length of the formatted Unicode \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
+\r
+  @param Format   Null-terminated Unicode format string.\r
+  @param ...      VARARG list consumed to process Format.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+ErrorPrint (\r
+  IN CONST CHAR16  *Format,\r
+  ...\r
+  );\r
+\r
+/** \r
+  Prints a formatted ASCII string to the console output device specified by \r
+  ConOut defined in the EFI_SYSTEM_TABLE.\r
+\r
+  This function prints a formatted ASCII string to the console output device \r
+  specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII \r
+  characters that printed to ConOut.  If the length of the formatted ASCII \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
+\r
+  @param Format   Null-terminated ASCII format string.\r
+  @param ...      VARARG list consumed to process Format.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiPrint (\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  );\r
+\r
+/** \r
+  Prints a formatted ASCII string to the console output device specified by \r
+  StdErr defined in the EFI_SYSTEM_TABLE.\r
+\r
+  This function prints a formatted ASCII string to the console output device \r
+  specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII \r
+  characters that printed to StdErr.  If the length of the formatted ASCII \r
+  string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+  PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
+\r
+  @param Format   Null-terminated ASCII format string.\r
+  @param ...      VARARG list consumed to process Format.\r
+  If Format is NULL, then ASSERT().\r
+  If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiErrorPrint (\r
+  IN CONST CHAR8  *Format,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Intialize a driver by installing the Driver Binding Protocol onto the\r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+  @param  ImageHandle          The image handle of the driver\r
+  @param  SystemTable          The EFI System Table that was passed to the driver's entry point\r
+  @param  DriverBinding        A Driver Binding Protocol instance that this driver is producing\r
+  @param  DriverBindingHandle  The handle that DriverBinding is to be installe onto.  If this\r
+                               parameter is NULL, then a new handle is created.\r
+\r
+  @retval EFI_SUCCESS          DriverBinding is installed onto DriverBindingHandle\r
+  @retval Other                Status from gBS->InstallProtocolInterface()\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibInstallDriverBinding (\r
+  IN CONST EFI_HANDLE             ImageHandle,\r
+  IN CONST EFI_SYSTEM_TABLE       *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding,\r
+  IN EFI_HANDLE                   DriverBindingHandle\r
+  );\r
+\r
+/**\r
+  Intialize a driver by installing the Driver Binding Protocol onto the\r
+  driver's DriverBindingHandle.  This is typically the same as the driver's\r
+  ImageHandle, but it can be different if the driver produces multiple\r
+  DriverBinding Protocols.  This function also initializes the EFI Driver\r
+  Library that initializes the global variables gST, gBS, gRT.\r
+\r
+  @ImageHandle                 The image handle of the driver\r
+  @SystemTable                 The EFI System Table that was passed to the driver's entry point\r
+  @DriverBinding               A Driver Binding Protocol instance that this driver is producing\r
+  @DriverBindingHandle         The handle that DriverBinding is to be installe onto.  If this\r
+                               parameter is NULL, then a new handle is created.\r
+  @ComponentName               A Component Name Protocol instance that this driver is producing\r
+  @DriverConfiguration         A Driver Configuration Protocol instance that this driver is producing\r
+  @DriverDiagnostics           A Driver Diagnostics Protocol instance that this driver is producing\r
+\r
+  @retval EFI_SUCCESS          DriverBinding is installed onto DriverBindingHandle\r
+  @retval Other                Status from gBS->InstallProtocolInterface()\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibInstallAllDriverProtocols (\r
+  IN CONST EFI_HANDLE                         ImageHandle,\r
+  IN CONST EFI_SYSTEM_TABLE                   *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL              *DriverBinding,\r
+  IN EFI_HANDLE                               DriverBindingHandle,\r
+  IN CONST EFI_COMPONENT_NAME_PROTOCOL        *ComponentName,       OPTIONAL\r
+  IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration, OPTIONAL\r
+  IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics    OPTIONAL\r
+  );\r
+\r
+\r
+/**\r
+  Intialize a driver by installing the Driver Binding Protocol\r
+  onto the driver's DriverBindingHandle.  This is typically the\r
+  same as the driver's ImageHandle, but it can be different if\r
+  the driver produces multiple DriverBinding Protocols.  This\r
+  function also initializes the EFI Driver Library that\r
+  initializes the global variables gST, gBS, gRT.\r
+\r
+  @ImageHandle                  The image handle of the driver\r
+  \r
+  @SystemTable                  The EFI System Table that was\r
+                                passed to the driver's entry\r
+                                point\r
+  \r
+  @DriverBinding                A Driver Binding Protocol\r
+                                instance that this driver is\r
+                                producing\r
+  \r
+  @DriverBindingHandle          The handle that DriverBinding is\r
+                                to be installe onto.  If this\r
+                                parameter is NULL, then a new\r
+                                handle is created.\r
+  \r
+  @ComponentName                A Component Name Protocol\r
+                                instance that this driver is\r
+                                producing\r
+  \r
+  @ComponentName2               A Component Name 2 Protocol\r
+                                instance that this driver is\r
+                                producing\r
+  \r
+  @DriverConfiguration          A Driver Configuration Protocol\r
+                                instance that this driver is\r
+                                producing\r
+  \r
+  @DriverDiagnostics            A Driver Diagnostics Protocol\r
+                                instance that this driver is\r
+                                producing\r
+  \r
+  @DriverDiagnostics2           A Driver Diagnostics 2 Protocol\r
+                                instance that this driver is\r
+                                producing\r
+\r
+  @retval EFI_SUCCESS          DriverBinding is installed onto DriverBindingHandle\r
+  @retval Other                Status from gBS->InstallProtocolInterface()\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibInstallAllDriverProtocols2 (\r
+  IN CONST EFI_HANDLE                         ImageHandle,\r
+  IN CONST EFI_SYSTEM_TABLE                   *SystemTable,\r
+  IN EFI_DRIVER_BINDING_PROTOCOL              *DriverBinding,\r
+  IN EFI_HANDLE                               DriverBindingHandle,\r
+  IN CONST EFI_COMPONENT_NAME_PROTOCOL        *ComponentName,       OPTIONAL\r
+  IN CONST EFI_COMPONENT_NAME2_PROTOCOL       *ComponentName2,      OPTIONAL\r
+  IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration, OPTIONAL\r
+  IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics,   OPTIONAL\r
+  IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL   *DriverDiagnostics2   OPTIONAL\r
+  );\r
+\r
 \r
 #endif\r