From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wj0-x22b.google.com (mail-wj0-x22b.google.com [IPv6:2a00:1450:400c:c01::22b]) (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 D180E81D36 for ; Mon, 21 Nov 2016 04:28:18 -0800 (PST) Received: by mail-wj0-x22b.google.com with SMTP id qp4so26010894wjc.3 for ; Mon, 21 Nov 2016 04:28:18 -0800 (PST) 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=xsX1EmZVFMGOS5Uxz4SVsn24eSTDb/mhR/8K+DOn5zY=; b=QXPYsVz/+FKa+VUVPYnMTvQmnSdIz9Z2cjtx/BKQQJ327VSrn+3SJ/NQPR2UVWT4vm uDsnu0zsVtChZNklc/rBxC8SgpBeLTiQIeL734VU88+a2iotmT86vAufbNqd2cKjoLXV wCWEF1FBiJ8x0mg+in/h5v+9ETByiNmnbN8xQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xsX1EmZVFMGOS5Uxz4SVsn24eSTDb/mhR/8K+DOn5zY=; b=hRFTRelOrQofuOc9KF6cxQSjiLYMAZveAJR6X9oZQv/f+MPF9F3Ia1p6RuUHde2tvi XP2sNWm2EaNZ4o6PZNIfvwYMfLrmRt4jIDEJk/wvX7v7VASa8NmDyQcyatjOROwqxAIv wJOKYaekqLuQab1ZfE4nhvuKbCuXIOfs8rjPVD+EnN4B6/m9YmnmHMdTM/ZoDZJ0DgFq AG2jAnbj1JVI3xtyqWrEd7S3+M5wZIGDgEYYqOjznH42vihWoq1kmu12ytMtevrmc57W 9Kt9JQ8TQqm5PWphmT93TIvUwZdjAjBMfmnWrB51CSz+LdjpbQVK5YNGTzMs6cZ8WRrK xARg== X-Gm-Message-State: AKaTC01FafKJcfzdTzdPoZkvGrifSpbyarxeb+t8Dwln5LpdWpuqkjgh7hMsZ6tufKlc+YPG X-Received: by 10.194.31.167 with SMTP id b7mr10583096wji.168.1479731297011; Mon, 21 Nov 2016 04:28:17 -0800 (PST) Received: from localhost.localdomain ([196.69.65.28]) by smtp.gmail.com with ESMTPSA id u18sm19299292wmd.1.2016.11.21.04.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Nov 2016 04:28:16 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, ryan.harkin@linaro.org Cc: Ard Biesheuvel Date: Mon, 21 Nov 2016 12:28:08 +0000 Message-Id: <1479731290-22497-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479731290-22497-1-git-send-email-ard.biesheuvel@linaro.org> References: <1479731290-22497-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [PATCH 1/3] EmbeddedPkg/AndroidFastboot: drop dependency on the LinuxLoader X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Nov 2016 12:28:19 -0000 When booting the kernel via Fastboot, invoke the kernel image directly rather than passing it to the LinuxLoader app. This requires the kernel image to be built with UEFI stub support. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- Build tested only. EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c | 70 ++++++-------------- 1 file changed, 22 insertions(+), 48 deletions(-) diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c index acedd3e0e3cd..46a7ceb3a41c 100644 --- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c +++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c @@ -21,11 +21,6 @@ #include #include -#define LINUX_LOADER_COMMAND_LINE L"%s -f %s -c %s" - -// This GUID is defined in the INGF file of ArmPkg/Application/LinuxLoader -CONST EFI_GUID mLinuxLoaderAppGuid = { 0x701f54f2, 0x0d70, 0x4b89, { 0xbc, 0x0a, 0xd9, 0xca, 0x25, 0x37, 0x90, 0x59 }}; - // Device Path representing an image in memory #pragma pack(1) typedef struct { @@ -68,11 +63,7 @@ BootAndroidBootImg ( VOID *Ramdisk; UINTN RamdiskSize; MEMORY_DEVICE_PATH KernelDevicePath; - MEMORY_DEVICE_PATH* RamdiskDevicePath; - CHAR16* KernelDevicePathTxt; - CHAR16* RamdiskDevicePathTxt; - EFI_DEVICE_PATH* LinuxLoaderDevicePath; - CHAR16* LoadOptions; + CHAR16 *LoadOptions, *NewLoadOptions; Status = ParseAndroidBootImg ( Buffer, @@ -93,55 +84,38 @@ BootAndroidBootImg ( KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel; KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel + KernelSize; - RamdiskDevicePath = NULL; - if (RamdiskSize != 0) { - RamdiskDevicePath = (MEMORY_DEVICE_PATH*)DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL*) &MemoryDevicePathTemplate); - - RamdiskDevicePath->Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk; - RamdiskDevicePath->Node1.EndingAddress = ((EFI_PHYSICAL_ADDRESS)(UINTN) Ramdisk) + RamdiskSize; - } - - // - // Boot Linux using the Legacy Linux Loader - // - - Status = LocateEfiApplicationInFvByGuid (&mLinuxLoaderAppGuid, &LinuxLoaderDevicePath); - if (EFI_ERROR (Status)) { - Print (L"Couldn't Boot Linux: %d\n", Status); - return EFI_DEVICE_ERROR; - } - - KernelDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, FALSE, FALSE); - if (KernelDevicePathTxt == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - RamdiskDevicePathTxt = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *) RamdiskDevicePath, FALSE, FALSE); - if (RamdiskDevicePathTxt == NULL) { + // Initialize Linux command line + LoadOptions = CatSPrint (NULL, L"%a", KernelArgs); + if (LoadOptions == NULL) { return EFI_OUT_OF_RESOURCES; } - // Initialize Legacy Linux loader command line - LoadOptions = CatSPrint (NULL, LINUX_LOADER_COMMAND_LINE, KernelDevicePathTxt, RamdiskDevicePathTxt, KernelArgs); - if (LoadOptions == NULL) { - return EFI_OUT_OF_RESOURCES; + if (RamdiskSize != 0) { + NewLoadOptions = CatSPrint (LoadOptions, L" initrd=0x%x,0x%x", + (UINTN)Ramdisk, RamdiskSize); + FreePool (LoadOptions); + if (NewLoadOptions == NULL) { + return EFI_OUT_OF_RESOURCES; + } + LoadOptions = NewLoadOptions; } - Status = BdsStartEfiApplication (gImageHandle, LinuxLoaderDevicePath, StrSize (LoadOptions), LoadOptions); + Status = BdsStartEfiApplication (gImageHandle, + (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath, + StrSize (LoadOptions), + LoadOptions); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Couldn't Boot Linux: %d\n", Status)); - return EFI_DEVICE_ERROR; - } - - if (RamdiskDevicePath) { - FreePool (RamdiskDevicePathTxt); - FreePool (RamdiskDevicePath); + Status = EFI_DEVICE_ERROR; + goto FreeLoadOptions; } - FreePool (KernelDevicePathTxt); - // If we got here we do a confused face because BootLinuxFdt returned, // reporting success. DEBUG ((EFI_D_ERROR, "WARNING: BdsBootLinuxFdt returned EFI_SUCCESS.\n")); return EFI_SUCCESS; + +FreeLoadOptions: + FreePool (LoadOptions); + return Status; } -- 2.7.4