]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.c
ArmPlatformPkg/ArmVExpressDxe: Load FDT into the EFI Configuration Table
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / ArmVExpressDxe / ArmFvpDxe.c
CommitLineData
94caa81c 1/** @file\r
2\r
04f1a709 3 Copyright (c) 2013-2015, ARM Ltd. All rights reserved.<BR>\r
94caa81c 4\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
dff72027
OM
15#include "ArmVExpressInternal.h"\r
16\r
94caa81c 17#include <Library/VirtioMmioDeviceLib.h>\r
ced216f8 18#include <Library/ArmShellCmdLib.h>\r
04f1a709 19#include <Library/MemoryAllocationLib.h>\r
94caa81c 20\r
21#define ARM_FVP_BASE_VIRTIO_BLOCK_BASE 0x1c130000\r
22\r
23#pragma pack(1)\r
24typedef struct {\r
25 VENDOR_DEVICE_PATH Vendor;\r
26 EFI_DEVICE_PATH_PROTOCOL End;\r
27} VIRTIO_BLK_DEVICE_PATH;\r
28#pragma pack()\r
29\r
30VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =\r
31{\r
32 {\r
33 {\r
34 HARDWARE_DEVICE_PATH,\r
35 HW_VENDOR_DP,\r
36 {\r
37 (UINT8)( sizeof(VENDOR_DEVICE_PATH) ),\r
38 (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8)\r
39 }\r
40 },\r
41 EFI_CALLER_ID_GUID,\r
42 },\r
43 {\r
44 END_DEVICE_PATH_TYPE,\r
45 END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
46 {\r
47 sizeof (EFI_DEVICE_PATH_PROTOCOL),\r
48 0\r
49 }\r
50 }\r
51};\r
52\r
04f1a709
RC
53/**\r
54 * Generic UEFI Entrypoint for 'ArmFvpDxe' driver\r
55 * See UEFI specification for the details of the parameters\r
56 */\r
94caa81c 57EFI_STATUS\r
58EFIAPI\r
59ArmFvpInitialise (\r
60 IN EFI_HANDLE ImageHandle,\r
61 IN EFI_SYSTEM_TABLE *SystemTable\r
62 )\r
63{\r
04f1a709
RC
64 CONST ARM_VEXPRESS_PLATFORM* Platform;\r
65 EFI_STATUS Status;\r
66 CHAR16 *TextDevicePath;\r
67 UINTN TextDevicePathSize;\r
68 VOID *Buffer;\r
94caa81c 69\r
70 Status = gBS->InstallProtocolInterface (&ImageHandle,\r
71 &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,\r
72 &mVirtioBlockDevicePath);\r
73 if (EFI_ERROR (Status)) {\r
74 return Status;\r
75 }\r
76\r
04f1a709
RC
77 Status = ArmVExpressGetPlatform (&Platform);\r
78 if (!EFI_ERROR (Status)) {\r
79 TextDevicePathSize = StrSize ((CHAR16*)PcdGetPtr (PcdFvpFdtDevicePathsBase)) - sizeof (CHAR16);\r
80 TextDevicePathSize += StrSize (Platform->FdtName);\r
81\r
82 TextDevicePath = AllocatePool (TextDevicePathSize);\r
83 if (TextDevicePath != NULL) {\r
84 StrCpy (TextDevicePath, ((CHAR16*)PcdGetPtr (PcdFvpFdtDevicePathsBase)));\r
85 StrCat (TextDevicePath, Platform->FdtName);\r
86 Buffer = PcdSetPtr (PcdFdtDevicePaths, &TextDevicePathSize, TextDevicePath);\r
87 if (Buffer == NULL) {\r
88 DEBUG ((\r
89 EFI_D_ERROR,\r
90 "ArmFvpDxe: Setting of FDT device path in PcdFdtDevicePaths failed - %r\n", EFI_BUFFER_TOO_SMALL\r
91 ));\r
92 }\r
93 FreePool (TextDevicePath);\r
94 }\r
95 }\r
96\r
94caa81c 97 // Declare the Virtio BlockIo device\r
98 Status = VirtioMmioInstallDevice (ARM_FVP_BASE_VIRTIO_BLOCK_BASE, ImageHandle);\r
99 if (EFI_ERROR (Status)) {\r
100 DEBUG ((EFI_D_ERROR, "ArmFvpDxe: Failed to install Virtio block device\n"));\r
101 }\r
102\r
ced216f8
HL
103 // Install dynamic Shell command to run baremetal binaries.\r
104 Status = ShellDynCmdRunAxfInstall (ImageHandle);\r
105 if (EFI_ERROR (Status)) {\r
106 DEBUG ((EFI_D_ERROR, "ArmFvpDxe: Failed to install ShellDynCmdRunAxf\n"));\r
107 }\r
108\r
94caa81c 109 return Status;\r
110}\r