From nobody Mon Dec 23 11:04:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518431986712744.3939171884198; Mon, 12 Feb 2018 02:39:46 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4F8F5223648B9; Mon, 12 Feb 2018 02:33:54 -0800 (PST) Received: from mail-pg0-x233.google.com (mail-pg0-x233.google.com [IPv6:2607:f8b0:400e:c05::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BCD0F222DE12C for ; Mon, 12 Feb 2018 02:26:11 -0800 (PST) Received: by mail-pg0-x233.google.com with SMTP id y8so9530pgr.9 for ; Mon, 12 Feb 2018 02:32:01 -0800 (PST) Received: from localhost.localdomain ([220.225.120.129]) by smtp.gmail.com with ESMTPSA id s82sm32355780pfa.151.2018.02.12.02.31.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Feb 2018 02:31:59 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c05::233; helo=mail-pg0-x233.google.com; envelope-from=moorthy.baskaravenkatraman-sambamoorthy@linaro.org; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0lKgrCLQ9rCfIJGCTiSLmwFCsMUfAH7W18Ei8qcofMg=; b=RMUvGcXV2SJmTCKudbNGkx/yzgs5cPcj0Yglxj7K5CgQuBnlLAF8Rr6ZYcHms9u9AD ZR/IQmmmSN86FLnXwKjd6nohqK/PlTFruxGW3g8LjiWi9ejN/5SSsjZM8iWHNIbXE3DA TBKWN3ZolSXev/pAFAaE+xMRsFuh2cGZJ49QM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0lKgrCLQ9rCfIJGCTiSLmwFCsMUfAH7W18Ei8qcofMg=; b=Y8Q+ZdJT8bCWu4o2BoWXSv/uY+XxuscYOxqA+G1QwBs/dvF/VYIg2gw4kTYUz0POYS Ctr/xuVgElHD7cCH46KtHH6tyPlvt87NJSlME4fg8wbs5rgHtuS5m6JHifZRF82Yo+el 8e5TrMtGZBbnE7E97jbraTLJKGRjn1jgbtksezSfxy7KhmmPah0SY4njiA1wJH9OFN/5 OMw0C522uxsPLT+JnwPAUj6v2HioRQWXhOxrg+NQf96YPkNDz6HeObC0eCJQtJ50Y72n Tf21C5skarJDSu6MK1AFuDMTqoRH9JcoKrUeZP8YFX8Vbb6I/zfkifj1ifHc+7U9WJs6 NaqQ== X-Gm-Message-State: APf1xPBRonu/zPZH1e21d3QI7iD98ThQnBvOmpSZzAnODcI9MmxQN7l0 WzTsE124go/rXgQ1eBwNrOngyP3MlhM= X-Google-Smtp-Source: AH8x227qGcE6c2BH9n9UJchD4BywX2KqglQu9Unv4PDW9tM85kQ5oiWBe/iPpMs1cLWdG2X9c3vBVQ== X-Received: by 10.99.37.193 with SMTP id l184mr9241146pgl.30.1518431520062; Mon, 12 Feb 2018 02:32:00 -0800 (PST) From: Moorthy Baskaravenkatraman To: edk2-devel@lists.01.org Date: Mon, 12 Feb 2018 16:01:19 +0530 Message-Id: <20180212103122.10729-2-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180212103122.10729-1-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> References: <20180212103122.10729-1-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> X-Mailman-Approved-At: Mon, 12 Feb 2018 02:33:53 -0800 Subject: [edk2] [PATCH v1 1/4] edk2-platforms:comcast: RDK boot manager Library implementation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kalyan Nagabhirava Implemented features related to secure boot and DRI (downloading the image and storing on flash), library has utility of file read and write operations for fat flash partition, it reads file path and load the file content using configuration file. Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Moorthy Baskaravenkatraman --- Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec | 50 ++ Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.inf | 76 +++ Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.h | 99 ++++ Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c | 376 +++= +++++++++++ Platform/Comcast/Library/RdkBootManagerLib/HttpBoot.c | 350 +++= ++++++++++ Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c | 389 +++= ++++++++++++ Platform/Comcast/Library/RdkBootManagerLib/SecureBoot.c | 523 +++= +++++++++++++++++ 7 files changed, 1863 insertions(+) diff --git a/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.d= ec b/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec new file mode 100644 index 000000000000..0db0c676a9b0 --- /dev/null +++ b/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec @@ -0,0 +1,50 @@ +# +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# + +[Defines] + DEC_SPECIFICATION =3D 0x00010019 + PACKAGE_NAME =3D RdkPkg + PACKAGE_GUID =3D 2f1f2d5e-d9e1-4aa1-8eb9-fed94682e140 + PACKAGE_VERSION =3D 0.1 + +##########################################################################= ###### +# +# Include Section - list of Include Paths that are provided by this packag= e. +# Comments are used for Keywords and Module Types. +# +# Supported Module Types: +# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_D= RIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION +# +##########################################################################= ###### +[Includes.common] +# Include # Root include for the package + +[Guids.common] + gRdkTokenSpaceGuid =3D { 0x408c1892, 0xf11a, 0x40c7, { 0xaa,= 0x5f, 0x0d, 0x16, 0xc8, 0xb2, 0x52, 0x59 } } + gRdkGlobalVariableGuid =3D { 0xc3253c90, 0xa24f, 0x4599, { 0xa6,= 0x64, 0x1f, 0x88, 0x13, 0x77, 0x8f, 0xc9 } } + +[PcdsFixedAtBuild.common] + # Rdk Library + gRdkTokenSpaceGuid.PcdRdkSystemPartitionName|""|VOID*|0x02000003 + gRdkTokenSpaceGuid.PcdRdkConfFileName|""|VOID*|0x02000004 + gRdkTokenSpaceGuid.PcdRdkCmdLineArgs|""|VOID*|0x02000013 + gRdkTokenSpaceGuid.PcdRdkConfFileDevicePath|L""|VOID*|0x02000014 + gRdkTokenSpaceGuid.PcdDtbAvailable|FALSE|BOOLEAN|0x00300014 + + # GUID of RdkSecureBootLoader + gRdkTokenSpaceGuid.PcdRdkSecureBootFile|{ 0x0f, 0x93, 0xc7, 0xb2, 0xef, = 0x07, 0x05, 0x43, 0xac, 0x4e, 0x1c, 0xe2, 0x08, 0x5a, 0x70, 0x31 }|VOID*|0x= 00000100 + + # GUID of RdkDri + gRdkTokenSpaceGuid.PcdRdkDriFile|{ 0x8a, 0xa1, 0x1b, 0x08, 0x1e, 0xd7, 0= xa7, 0x40, 0x99, 0xa9, 0xcd, 0xb8, 0x64, 0x63, 0x96, 0x6d }|VOID*|0x00001000 + + # GUID of RdkDriSecureBootLoader + gRdkTokenSpaceGuid.PcdRdkDriSecureBootFile|{ 0xd7, 0xd1, 0x52, 0xdd, 0xe= 2, 0x0d, 0x52, 0x45, 0x98, 0xe0, 0x8d, 0xbe, 0xe4, 0x58, 0xa5, 0x02 }|VOID*= |0x00100000 diff --git a/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.i= nf b/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.inf new file mode 100644 index 000000000000..0db783613740 --- /dev/null +++ b/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.inf @@ -0,0 +1,76 @@ +# +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# Copyright (c) 2016-2017, Comcast. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# + +##########################################################################= ###### +# +# Defines Section - statements that will be processed to create a Makefile. +# +##########################################################################= ###### + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D RdkBootManagerLib + FILE_GUID =3D 901f54f2-9d70-9b89-9c0a-d9ca25379059 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RdkBootManagerLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI= _APPLICATION UEFI_DRIVER + +[Sources] + DiskIo.c + SecureBoot.c + HttpBoot.c + RdkFile.c + +[Packages] + ArmPkg/ArmPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + NetworkPkg/NetworkPkg.dec + Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec + ShellPkg/ShellPkg.dec + SecurityPkg/SecurityPkg.dec + +[Guids] + gEfiCertX509Guid + gEfiCertPkcs7Guid + gEfiCustomModeEnableGuid + gEfiImageSecurityDatabaseGuid + gFdtTableGuid + gRdkGlobalVariableGuid + +[Protocols] + gEfiBlockIoProtocolGuid + gEfiDevicePathToTextProtocolGuid + gEfiDevicePathFromTextProtocolGuid + gEfiLoadedImageProtocolGuid + gEfiShellProtocolGuid + gEfiDiskIoProtocolGuid + gEfiLoadFileProtocolGuid + +[Pcd] + gRdkTokenSpaceGuid.PcdRdkCmdLineArgs + gRdkTokenSpaceGuid.PcdRdkSystemPartitionName + gRdkTokenSpaceGuid.PcdRdkConfFileName + gRdkTokenSpaceGuid.PcdRdkConfFileDevicePath + gRdkTokenSpaceGuid.PcdDtbAvailable + +[LibraryClasses] + ArmLib + BaseLib + DebugLib + DevicePathLib + FileHandleLib + NetLib + PcdLib + diff --git a/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.h= b/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.h new file mode 100644 index 000000000000..f3685363d38e --- /dev/null +++ b/Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.h @@ -0,0 +1,99 @@ +/* +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +*/ +#ifndef __RDK_BOOT_MANAGER_LIB_H__ +#define __RDK_BOOT_MANAGER_LIB_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern +EFI_STATUS +PartitionRead ( + IN CHAR8 *PartitionName, + IN VOID *Image, + IN UINTN Size + ); + +extern +EFI_STATUS +PartitionWrite ( + IN CHAR8 *PartitionName, + IN VOID *Image, + IN UINTN Size + ); + +extern +EFI_STATUS +GetRdkVariable ( + IN CONST CHAR16 *Name, + OUT CONST CHAR16 **Value + ); + +extern +EFI_STATUS +RdkSecureBoot ( + EFI_HANDLE ImageHandle, + EFI_BOOT_SERVICES *BootServices + ); + +extern +EFI_STATUS +RdkReadFile ( + IN CONST CHAR16 *Path, + IN OUT VOID **BufferPtr, + OUT UINTN *FileSize + ); + +extern +EFI_STATUS +RdkWriteFile ( + IN CONST CHAR16 *Path, + IN OUT VOID **BufferPtr, + OUT UINTN *FileSize + ); + +extern +EFI_STATUS +GetFileHandler ( + OUT EFI_FILE_HANDLE *FileHandle, + IN CONST CHAR16 *Path, + IN UINT64 OpenMode + ); + +extern +EFI_STATUS +RdkHttpBoot ( + VOID + ); + +#endif /* __RDK_BOOT_MANAGER_LIB_H__ */ diff --git a/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c b/Platform= /Comcast/Library/RdkBootManagerLib/DiskIo.c new file mode 100644 index 000000000000..2699bd395a05 --- /dev/null +++ b/Platform/Comcast/Library/RdkBootManagerLib/DiskIo.c @@ -0,0 +1,376 @@ +/* +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +*/ +#include + +/* See sparse_format.h in AOSP */ +#define SPARSE_HEADER_MAGIC 0xed26ff3a +#define CHUNK_TYPE_RAW 0xCAC1 +#define CHUNK_TYPE_FILL 0xCAC2 +#define CHUNK_TYPE_DONT_CARE 0xCAC3 +#define CHUNK_TYPE_CRC32 0xCAC4 + +#define PARTITION_NAME_MAX_LENGTH 72/2 + +#define FLASH_DEVICE_PATH_SIZE(DevPath) ( GetDevicePathSize (DevPath) - \ + sizeof (EFI_DEVICE_PATH_PROTOCOL)) + +#define IS_ALPHA(Char) (((Char) <=3D L'z' && (Char) >=3D L'a') || \ + ((Char) <=3D L'Z' && (Char) >=3D L'Z')) + +typedef struct _DISKIO_PARTITION_LIST { + LIST_ENTRY Link; + CHAR16 PartitionName[PARTITION_NAME_MAX_LENGTH]; + EFI_HANDLE PartitionHandle; +} DISKIO_PARTITION_LIST; + +typedef struct _SPARSE_HEADER { + UINT32 Magic; + UINT16 MajorVersion; + UINT16 MinorVersion; + UINT16 FileHeaderSize; + UINT16 ChunkHeaderSize; + UINT32 BlockSize; + UINT32 TotalBlocks; + UINT32 TotalChunks; + UINT32 ImageChecksum; +} SPARSE_HEADER; + +typedef struct _CHUNK_HEADER { + UINT16 ChunkType; + UINT16 Reserved1; + UINT32 ChunkSize; + UINT32 TotalSize; +} CHUNK_HEADER; + +STATIC LIST_ENTRY mPartitionListHead; +STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut; + +/* + * Helper to free the partition list + */ +STATIC +VOID +FreePartitionList ( + VOID +) +{ + DISKIO_PARTITION_LIST *Entry; + DISKIO_PARTITION_LIST *NextEntry; + + Entry =3D (DISKIO_PARTITION_LIST *)GetFirstNode (&mPartitionListHead); + while (!IsNull (&mPartitionListHead, &Entry->Link)) { + NextEntry =3D (DISKIO_PARTITION_LIST *) GetNextNode (\ + &mPartitionListHead, &Entry->Link); + + RemoveEntryList (&Entry->Link); + FreePool (Entry); + + Entry =3D NextEntry; + } +} + +/* + * lists the available Block Io and adds handle of given dev path + */ +STATIC +EFI_STATUS +ListBlockIos ( + IN CHAR16 *PartitionName + ) +{ + EFI_STATUS Status; + EFI_HANDLE *AllHandles; + EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + UINTN LoopIndex; + UINTN NumHandles; + UINT16 *DeviceFullPath; + DISKIO_PARTITION_LIST *Entry; + + InitializeListHead (&mPartitionListHead); + + Status =3D gBS->LocateProtocol ( + &gEfiDevicePathToTextProtocolGuid, + NULL, + (VOID **) &DevPathToText + ); + ASSERT_EFI_ERROR (Status); + + // Get every Block IO protocol instance installed in the system + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiBlockIoProtocolGuid, + NULL, + &NumHandles, + &AllHandles + ); + ASSERT_EFI_ERROR (Status); + DEBUG ((DEBUG_INFO, "Block IO: %d handles \n", NumHandles)); + + // Get HTTP driver handle from AllHandles + for (LoopIndex =3D 0; LoopIndex < NumHandles; LoopIndex++) { + // Get the device path for the handle + Status =3D gBS->OpenProtocol ( + AllHandles[LoopIndex], + &gEfiDevicePathProtocolGuid, + (VOID **) &DevicePath, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + + DeviceFullPath =3D DevPathToText->ConvertDevicePathToText ( + DevicePath, + FALSE, + TRUE + ); + + DEBUG((DEBUG_INFO,"Handle[%d] is %p, fullpath %s\n", \ + LoopIndex, AllHandles[LoopIndex], DeviceFullPath)); + + if (StrCmp (PartitionName, DeviceFullPath) =3D=3D 0) { + DEBUG((DEBUG_INFO, "rootfs partition path matched\n")); + // + // Add the partition handle to the list + // + // Create entry + Entry =3D AllocatePool (sizeof (DISKIO_PARTITION_LIST)); + if (Entry =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + // Copy handle and partition name + Entry->PartitionHandle =3D AllHandles[LoopIndex]; + StrnCpy ( + Entry->PartitionName, + PartitionName, + PARTITION_NAME_MAX_LENGTH + ); + InsertTailList (&mPartitionListHead, &Entry->Link); + break; + } + } + FreePool (AllHandles); + ASSERT (LoopIndex < NumHandles); +Exit: + return Status; +} + +STATIC +EFI_STATUS +OpenPartition ( + IN CHAR8 *PartitionName, + IN VOID *Image, + IN UINTN Size, + OUT EFI_BLOCK_IO_PROTOCOL **BlockIo, + OUT EFI_DISK_IO_PROTOCOL **DiskIo + ) +{ + EFI_STATUS Status; + UINTN PartitionSize; + DISKIO_PARTITION_LIST *Entry; + SPARSE_HEADER *SparseHeader; + UINT16 UnicodePartitionName[100]; + + AsciiStrToUnicodeStr ( PartitionName, UnicodePartitionName); + DEBUG((DEBUG_INFO, "Unicode partition name %s\n", UnicodePartitionName)); + + Status =3D ListBlockIos (UnicodePartitionName); + ASSERT_EFI_ERROR (Status); + + Entry =3D (DISKIO_PARTITION_LIST *)GetFirstNode (&(mPartitionListHead)); + ASSERT (Entry !=3D NULL); + + Status =3D gBS->OpenProtocol ( + Entry->PartitionHandle, + &gEfiBlockIoProtocolGuid, + (VOID **) BlockIo, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Unable to open Block IO protocol: %r\n", Status)= ); + Status =3D EFI_NOT_FOUND; + goto Exit; + } + + SparseHeader =3D (SPARSE_HEADER *)Image; + + if (SparseHeader->Magic =3D=3D SPARSE_HEADER_MAGIC) { + DEBUG ((DEBUG_INFO, \ + "Sparse Magic: 0x%x Major: %d Minor: %d fhs: %d chs: %d bs: %d tbs: = %d tcs: %d checksum: %d \n", \ + SparseHeader->Magic, SparseHeader->MajorVersion, \ + SparseHeader->MinorVersion, SparseHeader->FileHeaderSize, \ + SparseHeader->ChunkHeaderSize, SparseHeader->BlockSize, \ + SparseHeader->TotalBlocks, \ + SparseHeader->TotalChunks, SparseHeader->ImageChecksum)); + + if (SparseHeader->MajorVersion !=3D 1) { + DEBUG ((DEBUG_ERROR, "Sparse image version %d.%d not supported.\n", + SparseHeader->MajorVersion, SparseHeader->MinorVersion)); + Status =3D EFI_INVALID_PARAMETER; + goto Exit; + } + + Size =3D SparseHeader->BlockSize * SparseHeader->TotalBlocks; + } + + // Check image will fit on device + PartitionSize =3D (BlockIo[0]->Media->LastBlock + 1) * BlockIo[0]->Media= ->BlockSize; + if (PartitionSize < Size) { + DEBUG ((DEBUG_ERROR, "Partition not big enough.\n")); + DEBUG ((DEBUG_ERROR, \ + "Partition Size:\t%ld\nImage Size:\t%ld\n", PartitionSize, Size)); + + Status =3D EFI_VOLUME_FULL; + goto Exit; + } + + Status =3D gBS->OpenProtocol ( + Entry->PartitionHandle, + &gEfiDiskIoProtocolGuid, + (VOID **) DiskIo, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + +Exit: + FreePartitionList (); + return Status; +} + +EFI_STATUS +PartitionRead ( + IN CHAR8 *PartitionName, + IN VOID *Image, + IN UINTN Size + ) +{ + EFI_STATUS Status; + EFI_BLOCK_IO_PROTOCOL *BlockIo; + EFI_DISK_IO_PROTOCOL *DiskIo; + UINT32 MediaId; + + Status =3D OpenPartition (PartitionName, Image, Size, &BlockIo, &DiskIo); + if (EFI_ERROR (Status)) { + goto Exit; + } + + MediaId =3D BlockIo->Media->MediaId; + + Status =3D DiskIo->ReadDisk (DiskIo, MediaId, 0, Size, Image); + if (EFI_ERROR (Status)) { + goto Exit; + } + + BlockIo->FlushBlocks(BlockIo); + +Exit: + return Status; +} + +EFI_STATUS +PartitionWrite ( + IN CHAR8 *PartitionName, + IN VOID *Image, + IN UINTN Size + ) +{ + EFI_STATUS Status; + EFI_BLOCK_IO_PROTOCOL *BlockIo; + EFI_DISK_IO_PROTOCOL *DiskIo; + UINT32 MediaId; + SPARSE_HEADER *SparseHeader; + CHUNK_HEADER *ChunkHeader; + UINT32 Chunk; + UINTN Offset; + + Status =3D OpenPartition (PartitionName, Image, Size, &BlockIo, &DiskIo); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Offset =3D 0; + MediaId =3D BlockIo->Media->MediaId; + SparseHeader =3D (SPARSE_HEADER *)Image; + + if (SparseHeader->Magic =3D=3D SPARSE_HEADER_MAGIC) { + CHAR16 OutputString[64]; + UINTN ChunkPrintDensity =3D + SparseHeader->TotalChunks > 1600 ? SparseHeader->TotalChunks / 200 := 32; + + Image +=3D SparseHeader->FileHeaderSize; + for (Chunk =3D 0; Chunk < SparseHeader->TotalChunks; Chunk++) { + UINTN WriteSize; + ChunkHeader =3D (CHUNK_HEADER *)Image; + + // Show progress. Don't do it for every packet as outputting text + // might be time consuming. ChunkPrintDensity is calculated to + // provide an update every half percent change for large + // downloads. + if (Chunk % ChunkPrintDensity =3D=3D 0) { + UnicodeSPrint(OutputString, sizeof(OutputString), + L"\r%5d / %5d chunks written (%d%%)", Chunk, + SparseHeader->TotalChunks, + (Chunk * 100) / SparseHeader->TotalChunks); + mTextOut->OutputString(mTextOut, OutputString); + } + + DEBUG ((DEBUG_INFO, "Chunk #%d - Type: 0x%x Size: %d TotalSize: %d O= ffset %d\n", + (Chunk+1), ChunkHeader->ChunkType, ChunkHeader->ChunkSize, + ChunkHeader->TotalSize, Offset)); + Image +=3D sizeof(CHUNK_HEADER); + WriteSize =3D (SparseHeader->BlockSize) * ChunkHeader->ChunkSize; + switch (ChunkHeader->ChunkType) { + case CHUNK_TYPE_RAW: + DEBUG ((DEBUG_INFO, "Writing %d at Offset %d\n", WriteSize, Offs= et)); + Status =3D DiskIo->WriteDisk (DiskIo, MediaId, Offset, WriteSize= , Image); + if (EFI_ERROR (Status)) { + goto Exit; + } + Image +=3D WriteSize; + break; + case CHUNK_TYPE_DONT_CARE: + break; + case CHUNK_TYPE_CRC32: + break; + default: + DEBUG ((DEBUG_ERROR, "Unknown Chunk Type: 0x%x", ChunkHeader->Ch= unkType)); + Status =3D EFI_PROTOCOL_ERROR; + goto Exit; + } + Offset +=3D WriteSize; + } + + UnicodeSPrint (OutputString, sizeof (OutputString), + L"\r%5d / %5d chunks written (100%%)\r\n", + SparseHeader->TotalChunks, SparseHeader->TotalChunks); + mTextOut->OutputString(mTextOut, OutputString); + + } else { + + Status =3D DiskIo->WriteDisk (DiskIo, MediaId, 0, Size, Image); + if (EFI_ERROR (Status)) { + goto Exit; + } + } + + BlockIo->FlushBlocks (BlockIo); + +Exit: + return Status; +} diff --git a/Platform/Comcast/Library/RdkBootManagerLib/HttpBoot.c b/Platfo= rm/Comcast/Library/RdkBootManagerLib/HttpBoot.c new file mode 100644 index 000000000000..5de1427adbb6 --- /dev/null +++ b/Platform/Comcast/Library/RdkBootManagerLib/HttpBoot.c @@ -0,0 +1,350 @@ +/* +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +*/ +#include + +#define FILE_HDR_SIZE 16 + +STATIC EFI_LOAD_FILE_PROTOCOL *LoadFile =3D NULL; +STATIC HTTP_BOOT_PRIVATE_DATA *Private =3D NULL; + +STATIC +VOID +HttpPrivateFromLoadFile ( + IN EFI_LOAD_FILE_PROTOCOL *LoadFile, + OUT HTTP_BOOT_PRIVATE_DATA **Private + ) +{ + HTTP_BOOT_VIRTUAL_NIC *Ip4Nic =3D NULL; + + UINTN Offset =3D (UINTN)&Ip4Nic->LoadFile; + + Ip4Nic =3D (VOID *)((CHAR8 *)LoadFile - Offset); + ASSERT (Ip4Nic->Signature =3D=3D HTTP_BOOT_VIRTUAL_NIC_SIGNATURE); + *Private =3D Ip4Nic->Private; +} + +STATIC +VOID +HttpGetLoadFileHandle ( + OUT EFI_LOAD_FILE_PROTOCOL **LoadFile + ) +{ + EFI_STATUS Status; + UINTN LoopIndex; + UINTN NumHandles; + EFI_HANDLE *AllHandles; + EFI_HANDLE Handle; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText; + UINT16 *DeviceFullPath; + + Status =3D gBS->LocateProtocol ( + &gEfiDevicePathToTextProtocolGuid, + NULL, + (VOID **) &DevPathToText + ); + ASSERT_EFI_ERROR (Status); + + // Get every LoadFile protocol instance installed in the system + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiLoadFileProtocolGuid, + NULL, + &NumHandles, + &AllHandles + ); + ASSERT_EFI_ERROR (Status); + + // Get HTTP driver handle from AllHandles + for (LoopIndex =3D 0; LoopIndex < NumHandles; LoopIndex++) { + + Handle =3D AllHandles[LoopIndex]; + + // Get the device path for the handle + Status =3D gBS->OpenProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID **) &DevicePath, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + ASSERT_EFI_ERROR (Status); + + DeviceFullPath =3D DevPathToText->ConvertDevicePathToText ( + DevicePath, + FALSE, + TRUE + ); + + ASSERT (DeviceFullPath !=3D NULL); + + if (StrStr (DeviceFullPath, L"IPv4") !=3D NULL) { + DEBUG((DEBUG_INFO, "IPv4 protocol found\n")); + Status =3D gBS->OpenProtocol ( + Handle, + &gEfiLoadFileProtocolGuid, + (VOID **) LoadFile, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + ASSERT_EFI_ERROR (Status); + + FreePool (AllHandles); + break; + } + } + + ASSERT (LoopIndex < NumHandles); +} + +STATIC +EFI_STATUS +HttpUpdatePath ( + IN CHAR16 *Uri, + OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath + ) +{ + EFI_DEV_PATH *Node; + EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath; + EFI_STATUS Status; + UINTN Index; + UINTN Length; + CHAR8 AsciiUri[URI_STR_MAX_SIZE]; + + Node =3D NULL; + TmpDevicePath =3D NULL; + Status =3D EFI_SUCCESS; + + // Convert the scheme to all lower case. + for (Index =3D 0; Index < StrLen (Uri); Index++) { + if (Uri[Index] =3D=3D L':') { + break; + } + if (Uri[Index] >=3D L'A' && Uri[Index] <=3D L'Z') { + Uri[Index] -=3D (CHAR16)(L'A' - L'a'); + } + } + + // Only accept empty URI, or http and https URI. + if ((StrLen (Uri) !=3D 0) && + (StrnCmp (Uri, L"http://", 7) !=3D 0) && + (StrnCmp (Uri, L"https://", 8) !=3D 0)) { + return EFI_INVALID_PARAMETER; + } + + // Create a new device path by appending the IP node and URI node to + // the driver's parent device path + Node =3D AllocateZeroPool (sizeof (IPv4_DEVICE_PATH)); + if (Node =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + Node->Ipv4.Header.Type =3D MESSAGING_DEVICE_PATH; + Node->Ipv4.Header.SubType =3D MSG_IPv4_DP; + SetDevicePathNodeLength (Node, sizeof (IPv4_DEVICE_PATH)); + TmpDevicePath =3D AppendDevicePathNode (\ + Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*)Node); + FreePool (Node); + if (TmpDevicePath =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // Update the URI node with the input boot file URI. + UnicodeStrToAsciiStrS (Uri, AsciiUri, sizeof (AsciiUri)); + Length =3D sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (AsciiUri); + Node =3D AllocatePool (Length); + if (Node =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + FreePool (TmpDevicePath); + goto Exit; + } + Node->DevPath.Type =3D MESSAGING_DEVICE_PATH; + Node->DevPath.SubType =3D MSG_URI_DP; + + SetDevicePathNodeLength (Node, Length); + CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), \ + AsciiUri, AsciiStrSize (AsciiUri)); + *NewDevicePath =3D AppendDevicePathNode (TmpDevicePath, \ + (EFI_DEVICE_PATH_PROTOCOL*) Node); + + FreePool (Node); + FreePool (TmpDevicePath); + + if (*NewDevicePath =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + +Exit: + + return Status; +} + +STATIC +EFI_STATUS +HttpGetImage ( + IN CHAR16 *Uri, + OUT UINT8 **FileBuffer, + OUT UINTN *FileSize + ) +{ + EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; + EFI_STATUS Status; + + *FileBuffer =3D NULL; + NewDevicePath =3D NULL; + *FileSize =3D 0; + + // Get the LoadFile Handle and + // Private structure of HTTP driver + if (LoadFile =3D=3D NULL) { + HttpGetLoadFileHandle (&LoadFile); + HttpPrivateFromLoadFile (LoadFile, &Private); + } + + // Update URI path + Status =3D HttpUpdatePath (Uri, &NewDevicePath); + if (EFI_ERROR (Status)) { + goto Exit; + } + + // Get the HTTP image from server + Status =3D LoadFile->LoadFile (LoadFile, NewDevicePath, \ + TRUE, FileSize, *FileBuffer); + if((Status !=3D EFI_WARN_FILE_SYSTEM) && \ + (Status !=3D EFI_BUFFER_TOO_SMALL)) { + goto Exit; + } + + *FileBuffer =3D AllocatePool (*FileSize); + if (*FileBuffer =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + Status =3D LoadFile->LoadFile (LoadFile, NewDevicePath, \ + TRUE, FileSize, *FileBuffer); + if (EFI_ERROR (Status)) { + FreePool (FileBuffer); + goto Exit; + } + +Exit: + + if (NewDevicePath !=3D NULL) { + FreePool (NewDevicePath); + } + + return Status; +} + +UINTN +ParseHeader ( + VOID * Str + ) +{ + UINTN i, Size; + UINT8 *Ptr; + + Ptr =3D Str; + for (i =3D 0, Size =3D 0; i < FILE_HDR_SIZE; i++) { + Size =3D (Ptr[i] - '0') + (Size * 10); + } + + return Size; +} + +EFI_STATUS +RdkHttpBoot ( + VOID + ) +{ + EFI_STATUS Status; + VOID *FilePtr; + UINT8 *FileBuffer; + UINT16 *Uri; + UINTN FileSize; + UINTN LoopIndex; + UINTN Size; + CONST CHAR16 *DtbPath; + CONST CHAR16 *ImagePath; + CONST CHAR16 *ServerUrlPath; + + Status =3D GetRdkVariable (L"URL", &ServerUrlPath); + ASSERT_EFI_ERROR (Status); + + // Get the Server name stored in file Server.url + Status =3D RdkReadFile (ServerUrlPath, (VOID **)&FileBuffer, &FileSize); + ASSERT_EFI_ERROR (Status); + + Uri =3D AllocateZeroPool (sizeof(*Uri) * (FileSize + 1)); + if (Uri =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + ASSERT_EFI_ERROR (Status); + } + + for(LoopIndex =3D 0; LoopIndex < FileSize; LoopIndex++) { + Uri[LoopIndex] =3D FileBuffer[LoopIndex]; + } + + if(FileBuffer[FileSize-1] =3D=3D '\n') { + Uri[FileSize-1] =3D '\0'; + } + + FreePool (FileBuffer); + FileBuffer=3DNULL; + + // Disable watchdog + Status =3D gBS->SetWatchdogTimer (0, 0x10000, 0, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, \ + "HttpBoot: Couldn't disable watchdog timer: %r\n", Status)); + } + + // Get the File from server using it's URI + Status =3D HttpGetImage (Uri, &FileBuffer, &FileSize); + ASSERT_EFI_ERROR (Status); + + // Write the received image to flash + FilePtr =3D FileBuffer; + Size =3D ParseHeader (FilePtr); + FilePtr +=3D FILE_HDR_SIZE; + Status =3D PartitionWrite ((CHAR8 *)FixedPcdGetPtr (\ + PcdRdkSystemPartitionName), FilePtr, Size); + ASSERT_EFI_ERROR (Status); + + FilePtr +=3D Size; + Size =3D ParseHeader (FilePtr); + FilePtr +=3D FILE_HDR_SIZE; + Status =3D GetRdkVariable (L"IMAGE", &ImagePath); + ASSERT_EFI_ERROR (Status); + Status =3D RdkWriteFile (ImagePath, &FilePtr, &Size); + ASSERT_EFI_ERROR (Status); + + if ( FixedPcdGetBool (PcdDtbAvailable) ) { + FilePtr +=3D Size; + Size =3D ParseHeader (FilePtr); + FilePtr +=3D FILE_HDR_SIZE; + Status =3D GetRdkVariable (L"DTB", &DtbPath); + ASSERT_EFI_ERROR (Status); + Status =3D RdkWriteFile (DtbPath, &FilePtr, &Size); + ASSERT_EFI_ERROR (Status); + } + + FreePool (FileBuffer); + FreePool (Uri); + + return Status; +} diff --git a/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c b/Platfor= m/Comcast/Library/RdkBootManagerLib/RdkFile.c new file mode 100644 index 000000000000..fbe70bceb24e --- /dev/null +++ b/Platform/Comcast/Library/RdkBootManagerLib/RdkFile.c @@ -0,0 +1,389 @@ +/* +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +*/ +#include + +#define MAX_VAR 6 + +#define ALLOCATE_STRING_MEM(X) AllocateZeroPool((X + 1) * sizeof(CHAR16)) + +/** + * list_for_each_entry - iterate over list of given type + * @pos: the type * to use as a loop cursor. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ +#define LIST_FOR_EACH_ENTRY(Pos, Head, Member) \ + for (Pos =3D BASE_CR((Head)->ForwardLink, typeof(*Pos), Member); \ + &Pos->Member !=3D (Head); \ + Pos =3D BASE_CR(Pos->Member.ForwardLink, typeof(*Pos), Member)) + +/** + * list_for_each_entry_safe - iterate over list of given type safe against= removal of list entry + * @pos: the type * to use as a loop cursor. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ +#define LIST_FOR_EACH_ENTRY_SAFE(Pos, N, Head, Member) \ + for (Pos =3D BASE_CR((Head)->ForwardLink, typeof(*Pos), Member), \ + N =3D BASE_CR(Pos->Member.ForwardLink, typeof(*Pos), Member); \ + &Pos->Member !=3D (Head); \ + Pos =3D N, N =3D BASE_CR(N->Member.ForwardLink, typeof(*N), Member)) + +/* ************************** */ + +typedef struct { + CHAR16 *Name; + LIST_ENTRY List; +} DIR_NODE; +/* ************************** */ + +STATIC UINT8 VarablesInitialzed =3D 0; +STATIC CHAR16 *VarResult[MAX_VAR][2]; + +STATIC +VOID +SaveString ( + OUT CHAR16 **Dest, + IN CHAR16 *String1, + IN CHAR16 *String2 + ) +{ + *Dest =3D ALLOCATE_STRING_MEM (StrLen (String1) + StrLen (String2)); + ASSERT (Dest !=3D NULL); + StrCat (*Dest, String1); + StrCat (*Dest, String2); +} + +STATIC +EFI_STATUS +LsFiles ( + IN CONST CHAR16 *DirPath, + IN CONST CHAR16 *TargetFile, + OUT CHAR16 **Result, + IN LIST_ENTRY *Head + ) +{ + EFI_STATUS Status; + EFI_FILE_INFO *FileInfo; + EFI_FILE_PROTOCOL *FileHandle; + BOOLEAN NoFile; + CHAR16 *TempPath; + DIR_NODE *Node; + + NoFile =3D FALSE; + TempPath =3D ALLOCATE_STRING_MEM (StrLen(DirPath) + 1); + StrCat (TempPath, DirPath); + StrCat (TempPath, L"/"); + + Status =3D GetFileHandler (&FileHandle, DirPath, EFI_FILE_MODE_READ); + ASSERT_EFI_ERROR (Status); + + for ( Status =3D FileHandleFindFirstFile (FileHandle, &FileInfo); + !EFI_ERROR (Status) && !NoFile; + Status =3D FileHandleFindNextFile (FileHandle, FileInfo, &NoFile) + ) { + if ( (FileInfo->Attribute & EFI_FILE_DIRECTORY) && + (StrCmp (FileInfo->FileName, L".") !=3D 0) && + (StrCmp (FileInfo->FileName, L"..") !=3D 0)) { + Node =3D AllocateZeroPool (sizeof (DIR_NODE)); + //append directory name to the path + SaveString (&Node->Name, TempPath, FileInfo->FileName); + InsertHeadList (Head, &Node->List); + } else if (StrCmp (FileInfo->FileName, TargetFile) =3D=3D 0) { + //append file to the absolute path + SaveString (Result, TempPath, FileInfo->FileName); + Status =3D EFI_SUCCESS; + goto Exit; + } + } + + Status =3D EFI_NOT_FOUND; + +Exit: + FreePool (TempPath); + return Status; +} + +STATIC +VOID +DelDirList ( + IN LIST_ENTRY *Head + ) +{ + DIR_NODE *Node; + DIR_NODE *Temp; + + LIST_FOR_EACH_ENTRY_SAFE (Node, Temp, Head, List) { + RemoveEntryList (&Node->List); + FreePool (Node->Name); + FreePool (Node); + } +} + +STATIC +EFI_STATUS +FindFileInDir ( + IN CONST CHAR16 *DevPath, + IN CONST CHAR16 *TargetFile, + OUT CHAR16 **Result + ) +{ + UINT8 Current; + UINT8 Next; + DIR_NODE *Temp; + LIST_ENTRY DirList[2]; + + *Result =3D NULL; + EFI_STATUS Status =3D EFI_NOT_FOUND; + + InitializeListHead (&DirList[0]); + InitializeListHead (&DirList[1]); + + for (Current =3D Next =3D 0, Status =3D LsFiles (\ + DevPath, TargetFile, Result, &DirList[Current]); + !IsListEmpty (&DirList[Current]); + Current =3D Next) { + Next =3D Current ^ 1; + DelDirList (&DirList[Next]); + + LIST_FOR_EACH_ENTRY (Temp, &DirList[Current], List) { + Status =3D LsFiles (Temp->Name, TargetFile, Result, &DirList[Next]); + if (!EFI_ERROR (Status)) { + DelDirList (&DirList[Current]); + break; + } + } + } + + DelDirList (&DirList[Next]); + return Status; +} + +STATIC +UINTN +StrSpn ( + IN CHAR8 *String, + IN CHAR8 *CharSet + ) +{ + UINTN Count; + + for (Count =3D 0; + String[Count] && ! (String[Count] =3D=3D CharSet[0]); + Count++); + return Count; +} + +STATIC +EFI_STATUS +InitVarList ( + IN CHAR8 *FileData, + IN UINTN FileSize + ) +{ + UINTN InnerLoopIndex; + UINTN OuterLoopIndex; + UINTN Current; + UINTN Next; + CHAR8 *VarDelimiter[2]; + EFI_STATUS Status; + + VarDelimiter[0] =3D "=3D"; + VarDelimiter[1] =3D "\""; + Status =3D EFI_SUCCESS; + + //Initialize to NULL + for (OuterLoopIndex =3D 0; OuterLoopIndex < MAX_VAR; OuterLoopIndex++) { + VarResult[OuterLoopIndex][0] =3D VarResult[OuterLoopIndex][1] =3D NU= LL; + } + + for (OuterLoopIndex =3D 0, Next=3D0; + OuterLoopIndex < MAX_VAR && Next < FileSize; + OuterLoopIndex++) { + for (InnerLoopIndex =3D 0; InnerLoopIndex < 2; InnerLoopIndex++) { + Current =3D Next; + Next +=3D StrSpn (&FileData[Next], VarDelimiter[InnerLoopIndex]); + FileData[Next] =3D '\0'; + if (VarResult[OuterLoopIndex][InnerLoopIndex]) { + FreePool (VarResult[OuterLoopIndex][InnerLoopIndex]); + } + VarResult[OuterLoopIndex][InnerLoopIndex] =3D \ + ALLOCATE_STRING_MEM (AsciiStrLen (&FileData[Current])); + AsciiStrToUnicodeStr (&FileData[Current], \ + VarResult[OuterLoopIndex][InnerLoopIndex]); + //skip new line + Next +=3D 2; + } + } + + return Status; +} + +STATIC +EFI_STATUS +InitRdkVariables ( + VOID + ) +{ + EFI_STATUS Status; + UINTN RdkSize; + UINT8 *RdkData; + CHAR16 *Result; + CONST CHAR16 *DevPath; + CONST CHAR16 *RdkFileName; + + DevPath =3D (CONST CHAR16 *)FixedPcdGetPtr (PcdRdkConfFileDevicePath= ); + RdkFileName =3D (CONST CHAR16 *)FixedPcdGetPtr (PcdRdkConfFileName); + + Status =3D FindFileInDir (DevPath, RdkFileName, &Result); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to find file %s in %s\n", \ + RdkFileName, DevPath)); + return Status; + } + + Status =3D RdkReadFile ((CONST CHAR16 *)Result, \ + (VOID**)&RdkData, &RdkSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to read file %s\n", RdkFileName)); + return Status; + } + + Status =3D InitVarList ((CHAR8 *)RdkData, RdkSize); + return Status; +} + +STATIC +EFI_STATUS +GetVarValue ( + IN CONST CHAR16 *Name, + OUT CONST CHAR16 **Value + ) +{ + UINTN Count; + EFI_STATUS Status; + + if (!VarablesInitialzed) { + Status =3D InitRdkVariables (); + if (EFI_ERROR (Status)) { + return Status; + } + + VarablesInitialzed =3D 1; + } + + //Initialize to NULL + *Value =3D NULL; + + for (Count =3D 0; Count < MAX_VAR; Count++) { + if (VarResult[Count][0] !=3D NULL && + StrCmp (Name, VarResult[Count][0]) =3D=3D 0) { + *Value =3D VarResult[Count][1]; + return EFI_SUCCESS; + } + } + + return EFI_NOT_FOUND; +} + +EFI_STATUS +GetRdkVariable ( + IN CONST CHAR16 *Name, + OUT CONST CHAR16 **Value + ) +{ + EFI_STATUS Status; + + Status =3D GetVarValue (Name, Value); + return Status; +} + +EFI_STATUS +RdkReadFile ( + IN CONST CHAR16 *Path, + IN OUT VOID **BufferPtr, + OUT UINTN *FileSize +) +{ + UINTN BufferSize; + UINT64 SourceFileSize; + VOID *Buffer; + EFI_STATUS Status; + EFI_FILE_HANDLE FileHandle; + + Status =3D GetFileHandler (&FileHandle, Path, EFI_FILE_MODE_READ); + ASSERT_EFI_ERROR (Status); + + Buffer =3D NULL; + + // Get the file size + Status =3D FileHandle->SetPosition (FileHandle, (UINT64) -1); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D FileHandle->GetPosition (FileHandle, &SourceFileSize); + if (EFI_ERROR (Status)) { + goto Exit; + } + + Status =3D FileHandle->SetPosition (FileHandle, 0); + if (EFI_ERROR (Status)) { + goto Exit; + } + + BufferSize =3D (UINTN)SourceFileSize; + Buffer =3D AllocateZeroPool (BufferSize); + if (Buffer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if (FileSize !=3D NULL) *FileSize =3D BufferSize; + + Status =3D FileHandle->Read (FileHandle, &BufferSize, Buffer); + if (EFI_ERROR (Status) || BufferSize !=3D SourceFileSize) { + FreePool (Buffer); + Buffer =3D NULL; + Status =3D EFI_BAD_BUFFER_SIZE; + goto Exit; + } + +Exit: + *BufferPtr =3D Buffer; + return Status; +} + +EFI_STATUS +RdkWriteFile ( + IN CONST CHAR16 *Path, + IN OUT VOID **BufferPtr, + OUT UINTN *FileSize +) +{ + EFI_STATUS Status; + EFI_FILE_HANDLE FileHandle; + + if (FileSize =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D GetFileHandler (&FileHandle, Path, \ + EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE); + ASSERT_EFI_ERROR (Status); + + Status =3D FileHandle->Write (FileHandle, FileSize, *BufferPtr); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/Platform/Comcast/Library/RdkBootManagerLib/SecureBoot.c b/Plat= form/Comcast/Library/RdkBootManagerLib/SecureBoot.c new file mode 100644 index 000000000000..391c648da294 --- /dev/null +++ b/Platform/Comcast/Library/RdkBootManagerLib/SecureBoot.c @@ -0,0 +1,523 @@ +/* +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +*/ +#include + +typedef enum KEY +{ + PK_KEY=3D1, + KEK_KEY, + DB_KEY, + DBX_KEY +} eKey; +/* ************************** */ + +STATIC +EFI_STATUS +OpenFileByDevicePath( + IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath, + OUT EFI_FILE_HANDLE *FileHandle, + IN UINT64 OpenMode, + IN UINT64 Attributes +) +{ + EFI_STATUS Status; + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *EfiSimpleFileSystemProtocol; + EFI_FILE_PROTOCOL *Handle1; + EFI_FILE_PROTOCOL *Handle2; + EFI_HANDLE DeviceHandle; + + if (FilePath =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D gBS->LocateDevicePath ( + &gEfiSimpleFileSystemProtocolGuid, + FilePath, + &DeviceHandle + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D gBS->OpenProtocol ( + DeviceHandle, + &gEfiSimpleFileSystemProtocolGuid, + (VOID**)&EfiSimpleFileSystemProtocol, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D EfiSimpleFileSystemProtocol->OpenVolume (\ + EfiSimpleFileSystemProtocol, &Handle1); + if (EFI_ERROR (Status)) { + FileHandle =3D NULL; + return Status; + } + + // + // go down directories one node at a time. + // + while (!IsDevicePathEnd (*FilePath)) { + // + // For file system access each node should be a file path component + // + if (DevicePathType (*FilePath) !=3D MEDIA_DEVICE_PATH || + DevicePathSubType (*FilePath) !=3D MEDIA_FILEPATH_DP + ) { + FileHandle =3D NULL; + return (EFI_INVALID_PARAMETER); + } + // + // Open this file path node + // + Handle2 =3D Handle1; + Handle1 =3D NULL; + + // + // Try to test opening an existing file + // + Status =3D Handle2->Open ( + Handle2, + &Handle1, + ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName, + OpenMode &~EFI_FILE_MODE_CREATE, + 0 + ); + + // + // see if the error was that it needs to be created + // + if ((EFI_ERROR (Status)) && + (OpenMode !=3D (OpenMode &~EFI_FILE_MODE_CREATE))) { + Status =3D Handle2->Open ( + Handle2, + &Handle1, + ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName, + OpenMode, + Attributes + ); + } + // + // Close the last node + // + Handle2->Close (Handle2); + + if (EFI_ERROR (Status)) { + return (Status); + } + + // + // Get the next node + // + *FilePath =3D NextDevicePathNode (*FilePath); + } + + // + // This is a weak spot since if the undefined + // SHELL_FILE_HANDLE format changes this must change also! + // + *FileHandle =3D (VOID*)Handle1; + + return EFI_SUCCESS; +} + +EFI_STATUS +GetFileHandler ( + OUT EFI_FILE_HANDLE *FileHandle, + IN CONST CHAR16 *Path, + IN UINT64 OpenMode +) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *KeyFileDevicePath; + EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DevicePathFromTextProtocol; + + Status =3D EFI_SUCCESS; + KeyFileDevicePath =3D NULL; + + Status =3D gBS->LocateProtocol ( + &gEfiDevicePathFromTextProtocolGuid, + NULL, + (VOID**)&DevicePathFromTextProtocol + ); + ASSERT_EFI_ERROR (Status); + + KeyFileDevicePath =3D DevicePathFromTextProtocol->ConvertTextToDevicePat= h (Path); + if (KeyFileDevicePath !=3D NULL) + { + Status =3D OpenFileByDevicePath (&KeyFileDevicePath, FileHandle, OpenM= ode, 0); + if (Status !=3D EFI_SUCCESS) + { + DEBUG ((DEBUG_ERROR, "Getting FileHandle of %s Failed\n",Path)); + } + } + return Status; +} + +STATIC +EFI_STATUS +CreateTimeBasedPayload ( + IN OUT UINTN *DataSize, + IN OUT UINT8 **Data +) +{ + EFI_STATUS Status; + UINT8 *NewData; + UINT8 *Payload; + UINTN PayloadSize; + EFI_VARIABLE_AUTHENTICATION_2 *DescriptorData; + UINTN DescriptorSize; + EFI_TIME Time; + + if (Data =3D=3D NULL || DataSize =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // In Setup mode or Custom mode, the variable does not need to be signed= but the + // parameters to the SetVariable() call still need to be prepared as aut= henticated + // variable. So we create EFI_VARIABLE_AUTHENTICATED_2 descriptor withou= t certificate + // data in it. + // + + Payload =3D *Data; + PayloadSize =3D *DataSize; + + DescriptorSize =3D OFFSET_OF (EFI_VARIABLE_AUTHENTICATION_2, AuthInfo) += \ + OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData); + NewData =3D (UINT8*) AllocateZeroPool (DescriptorSize + PayloadSize); + if (NewData =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + if ((Payload !=3D NULL) && (PayloadSize !=3D 0)) { + CopyMem (NewData + DescriptorSize, Payload, PayloadSize); + } + + DescriptorData =3D (EFI_VARIABLE_AUTHENTICATION_2 *) (NewData); + + ZeroMem (&Time, sizeof (EFI_TIME)); + Status =3D gRT->GetTime (&Time, NULL); + if (EFI_ERROR (Status)) { + FreePool(NewData); + return Status; + } + Time.Pad1 =3D 0; + Time.Nanosecond =3D 0; + Time.TimeZone =3D 0; + Time.Daylight =3D 0; + Time.Pad2 =3D 0; + CopyMem (&DescriptorData->TimeStamp, &Time, sizeof (EFI_TIME)); + + DescriptorData->AuthInfo.Hdr.dwLength =3D \ + OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData); + DescriptorData->AuthInfo.Hdr.wRevision =3D 0x0200; + DescriptorData->AuthInfo.Hdr.wCertificateType =3D WIN_CERT_TYPE_EFI_GUID; + CopyGuid (&DescriptorData->AuthInfo.CertType, &gEfiCertPkcs7Guid); + + if (Payload !=3D NULL) { + FreePool(Payload); + } + + *DataSize =3D DescriptorSize + PayloadSize; + *Data =3D NewData; + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +SetBootMode ( + IN UINT8 SecureBootMode +) +{ + return gRT->SetVariable ( + EFI_CUSTOM_MODE_NAME, + &gEfiCustomModeEnableGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof (UINT8), + &SecureBootMode + ); +} + +STATIC +EFI_STATUS +SetVariable ( + IN EFI_SIGNATURE_LIST *PkCert, + IN UINTN DataSize, + IN eKey KeyType +) +{ + UINT32 Attr; + EFI_STATUS Status; + + Status =3D EFI_SUCCESS; + Attr =3D EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATE= D_WRITE_ACCESS; + if (KeyType =3D=3D PK_KEY) + { + DEBUG ((DEBUG_INFO, "Setting PK Key\n")); + Status =3D gRT->SetVariable ( + EFI_PLATFORM_KEY_NAME, + &gEfiGlobalVariableGuid, + Attr, + DataSize, + PkCert + ); + } + else if (KeyType =3D=3D KEK_KEY) + { + DEBUG ((DEBUG_INFO, "Setting KEK Key\n")); + Status =3D gRT->SetVariable ( + EFI_KEY_EXCHANGE_KEY_NAME, + &gEfiGlobalVariableGuid, + Attr, + DataSize, + PkCert + ); + + Status =3D gRT->SetVariable ( + EFI_IMAGE_SECURITY_DATABASE, + &gEfiImageSecurityDatabaseGuid, + Attr, + DataSize, + PkCert + ); + } + else + { + ASSERT(FALSE); + } + return Status; +} + +STATIC +VOID +PopulateCert ( + OUT EFI_SIGNATURE_LIST **Cert, + IN UINTN DataSize, + IN UINT8 *Data +) +{ + EFI_SIGNATURE_DATA *CertData =3D NULL; + + if ((*Cert) =3D=3D NULL) + { + (*Cert) =3D (EFI_SIGNATURE_LIST*) AllocateZeroPool (sizeof (EFI_SIGNAT= URE_LIST) + + sizeof(EFI_SIGNATURE_DATA) - 1 + + DataSize ); + + ASSERT ((*Cert) !=3D NULL); + } + (*Cert)->SignatureListSize =3D (UINT32) (sizeof (EFI_SIGNATURE_LIST) + + sizeof (EFI_SIGNATURE_DATA) - 1 + + DataSize); + (*Cert)->SignatureSize =3D (UINT32) (sizeof (EFI_SIGNATURE_DATA) -= 1 + DataSize); + (*Cert)->SignatureHeaderSize =3D 0; + CopyGuid (&(*Cert)->SignatureType, &gEfiCertX509Guid); + + + CertData =3D (EFI_SIGNATURE_DATA*) ((UINTN)(*Cert) + \ + sizeof(EFI_SIGNATURE_LIST) + (*Cert)->SignatureHeaderSize); + ASSERT (CertData !=3D NULL); + + CopyGuid (&CertData->SignatureOwner, &gEfiGlobalVariableGuid); + CopyMem (&CertData->SignatureData, Data, DataSize); +} + +STATIC +EFI_STATUS +RegisterCert ( + IN UINT8 *KeyData, + IN UINTN KeySize, + IN eKey KeyType +) +{ + EFI_STATUS Status; + EFI_SIGNATURE_LIST *Cert; + + Cert =3D NULL; + + Status =3D SetBootMode (CUSTOM_SECURE_BOOT_MODE); + ASSERT_EFI_ERROR (Status); + + PopulateCert (&Cert, KeySize, KeyData); + + KeySize =3D Cert->SignatureListSize; + + Status =3D CreateTimeBasedPayload (&KeySize, (UINT8**) &Cert); + ASSERT_EFI_ERROR (Status); + + Status =3D SetVariable (Cert, KeySize, KeyType); + return Status; +} + +STATIC +VOID +RdkSetVariable ( + VOID +) +{ + CONST CHAR16 *KeyPath; + EFI_STATUS Status; + UINT8 *KekKey, *PkKey, *KekCrtData; + UINTN KekKeySize, PkKeySize, KekCrtSize; + INT8* SetupMode; + eKey KeyType; + + KeyPath =3D NULL; + SetupMode =3D NULL; + KekKey =3D PkKey =3D KekCrtData =3D NULL; + KekKeySize =3D PkKeySize =3D KekCrtSize =3D 0; + + Status =3D GetRdkVariable (L"ROOTCERT", &KeyPath); + + //set only if the Kek Crt file mentioned in the configuration file + if (KeyPath !=3D NULL) { + Status =3D RdkReadFile ( + KeyPath, + (VOID **)&KekCrtData, + &KekCrtSize + ); + ASSERT_EFI_ERROR (Status); + + Status =3D gRT->SetVariable ( + L"RdkRootCertificate", + &gRdkGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + KekCrtSize, + KekCrtData + ); + ASSERT_EFI_ERROR (Status); + + if (KekCrtData) FreePool (KekCrtData); + } + + Status =3D GetRdkVariable (L"KEKCERT", &KeyPath); + ASSERT_EFI_ERROR (Status); + + Status =3D RdkReadFile ( + KeyPath, + (VOID **)&KekKey, + &KekKeySize + ); + ASSERT_EFI_ERROR (Status); + + Status =3D GetRdkVariable (L"PKCERT", &KeyPath); + ASSERT_EFI_ERROR (Status); + + Status =3D RdkReadFile ( + KeyPath, + (VOID **)&PkKey, + &PkKeySize + ); + ASSERT_EFI_ERROR (Status); + + KeyType =3D PK_KEY; + Status =3D RegisterCert (PkKey, PkKeySize, KeyType); + GetEfiGlobalVariable2 (L"SetupMode", (VOID**)&SetupMode, NULL); + + if (*SetupMode =3D=3D 0) + { + DEBUG ((DEBUG_INFO, "PK Key Got Registered. Now System in User Mode\n"= )); + KeyType =3D KEK_KEY; + Status =3D RegisterCert (KekKey, KekKeySize, KeyType); + } + else if(*SetupMode =3D=3D 1) + { + DEBUG ((DEBUG_INFO, "System in Standard System Mode ::: Secure Boot No= t enabled\n")); + ASSERT_EFI_ERROR (Status); + } + + if ( PkKey ) FreePool (PkKey); + if ( KekKey ) FreePool (KekKey); +} + +EFI_STATUS +RdkSecureBoot ( + EFI_HANDLE ImageHandle, + EFI_BOOT_SERVICES *BootServices +) +{ + UINTN ExitDataSize; + CHAR16 *ExitData; + CHAR16 LoadOption[128]; + CONST CHAR8 *CmdLine; + CHAR16 *ImagePath; + UINT8 *FdtData; + CONST CHAR16 *DtbPath; + EFI_STATUS Status; + EFI_HANDLE Handle; + EFI_DEVICE_PATH_PROTOCOL *FilePath; + EFI_LOADED_IMAGE_PROTOCOL *ImageInfo; + EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DevicePathFromTextProtocol; + + FilePath =3D NULL; + ExitData =3D NULL; + CmdLine =3D (CONST CHAR8 *)FixedPcdGetPtr (PcdRdkCmdLineArgs); + + if (FixedPcdGetBool (PcdDtbAvailable)) { + FdtData =3D NULL; + DtbPath =3D NULL; + + Status =3D GetRdkVariable (L"DTB", &DtbPath); + ASSERT_EFI_ERROR (Status); + + Status =3D RdkReadFile (DtbPath, (VOID**) &FdtData, NULL); + ASSERT_EFI_ERROR (Status); + + Status =3D gBS->InstallConfigurationTable (&gFdtTableGuid,(VOID*)FdtDa= ta); + ASSERT_EFI_ERROR (Status); + } + + RdkSetVariable (); + + Status =3D GetRdkVariable (L"IMAGE", (CONST CHAR16**)&ImagePath); + ASSERT_EFI_ERROR (Status); + + Status =3D gBS->LocateProtocol ( + &gEfiDevicePathFromTextProtocolGuid, + NULL, + (VOID**)&DevicePathFromTextProtocol + ); + ASSERT_EFI_ERROR (Status); + + FilePath =3D DevicePathFromTextProtocol->ConvertTextToDevicePath (ImageP= ath); + ASSERT(NULL !=3D FilePath); + + Status =3D BootServices->LoadImage ( + TRUE, + ImageHandle, + FilePath, + NULL, + 0, + &Handle + ); + ASSERT_EFI_ERROR (Status); + + UnicodeSPrintAsciiFormat (LoadOption, sizeof (LoadOption), CmdLine); + + Status =3D BootServices->HandleProtocol (\ + Handle, &gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo); + ASSERT_EFI_ERROR (Status); + ImageInfo->LoadOptionsSize =3D sizeof (LoadOption); + ImageInfo->LoadOptions =3D LoadOption; + + Status =3D BootServices->StartImage (Handle, &ExitDataSize, &ExitData); + ASSERT_EFI_ERROR (Status); + + return Status; +} --=20 2.15.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 11:04:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518431989507700.5276687689284; Mon, 12 Feb 2018 02:39:49 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C17812237A4D8; Mon, 12 Feb 2018 02:33:54 -0800 (PST) Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3C4D722361E47 for ; Mon, 12 Feb 2018 02:26:13 -0800 (PST) Received: by mail-pg0-x244.google.com with SMTP id w17so7244080pgv.6 for ; Mon, 12 Feb 2018 02:32:02 -0800 (PST) Received: from localhost.localdomain ([220.225.120.129]) by smtp.gmail.com with ESMTPSA id s82sm32355780pfa.151.2018.02.12.02.32.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Feb 2018 02:32:01 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c05::244; helo=mail-pg0-x244.google.com; envelope-from=moorthy.baskaravenkatraman-sambamoorthy@linaro.org; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z336l98BTZugkTZwtrgVsYjLPgyvi6/gLuCVez0ruRM=; b=a7p/fqui6KXp49rxkCyln++ElTh8kQdgUG3Kzpi1N0s4mIBEnjaVuAu6FtGQwIlZa+ 8bCUG+PuP3eKLFoqSUDa51RvVgiPavwYgcVOqcvMWtl0OQ3T8eR2wSc63Yc9pmmfO9uo FoxYsD8B5iwoLtKvmArPTdOf5ZA5V5SubvYGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z336l98BTZugkTZwtrgVsYjLPgyvi6/gLuCVez0ruRM=; b=QvkP/zLeHy4udtLiS/Kh8JzcWwfYRdhw/9qFpdZw6nST5VZZt75U3WWnMpVUHgUYXT nlzlPTNchvMlv1LsfvrirVKX9+jCcsRDF0sHykV/+XQAeA7+U0L4oZPf7wuYeApN3C75 Xfpg2FzNORYcM5PrRmTwaW3g9iz9zC88GP6WsrZVhUcKAmx8Amwz4fQneCT++aSidkxQ 1AfuN1bEMV/t5Ayc3kQETNnJLe4HccpAqU2MyFZYIMBeMkobgPYkrSniV9Z3+QJsPm04 WqSthNilh2xdwx9Z5EG+PwFD9VIk81DbYp7MhX1NujuILDzAo3/aOr8JTBMKFL3h5gQs wB6Q== X-Gm-Message-State: APf1xPBiSZPPcmmjsPRGIt+ngniGYgfWKzdSJgG/KktQtMnxq9XooPdw pPeNHzU7o7ZE7XGzli9bjpctJ8rRXZ8= X-Google-Smtp-Source: AH8x225jMKRcuOiwrew9lXNWmDG6p8E9lGyEaDjYtWBdcIYeaj54t6GdryP3oEAqU3n9u8VvHCc0sg== X-Received: by 10.99.1.206 with SMTP id 197mr99536pgb.179.1518431521926; Mon, 12 Feb 2018 02:32:01 -0800 (PST) From: Moorthy Baskaravenkatraman To: edk2-devel@lists.01.org Date: Mon, 12 Feb 2018 16:01:20 +0530 Message-Id: <20180212103122.10729-3-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180212103122.10729-1-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> References: <20180212103122.10729-1-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> X-Mailman-Approved-At: Mon, 12 Feb 2018 02:33:53 -0800 Subject: [edk2] [PATCH v1 2/4] edk2-platforms:comcast: RDK secure boot Application X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kalyan Nagabhirava Application will get file path of PK key and KEK keys using rdk.conf file, once keys are available, application will enable secure boot and validates the signed kernel Image. Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Moorthy Baskaravenkatraman --- Platform/Comcast/Application/SecureBoot/SecureBoot.inf | 43 ++++++++++++++= ++++++ Platform/Comcast/Application/SecureBoot/SecureBoot.c | 30 ++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/Platform/Comcast/Application/SecureBoot/SecureBoot.inf b/Platf= orm/Comcast/Application/SecureBoot/SecureBoot.inf new file mode 100644 index 000000000000..da0cd3b3b742 --- /dev/null +++ b/Platform/Comcast/Application/SecureBoot/SecureBoot.inf @@ -0,0 +1,43 @@ +# +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# Copyright (c) 2016-2017, Comcast. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# + +##########################################################################= ###### +# +# Defines Section - statements that will be processed to create a Makefile. +# +##########################################################################= ###### + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D RdkSecureLoader + FILE_GUID =3D b2c7930f-07ef-4305-ac4e-1ce2085a7031 + MODULE_TYPE =3D UEFI_APPLICATION + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D SecureBootEntryPoint + +[Sources] + SecureBoot.c + +[Packages] + ArmPkg/ArmPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ShellPkg/ShellPkg.dec + SecurityPkg/SecurityPkg.dec + NetworkPkg/NetworkPkg.dec + Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec + +[LibraryClasses] + RdkBootManagerLib + UefiApplicationEntryPoint diff --git a/Platform/Comcast/Application/SecureBoot/SecureBoot.c b/Platfor= m/Comcast/Application/SecureBoot/SecureBoot.c new file mode 100644 index 000000000000..bea1e5888703 --- /dev/null +++ b/Platform/Comcast/Application/SecureBoot/SecureBoot.c @@ -0,0 +1,30 @@ +/* +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# + */ +#include + +EFI_STATUS +EFIAPI +SecureBootEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RdkSecureBoot ( + ImageHandle, + SystemTable->BootServices + ); + + return Status; +} --=20 2.15.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 11:04:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518431992688248.64874231349256; Mon, 12 Feb 2018 02:39:52 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 34DFA2237A4DE; Mon, 12 Feb 2018 02:33:55 -0800 (PST) Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1D76122361E47 for ; Mon, 12 Feb 2018 02:26:14 -0800 (PST) Received: by mail-pl0-x244.google.com with SMTP id ay8so4834028plb.4 for ; Mon, 12 Feb 2018 02:32:04 -0800 (PST) Received: from localhost.localdomain ([220.225.120.129]) by smtp.gmail.com with ESMTPSA id s82sm32355780pfa.151.2018.02.12.02.32.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Feb 2018 02:32:03 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=moorthy.baskaravenkatraman-sambamoorthy@linaro.org; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d9V5iLsKmEgEWw4vzQDmR5LyDEoEpoatXr0PU2x204o=; b=Ec8EHh4fFUX2U1uPw1jfy4lDh5kgpri39NWCquz4kXj4Maits6HJrBAqpwDdYmDp1M QclfNQ12ljc8AbNsLQN1klWkTk88VcPZG6BDM3VU46XsFhyWfuNLzCTTeIZoauuKJOBd k0Dg1Xgo8LqmOkf+1bWWiMgEPkJdwtcJemnj0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d9V5iLsKmEgEWw4vzQDmR5LyDEoEpoatXr0PU2x204o=; b=SnW+1RBoOUTy6CDrB9lIsxLTEpw+gK4c9qAZ83Iat6n5DkebgAB83FJY9r4eNTzAGv G8cbUL8rtJatF8QqLu3Nv63OscY0QBQzNaR1M8Zqy3WnSkZFrjDn+q+WBwVGDKStOqc2 gceawngoaKTakkgd4U7xjD9tOTdjU1ipQ48nDqV94zjm+dElav3Gp2AshegLcnIVGiuD N+9M/gq2V36c1XKW/mwDZDzvVRrpGo7+uGJqYM+mUDJeItpp0gb+t5+up8jPzbcyByuW tBN22DfQJj0LYqnsCCLX21SiQ1eTpwFpG7S+LZ9PgM4RlftxZmINhHjq45YtIGyeR+LK ccPg== X-Gm-Message-State: APf1xPBcAfwfAK/lbhDG0xdlQLlsCCdlt8ZsOJqMqv581U64qK5soU+k 0Bw1BckCFuljhl49Q6XuDgbg1TPLxZs= X-Google-Smtp-Source: AH8x2258C+HeQWs1cseC+m41autYLG2oXYuicZMOCiufW24F57eF+uHTYSKeaXueSP+yVSsAnE1VTQ== X-Received: by 2002:a17:902:bf01:: with SMTP id bi1-v6mr10207931plb.254.1518431523725; Mon, 12 Feb 2018 02:32:03 -0800 (PST) From: Moorthy Baskaravenkatraman To: edk2-devel@lists.01.org Date: Mon, 12 Feb 2018 16:01:21 +0530 Message-Id: <20180212103122.10729-4-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180212103122.10729-1-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> References: <20180212103122.10729-1-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> X-Mailman-Approved-At: Mon, 12 Feb 2018 02:33:53 -0800 Subject: [edk2] [PATCH v1 3/4] edk2-platforms:comcast: RDK DRI Application X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kalyan Nagabhirava Application will Download platform code Image (kernel + DTB + rootfs) and writes into Flash partition. Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Moorthy Baskaravenkatraman --- Platform/Comcast/Application/Dri/Dri.inf | 43 ++++++++= ++++++++++++ Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.inf | 43 ++++++++= ++++++++++++ Platform/Comcast/Application/Dri/Dri.c | 26 ++++++++= ++++ Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.c | 32 ++++++++= +++++++ 4 files changed, 144 insertions(+) diff --git a/Platform/Comcast/Application/Dri/Dri.inf b/Platform/Comcast/Ap= plication/Dri/Dri.inf new file mode 100644 index 000000000000..ba0656cbc6d7 --- /dev/null +++ b/Platform/Comcast/Application/Dri/Dri.inf @@ -0,0 +1,43 @@ +# +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# Copyright (c) 2016-2017, Comcast. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# + +##########################################################################= ###### +# +# Defines Section - statements that will be processed to create a Makefile. +# +##########################################################################= ###### + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D RdkDriLoader + FILE_GUID =3D 081ba18a-d71e-40a7-99a9-cdb86463966d + MODULE_TYPE =3D UEFI_APPLICATION + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D DriEntryPoint + +[Sources] + Dri.c + +[Packages] + ArmPkg/ArmPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + NetworkPkg/NetworkPkg.dec + ShellPkg/ShellPkg.dec + SecurityPkg/SecurityPkg.dec + Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec + +[LibraryClasses] + RdkBootManagerLib + UefiApplicationEntryPoint diff --git a/Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.inf b= /Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.inf new file mode 100644 index 000000000000..d31f8f8a5235 --- /dev/null +++ b/Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.inf @@ -0,0 +1,43 @@ +# +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# Copyright (c) 2016-2017, Comcast. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# + +##########################################################################= ###### +# +# Defines Section - statements that will be processed to create a Makefile. +# +##########################################################################= ###### + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D RdkDriSecureLoader + FILE_GUID =3D dd52d1d7-0de2-4552-98e0-8dbee458a502 + MODULE_TYPE =3D UEFI_APPLICATION + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D DriSecureBootEntryPoint + +[Sources] + DriSecureBoot.c + +[Packages] + ArmPkg/ArmPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ShellPkg/ShellPkg.dec + SecurityPkg/SecurityPkg.dec + NetworkPkg/NetworkPkg.dec + Platform/Comcast/Library/RdkBootManagerLib/RdkBootManagerLib.dec + +[LibraryClasses] + RdkBootManagerLib + UefiApplicationEntryPoint diff --git a/Platform/Comcast/Application/Dri/Dri.c b/Platform/Comcast/Appl= ication/Dri/Dri.c new file mode 100644 index 000000000000..4e5ede2e0ca4 --- /dev/null +++ b/Platform/Comcast/Application/Dri/Dri.c @@ -0,0 +1,26 @@ +/* +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# + */ +#include + +EFI_STATUS +EFIAPI +DriEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RdkHttpBoot (); + return Status; +} diff --git a/Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.c b/P= latform/Comcast/Application/DriSecureBoot/DriSecureBoot.c new file mode 100644 index 000000000000..abe10c029d27 --- /dev/null +++ b/Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.c @@ -0,0 +1,32 @@ +/* +# Copyright (c) 2014-2018, Linaro Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# + */ +#include + +EFI_STATUS +EFIAPI +DriSecureBootEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RdkHttpBoot (); + + Status =3D RdkSecureBoot ( + ImageHandle, + SystemTable->BootServices + ); + + return Status; +} --=20 2.15.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 11:04:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518431995492120.64372348251118; Mon, 12 Feb 2018 02:39:55 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9700A2239363B; Mon, 12 Feb 2018 02:33:55 -0800 (PST) Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 832AC222DE12C for ; Mon, 12 Feb 2018 02:26:17 -0800 (PST) Received: by mail-pl0-x244.google.com with SMTP id t4so4841532plo.0 for ; Mon, 12 Feb 2018 02:32:06 -0800 (PST) Received: from localhost.localdomain ([220.225.120.129]) by smtp.gmail.com with ESMTPSA id s82sm32355780pfa.151.2018.02.12.02.32.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Feb 2018 02:32:05 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=moorthy.baskaravenkatraman-sambamoorthy@linaro.org; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zpHTqwmzwddlE84cPBBFXt44+duZZy2zPggjdo0/rVE=; b=ZWc3QmLBOa7xvfV+YyHMECkYt9t2Q3QGvLJSyVvNjlfOtQRAZQa83XiBGLKf6lwaJ1 MPel/DTKkPqdFUBzm6/QYdziY4j/ekVZU6Fy3gSoJzAFilqP63+6e/w2y9tixB2QMpgQ 73J5ZV1MUC4kPprT4XEMWcd7gGrOOXFJs4wyU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zpHTqwmzwddlE84cPBBFXt44+duZZy2zPggjdo0/rVE=; b=NIqJA1v02XclJgg3BQ2GsgQ4AK/anBvbujgpvpyw91r4cp+ymIvg/SZbGvo6sfuTbC A461cvreD5zc6+xCUcPSll/LFJ4x2NFiDORYiqyebAzdueCwvb0YzLOG+CKYXqhUT5Ld rPHvd5Rv4WCFJvLaX5SmAcgnOauRQ+pBHRgbFcDmMczvvVI510ez6lTF44q+/AjWE2eQ yKKmsyC9Y9v9lEkZo+Zniq8OPKmnyLnguMOEGKzoK4YnsD6uFR/nbBycextq2n8o3hTF WPwW0nLMcBBzOLm3F2m8LB/pXrdoGMA3UB/3NIZk5AcMcuvOw6neY24MI9EhHK6FiZRw 670w== X-Gm-Message-State: APf1xPDSc8/5KiQEvCt4j71lxt6qYRztcc0pP4tgHNoXiB6/kOSxCcl8 qyRzVMQvz6dDGJCfNTPNh3MX5CHvTS4= X-Google-Smtp-Source: AH8x224UXwBoZocZrbIzSWFcLJeTzHQrq7mgEE0Vavl6ibu+V6hrUswhY5xA0YIpxOmCxBRzczAOiw== X-Received: by 2002:a17:902:e85:: with SMTP id 5-v6mr10336840plx.208.1518431526044; Mon, 12 Feb 2018 02:32:06 -0800 (PST) From: Moorthy Baskaravenkatraman To: edk2-devel@lists.01.org Date: Mon, 12 Feb 2018 16:01:22 +0530 Message-Id: <20180212103122.10729-5-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180212103122.10729-1-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> References: <20180212103122.10729-1-moorthy.baskaravenkatraman-sambamoorthy@linaro.org> X-Mailman-Approved-At: Mon, 12 Feb 2018 02:33:53 -0800 Subject: [edk2] [PATCH v1 4/4] edk2-platforms: created RDK Qemu platform for RDK UEFI applications X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kalyan Nagabhirava Linaro and RDK are working on standardizing the boot process for RDK STB boxes using Uefi. Implmented couple of RDK UEFI apllications (secure boot and DRI) which are tested on RDK Qemu platform Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Moorthy Baskaravenkatraman Reviewed-by: Ard Biesheuvel --- Platform/Comcast/RDKQemu/RDKQemu.dsc | 431 ++++++++++++++++++++ Platform/Comcast/RDKQemu/RDKQemu.fdf | 128 ++++++ Platform/Comcast/RDKQemu/README | 73 ++++ 3 files changed, 632 insertions(+) diff --git a/Platform/Comcast/RDKQemu/RDKQemu.dsc b/Platform/Comcast/RDKQem= u/RDKQemu.dsc new file mode 100644 index 000000000000..f5c9f328a2ed --- /dev/null +++ b/Platform/Comcast/RDKQemu/RDKQemu.dsc @@ -0,0 +1,431 @@ +# +# Copyright (c) 2011-2015, ARM Limited. All rights reserved. +# Copyright (c) 2014 - 2018, Linaro Limited. All rights reserved. +# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +# + +##########################################################################= ###### +# +# Defines Section - statements that will be processed to create a Makefile. +# +##########################################################################= ###### +[Defines] + PLATFORM_NAME =3D RdkQemu + PLATFORM_GUID =3D 2D89EF13-B604-4550-B080-5E2E5E382854 + PLATFORM_VERSION =3D 0.1 + DSC_SPECIFICATION =3D 0x00010005 + OUTPUT_DIRECTORY =3D Build/RDK-$(ARCH) + SUPPORTED_ARCHITECTURES =3D AARCH64|ARM + BUILD_TARGETS =3D DEBUG|RELEASE + SKUID_IDENTIFIER =3D DEFAULT + FLASH_DEFINITION =3D Platform/Comcast/RDKQemu/RDKQemu.fdf + + # + # Defines for default states. These can be changed on the command line. + # -D FLAG=3DVALUE + # + DEFINE SECURE_BOOT_ENABLE =3D TRUE + DEFINE HTTP_BOOT_ENABLE =3D TRUE + +!include ArmVirtPkg/ArmVirt.dsc.inc + +[LibraryClasses.common] + ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf + + # Virtio Support + VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf + VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice= Lib.inf + QemuFwCfgLib|ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf + QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf + + ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibN= ull.inf + + TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf + NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.i= nf + + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf + BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf + PlatformBootManagerLib|ArmVirtPkg/Library/PlatformBootManagerLib/Platfor= mBootManagerLib.inf + CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Customize= dDisplayLib.inf + QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf + FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf + PciPcdProducerLib|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProdu= cerLib.inf + PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.i= nf + PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridge= Lib.inf + RdkBootManagerLib|Platform/Comcast/Library/RdkBootManagerLib/RdkBootMana= gerLib.inf +!if $(HTTP_BOOT_ENABLE) =3D=3D TRUE + HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf +!endif + +[LibraryClasses.common.PEIM] + ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoP= eiLib.inf + +[LibraryClasses.common.UEFI_DRIVER] + UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf + +##########################################################################= ###### +# +# Pcd Section - list of all EDK II PCD Entries defined by this Platform +# +##########################################################################= ###### + +[PcdsFeatureFlag.common] + gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE + gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE + + ## If TRUE, Graphics Output Protocol will be installed on virtual handle= created by ConsplitterDxe. + # It could be set FALSE to save size. + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE + +[PcdsFixedAtBuild.common] + gArmPlatformTokenSpaceGuid.PcdCoreCount|1 +!if $(ARCH) =3D=3D AARCH64 + gArmTokenSpaceGuid.PcdVFPEnabled|1 +!endif + + gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase|0x4007c000 + gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000 + gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 + gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 + + # Size of the region used by UEFI in permanent memory (Reserved 64MB) + gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000 + + ## Trustzone enable (to make the transition from EL3 to EL2 in ArmPlatfo= rmPkg/Sec) + gArmTokenSpaceGuid.PcdTrustzoneSupport|FALSE + + # + # ARM PrimeCell + # + + ## PL011 - Serial Terminal + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|38400 + + ## Default Terminal Type + ## 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM +!if $(TTY_TERMINAL) =3D=3D TRUE + gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4 +!else + gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1 +!endif + + # + # ARM Virtual Architectural Timer -- fetch frequency from QEMU (TCG) or = KVM + # + gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|0 + +!if $(HTTP_BOOT_ENABLE) =3D=3D TRUE + gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE +!endif + # System Memory Base -- fixed at 0x4000_0000 + gArmTokenSpaceGuid.PcdSystemMemoryBase|0x40000000 + + # initial location of the device tree blob passed by QEMU -- base of DRAM + gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x40000000 + + gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FAL= SE + gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c= , 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0= x31 } + + # + # The maximum physical I/O addressability of the processor, set with + # BuildCpuHob(). + # + gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16 + + # + # RdkPkg Pcds + # + # system partition name is nothing but rootfs partition, used only in Ht= tp boot (DRI) + gRdkTokenSpaceGuid.PcdRdkSystemPartitionName|"VenHw(837DCA9E-E874-4D82-B= 29A-23FE0E23D1E2,003E000A00000000)" + gRdkTokenSpaceGuid.PcdRdkCmdLineArgs|"root=3D/dev/vda" + gRdkTokenSpaceGuid.PcdRdkConfFileName|L"Rdk.conf" + gRdkTokenSpaceGuid.PcdRdkConfFileDevicePath|L"PciRoot(0x0)/Pci(0x2,0x0)" + +[PcdsFixedAtBuild.AARCH64] + # KVM limits it IPA space to 40 bits (1 TB), so there is no need to + # support anything bigger, even if the host hardware does + gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40 + + # Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry po= int, + # if the entry point version is >=3D 3.0. AARCH64 OSes cannot assume the + # presence of the 32-bit entry point anyway (because many AARCH64 systems + # don't have 32-bit addressable physical RAM), and the additional alloca= tions + # below 4 GB needlessly fragment the memory map. So expose the 64-bit en= try + # point only, for entry point versions >=3D 3.0. + gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosEntryPointProvideMethod|0x2 + + # ACPI predates the AARCH64 architecture by 5 versions, so + # we only target OSes that support ACPI v5.0 or later + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20 + +[PcdsDynamicDefault.common] + gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3 + + ## If TRUE, OvmfPkg/AcpiPlatformDxe will not wait for PCI + # enumeration to complete before installing ACPI tables. + gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE + + # System Memory Size -- 1 MB initially, actual size will be fetched from= DT + gArmTokenSpaceGuid.PcdSystemMemorySize|0x00100000 + + gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0 + gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0 + gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0 + gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum|0x0 + + # + # ARM General Interrupt Controller + # + gArmTokenSpaceGuid.PcdGicDistributorBase|0x0 + gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x0 + gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x0 + + ## PL031 RealTimeClock + gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0 + + # set PcdPciExpressBaseAddress to MAX_UINT64, which signifies that this + # PCD and PcdPciDisableBusEnumeration above have not been assigned yet + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xFFFFFFFFFFFFFFFF + + gArmTokenSpaceGuid.PcdPciIoTranslation|0x0 + + # + # Set video resolution for boot options and for text setup. + # PlatformDxe can set the former at runtime. + # + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600 + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640 + gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480 + + # + # SMBIOS entry point version + # + gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0300 + gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0 + gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE + +[PcdsDynamicHii] + gArmVirtTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gArmVirtVariableGui= d|0x0|FALSE|NV,BS + +##########################################################################= ###### +# +# Components Section - list of all EDK II Modules needed by this Platform +# +##########################################################################= ###### +[Components.common] + # + # PEI Phase modules + # + ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf + MdeModulePkg/Core/Pei/PeiMain.inf + MdeModulePkg/Universal/PCD/Pei/Pcd.inf { + + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + } + ArmPlatformPkg/PlatformPei/PlatformPeim.inf + ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf + ArmPkg/Drivers/CpuPei/CpuPei.inf + + MdeModulePkg/Universal/Variable/Pei/VariablePei.inf + + MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf { + + NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompre= ssLib.inf + } + + # + # DXE + # + MdeModulePkg/Core/Dxe/DxeMain.inf { + + NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32Gu= idedSectionExtractLib.inf + } + MdeModulePkg/Universal/PCD/Dxe/Pcd.inf { + + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + } + + # + # Architectural Protocols + # + ArmPkg/Drivers/CpuDxe/CpuDxe.inf + MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { + + NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf + # don't use unaligned CopyMem () on the UEFI varstore NOR flash regi= on + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + } +!if $(SECURE_BOOT_ENABLE) =3D=3D TRUE + MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { + + NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificatio= nLib.inf + } + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDx= e.inf +!else + MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf +!endif + MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf + MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf + MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf + EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf { + + NULL|ArmVirtPkg/Library/ArmVirtPL031FdtClientLib/ArmVirtPL031FdtClie= ntLib.inf + } + EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf + + MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf + MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf + MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf + MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf + MdeModulePkg/Universal/SerialDxe/SerialDxe.inf + + MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf + + ArmPkg/Drivers/ArmGic/ArmGicDxe.inf + ArmPkg/Drivers/TimerDxe/TimerDxe.inf { + + NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClie= ntLib.inf + } + ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf + MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf + + # + # Platform Driver + # + ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf + ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf + ArmVirtPkg/HighMemDxe/HighMemDxe.inf + OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + OvmfPkg/VirtioScsiDxe/VirtioScsi.inf + OvmfPkg/VirtioNetDxe/VirtioNet.inf + OvmfPkg/VirtioRngDxe/VirtioRng.inf + + # + # FAT filesystem + GPT/MBR partitioning + UDF filesystem + # + MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf + MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf + MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + + # + # Bds + # + MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf + MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf + MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf + MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf + MdeModulePkg/Universal/BdsDxe/BdsDxe.inf + MdeModulePkg/Logo/LogoDxe.inf + MdeModulePkg/Application/UiApp/UiApp.inf { + + NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf + NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf + NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanc= eManagerUiLib.inf + } + + # + # Networking stack + # + MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf + MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf + MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf + MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf + MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf + MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf + MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf + MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf + MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf + MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf + MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf +!if $(HTTP_BOOT_ENABLE) =3D=3D TRUE + NetworkPkg/DnsDxe/DnsDxe.inf + NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf + NetworkPkg/HttpDxe/HttpDxe.inf + NetworkPkg/HttpBootDxe/HttpBootDxe.inf +!endif + # + # SCSI Bus and Disk Driver + # + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + + # + # SMBIOS Support + # + MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf { + + NULL|OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf + } + OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf + + # + # PCI support + # + ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf { + + NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf + } + MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf + MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { + + NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf + } + OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf + OvmfPkg/Virtio10Dxe/Virtio10.inf + + # + # Video support + # + OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + OvmfPkg/PlatformDxe/Platform.inf + + # + # USB Support + # + MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf + MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf + MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf + MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf + MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + # + # ACPI Support + # + ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf + + # + # RdkPkg + # + Platform/Comcast/Application/Dri/Dri.inf + Platform/Comcast/Application/SecureBoot/SecureBoot.inf + Platform/Comcast/Application/DriSecureBoot/DriSecureBoot.inf + +[Components.AARCH64] + MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsRes= ourceTableDxe.inf + OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf { + + NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf + } + +[PcdsFixedAtBuild] + gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE + +[BuildOptions] + GCC:*_*_*_CC_FLAGS =3D -UDISABLE_NEW_DEPRECATED_INTERFACES diff --git a/Platform/Comcast/RDKQemu/RDKQemu.fdf b/Platform/Comcast/RDKQem= u/RDKQemu.fdf new file mode 100644 index 000000000000..2ff7bef08adf --- /dev/null +++ b/Platform/Comcast/RDKQemu/RDKQemu.fdf @@ -0,0 +1,128 @@ +# +# Copyright (c) 2011-2015, ARM Limited. All rights reserved. +# Copyright (c) 2014 - 2018, Linaro Limited. All rights reserved. +# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# + +##########################################################################= ###### +# +# FD Section +# The [FD] Section is made up of the definition statements and a +# description of what goes into the Flash Device Image. Each FD section +# defines one flash "device" image. A flash device image may be one of +# the following: Removable media bootable image (like a boot floppy +# image,) an Option ROM image (that would be "flashed" into an add-in +# card,) a System "Flash" image (that would be burned into a system's +# flash) or an Update ("Capsule") image that will be used to update and +# existing system flash. +# +##########################################################################= ###### + +[FD.RDK_EFI] +BaseAddress =3D 0x00000000|gArmTokenSpaceGuid.PcdFdBaseAddress # QEMU a= ssigns 0 - 0x8000000 for a BootROM +Size =3D 0x00200000|gArmTokenSpaceGuid.PcdFdSize # The si= ze in bytes of the FLASH Device +ErasePolarity =3D 1 + +# This one is tricky, it must be: BlockSize * NumBlocks =3D Size +BlockSize =3D 0x00001000 +NumBlocks =3D 0x200 + +##########################################################################= ###### +# +# Following are lists of FD Region layout which correspond to the location= s of different +# images within the flash device. +# +# Regions must be defined in ascending order and may not overlap. +# +# A Layout Region start with a eight digit hex offset (leading "0x" requir= ed) followed by +# the pipe "|" character, followed by the size of the region, also in hex = with the leading +# "0x" characters. Like: +# Offset|Size +# PcdOffsetCName|PcdSizeCName +# RegionType +# +##########################################################################= ###### + +# +# UEFI has trouble dealing with FVs that reside at physical address 0x0. +# So instead, put a hardcoded 'jump to 0x1000' at offset 0x0, and put the +# real FV at offset 0x1000 +# +0x00000000|0x00001000 +DATA =3D { +!if $(ARCH) =3D=3D AARCH64 + 0x00, 0x04, 0x00, 0x14 # 'b 0x1000' in AArch64 ASM +!else + 0xfe, 0x03, 0x00, 0xea # 'b 0x1000' in AArch32 ASM +!endif +} + +0x00001000|0x001ff000 +gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize +FV =3D FVMAIN_COMPACT + +!include ArmVirtPkg/VarStore.fdf.inc + +##########################################################################= ###### +# +# FV Section +# +# [FV] section is used to define what components or modules are placed wit= hin a flash +# device file. This section also defines order the components and modules= are positioned +# within the image. The [FV] section consists of define statements, set s= tatements and +# module statements. +# +##########################################################################= ###### + +!include ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc + +[FV.FVMAIN_COMPACT] +#FvNameGuid =3D 64074afe-340a-4be6-94ba-91b5b4d0d412 +FvAlignment =3D 16 +ERASE_POLARITY =3D 1 +MEMORY_MAPPED =3D TRUE +STICKY_WRITE =3D TRUE +LOCK_CAP =3D TRUE +LOCK_STATUS =3D TRUE +WRITE_DISABLED_CAP =3D TRUE +WRITE_ENABLED_CAP =3D TRUE +WRITE_STATUS =3D TRUE +WRITE_LOCK_CAP =3D TRUE +WRITE_LOCK_STATUS =3D TRUE +READ_DISABLED_CAP =3D TRUE +READ_ENABLED_CAP =3D TRUE +READ_STATUS =3D TRUE +READ_LOCK_CAP =3D TRUE +READ_LOCK_STATUS =3D TRUE + + INF ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf + INF MdeModulePkg/Core/Pei/PeiMain.inf + INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf + INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf + INF ArmPkg/Drivers/CpuPei/CpuPei.inf + INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf + INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf + INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf + + # + # FDT installation + # + # The UEFI driver is at the end of the list of the driver to be dispatch= ed + # after the device drivers (eg: Ethernet) to ensure we have support for = them. + #INF Platform/ARM/Drivers/FdtPlatformDxe/FdtPlatformDxe.inf + + FILE FV_IMAGE =3D 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { + SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRE= D =3D TRUE { + SECTION FV_IMAGE =3D FVMAIN + } + } + +!include ArmVirtPkg/ArmVirtRules.fdf.inc diff --git a/Platform/Comcast/RDKQemu/README b/Platform/Comcast/RDKQemu/REA= DME new file mode 100644 index 000000000000..d03de725ed23 --- /dev/null +++ b/Platform/Comcast/RDKQemu/README @@ -0,0 +1,73 @@ +workspace structure: +-------------------- + +base directory + |__ edk2 + |__ edk2-platforms + |__ uefi-tools + +Prerequisites: +-------------- + +Before building EDK-II UEFI, prepare base tools +$ cd edk2 +$ make -C BaseTools +$ cd .. + +Application can be tested: +------------------------- +1) Secure boot +2) Disaster Recovery Image (DRI) download +3) DRI Secure boot + +above applications source code path- edk2-platforms/Platform/Comcast/Appli= cation + +QEMU setup: +----------- +$ qemu-system-aarch64 -cpu cortex-a57 -M virt -m 512M -bios RDK_EFI.fd -no= graphic -no-acpi -hda bootpartition.img -hdb fat:keys -drive if=3Dnone,file= =3Drootfs.img,format=3Draw,id=3Dhd0 -device virtio-blk-device,drive=3Dhd0 + +hdb: a directory which contains KEK.cer and PK.cer (public key) files + +hda: bootpartition.img + +$ dd if=3D/dev/zero bs=3D1M count=3D64 of=3Dbootpartition.img +$ mkfs.vfat -F 32 bootpartition.img +$ sudo mount bootpartition.img /mnt +#copy kernel image file (for secure boot), Rdk.conf configuration file, se= rver.url file +$ sudo cp /mnt +$ sudo umount /mnt + +Configuration file: + +RDK Secure boot application accepts 6 configuration +ROOTCERT - key file to validate rootfs +KEKCERT - KEK public Key +PKCERT - PK public key +URL - a text file that contains server URL where DRI image is stored +IMAGE - kernel image file +DTB - Device tree blob file + +# rdk conf file for getting PK, KEK and kernel file path in flash partitio= ns +Typical Rdk.conf file: +################################################################ +KEKCERT=3D"PciRoot(0x0)/Pci(0x3,0x0)/HD(1,MBR,0xBE1AFDFA,0x3F,0xFBFC1)/KEK= .cer" +PKCERT=3D"PciRoot(0x0)/Pci(0x3,0x0)/HD(1,MBR,0xBE1AFDFA,0x3F,0xFBFC1)/PK.c= er" +URL=3D"PciRoot(0x0)/Pci(0x2,0x0)/server.url" +IMAGE=3D"PciRoot(0x0)/Pci(0x2,0x0)/Image" +################################################################ + +server.url: + +contains the url path to HTTP image (rootfs + kernel + dtb) +Eg. http://xx.xx.xx.xx/path/http.img + +http.img formation: + +$ touch tmp +$ printf "%016d" `stat -c "%s" rootfs.img` >> tmp +$ cat rootfs.img >> tmp +$ printf "%016d" `stat -c "%s" kernelSignedImage` >> tmp +$ cat kernelSignedImage >> tmp +$ printf "%016d" `stat -c "%s" dtb` >> tmp +$ cat dtb >> tmp +$ mv tmp http.img --=20 2.15.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel