From 14d61d4e577c57ba77b826c6cc9d99a0b3f3fc37 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 4 Dec 2017 16:33:26 +0100 Subject: [PATCH 1/5] efi_stub: Fix GDT_NOTSYS check The get_codeseg32() wants to know if a passed in descriptor has flag GDT_NOTSYS set (desc & GDT_NOTSYS), not whether desc and GDT_NOTSYS are not != 0 (desk && GDT_NOTSYS). This is an obvious typo. Fix it up. Signed-off-by: Alexander Graf Reviewed-by: Bin Meng --- lib/efi/efi_stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index 2e8d409d31..205aa19947 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -182,7 +182,7 @@ static int get_codeseg32(void) << 16; base <<= 12; /* 4KB granularity */ limit <<= 12; - if ((desc & GDT_PRESENT) && (desc && GDT_NOTSYS) && + if ((desc & GDT_PRESENT) && (desc & GDT_NOTSYS) && !(desc & GDT_LONG) && (desc & GDT_4KB) && (desc & GDT_32BIT) && (desc & GDT_CODE) && CONFIG_SYS_TEXT_BASE > base && From 1eaf7800b6b99b48e73eab56202cf1c7a0e19ac9 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 27 Mar 2018 00:46:05 -0700 Subject: [PATCH 2/5] dm: pci: Check board information pointer in decode_regions() PCI enumeration may happen very early on an x86 board. The board information pointer should have been checked in decode_regions() as its space may not be allocated yet. With this commit, Intel Galileo board boots again. Fixes: 664758c ("pci: Fix decode regions for memory banks") Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- drivers/pci/pci-uclass.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index ad43e8a27c..9d51236770 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -876,6 +876,9 @@ static int decode_regions(struct pci_controller *hose, ofnode parent_node, #ifdef CONFIG_NR_DRAM_BANKS bd_t *bd = gd->bd; + if (!bd) + return 0; + for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { if (bd->bi_dram[i].size) { pci_set_region(hose->regions + hose->region_count++, From ee1109bb45be4aaf057a44a70c9bdf2d7ff5bbc7 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 27 Mar 2018 00:46:06 -0700 Subject: [PATCH 3/5] dm: pci: Avoid setting a PCI region that has 0 size It makes no sense to set a PCI region that has 0 size. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- drivers/pci/pci-uclass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 9d51236770..a2e829608a 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -897,8 +897,9 @@ static int decode_regions(struct pci_controller *hose, ofnode parent_node, #endif if (gd->pci_ram_top && gd->pci_ram_top < base + size) size = gd->pci_ram_top - base; - pci_set_region(hose->regions + hose->region_count++, base, base, - size, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY); + if (size) + pci_set_region(hose->regions + hose->region_count++, base, + base, size, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY); #endif return 0; From 0851f344d7b3ef73e2520d4b6f5ad1e3bca8dc44 Mon Sep 17 00:00:00 2001 From: Bernhard Messerklinger Date: Thu, 15 Feb 2018 09:09:43 +0100 Subject: [PATCH 4/5] x86: mmc: Fix mapping of BAR memory Use dm_pci_map_bar function for BAR mapping. This has the advantage of clearing BAR flags and and only accepting mapped memory. Signed-off-by: Bernhard Messerklinger Reviewed-by: Hannes Schmelzer Reviewed-by: Bin Meng --- drivers/mmc/pci_mmc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c index 05c0044a7a..b7a2ebfe3f 100644 --- a/drivers/mmc/pci_mmc.c +++ b/drivers/mmc/pci_mmc.c @@ -29,11 +29,10 @@ static int pci_mmc_probe(struct udevice *dev) struct pci_mmc_plat *plat = dev_get_platdata(dev); struct pci_mmc_priv *priv = dev_get_priv(dev); struct sdhci_host *host = &priv->host; - u32 ioaddr; int ret; - dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &ioaddr); - host->ioaddr = map_sysmem(ioaddr, 0); + host->ioaddr = (void *)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, + PCI_REGION_MEM); host->name = dev->name; ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0); if (ret) From 5d73292cf84db1e8f7d99dd27100ef2e8ac15c4e Mon Sep 17 00:00:00 2001 From: Ivan Gorinov Date: Mon, 26 Mar 2018 18:06:54 -0700 Subject: [PATCH 5/5] x86: zImage: Pass working device tree data to the kernel On x86 platforms, U-Boot does not pass Device Tree data to the kernel. This prevents the kernel from using FDT loaded by U-Boot. Read the working FDT address from the "fdtaddr" environment variable and add a copy of the FDT data to the kernel setup_data list. Signed-off-by: Ivan Gorinov Reviewed-by: Bin Meng [bmeng: add #include to zimage.c to fix build error] Signed-off-by: Bin Meng --- arch/x86/include/asm/bootparam.h | 7 +++++-- arch/x86/lib/zimage.c | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h index 90768a99ce..6aba614361 100644 --- a/arch/x86/include/asm/bootparam.h +++ b/arch/x86/include/asm/bootparam.h @@ -10,8 +10,11 @@ #include /* setup data types */ -#define SETUP_NONE 0 -#define SETUP_E820_EXT 1 +enum { + SETUP_NONE = 0, + SETUP_E820_EXT, + SETUP_DTB, +}; /* extensible setup data list node */ struct setup_data { diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 2a82bc83d6..6af1bf4678 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #endif #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -95,6 +97,38 @@ static int get_boot_protocol(struct setup_header *hdr) } } +static int setup_device_tree(struct setup_header *hdr, const void *fdt_blob) +{ + int bootproto = get_boot_protocol(hdr); + struct setup_data *sd; + int size; + + if (bootproto < 0x0209) + return -ENOTSUPP; + + if (!fdt_blob) + return 0; + + size = fdt_totalsize(fdt_blob); + if (size < 0) + return -EINVAL; + + size += sizeof(struct setup_data); + sd = (struct setup_data *)malloc(size); + if (!sd) { + printf("Not enough memory for DTB setup data\n"); + return -ENOMEM; + } + + sd->next = hdr->setup_data; + sd->type = SETUP_DTB; + sd->len = fdt_totalsize(fdt_blob); + memcpy(sd->data, fdt_blob, sd->len); + hdr->setup_data = (unsigned long)sd; + + return 0; +} + struct boot_params *load_zimage(char *image, unsigned long kernel_size, ulong *load_addressp) { @@ -261,6 +295,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, hdr->acpi_rsdp_addr = acpi_get_rsdp_addr(); #endif + setup_device_tree(hdr, (const void *)env_get_hex("fdtaddr", 0)); setup_video(&setup_base->screen_info); return 0;