]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.c
ArmPlatformPkg/ArmVExpressDxe: Load FDT into the EFI Configuration Table
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / ArmVExpressDxe / ArmFvpDxe.c
index 6a3d3503824c552a596b1b785c42dcb65ff0ec34..9a60f1d611d458a28d87e9ffe86d6d6214051c83 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
 /** @file\r
 \r
-  Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2013-2015, ARM Ltd. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -16,6 +16,7 @@
 \r
 #include <Library/VirtioMmioDeviceLib.h>\r
 #include <Library/ArmShellCmdLib.h>\r
 \r
 #include <Library/VirtioMmioDeviceLib.h>\r
 #include <Library/ArmShellCmdLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
 \r
 #define ARM_FVP_BASE_VIRTIO_BLOCK_BASE    0x1c130000\r
 \r
 \r
 #define ARM_FVP_BASE_VIRTIO_BLOCK_BASE    0x1c130000\r
 \r
@@ -49,6 +50,10 @@ VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
   }\r
 };\r
 \r
   }\r
 };\r
 \r
+/**\r
+ * Generic UEFI Entrypoint for 'ArmFvpDxe' driver\r
+ * See UEFI specification for the details of the parameters\r
+ */\r
 EFI_STATUS\r
 EFIAPI\r
 ArmFvpInitialise (\r
 EFI_STATUS\r
 EFIAPI\r
 ArmFvpInitialise (\r
@@ -56,7 +61,11 @@ ArmFvpInitialise (
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
   IN EFI_SYSTEM_TABLE   *SystemTable\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
+  CONST ARM_VEXPRESS_PLATFORM* Platform;\r
+  EFI_STATUS                   Status;\r
+  CHAR16                       *TextDevicePath;\r
+  UINTN                        TextDevicePathSize;\r
+  VOID                         *Buffer;\r
 \r
   Status = gBS->InstallProtocolInterface (&ImageHandle,\r
                  &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,\r
 \r
   Status = gBS->InstallProtocolInterface (&ImageHandle,\r
                  &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,\r
@@ -65,6 +74,26 @@ ArmFvpInitialise (
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
+  Status = ArmVExpressGetPlatform (&Platform);\r
+  if (!EFI_ERROR (Status)) {\r
+    TextDevicePathSize  = StrSize ((CHAR16*)PcdGetPtr (PcdFvpFdtDevicePathsBase)) - sizeof (CHAR16);\r
+    TextDevicePathSize += StrSize (Platform->FdtName);\r
+\r
+    TextDevicePath = AllocatePool (TextDevicePathSize);\r
+    if (TextDevicePath != NULL) {\r
+      StrCpy (TextDevicePath, ((CHAR16*)PcdGetPtr (PcdFvpFdtDevicePathsBase)));\r
+      StrCat (TextDevicePath, Platform->FdtName);\r
+      Buffer = PcdSetPtr (PcdFdtDevicePaths, &TextDevicePathSize, TextDevicePath);\r
+      if (Buffer == NULL) {\r
+        DEBUG ((\r
+          EFI_D_ERROR,\r
+          "ArmFvpDxe: Setting of FDT device path in PcdFdtDevicePaths failed - %r\n", EFI_BUFFER_TOO_SMALL\r
+          ));\r
+      }\r
+      FreePool (TextDevicePath);\r
+    }\r
+  }\r
+\r
   // Declare the Virtio BlockIo device\r
   Status = VirtioMmioInstallDevice (ARM_FVP_BASE_VIRTIO_BLOCK_BASE, ImageHandle);\r
   if (EFI_ERROR (Status)) {\r
   // Declare the Virtio BlockIo device\r
   Status = VirtioMmioInstallDevice (ARM_FVP_BASE_VIRTIO_BLOCK_BASE, ImageHandle);\r
   if (EFI_ERROR (Status)) {\r