of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is\r
defined, then debug and assert related macros wrapped by it are the NULL implementations.\r
\r
+Copyright (c) 2019, NVIDIA Corporation. All rights reserved.\r
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials are licensed and made available under\r
-the terms and conditions of the BSD License that accompanies this distribution.\r
-The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#ifndef __UEFI_LIB_H__\r
#define __UEFI_LIB_H__\r
\r
+#include <IndustryStandard/Acpi.h>\r
+\r
#include <Protocol/DriverBinding.h>\r
#include <Protocol/DriverConfiguration.h>\r
#include <Protocol/ComponentName.h>\r
#include <Protocol/DriverDiagnostics.h>\r
#include <Protocol/DriverDiagnostics2.h>\r
#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/SimpleFileSystem.h>\r
\r
#include <Library/BaseLib.h>\r
\r
IN CONST EFI_GUID *ProtocolGuid\r
);\r
\r
+/**\r
+ * This function checks the supported languages list for a target language,\r
+ * This only supports RFC 4646 Languages.\r
+ *\r
+ * @param SupportedLanguages The supported languages\r
+ * @param TargetLanguage The target language\r
+ *\r
+ * @return Returns EFI_SUCCESS if the language is supported,\r
+ * EFI_UNSUPPORTED otherwise\r
+ */\r
+EFI_STATUS\r
+EFIAPI\r
+IsLanguageSupported (\r
+ IN CONST CHAR8 *SupportedLanguages,\r
+ IN CONST CHAR8 *TargetLanguage\r
+ );\r
+\r
/**\r
This function looks up a Unicode string in UnicodeStringTable.\r
\r
@param[out] Value The buffer point saved the variable info.\r
@param[out] Size The buffer size of the variable.\r
\r
- @return EFI_OUT_OF_RESOURCES Allocate buffer failed.\r
- @return EFI_SUCCESS Find the specified variable.\r
- @return Others Errors Return errors from call to gRT->GetVariable.\r
+ @retval EFI_OUT_OF_RESOURCES Allocate buffer failed.\r
+ @retval EFI_SUCCESS Find the specified variable.\r
+ @retval Others Errors Return errors from call to gRT->GetVariable.\r
\r
**/\r
EFI_STATUS\r
@param[out] Value The buffer point saved the variable info.\r
@param[out] Size The buffer size of the variable.\r
\r
- @return EFI_OUT_OF_RESOURCES Allocate buffer failed.\r
- @return EFI_SUCCESS Find the specified variable.\r
- @return Others Errors Return errors from call to gRT->GetVariable.\r
+ @retval EFI_OUT_OF_RESOURCES Allocate buffer failed.\r
+ @retval EFI_SUCCESS Find the specified variable.\r
+ @retval Others Errors Return errors from call to gRT->GetVariable.\r
\r
**/\r
EFI_STATUS\r
OUT UINTN *Size OPTIONAL\r
);\r
\r
+/** Return the attributes of the variable.\r
+\r
+ Returns the status whether get the variable success. The function retrieves\r
+ variable through the UEFI Runtime Service GetVariable(). The\r
+ returned buffer is allocated using AllocatePool(). The caller is responsible\r
+ for freeing this buffer with FreePool(). The attributes are returned if\r
+ the caller provides a valid Attribute parameter.\r
+\r
+ If Name is NULL, then ASSERT().\r
+ If Guid is NULL, then ASSERT().\r
+ If Value is NULL, then ASSERT().\r
+\r
+ @param[in] Name The pointer to a Null-terminated Unicode string.\r
+ @param[in] Guid The pointer to an EFI_GUID structure\r
+ @param[out] Value The buffer point saved the variable info.\r
+ @param[out] Size The buffer size of the variable.\r
+ @param[out] Attr The pointer to the variable attributes as found in var store\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Allocate buffer failed.\r
+ @retval EFI_SUCCESS Find the specified variable.\r
+ @retval Others Errors Return errors from call to gRT->GetVariable.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetVariable3(\r
+ IN CONST CHAR16 *Name,\r
+ IN CONST EFI_GUID *Guid,\r
+ OUT VOID **Value,\r
+ OUT UINTN *Size OPTIONAL,\r
+ OUT UINT32 *Attr OPTIONAL\r
+ );\r
+\r
/**\r
Returns a pointer to an allocated buffer that contains the best matching language\r
from a set of supported languages.\r
...\r
);\r
\r
+\r
/**\r
Installs and completes the initialization of a Driver Binding Protocol instance.\r
\r
);\r
\r
\r
+/**\r
+ Uninstalls a Driver Binding Protocol instance.\r
+\r
+ If DriverBinding is NULL, then ASSERT().\r
+ If DriverBinding can not be uninstalled, then ASSERT().\r
+\r
+ @param DriverBinding A Driver Binding Protocol instance that this driver produced.\r
+\r
+ @retval EFI_SUCCESS The protocol uninstallation successfully completed.\r
+ @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibUninstallDriverBinding (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding\r
+ );\r
+\r
+\r
/**\r
Installs and completes the initialization of a Driver Binding Protocol instance and\r
optionally installs the Component Name, Driver Configuration and Driver Diagnostics Protocols.\r
);\r
\r
\r
+/**\r
+ Uninstalls a Driver Binding Protocol instance and optionally uninstalls the\r
+ Component Name, Driver Configuration and Driver Diagnostics Protocols.\r
+\r
+ If DriverBinding is NULL, then ASSERT().\r
+ If the uninstallation fails, then ASSERT().\r
+\r
+ @param DriverBinding A Driver Binding Protocol instance that this driver produced.\r
+ @param ComponentName A Component Name Protocol instance that this driver produced.\r
+ @param DriverConfiguration A Driver Configuration Protocol instance that this driver produced.\r
+ @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver produced.\r
+\r
+ @retval EFI_SUCCESS The protocol uninstallation successfully completed.\r
+ @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibUninstallAllDriverProtocols (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\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
Installs Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.\r
);\r
\r
\r
+/**\r
+ Uninstalls Driver Binding Protocol with optional Component Name and Component Name 2 Protocols.\r
+\r
+ If DriverBinding is NULL, then ASSERT().\r
+ If the uninstallation fails, then ASSERT().\r
+\r
+ @param DriverBinding A Driver Binding Protocol instance that this driver produced.\r
+ @param ComponentName A Component Name Protocol instance that this driver produced.\r
+ @param ComponentName2 A Component Name 2 Protocol instance that this driver produced.\r
+\r
+ @retval EFI_SUCCESS The protocol installation successfully completed.\r
+ @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibUninstallDriverBindingComponentName2 (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
+ IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
+ IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL\r
+ );\r
+\r
+\r
/**\r
Installs Driver Binding Protocol with optional Component Name, Component Name 2, Driver\r
Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.\r
IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL\r
);\r
\r
+\r
+/**\r
+ Uninstalls Driver Binding Protocol with optional Component Name, Component Name 2, Driver\r
+ Configuration, Driver Configuration 2, Driver Diagnostics, and Driver Diagnostics 2 Protocols.\r
+\r
+ If DriverBinding is NULL, then ASSERT().\r
+ If the installation fails, then ASSERT().\r
+\r
+\r
+ @param DriverBinding A Driver Binding Protocol instance that this driver produced.\r
+ @param ComponentName A Component Name Protocol instance that this driver produced.\r
+ @param ComponentName2 A Component Name 2 Protocol instance that this driver produced.\r
+ @param DriverConfiguration A Driver Configuration Protocol instance that this driver produced.\r
+ @param DriverConfiguration2 A Driver Configuration Protocol 2 instance that this driver produced.\r
+ @param DriverDiagnostics A Driver Diagnostics Protocol instance that this driver produced.\r
+ @param DriverDiagnostics2 A Driver Diagnostics Protocol 2 instance that this driver produced.\r
+\r
+ @retval EFI_SUCCESS The protocol uninstallation successfully completed.\r
+ @retval Others Status from gBS->UninstallMultipleProtocolInterfaces().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiLibUninstallAllDriverProtocols2 (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\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_CONFIGURATION2_PROTOCOL *DriverConfiguration2, OPTIONAL\r
+ IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL\r
+ IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL\r
+ );\r
+\r
+\r
/**\r
Appends a formatted Unicode string to a Null-terminated Unicode string\r
\r
OUT UINTN *NoProtocols,\r
OUT VOID ***Buffer\r
);\r
+\r
+/**\r
+ Open or create a file or directory, possibly creating the chain of\r
+ directories leading up to the directory.\r
+\r
+ EfiOpenFileByDevicePath() first locates EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on\r
+ FilePath, and opens the root directory of that filesystem with\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume().\r
+\r
+ On the remaining device path, the longest initial sequence of\r
+ FILEPATH_DEVICE_PATH nodes is node-wise traversed with\r
+ EFI_FILE_PROTOCOL.Open().\r
+\r
+ (As a consequence, if OpenMode includes EFI_FILE_MODE_CREATE, and Attributes\r
+ includes EFI_FILE_DIRECTORY, and each FILEPATH_DEVICE_PATH specifies a single\r
+ pathname component, then EfiOpenFileByDevicePath() ensures that the specified\r
+ series of subdirectories exist on return.)\r
+\r
+ The EFI_FILE_PROTOCOL identified by the last FILEPATH_DEVICE_PATH node is\r
+ output to the caller; intermediate EFI_FILE_PROTOCOL instances are closed. If\r
+ there are no FILEPATH_DEVICE_PATH nodes past the node that identifies the\r
+ filesystem, then the EFI_FILE_PROTOCOL of the root directory of the\r
+ filesystem is output to the caller. If a device path node that is different\r
+ from FILEPATH_DEVICE_PATH is encountered relative to the filesystem, the\r
+ traversal is stopped with an error, and a NULL EFI_FILE_PROTOCOL is output.\r
+\r
+ @param[in,out] FilePath On input, the device path to the file or directory\r
+ to open or create. The caller is responsible for\r
+ ensuring that the device path pointed-to by FilePath\r
+ is well-formed. On output, FilePath points one past\r
+ the last node in the original device path that has\r
+ been successfully processed. FilePath is set on\r
+ output even if EfiOpenFileByDevicePath() returns an\r
+ error.\r
+\r
+ @param[out] File On error, File is set to NULL. On success, File is\r
+ set to the EFI_FILE_PROTOCOL of the root directory\r
+ of the filesystem, if there are no\r
+ FILEPATH_DEVICE_PATH nodes in FilePath; otherwise,\r
+ File is set to the EFI_FILE_PROTOCOL identified by\r
+ the last node in FilePath.\r
+\r
+ @param[in] OpenMode The OpenMode parameter to pass to\r
+ EFI_FILE_PROTOCOL.Open().\r
+\r
+ @param[in] Attributes The Attributes parameter to pass to\r
+ EFI_FILE_PROTOCOL.Open().\r
+\r
+ @retval EFI_SUCCESS The file or directory has been opened or\r
+ created.\r
+\r
+ @retval EFI_INVALID_PARAMETER FilePath is NULL; or File is NULL; or FilePath\r
+ contains a device path node, past the node\r
+ that identifies\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, that is not a\r
+ FILEPATH_DEVICE_PATH node.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r
+\r
+ @return Error codes propagated from the\r
+ LocateDevicePath() and OpenProtocol() boot\r
+ services, and from the\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume()\r
+ and EFI_FILE_PROTOCOL.Open() member functions.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiOpenFileByDevicePath (\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
+ OUT EFI_FILE_PROTOCOL **File,\r
+ IN UINT64 OpenMode,\r
+ IN UINT64 Attributes\r
+ );\r
+\r
+/**\r
+ This function locates next ACPI table in XSDT/RSDT based on Signature and\r
+ previous returned Table.\r
+\r
+ If PreviousTable is NULL:\r
+ This function will locate the first ACPI table in XSDT/RSDT based on\r
+ Signature in gEfiAcpi20TableGuid system configuration table first, and then\r
+ gEfiAcpi10TableGuid system configuration table.\r
+ This function will locate in XSDT first, and then RSDT.\r
+ For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in\r
+ FADT.\r
+ For FACS, this function will locate XFirmwareCtrl in FADT first, and then\r
+ FirmwareCtrl in FADT.\r
+\r
+ If PreviousTable is not NULL:\r
+ 1. If it could be located in XSDT in gEfiAcpi20TableGuid system configuration\r
+ table, then this function will just locate next table in XSDT in\r
+ gEfiAcpi20TableGuid system configuration table.\r
+ 2. If it could be located in RSDT in gEfiAcpi20TableGuid system configuration\r
+ table, then this function will just locate next table in RSDT in\r
+ gEfiAcpi20TableGuid system configuration table.\r
+ 3. If it could be located in RSDT in gEfiAcpi10TableGuid system configuration\r
+ table, then this function will just locate next table in RSDT in\r
+ gEfiAcpi10TableGuid system configuration table.\r
+\r
+ It's not supported that PreviousTable is not NULL but PreviousTable->Signature\r
+ is not same with Signature, NULL will be returned.\r
+\r
+ @param Signature ACPI table signature.\r
+ @param PreviousTable Pointer to previous returned table to locate next\r
+ table, or NULL to locate first table.\r
+\r
+ @return Next ACPI table or NULL if not found.\r
+\r
+**/\r
+EFI_ACPI_COMMON_HEADER *\r
+EFIAPI\r
+EfiLocateNextAcpiTable (\r
+ IN UINT32 Signature,\r
+ IN EFI_ACPI_COMMON_HEADER *PreviousTable OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function locates first ACPI table in XSDT/RSDT based on Signature.\r
+\r
+ This function will locate the first ACPI table in XSDT/RSDT based on\r
+ Signature in gEfiAcpi20TableGuid system configuration table first, and then\r
+ gEfiAcpi10TableGuid system configuration table.\r
+ This function will locate in XSDT first, and then RSDT.\r
+ For DSDT, this function will locate XDsdt in FADT first, and then Dsdt in\r
+ FADT.\r
+ For FACS, this function will locate XFirmwareCtrl in FADT first, and then\r
+ FirmwareCtrl in FADT.\r
+\r
+ @param Signature ACPI table signature.\r
+\r
+ @return First ACPI table or NULL if not found.\r
+\r
+**/\r
+EFI_ACPI_COMMON_HEADER *\r
+EFIAPI\r
+EfiLocateFirstAcpiTable (\r
+ IN UINT32 Signature\r
+ );\r
+\r
#endif\r