]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h
Add comments to describe the difference between code and spec to fix the bug #202430
[mirror_edk2.git] / IntelFrameworkModulePkg / Include / Library / GenericBdsLib.h
index db302c986a7f002e555508d18f26a47c791734c0..921326dcfcfaa192fbc5f7423b3a6279c846ab47 100644 (file)
@@ -20,28 +20,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 extern EFI_HANDLE mBdsImageHandle;\r
 \r
-//\r
-// Constants which are variable names used to access variables\r
-//\r
+///\r
+/// Constants which are variable names used to access variables\r
+///\r
 #define VAR_LEGACY_DEV_ORDER L"LegacyDevOrder"\r
 \r
-//\r
-// Data structures and defines\r
-//\r
+///\r
+/// Data structures and defines\r
+///\r
 #define FRONT_PAGE_QUESTION_ID  0x0000\r
 #define FRONT_PAGE_DATA_WIDTH   0x01\r
 \r
-//\r
-// ConnectType\r
-//\r
+///\r
+/// ConnectType\r
+///\r
 #define CONSOLE_OUT 0x00000001\r
 #define STD_ERROR   0x00000002\r
 #define CONSOLE_IN  0x00000004\r
 #define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
 \r
-//\r
-// Load Option Attributes defined in EFI Specification\r
-//\r
+///\r
+/// Load Option Attributes\r
+///\r
 #define LOAD_OPTION_ACTIVE              0x00000001\r
 #define LOAD_OPTION_FORCE_RECONNECT     0x00000002\r
 \r
@@ -56,22 +56,19 @@ extern EFI_HANDLE mBdsImageHandle;
 \r
 #define IS_LOAD_OPTION_TYPE(_c, _Mask)  (BOOLEAN) (((_c) & (_Mask)) != 0)\r
 \r
-//\r
-// Define Maxmim characters that will be accepted\r
-//\r
+///\r
+/// Define Maxmim characters that will be accepted\r
+///\r
 #define MAX_CHAR            480\r
 #define MAX_CHAR_SIZE       (MAX_CHAR * 2)\r
 \r
-#define MIN_ALIGNMENT_SIZE  4\r
-#define ALIGN_SIZE(a)       ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)\r
-\r
-//\r
-// Define maximum characters for boot option variable "BootXXXX"\r
-//\r
+///\r
+/// Define maximum characters for boot option variable "BootXXXX"\r
+///\r
 #define BOOT_OPTION_MAX_CHAR 10\r
 \r
 //\r
-// This data structure is the part of BDS_CONNECT_ENTRY that we can hard code.\r
+// This data structure is the part of BDS_CONNECT_ENTRY\r
 //\r
 #define BDS_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'C', 'O')\r
 \r
@@ -98,10 +95,6 @@ typedef struct {
   UINTN                     ConnectType;\r
 } BDS_CONSOLE_CONNECT_ENTRY;\r
 \r
-//\r
-// Lib Functions\r
-//\r
-\r
 //\r
 // Bds boot related lib functions\r
 //\r
@@ -182,6 +175,7 @@ BdsLibBootViaBootOption (
   @retval EFI_SUCCESS            Finished all the boot device enumerate and create\r
                                  the boot option base on that boot device\r
 \r
+  @retval EFI_OUT_OF_RESOURCES   Failed to enumerate the boot device and create the boot option list\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -260,15 +254,11 @@ BdsLibLoadDrivers (
   Process BootOrder, or DriverOrder variables, by calling\r
   BdsLibVariableToOption () for each UINT16 in the variables.\r
 \r
-  @param  BdsCommonOptionList   The header of the option list base on variable\r
-                                VariableName\r
-  @param  VariableName          EFI Variable name indicate the BootOrder or\r
-                                DriverOrder\r
-\r
-  @retval EFI_SUCCESS           Success create the boot option or driver option\r
-                                list\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to get the boot option or driver option list\r
+  @param  BdsCommonOptionList   The header of the option list base on variable VariableName.\r
+  @param  VariableName          EFI Variable name indicate the BootOrder or DriverOrder.\r
 \r
+  @retval EFI_SUCCESS           Success create the boot option or driver option list.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to get the boot option or driver option list.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -666,12 +656,13 @@ BdsDeleteAllInvalidLegacyBootOptions (
   );\r
 \r
 /**\r
-\r
   Add the legacy boot options from BBS table if they do not exist.\r
 \r
-  @retval EFI_SUCCESS       The boot options are added successfully \r
-                            or they are already in boot options.\r
-\r
+  @retval EFI_SUCCESS          The boot options are added successfully \r
+                               or they are already in boot options.\r
+  @retval EFI_NOT_FOUND        No legacy boot options is found.\r
+  @retval EFI_OUT_OF_RESOURCE  No enough memory.\r
+  @return Other value          LegacyBoot options are not added.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -680,12 +671,14 @@ BdsAddNonExistingLegacyBootOptions (
   );\r
 \r
 /**\r
-\r
   Add the legacy boot devices from BBS table into \r
   the legacy device boot order.\r
 \r
-  @retval EFI_SUCCESS       The boot devices are added successfully.\r
-\r
+  @retval EFI_SUCCESS           The boot devices are added successfully.\r
+  @retval EFI_NOT_FOUND         The legacy boot devices are not found.\r
+  @retval EFI_OUT_OF_RESOURCES  Memmory or storage is not enough.\r
+  @retval EFI_DEVICE_ERROR      Fail to add the legacy device boot order into EFI variable\r
+                                because of hardware error.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -694,13 +687,13 @@ BdsUpdateLegacyDevOrder (
   );\r
 \r
 /**\r
-\r
   Set the boot priority for BBS entries based on boot option entry and boot order.\r
 \r
   @param  Entry             The boot option is to be checked for refresh BBS table.\r
   \r
-  @retval EFI_SUCCESS       The boot priority for BBS entries is refreshed successfully.\r
-\r
+  @retval EFI_SUCCESS           The boot priority for BBS entries is refreshed successfully.\r
+  @retval EFI_NOT_FOUND         BBS entries can't be found.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to get the legacy device boot order.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -709,15 +702,16 @@ BdsRefreshBbsTableForBoot (
   );\r
 \r
 /**\r
+  Deletete the Boot Option from EFI Variable. The Boot Order Arrray\r
+  is also updated.\r
 \r
-  Delete boot option specified by OptionNumber and adjust the boot order.\r
-\r
-  @param  OptionNumber      The boot option to be deleted.\r
-  @param  BootOrder         Boot order list to be adjusted by remove this boot option.\r
-  @param  BootOrderSize     The size of Boot order list will be modified.\r
-  \r
-  @retval EFI_SUCCESS       The boot option is deleted successfully.\r
+  @param OptionNumber    The number of Boot option want to be deleted.\r
+  @param BootOrder       The Boot Order array.\r
+  @param BootOrderSize   The size of the Boot Order Array.\r
 \r
+  @retval  EFI_SUCCESS           The Boot Option Variable was found and removed\r
+  @retval  EFI_UNSUPPORTED       The Boot Option Variable store was inaccessible\r
+  @retval  EFI_NOT_FOUND         The Boot Option Variable was not found\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -808,10 +802,9 @@ SetupResetReminder (
   );\r
 \r
 \r
-//\r
-// Define the boot option default description \r
-// NOTE: This is not defined in UEFI spec.\r
-//\r
+///\r
+/// Define the boot option default description \r
+///\r
 #define DESCRIPTION_FLOPPY        L"EFI Floppy"\r
 #define DESCRIPTION_FLOPPY_NUM    L"EFI Floppy %d"\r
 #define DESCRIPTION_DVD           L"EFI DVD/CDROM"\r
@@ -827,42 +820,43 @@ SetupResetReminder (
 #define DESCRIPTION_NON_BLOCK     L"EFI Non-Block Boot Device"\r
 #define DESCRIPTION_NON_BLOCK_NUM L"EFI Non-Block Boot Device %d"\r
 \r
-//\r
-// Define the boot type which to classify the boot option type\r
-// Different boot option type could have different boot behavior\r
-// Use their device path node (Type + SubType) as type value\r
-// The boot type here can be added according to requirement\r
-//\r
-//\r
-// ACPI boot type. For ACPI device, cannot use sub-type to distinguish device, so hardcode their value\r
-//\r
+///\r
+/// Define the boot type which to classify the boot option type\r
+/// Different boot option type could have different boot behavior\r
+/// Use their device path node (Type + SubType) as type value\r
+/// The boot type here can be added according to requirement\r
+///\r
+\r
+///\r
+/// ACPI boot type. For ACPI device, cannot use sub-type to distinguish device, so hardcode their value\r
+///\r
 #define  BDS_EFI_ACPI_FLOPPY_BOOT         0x0201\r
-//\r
-// Message boot type\r
-// If a device path of boot option only point to a message node, the boot option is message boot type\r
-//\r
+///\r
+/// Message boot type\r
+/// If a device path of boot option only point to a message node, the boot option is message boot type\r
+///\r
 #define  BDS_EFI_MESSAGE_ATAPI_BOOT       0x0301 // Type 03; Sub-Type 01\r
 #define  BDS_EFI_MESSAGE_SCSI_BOOT        0x0302 // Type 03; Sub-Type 02\r
 #define  BDS_EFI_MESSAGE_USB_DEVICE_BOOT  0x0305 // Type 03; Sub-Type 05\r
 #define  BDS_EFI_MESSAGE_SATA_BOOT        0x0318 // Type 03; Sub-Type 18\r
 #define  BDS_EFI_MESSAGE_MISC_BOOT        0x03FF\r
-//\r
-// Media boot type\r
-// If a device path of boot option contain a media node, the boot option is media boot type\r
-//\r
+///\r
+/// Media boot type\r
+/// If a device path of boot option contain a media node, the boot option is media boot type\r
+///\r
 #define  BDS_EFI_MEDIA_HD_BOOT            0x0401 // Type 04; Sub-Type 01\r
 #define  BDS_EFI_MEDIA_CDROM_BOOT         0x0402 // Type 04; Sub-Type 02\r
-//\r
-// BBS boot type\r
-// If a device path of boot option contain a BBS node, the boot option is BBS boot type\r
-//\r
+///\r
+/// BBS boot type\r
+/// If a device path of boot option contain a BBS node, the boot option is BBS boot type\r
+///\r
 #define  BDS_LEGACY_BBS_BOOT              0x0501 //  Type 05; Sub-Type 01\r
 \r
 #define  BDS_EFI_UNSUPPORT                0xFFFF\r
 \r
-//\r
-// USB host controller Programming Interface.\r
-//\r
+///\r
+/// USB host controller Programming Interface.\r
+///\r
 #define  PCI_CLASSC_PI_UHCI               0x00\r
 #define  PCI_CLASSC_PI_EHCI               0x20\r
 \r
@@ -914,7 +908,7 @@ BdsExpandPartitionPartialDevicePathToFull (
 \r
   @param  DevicePath             Device Path to a  bootable device\r
 \r
-  @retval NULL                   The media on the DevicePath is not bootable\r
+  @return  The bootable media handle. If the media on the DevicePath is not bootable, NULL will return.\r
 \r
 **/\r
 EFI_HANDLE\r
@@ -970,23 +964,22 @@ BdsLibIsValidEFIBootOptDevicePathExt (
 \r
   @param  DevicePath                      The bootable device Path to check\r
 \r
-  @retval BDS_EFI_MEDIA_HD_BOOT           If the device path contains any media deviec path node, it is media boot type\r
-                                          For the floppy node, handle it as media node\r
-  @retval BDS_EFI_MEDIA_CDROM_BOOT        If the device path contains any media deviec path node, it is media boot type\r
-                                          For the floppy node, handle it as media node\r
-  @retval BDS_EFI_ACPI_FLOPPY_BOOT        If the device path contains any media deviec path node, it is media boot type\r
-                                          For the floppy node, handle it as media node\r
-  @retval BDS_EFI_MESSAGE_ATAPI_BOOT      If the device path not contains any media deviec path node,  and\r
-                                          its last device path node point to a message device path node, it is\r
-  \r
-  @retval BDS_EFI_MESSAGE_SCSI_BOOT       If the device path not contains any media deviec path node,  and\r
-                                          its last device path node point to a message device path node, it is\r
-  @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT If the device path not contains any media deviec path node,  and\r
-                                          its last device path node point to a message device path node, it is\r
-  @retval BDS_EFI_MESSAGE_MISC_BOOT       If the device path not contains any media deviec path node,  and\r
-                                          its last device path node point to a message device path node, it is\r
-  @retval BDS_LEGACY_BBS_BOOT             Legacy boot type\r
-  @retval BDS_EFI_UNSUPPORT               An EFI Removable BlockIO device path not point to a media and message devie,   \r
+  @retval BDS_EFI_MEDIA_HD_BOOT           If given device path contains MEDIA_DEVICE_PATH type device path node \r
+                                          which subtype is MEDIA_HARDDRIVE_DP\r
+  @retval BDS_EFI_MEDIA_CDROM_BOOT        If given device path contains MEDIA_DEVICE_PATH type device path node\r
+                                          which subtype is MEDIA_CDROM_DP\r
+  @retval BDS_EFI_ACPI_FLOPPY_BOOT        If given device path contains ACPI_DEVICE_PATH type device path node\r
+                                          which HID is floppy device.\r
+  @retval BDS_EFI_MESSAGE_ATAPI_BOOT      If given device path contains MESSAGING_DEVICE_PATH type device path node\r
+                                          and its last device path node's subtype is MSG_ATAPI_DP.\r
+  @retval BDS_EFI_MESSAGE_SCSI_BOOT       If given device path contains MESSAGING_DEVICE_PATH type device path node\r
+                                          and its last device path node's subtype is MSG_SCSI_DP.\r
+  @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT If given device path contains MESSAGING_DEVICE_PATH type device path node\r
+                                          and its last device path node's subtype is MSG_USB_DP.\r
+  @retval BDS_EFI_MESSAGE_MISC_BOOT       If the device path not contains any media device path node,  and\r
+                                          its last device path node point to a message device path node.\r
+  @retval BDS_LEGACY_BBS_BOOT             If given device path contains BBS_DEVICE_PATH type device path node.\r
+  @retval BDS_EFI_UNSUPPORT               An EFI Removable BlockIO device path not point to a media and message device,   \r
 \r
 **/\r
 UINT32\r