]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/Bds: Fix various bugs in the new BDS
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 15 Jun 2011 19:56:50 +0000 (19:56 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 15 Jun 2011 19:56:50 +0000 (19:56 +0000)
The errors were:
- uncaught returned error
- used of uninitialized variables

ArmPlatformPkg/Bds: Implement the update of MemMap Boot Device

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11830 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Include/Library/BdsLib.h
ArmPkg/Library/BdsLib/BdsFilePath.c
ArmPkg/Library/BdsLib/BdsInternal.h
ArmPlatformPkg/Bds/BootOption.c
ArmPlatformPkg/Bds/BootOptionSupport.c

index a6ae2f108bc7373f4c227bc79904cc58e70ddd6d..75d01505fd3a75dd2af35bf764662c96148f775a 100644 (file)
 #ifndef __BDS_ENTRY_H__\r
 #define __BDS_ENTRY_H__\r
 \r
+/**\r
+  Connect a Device Path and return the handle of the driver that support this DevicePath\r
+\r
+  @param  DevicePath            Device Path of the File to connect\r
+  @param  Handle                Handle of the driver that support this DevicePath\r
+  @param  RemainingDevicePath   Remaining DevicePath nodes that do not match the driver DevicePath\r
+\r
+  @retval EFI_SUCCESS           A driver that matches the Device Path has been found\r
+  @retval EFI_NOT_FOUND         No handles match the search.\r
+  @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL\r
+\r
+**/\r
+EFI_STATUS\r
+BdsConnectDevicePath (\r
+  IN  EFI_DEVICE_PATH_PROTOCOL* DevicePath,\r
+  OUT EFI_HANDLE                *Handle,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **RemainingDevicePath\r
+  );\r
+\r
 /**\r
   Connect all DXE drivers\r
 \r
@@ -32,7 +51,7 @@ BdsConnectAllDrivers (
   Start a Linux kernel from a Device Path\r
 \r
   @param  LinuxKernel           Device Path to the Linux Kernel\r
-  @param  Parameters            Linux kernel agruments\r
+  @param  Parameters            Linux kernel arguments\r
   @param  Fdt                   Device Path to the Flat Device Tree\r
 \r
   @retval EFI_SUCCESS           All drivers have been connected\r
@@ -47,6 +66,23 @@ BdsBootLinux (
   IN  EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath\r
   );\r
 \r
+/**\r
+  Start an EFI Application from a Device Path\r
+\r
+  @param  ParentImageHandle     Handle of the calling image\r
+  @param  DevicePath            Location of the EFI Application\r
+\r
+  @retval EFI_SUCCESS           All drivers have been connected\r
+  @retval EFI_NOT_FOUND         The Linux kernel Device Path has not been found\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough resource memory to store the matching results.\r
+\r
+**/\r
+EFI_STATUS\r
+BdsStartEfiApplication (\r
+  IN EFI_HANDLE                  ParentImageHandle,\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
+  );\r
+\r
 /**\r
   Start an EFI Application from any Firmware Volume\r
 \r
index be1a824d50c8e7f99477339bfa997692a8ad0cec..69aa25561c293210e288fdf3a48618a14729ea3e 100644 (file)
@@ -298,6 +298,18 @@ TryRemovableDevice (
   return Status;
 }
 
+/**
+  Connect a Device Path and return the handle of the driver that support this DevicePath
+
+  @param  DevicePath            Device Path of the File to connect
+  @param  Handle                Handle of the driver that support this DevicePath
+  @param  RemainingDevicePath   Remaining DevicePath nodes that do not match the driver DevicePath
+
+  @retval EFI_SUCCESS           A driver that matches the Device Path has been found
+  @retval EFI_NOT_FOUND         No handles match the search.
+  @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL
+
+**/
 EFI_STATUS
 BdsConnectDevicePath (
   IN  EFI_DEVICE_PATH_PROTOCOL* DevicePath,
@@ -335,7 +347,7 @@ BdsConnectDevicePath (
     // Now, we have got the whole Device Path connected, call again ConnectController to ensure all the supported Driver
     // Binding Protocol are connected (such as DiskIo and SimpleFileSystem)
     Remaining = DevicePath;
-    Status = gBS->LocateDevicePath(&gEfiDevicePathProtocolGuid,&Remaining,Handle);
+    Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid,&Remaining,Handle);
     if (!EFI_ERROR (Status)) {
       Status = gBS->ConnectController (*Handle, NULL, Remaining, FALSE);
       if (EFI_ERROR (Status)) {
@@ -420,6 +432,9 @@ BdsFileSystemLoadImage (
 
   File = NULL;
   Status = Fs->Open(Fs, &File, FilePathDevicePath->PathName, EFI_FILE_MODE_READ, 0);
+  if (EFI_ERROR(Status)) {
+    return Status;
+  }
 
   Size = 0;
   File->GetInfo(File, &gEfiFileInfoGuid, &Size, NULL);
@@ -811,6 +826,17 @@ BdsLoadImage (
   return EFI_UNSUPPORTED;
 }
 
+/**
+  Start an EFI Application from a Device Path
+
+  @param  ParentImageHandle     Handle of the calling image
+  @param  DevicePath            Location of the EFI Application
+
+  @retval EFI_SUCCESS           All drivers have been connected
+  @retval EFI_NOT_FOUND         The Linux kernel Device Path has not been found
+  @retval EFI_OUT_OF_RESOURCES  There is not enough resource memory to store the matching results.
+
+**/
 EFI_STATUS
 BdsStartEfiApplication (
   IN EFI_HANDLE                  ParentImageHandle,
index a497df03ea97abbce779dc2ebb242333a58b18a1..dd961c816bfbda7d5662cdb345316b6511aaa391 100644 (file)
@@ -23,6 +23,7 @@
 #include <Library/DevicePathLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/DebugLib.h>
+#include <Library/BdsLib.h>
 #include <Library/BdsUnixLib.h>
 #include <Library/PerformanceLib.h>
 
index a8ba23fe739ce0e9ca83bbcc23526ed7c19c8e95..d3c7445fae3d7b463c965409bc5804eb4c1e5212 100644 (file)
@@ -258,8 +258,13 @@ BootOptionSetFields (
   CopyMem (&((BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments, BootArguments, AsciiStrSize(BootArguments));\r
   BootOption->OptionalData = (BDS_LOADER_OPTIONAL_DATA *)EfiLoadOptionPtr;\r
 \r
+  // If this function is called at the creation of the Boot Device entry (not at the update) the\r
+  // BootOption->LoadOptionSize must be zero then we get a new BootIndex for this entry\r
+  if (BootOption->LoadOptionSize == 0) {\r
+    BootOption->LoadOptionIndex = BootOptionAllocateBootIndex();\r
+  }\r
+\r
   // Fill the EFI Load option fields\r
-  BootOption->LoadOptionIndex = BootOptionAllocateBootIndex();\r
   BootOption->LoadOption = EfiLoadOption;\r
   BootOption->LoadOptionSize = EfiLoadOptionSize;\r
 \r
@@ -341,20 +346,20 @@ BootOptionUpdate (
   )\r
 {\r
   EFI_STATUS      Status;\r
-  BDS_LOAD_OPTION *BootOption;\r
   CHAR16          BootVariableName[9];\r
 \r
   // Update the BDS Load Option structure\r
   BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, BootArguments);\r
 \r
   // Update the related environment variables\r
-  UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BootOption->LoadOptionIndex);\r
+  UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex);\r
+\r
   Status = gRT->SetVariable (\r
       BootVariableName,\r
       &gEfiGlobalVariableGuid,\r
       EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-      BootOption->LoadOptionSize,\r
-      BootOption->LoadOption\r
+      BdsLoadOption->LoadOptionSize,\r
+      BdsLoadOption->LoadOption\r
       );\r
 \r
   return Status;\r
index 7de2df4825b761c279f8ea91b5d6e1944a74c632..a4396b5109bc01722cc448e069900789d560656f 100644 (file)
@@ -386,7 +386,7 @@ BdsLoadOptionFileSystemUpdateDevicePath (
 \r
   Print(L"File path of the EFI Application or the kernel: ");\r
   UnicodeStrToAsciiStr (EndingDevicePath->PathName,AsciiBootFilePath);\r
-  Status = EditHIInputAscii(AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\r
+  Status = EditHIInputAscii (AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return Status;\r
   }\r
@@ -567,9 +567,40 @@ BdsLoadOptionMemMapUpdateDevicePath (
   OUT UINT32 *Attributes\r
   )\r
 {\r
-  ASSERT(0);\r
-  //TODO: Implement me\r
-  return EFI_SUCCESS;\r
+  EFI_STATUS          Status;\r
+  CHAR8               AsciiStartingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+  CHAR8               AsciiEndingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+  MEMMAP_DEVICE_PATH* EndingDevicePath;\r
+  EFI_DEVICE_PATH*    DevicePath;\r
+\r
+  DevicePath = DuplicateDevicePath (BootOption->FilePathList);\r
+  EndingDevicePath = (MEMMAP_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
+\r
+  Print(L"Starting Address of the binary: ");\r
+  AsciiSPrint (AsciiStartingAddress,BOOT_DEVICE_ADDRESS_MAX,"0x%X",(UINTN)EndingDevicePath->StartingAddress);\r
+  Status = EditHIInputAscii (AsciiStartingAddress,BOOT_DEVICE_ADDRESS_MAX);\r
+  if (EFI_ERROR(Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  Print(L"Ending Address of the binary: ");\r
+  AsciiSPrint (AsciiEndingAddress,BOOT_DEVICE_ADDRESS_MAX,"0x%X",(UINTN)EndingDevicePath->EndingAddress);\r
+  Status = EditHIInputAscii (AsciiEndingAddress,BOOT_DEVICE_ADDRESS_MAX);\r
+  if (EFI_ERROR(Status)) {\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  EndingDevicePath->StartingAddress = AsciiStrHexToUint64 (AsciiStartingAddress);\r
+  EndingDevicePath->EndingAddress = AsciiStrHexToUint64 (AsciiEndingAddress);\r
+\r
+  Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  if (EFI_ERROR(Status)) {\r
+    FreePool(DevicePath);\r
+  } else {\r
+    *NewDevicePath = DevicePath;\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 BOOLEAN\r