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