From patchwork Tue Jun 12 15:36:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 928382 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aD8EgNil"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 414v6N73jyz9s0w for ; Wed, 13 Jun 2018 01:33:16 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9ABFFC21E52; Tue, 12 Jun 2018 15:32:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 00713C21DA6; Tue, 12 Jun 2018 15:31:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EED93C21DE8; Tue, 12 Jun 2018 15:31:48 +0000 (UTC) Received: from mail-io0-f195.google.com (mail-io0-f195.google.com [209.85.223.195]) by lists.denx.de (Postfix) with ESMTPS id 84AE3C21DD3 for ; Tue, 12 Jun 2018 15:31:44 +0000 (UTC) Received: by mail-io0-f195.google.com with SMTP id r24-v6so28536001ioh.9 for ; Tue, 12 Jun 2018 08:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=z0tWQZ/UFmppx1M2ZPAsDeUkQ/r+kToFzvAC9rNUV1M=; b=aD8EgNilVN1mE63sstcaRBtx67KrL4p0C0d4COUs+OtWVn5PManm8RnuNaNTh37bru 0ZekVQ9sQYTzmgd4wChtMpjQk39ZRos3opG+H4+u6A9WcDMOqzhH8c10dfx/CPYqk4QO U01kOXyBJFMfoztkALjANlRzU9+ZaKYeLelhSub50RKP4hrkVs+SphDoGASN35QoqPPV GPhlkgaBDjyKPh1+X9xOgbHMO9vfQ87C9ukeTv8ZYMtvw3V03tXmuwg6yfQRO/gqAsA8 nJKK1Z9h6fnaY8YiO92sAbqXu7/2KiISqDbgcMlMUlpCF7/dX/BJPe/B+3dB3+dYN3ZZ WK5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=z0tWQZ/UFmppx1M2ZPAsDeUkQ/r+kToFzvAC9rNUV1M=; b=LBdHd6vLbiUsp8SWrpnBnMP7HluWJSpruUl4RWQ3g3z7Zaj1BNQrqQNDqKXTrnFvbI EBD92daMDuBoHnbRtgQW6mmSBdJfCwSeWc34pmcEEQRnsdWTC6QzDXuT90nOG8Pv0SCT ro9/0NzLKYKUQxQIe+RGLUjgpAJ4YLMKXAwEtb4RG5lC6Ln7C/bywp8ax6Z83jMaZZQC VqHY8xoeZv9RLyS7C9EnEKmWbLA6HDVbz9CDcteDKXmgUU5evgzSlcrGx74fnCX3TbKA jK43/FmeqyvYUKcKdyfMPWgKYsXe0aZfV/YyNMvp9Rz8aIjIYxT+CtBQtkRSJweG2WM3 Oviw== X-Gm-Message-State: APt69E3BbEttujdYLUDhhVL28MxoNDaomr7idLZ303BvFwNBfGBhrPM6 VmRKbxEo0wmGRo9hZNNCnxM= X-Google-Smtp-Source: ADUXVKKFUPmEfzL9CwlHmTZL/XejjAraFj/I6c8GgTF87fKRlGE4OxlwZm7dyvtWYTO56hRCoYiQ1w== X-Received: by 2002:a5e:c811:: with SMTP id y17-v6mr933338iol.29.1528817503353; Tue, 12 Jun 2018 08:31:43 -0700 (PDT) Received: from ala-d2121-lx1.wrs.com (unknown-156-139.windriver.com. [147.11.156.139]) by smtp.gmail.com with ESMTPSA id l82-v6sm369743itl.25.2018.06.12.08.31.41 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Jun 2018 08:31:42 -0700 (PDT) From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Tue, 12 Jun 2018 08:36:18 -0700 Message-Id: <1528817785-20208-7-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1528817785-20208-1-git-send-email-bmeng.cn@gmail.com> References: <1528817785-20208-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH v2 06/13] x86: Add generic EFI payload support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" It is possible to create a generic EFI payload for all x86 boards. The payload is configured to include as many generic drivers as possible. All stuff that touches low-level initialization are not allowed as such is the EFI BIOS's responsibility. Platform specific drivers (like gpio, spi, etc) are not included. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- Changes in v2: - update README.u-boot_on_efi to mention generic EFI payload support arch/x86/dts/Makefile | 1 + arch/x86/dts/efi-x86_payload.dts | 36 +++++++++++++++++++++++++++++++++ board/efi/Kconfig | 9 +++++++++ board/efi/efi-x86_payload/Kconfig | 38 +++++++++++++++++++++++++++++++++++ board/efi/efi-x86_payload/MAINTAINERS | 7 +++++++ board/efi/efi-x86_payload/Makefile | 5 +++++ board/efi/efi-x86_payload/start.S | 8 ++++++++ configs/efi-x86_payload32_defconfig | 35 ++++++++++++++++++++++++++++++++ configs/efi-x86_payload64_defconfig | 36 +++++++++++++++++++++++++++++++++ doc/README.u-boot_on_efi | 19 +++++++++--------- include/configs/efi-x86_payload.h | 32 +++++++++++++++++++++++++++++ 11 files changed, 216 insertions(+), 10 deletions(-) create mode 100644 arch/x86/dts/efi-x86_payload.dts create mode 100644 board/efi/efi-x86_payload/Kconfig create mode 100644 board/efi/efi-x86_payload/MAINTAINERS create mode 100644 board/efi/efi-x86_payload/Makefile create mode 100644 board/efi/efi-x86_payload/start.S create mode 100644 configs/efi-x86_payload32_defconfig create mode 100644 configs/efi-x86_payload64_defconfig create mode 100644 include/configs/efi-x86_payload.h diff --git a/arch/x86/dts/Makefile b/arch/x86/dts/Makefile index 7379774..9872c04 100644 --- a/arch/x86/dts/Makefile +++ b/arch/x86/dts/Makefile @@ -11,6 +11,7 @@ dtb-y += bayleybay.dtb \ dfi-bt700-q7x-151.dtb \ edison.dtb \ efi.dtb \ + efi-x86_payload.dtb \ galileo.dtb \ minnowmax.dtb \ qemu-x86_i440fx.dtb \ diff --git a/arch/x86/dts/efi-x86_payload.dts b/arch/x86/dts/efi-x86_payload.dts new file mode 100644 index 0000000..137bde5 --- /dev/null +++ b/arch/x86/dts/efi-x86_payload.dts @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018, Bin Meng + * + * Generic EFI payload device tree for x86 targets + */ + +/dts-v1/; + +/include/ "skeleton.dtsi" +/include/ "serial.dtsi" +/include/ "keyboard.dtsi" +/include/ "rtc.dtsi" +/include/ "tsc_timer.dtsi" + +/ { + model = "EFI x86 Payload"; + compatible = "efi,x86-payload"; + + aliases { + serial0 = &serial; + }; + + config { + silent_console = <0>; + }; + + chosen { + stdout-path = "/serial"; + }; + + pci { + compatible = "pci-x86"; + u-boot,dm-pre-reloc; + }; +}; diff --git a/board/efi/Kconfig b/board/efi/Kconfig index 6f86a48..d37f6ff 100644 --- a/board/efi/Kconfig +++ b/board/efi/Kconfig @@ -12,8 +12,17 @@ config TARGET_EFI takes over once the RAM, video and CPU are fully running. U-Boot is loaded as an application from EFI. +config TARGET_EFI_PAYLOAD + bool "efi payload" + help + This target is used for running U-Boot on top of EFI. In + this case EFI does the early initialisation, and U-Boot + takes over once the RAM, video and CPU are fully running. + U-Boot is loaded as a payload from EFI. + endchoice source "board/efi/efi-x86/Kconfig" +source "board/efi/efi-x86_payload/Kconfig" endif diff --git a/board/efi/efi-x86_payload/Kconfig b/board/efi/efi-x86_payload/Kconfig new file mode 100644 index 0000000..dcf4de8 --- /dev/null +++ b/board/efi/efi-x86_payload/Kconfig @@ -0,0 +1,38 @@ +if TARGET_EFI_PAYLOAD + +config SYS_BOARD + default "efi-x86_payload" + +config SYS_VENDOR + default "efi" + +config SYS_SOC + default "efi" + +config SYS_CONFIG_NAME + default "efi-x86_payload" + +config SYS_TEXT_BASE + default 0x00200000 + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + imply SYS_NS16550 + imply SCSI + imply SCSI_AHCI + imply AHCI_PCI + imply MMC + imply MMC_PCI + imply MMC_SDHCI + imply MMC_SDHCI_SDMA + imply USB + imply USB_EHCI_HCD + imply USB_XHCI_HCD + imply USB_STORAGE + imply USB_KEYBOARD + imply E1000 + imply ETH_DESIGNWARE + imply PCH_GBE + imply RTL8169 + +endif diff --git a/board/efi/efi-x86_payload/MAINTAINERS b/board/efi/efi-x86_payload/MAINTAINERS new file mode 100644 index 0000000..abf3a15 --- /dev/null +++ b/board/efi/efi-x86_payload/MAINTAINERS @@ -0,0 +1,7 @@ +EFI-X86_PAYLOAD BOARD +M: Bin Meng +S: Maintained +F: board/efi/efi-x86_payload/ +F: include/configs/efi-x86_payload.h +F: configs/efi-x86_payload32_defconfig +F: configs/efi-x86_payload64_defconfig diff --git a/board/efi/efi-x86_payload/Makefile b/board/efi/efi-x86_payload/Makefile new file mode 100644 index 0000000..6982340 --- /dev/null +++ b/board/efi/efi-x86_payload/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018, Bin Meng + +obj-y += start.o diff --git a/board/efi/efi-x86_payload/start.S b/board/efi/efi-x86_payload/start.S new file mode 100644 index 0000000..f7eaa7c --- /dev/null +++ b/board/efi/efi-x86_payload/start.S @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2018, Bin Meng + */ + +.globl early_board_init +early_board_init: + jmp early_board_init_ret diff --git a/configs/efi-x86_payload32_defconfig b/configs/efi-x86_payload32_defconfig new file mode 100644 index 0000000..7f0cab0 --- /dev/null +++ b/configs/efi-x86_payload32_defconfig @@ -0,0 +1,35 @@ +CONFIG_X86=y +CONFIG_VENDOR_EFI=y +CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" +CONFIG_TARGET_EFI_PAYLOAD=y +CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" +CONFIG_SYS_CONSOLE_INFO_QUIET=y +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_LAST_STAGE_INIT=y +CONFIG_HUSH_PARSER=y +# CONFIG_CMD_FLASH is not set +CONFIG_CMD_IDE=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PART=y +CONFIG_CMD_USB=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y +# CONFIG_CMD_NFS is not set +CONFIG_CMD_PING=y +CONFIG_CMD_TIME=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_CMD_FAT=y +CONFIG_CMD_FS_GENERIC=y +CONFIG_MAC_PARTITION=y +CONFIG_ISO_PARTITION=y +CONFIG_EFI_PARTITION=y +CONFIG_REGMAP=y +CONFIG_SYSCON=y +# CONFIG_PCI_PNP is not set +CONFIG_EFI=y +CONFIG_EFI_STUB=y diff --git a/configs/efi-x86_payload64_defconfig b/configs/efi-x86_payload64_defconfig new file mode 100644 index 0000000..8d7f3f0 --- /dev/null +++ b/configs/efi-x86_payload64_defconfig @@ -0,0 +1,36 @@ +CONFIG_X86=y +CONFIG_VENDOR_EFI=y +CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" +CONFIG_TARGET_EFI_PAYLOAD=y +CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" +CONFIG_SYS_CONSOLE_INFO_QUIET=y +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_LAST_STAGE_INIT=y +CONFIG_HUSH_PARSER=y +# CONFIG_CMD_FLASH is not set +CONFIG_CMD_IDE=y +CONFIG_CMD_MMC=y +CONFIG_CMD_PART=y +CONFIG_CMD_USB=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y +# CONFIG_CMD_NFS is not set +CONFIG_CMD_PING=y +CONFIG_CMD_TIME=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_CMD_FAT=y +CONFIG_CMD_FS_GENERIC=y +CONFIG_MAC_PARTITION=y +CONFIG_ISO_PARTITION=y +CONFIG_EFI_PARTITION=y +CONFIG_REGMAP=y +CONFIG_SYSCON=y +# CONFIG_PCI_PNP is not set +CONFIG_EFI=y +CONFIG_EFI_STUB=y +CONFIG_EFI_STUB_64BIT=y diff --git a/doc/README.u-boot_on_efi b/doc/README.u-boot_on_efi index 0349c56..8fba112 100644 --- a/doc/README.u-boot_on_efi +++ b/doc/README.u-boot_on_efi @@ -71,12 +71,13 @@ Just build U-Boot as normal, e.g. make efi-x86_defconfig make -To build U-Boot as an EFI payload (32-bit or 64-bit EFI can be used), adjust an -existing config (like qemu-x86_defconfig) to enable CONFIG_EFI, CONFIG_EFI_STUB -and either CONFIG_EFI_STUB_32BIT or CONFIG_EFI_STUB_64BIT. All of these are -boolean Kconfig options. Then build U-Boot as normal, e.g. +To build U-Boot as an EFI payload (32-bit or 64-bit EFI can be used), enable +CONFIG_EFI, CONFIG_EFI_STUB, and select either CONFIG_EFI_STUB_32BIT or +CONFIG_EFI_STUB_64BIT. The efi-x86_payload configs (efi-x86_payload32_defconfig +and efi-x86_payload32_defconfig) are set up for this. Then build U-Boot as +normal, e.g. - make qemu-x86_defconfig + make efi-x86_payload32_defconfig (or efi-x86_payload64_defconfig) make You will end up with one of these files depending on what you build for: @@ -211,11 +212,6 @@ Future work ----------- This work could be extended in a number of ways: -- Add a generic x86 EFI payload configuration. At present you need to modify -an existing one, but mostly the low-level x86 code is disabled when booting -on EFI anyway, so a generic 'EFI' board could be created with a suitable set -of drivers enabled. - - Add ARM support - Add 64-bit application support @@ -241,6 +237,9 @@ arch/x86/cpu/efi board/efi/efi-x86/efi.c x86 board code for running as an EFI application +board/efi/efi-x86_payload + generic x86 EFI payload board support code + common/cmd_efi.c the 'efi' command diff --git a/include/configs/efi-x86_payload.h b/include/configs/efi-x86_payload.h new file mode 100644 index 0000000..9c62fd2 --- /dev/null +++ b/include/configs/efi-x86_payload.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2018, Bin Meng + */ + +/* + * board/config.h - configuration options, board specific + */ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#include + +#define CONFIG_SYS_MONITOR_LEN (1 << 20) + +#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial,i8042-kbd\0" \ + "stdout=serial,vidconsole\0" \ + "stderr=serial,vidconsole\0" + +/* ATA/IDE support */ +#define CONFIG_SYS_IDE_MAXBUS 2 +#define CONFIG_SYS_IDE_MAXDEVICE 4 +#define CONFIG_SYS_ATA_BASE_ADDR 0 +#define CONFIG_SYS_ATA_DATA_OFFSET 0 +#define CONFIG_SYS_ATA_REG_OFFSET 0 +#define CONFIG_SYS_ATA_ALT_OFFSET 0 +#define CONFIG_SYS_ATA_IDE0_OFFSET 0x1f0 +#define CONFIG_SYS_ATA_IDE1_OFFSET 0x170 +#define CONFIG_ATAPI + +#endif /* __CONFIG_H */