diff mbox

[1/2] Auto boot feature for Origen.

Message ID 1349793510-17771-1-git-send-email-rony.nandy@linaro.org
State Accepted
Headers show

Commit Message

Rony Nandy Oct. 9, 2012, 2:38 p.m. UTC
Signed-off-by: Shivamurthy Shastri <shiva.murthy@samsung.com>
Signed-off-by: Rony Nandy <rony.nandy@linaro.org>
---
 .../0001-Auto-boot-feature-for-the-Origen.patch    |  124 ++++++++++++++++++++
 1 files changed, 124 insertions(+), 0 deletions(-)
 create mode 100644 SamsungPlatformPkg/patches/0001-Auto-boot-feature-for-the-Origen.patch
diff mbox

Patch

diff --git a/SamsungPlatformPkg/patches/0001-Auto-boot-feature-for-the-Origen.patch b/SamsungPlatformPkg/patches/0001-Auto-boot-feature-for-the-Origen.patch
new file mode 100644
index 0000000..83e8b77
--- /dev/null
+++ b/SamsungPlatformPkg/patches/0001-Auto-boot-feature-for-the-Origen.patch
@@ -0,0 +1,124 @@ 
+From 3d8ea36efcbc4dd772047b087caf4f6e0736f6de Mon Sep 17 00:00:00 2001
+From: Shivamurthy Shastri <shiva.linuxworks@gmail.com>
+Date: Tue, 9 Oct 2012 13:34:25 +0530
+Subject: [PATCH] Auto boot feature for the SMDK5250. The code will search for
+ "uImage" in the available partitions. The code will boot
+ the board with the first image it gets.
+
+Signed-off-by: Shivamurthy Shastri <shiva.linuxworks@gmail.com>
+Signed-off-by: Rony Nandy <rony.nandy@linaro.org>
+---
+ ArmPlatformPkg/Bds/BootOption.c |   81 +++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 81 insertions(+)
+
+diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
+index 289d36a..a457b09 100644
+--- a/ArmPlatformPkg/Bds/BootOption.c
++++ b/ArmPlatformPkg/Bds/BootOption.c
+@@ -14,6 +14,13 @@
+ 
+ #include "BdsInternal.h"
+ 
++//CHANGE -- START
++#include <Library/DxeServicesTableLib.h>
++#include <Protocol/BlockIo.h>
++#include <Guid/DebugImageInfoTable.h>
++#include <Protocol/DevicePathToText.h>
++//CHANGE -- END
++
+ extern EFI_HANDLE mImageHandle;
+ 
+ EFI_STATUS
+@@ -34,6 +41,17 @@ BootOptionStart (
+   EFI_DEVICE_PATH*                      Initrd;
+   UINT16                                LoadOptionIndexSize;
+ 
++//CHANGE -- START
++  UINTN                     HandleCount;
++  EFI_HANDLE                *HandleBuffer;
++  UINTN                     Index;
++  //CHAR16*                   String;
++  //EFI_DEVICE_PATH_PROTOCOL* DevicePathProtocol;
++  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL*  DevicePathToTextProtocol;
++  EFI_DEVICE_PATH_PROTOCOL  *LoadImageDevicePath;
++  EFI_DEVICE_PATH_PROTOCOL  *FileSystemDevicePath;
++//CHANGE -- END
++
+   if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
+     Status = EFI_UNSUPPORTED;
+     OptionalData = BootOption->OptionalData;
+@@ -55,9 +73,72 @@ BootOptionStart (
+         Initrd = NULL;
+       }
+ 
++//CHANGE CODE -- START
++    do {
++    // Locate all the driver handles
++    Status = gBS->LocateHandleBuffer (
++                AllHandles,
++                NULL,
++                NULL,
++                &HandleCount,
++                &HandleBuffer
++                );
++    if (EFI_ERROR (Status)) {
++      break;
++    }
++
++    // Connect every handles
++    for (Index = 0; Index < HandleCount; Index++) {
++      gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
++    }
++
++    if (HandleBuffer != NULL) {
++      FreePool (HandleBuffer);
++    }
++
++    // Check if new handles have been created after the start of the previous handles
++    Status = gDS->Dispatch ();
++  } while (!EFI_ERROR(Status));
++
++
++  Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);
++  if (EFI_ERROR (Status)) {
++    AsciiPrint ("Did not find the DevicePathToTextProtocol.\n");
++    return Status;
++  }
++
++  Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &HandleCount, &HandleBuffer);
++  if (EFI_ERROR (Status)) {
++    AsciiPrint ("No device path found\n");
++    return Status;
++  }
++
++  /*for (Index = 0; Index < HandleCount; Index++) {
++    Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&DevicePathProtocol);
++    String = DevicePathToTextProtocol->ConvertDevicePathToText(DevicePathProtocol,TRUE,TRUE);
++    Print (L"[0x%X] %s\n",(UINT32)HandleBuffer[Index], String);
++  }*/
++
++  for (Index = 0; Index < HandleCount; Index++) {
++    //Get the device path
++    FileSystemDevicePath = DevicePathFromHandle(HandleBuffer[Index]);
++    if (FileSystemDevicePath == NULL) {
++      continue;
++    }
++
++    //Check if zImage file on SD-MMC.
++    LoadImageDevicePath = FileDevicePath(HandleBuffer[Index], L"zImage");
++    Status = BdsBootLinuxAtag (LoadImageDevicePath, Initrd, (CHAR8*)(LinuxArguments + 1));
++    if (EFI_ERROR(Status)) {
++      continue;
++    }
++  }
++//CHANGE CODE -- END
++#if 0 //remove while removing CHANGE CODE
+       Status = BdsBootLinuxAtag (BootOption->FilePathList,
+                                  Initrd, // Initrd
+                                  (CHAR8*)(LinuxArguments + 1)); // CmdLine
++#endif
+     } else if (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT) {
+       LinuxArguments = &(OptionalData->Arguments.LinuxArguments);
+       CmdLineSize = ReadUnaligned16 ((CONST UINT16*)&LinuxArguments->CmdLineSize);
+-- 
+1.7.9.5