summaryrefslogtreecommitdiff
path: root/arch/x86/lib
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/lib')
-rw-r--r--arch/x86/lib/Makefile1
-rw-r--r--arch/x86/lib/acpi_table.c383
-rw-r--r--arch/x86/lib/acpigen.c96
-rw-r--r--arch/x86/lib/bootm.c2
-rw-r--r--arch/x86/lib/fsp/fsp_common.c16
-rw-r--r--arch/x86/lib/fsp/fsp_dram.c17
-rw-r--r--arch/x86/lib/fsp/fsp_graphics.c32
-rw-r--r--arch/x86/lib/fsp2/fsp_silicon_init.c4
-rw-r--r--arch/x86/lib/fsp2/fsp_support.c22
-rw-r--r--arch/x86/lib/zimage.c484
10 files changed, 977 insertions, 80 deletions
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 1185a88c27..1bcbb49a61 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -38,6 +38,7 @@ obj-y += sfi.o
obj-y += acpi.o
obj-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.o
ifndef CONFIG_QEMU
+obj-y += acpigen.o
obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o
endif
obj-y += tables.o
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index c445aa6870..6d405b09fd 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -6,7 +6,10 @@
* Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
*/
+#define LOG_CATEGORY LOGC_ACPI
+
#include <common.h>
+#include <bloblist.h>
#include <cpu.h>
#include <dm.h>
#include <log.h>
@@ -15,6 +18,7 @@
#include <serial.h>
#include <version.h>
#include <acpi/acpigen.h>
+#include <acpi/acpi_device.h>
#include <acpi/acpi_table.h>
#include <asm/acpi/global_nvs.h>
#include <asm/ioapic.h>
@@ -65,14 +69,17 @@ int acpi_create_madt_lapics(u32 current)
{
struct udevice *dev;
int total_length = 0;
+ int cpu_num = 0;
for (uclass_find_first_device(UCLASS_CPU, &dev);
dev;
uclass_find_next_device(&dev)) {
struct cpu_platdata *plat = dev_get_parent_platdata(dev);
- int length = acpi_create_madt_lapic(
- (struct acpi_madt_lapic *)current,
- plat->cpu_id, plat->cpu_id);
+ int length;
+
+ length = acpi_create_madt_lapic(
+ (struct acpi_madt_lapic *)current, cpu_num++,
+ plat->cpu_id);
current += length;
total_length += length;
}
@@ -210,6 +217,105 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg)
header->checksum = table_compute_checksum((void *)mcfg, header->length);
}
+/**
+ * acpi_create_tcpa() - Create a TCPA table
+ *
+ * @tcpa: Pointer to place to put table
+ *
+ * Trusted Computing Platform Alliance Capabilities Table
+ * TCPA PC Specific Implementation SpecificationTCPA is defined in the PCI
+ * Firmware Specification 3.0
+ */
+static int acpi_create_tcpa(struct acpi_tcpa *tcpa)
+{
+ struct acpi_table_header *header = &tcpa->header;
+ u32 current = (u32)tcpa + sizeof(struct acpi_tcpa);
+ int size = 0x10000; /* Use this as the default size */
+ void *log;
+ int ret;
+
+ if (!CONFIG_IS_ENABLED(BLOBLIST))
+ return -ENXIO;
+ memset(tcpa, '\0', sizeof(struct acpi_tcpa));
+
+ /* Fill out header fields */
+ acpi_fill_header(header, "TCPA");
+ header->length = sizeof(struct acpi_tcpa);
+ header->revision = 1;
+
+ ret = bloblist_ensure_size_ret(BLOBLISTT_TCPA_LOG, &size, &log);
+ if (ret)
+ return log_msg_ret("blob", ret);
+
+ tcpa->platform_class = 0;
+ tcpa->laml = size;
+ tcpa->lasa = (ulong)log;
+
+ /* (Re)calculate length and checksum */
+ header->length = current - (u32)tcpa;
+ header->checksum = table_compute_checksum((void *)tcpa, header->length);
+
+ return 0;
+}
+
+static int get_tpm2_log(void **ptrp, int *sizep)
+{
+ const int tpm2_default_log_len = 0x10000;
+ int size;
+ int ret;
+
+ *sizep = 0;
+ size = tpm2_default_log_len;
+ ret = bloblist_ensure_size_ret(BLOBLISTT_TPM2_TCG_LOG, &size, ptrp);
+ if (ret)
+ return log_msg_ret("blob", ret);
+ *sizep = size;
+
+ return 0;
+}
+
+static int acpi_create_tpm2(struct acpi_tpm2 *tpm2)
+{
+ struct acpi_table_header *header = &tpm2->header;
+ int tpm2_log_len;
+ void *lasa;
+ int ret;
+
+ memset((void *)tpm2, 0, sizeof(struct acpi_tpm2));
+
+ /*
+ * Some payloads like SeaBIOS depend on log area to use TPM2.
+ * Get the memory size and address of TPM2 log area or initialize it.
+ */
+ ret = get_tpm2_log(&lasa, &tpm2_log_len);
+ if (ret)
+ return ret;
+
+ /* Fill out header fields. */
+ acpi_fill_header(header, "TPM2");
+ memcpy(header->aslc_id, ASLC_ID, 4);
+
+ header->length = sizeof(struct acpi_tpm2);
+ header->revision = acpi_get_table_revision(ACPITAB_TPM2);
+
+ /* Hard to detect for coreboot. Just set it to 0 */
+ tpm2->platform_class = 0;
+
+ /* Must be set to 0 for FIFO-interface support */
+ tpm2->control_area = 0;
+ tpm2->start_method = 6;
+ memset(tpm2->msp, 0, sizeof(tpm2->msp));
+
+ /* Fill the log area size and start address fields. */
+ tpm2->laml = tpm2_log_len;
+ tpm2->lasa = (uintptr_t)lasa;
+
+ /* Calculate checksum. */
+ header->checksum = table_compute_checksum((void *)tpm2, header->length);
+
+ return 0;
+}
+
__weak u32 acpi_fill_csrt(u32 current)
{
return 0;
@@ -394,11 +500,13 @@ ulong write_acpi_tables(ulong start_addr)
struct acpi_fadt *fadt;
struct acpi_table_header *ssdt;
struct acpi_mcfg *mcfg;
+ struct acpi_tcpa *tcpa;
struct acpi_madt *madt;
struct acpi_csrt *csrt;
struct acpi_spcr *spcr;
void *start;
ulong addr;
+ int ret;
int i;
start = map_sysmem(start_addr, 0);
@@ -430,17 +538,31 @@ ulong write_acpi_tables(ulong start_addr)
dsdt->length - sizeof(struct acpi_table_header));
acpi_inc(ctx, dsdt->length - sizeof(struct acpi_table_header));
+ dsdt->length = ctx->current - (void *)dsdt;
+ acpi_align(ctx);
- /* Pack GNVS into the ACPI table area */
- for (i = 0; i < dsdt->length; i++) {
- u32 *gnvs = (u32 *)((u32)dsdt + i);
- if (*gnvs == ACPI_GNVS_ADDR) {
- ulong addr = (ulong)map_to_sysmem(ctx->current);
-
- debug("Fix up global NVS in DSDT to %#08lx\n", addr);
- *gnvs = addr;
- break;
+ if (!IS_ENABLED(CONFIG_ACPI_GNVS_EXTERNAL)) {
+ /* Pack GNVS into the ACPI table area */
+ for (i = 0; i < dsdt->length; i++) {
+ u32 *gnvs = (u32 *)((u32)dsdt + i);
+
+ if (*gnvs == ACPI_GNVS_ADDR) {
+ *gnvs = map_to_sysmem(ctx->current);
+ debug("Fix up global NVS in DSDT to %#08x\n",
+ *gnvs);
+ break;
+ }
}
+
+ /*
+ * Fill in platform-specific global NVS variables. If this fails
+ * we cannot return the error but this should only happen while
+ * debugging.
+ */
+ addr = acpi_create_gnvs(ctx->current);
+ if (IS_ERR_VALUE(addr))
+ printf("Error: Gailed to create GNVS\n");
+ acpi_inc_align(ctx, sizeof(struct acpi_global_nvs));
}
/*
@@ -448,12 +570,9 @@ ulong write_acpi_tables(ulong start_addr)
* the GNVS address. Set the checksum to zero since it is part of the
* region being checksummed.
*/
- dsdt->length = ctx->current - (void *)dsdt;
dsdt->checksum = 0;
dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length);
- acpi_align(ctx);
-
/*
* Fill in platform-specific global NVS variables. If this fails we
* cannot return the error but this should only happen while debugging.
@@ -484,12 +603,36 @@ ulong write_acpi_tables(ulong start_addr)
acpi_inc_align(ctx, mcfg->header.length);
acpi_add_table(ctx, mcfg);
+ if (IS_ENABLED(CONFIG_TPM_V2)) {
+ struct acpi_tpm2 *tpm2;
+
+ debug("ACPI: * TPM2\n");
+ tpm2 = (struct acpi_tpm2 *)ctx->current;
+ ret = acpi_create_tpm2(tpm2);
+ if (!ret) {
+ acpi_inc_align(ctx, tpm2->header.length);
+ acpi_add_table(ctx, tpm2);
+ } else {
+ log_warning("TPM2 table creation failed\n");
+ }
+ }
+
debug("ACPI: * MADT\n");
madt = ctx->current;
acpi_create_madt(madt);
acpi_inc_align(ctx, madt->header.length);
acpi_add_table(ctx, madt);
+ debug("ACPI: * TCPA\n");
+ tcpa = (struct acpi_tcpa *)ctx->current;
+ ret = acpi_create_tcpa(tcpa);
+ if (ret) {
+ log_warning("Failed to create TCPA table (err=%d)\n", ret);
+ } else {
+ acpi_inc_align(ctx, tcpa->header.length);
+ acpi_add_table(ctx, tcpa);
+ }
+
debug("ACPI: * CSRT\n");
csrt = ctx->current;
if (!acpi_create_csrt(csrt)) {
@@ -518,3 +661,213 @@ ulong acpi_get_rsdp_addr(void)
{
return acpi_rsdp_addr;
}
+
+/**
+ * acpi_write_hpet() - Write out a HPET table
+ *
+ * Write out the table for High-Precision Event Timers
+ *
+ * @hpet: Place to put HPET table
+ */
+static int acpi_create_hpet(struct acpi_hpet *hpet)
+{
+ struct acpi_table_header *header = &hpet->header;
+ struct acpi_gen_regaddr *addr = &hpet->addr;
+
+ /*
+ * See IA-PC HPET (High Precision Event Timers) Specification v1.0a
+ * https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/software-developers-hpet-spec-1-0a.pdf
+ */
+ memset((void *)hpet, '\0', sizeof(struct acpi_hpet));
+
+ /* Fill out header fields. */
+ acpi_fill_header(header, "HPET");
+
+ header->aslc_revision = ASL_REVISION;
+ header->length = sizeof(struct acpi_hpet);
+ header->revision = acpi_get_table_revision(ACPITAB_HPET);
+
+ /* Fill out HPET address */
+ addr->space_id = 0; /* Memory */
+ addr->bit_width = 64;
+ addr->bit_offset = 0;
+ addr->addrl = CONFIG_HPET_ADDRESS & 0xffffffff;
+ addr->addrh = ((unsigned long long)CONFIG_HPET_ADDRESS) >> 32;
+
+ hpet->id = *(u32 *)CONFIG_HPET_ADDRESS;
+ hpet->number = 0;
+ hpet->min_tick = 0; /* HPET_MIN_TICKS */
+
+ header->checksum = table_compute_checksum(hpet,
+ sizeof(struct acpi_hpet));
+
+ return 0;
+}
+
+int acpi_write_hpet(struct acpi_ctx *ctx)
+{
+ struct acpi_hpet *hpet;
+ int ret;
+
+ log_debug("ACPI: * HPET\n");
+
+ hpet = ctx->current;
+ acpi_inc_align(ctx, sizeof(struct acpi_hpet));
+ acpi_create_hpet(hpet);
+ ret = acpi_add_table(ctx, hpet);
+ if (ret)
+ return log_msg_ret("add", ret);
+
+ return 0;
+}
+
+int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
+ uint access_size)
+{
+ struct acpi_dbg2_header *dbg2 = ctx->current;
+ char path[ACPI_PATH_MAX];
+ struct acpi_gen_regaddr address;
+ phys_addr_t addr;
+ int ret;
+
+ if (!device_active(dev)) {
+ log_info("Device not enabled\n");
+ return -EACCES;
+ }
+ /*
+ * PCI devices don't remember their resource allocation information in
+ * U-Boot at present. We assume that MMIO is used for the UART and that
+ * the address space is 32 bytes: ns16550 uses 8 registers of up to
+ * 32-bits each. This is only for debugging so it is not a big deal.
+ */
+ addr = dm_pci_read_bar32(dev, 0);
+ printf("UART addr %lx\n", (ulong)addr);
+
+ memset(&address, '\0', sizeof(address));
+ address.space_id = ACPI_ADDRESS_SPACE_MEMORY;
+ address.addrl = (uint32_t)addr;
+ address.addrh = (uint32_t)((addr >> 32) & 0xffffffff);
+ address.access_size = access_size;
+
+ ret = acpi_device_path(dev, path, sizeof(path));
+ if (ret)
+ return log_msg_ret("path", ret);
+ acpi_create_dbg2(dbg2, ACPI_DBG2_SERIAL_PORT,
+ ACPI_DBG2_16550_COMPATIBLE, &address, 0x1000, path);
+
+ acpi_inc_align(ctx, dbg2->header.length);
+ acpi_add_table(ctx, dbg2);
+
+ return 0;
+}
+
+void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
+ void *dsdt)
+{
+ struct acpi_table_header *header = &fadt->header;
+
+ memset((void *)fadt, '\0', sizeof(struct acpi_fadt));
+
+ acpi_fill_header(header, "FACP");
+ header->length = sizeof(struct acpi_fadt);
+ header->revision = 4;
+ memcpy(header->oem_id, OEM_ID, 6);
+ memcpy(header->oem_table_id, OEM_TABLE_ID, 8);
+ memcpy(header->aslc_id, ASLC_ID, 4);
+ header->aslc_revision = 1;
+
+ fadt->firmware_ctrl = (unsigned long)facs;
+ fadt->dsdt = (unsigned long)dsdt;
+
+ fadt->x_firmware_ctl_l = (unsigned long)facs;
+ fadt->x_firmware_ctl_h = 0;
+ fadt->x_dsdt_l = (unsigned long)dsdt;
+ fadt->x_dsdt_h = 0;
+
+ fadt->preferred_pm_profile = ACPI_PM_MOBILE;
+
+ /* Use ACPI 3.0 revision */
+ fadt->header.revision = 4;
+}
+
+void acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment,
+ u64 bar)
+{
+ struct dmar_entry *drhd = ctx->current;
+
+ memset(drhd, '\0', sizeof(*drhd));
+ drhd->type = DMAR_DRHD;
+ drhd->length = sizeof(*drhd); /* will be fixed up later */
+ drhd->flags = flags;
+ drhd->segment = segment;
+ drhd->bar = bar;
+ acpi_inc(ctx, drhd->length);
+}
+
+void acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar,
+ u64 limit)
+{
+ struct dmar_rmrr_entry *rmrr = ctx->current;
+
+ memset(rmrr, '\0', sizeof(*rmrr));
+ rmrr->type = DMAR_RMRR;
+ rmrr->length = sizeof(*rmrr); /* will be fixed up later */
+ rmrr->segment = segment;
+ rmrr->bar = bar;
+ rmrr->limit = limit;
+ acpi_inc(ctx, rmrr->length);
+}
+
+void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base)
+{
+ struct dmar_entry *drhd = base;
+
+ drhd->length = ctx->current - base;
+}
+
+void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base)
+{
+ struct dmar_rmrr_entry *rmrr = base;
+
+ rmrr->length = ctx->current - base;
+}
+
+static int acpi_create_dmar_ds(struct acpi_ctx *ctx, enum dev_scope_type type,
+ uint enumeration_id, pci_dev_t bdf)
+{
+ /* we don't support longer paths yet */
+ const size_t dev_scope_length = sizeof(struct dev_scope) + 2;
+ struct dev_scope *ds = ctx->current;
+
+ memset(ds, '\0', dev_scope_length);
+ ds->type = type;
+ ds->length = dev_scope_length;
+ ds->enumeration = enumeration_id;
+ ds->start_bus = PCI_BUS(bdf);
+ ds->path[0].dev = PCI_DEV(bdf);
+ ds->path[0].fn = PCI_FUNC(bdf);
+
+ return ds->length;
+}
+
+int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf)
+{
+ return acpi_create_dmar_ds(ctx, SCOPE_PCI_SUB, 0, bdf);
+}
+
+int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf)
+{
+ return acpi_create_dmar_ds(ctx, SCOPE_PCI_ENDPOINT, 0, bdf);
+}
+
+int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id,
+ pci_dev_t bdf)
+{
+ return acpi_create_dmar_ds(ctx, SCOPE_IOAPIC, enumeration_id, bdf);
+}
+
+int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id,
+ pci_dev_t bdf)
+{
+ return acpi_create_dmar_ds(ctx, SCOPE_MSI_HPET, enumeration_id, bdf);
+}
diff --git a/arch/x86/lib/acpigen.c b/arch/x86/lib/acpigen.c
new file mode 100644
index 0000000000..ea2ec2a908
--- /dev/null
+++ b/arch/x86/lib/acpigen.c
@@ -0,0 +1,96 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Google LLC
+ */
+
+#include <common.h>
+#include <acpi/acpigen.h>
+#include <acpi/acpi_table.h>
+#include <asm/acpigen.h>
+
+void acpigen_write_empty_pct(struct acpi_ctx *ctx)
+{
+ /*
+ * Name (_PCT, Package (0x02)
+ * {
+ * ResourceTemplate ()
+ * {
+ * Register (FFixedHW,
+ * 0x00, // Bit Width
+ * 0x00, // Bit Offset
+ * 0x0000000000000000, // Address
+ * ,)
+ * },
+ *
+ * ResourceTemplate ()
+ * {
+ * Register (FFixedHW,
+ * 0x00, // Bit Width
+ * 0x00, // Bit Offset
+ * 0x0000000000000000, // Address
+ * ,)
+ * }
+ * })
+ */
+ static char stream[] = {
+ /* 00000030 "0._PCT.," */
+ 0x08, 0x5f, 0x50, 0x43, 0x54, 0x12, 0x2c,
+ /* 00000038 "........" */
+ 0x02, 0x11, 0x14, 0x0a, 0x11, 0x82, 0x0c, 0x00,
+ /* 00000040 "........" */
+ 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* 00000048 "....y..." */
+ 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x11, 0x14,
+ /* 00000050 "........" */
+ 0x0a, 0x11, 0x82, 0x0c, 0x00, 0x7f, 0x00, 0x00,
+ /* 00000058 "........" */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x79, 0x00
+ };
+ acpigen_emit_stream(ctx, stream, ARRAY_SIZE(stream));
+}
+
+void acpigen_write_empty_ptc(struct acpi_ctx *ctx)
+{
+ /*
+ * Name (_PTC, Package (0x02)
+ * {
+ * ResourceTemplate ()
+ * {
+ * Register (FFixedHW,
+ * 0x00, // Bit Width
+ * 0x00, // Bit Offset
+ * 0x0000000000000000, // Address
+ * ,)
+ * },
+ *
+ * ResourceTemplate ()
+ * {
+ * Register (FFixedHW,
+ * 0x00, // Bit Width
+ * 0x00, // Bit Offset
+ * 0x0000000000000000, // Address
+ * ,)
+ * }
+ * })
+ */
+ struct acpi_gen_regaddr addr = {
+ .space_id = ACPI_ADDRESS_SPACE_FIXED,
+ .bit_width = 0,
+ .bit_offset = 0,
+ .access_size = 0,
+ .addrl = 0,
+ .addrh = 0,
+ };
+
+ acpigen_write_name(ctx, "_PTC");
+ acpigen_write_package(ctx, 2);
+
+ /* ControlRegister */
+ acpigen_write_register_resource(ctx, &addr);
+
+ /* StatusRegister */
+ acpigen_write_register_resource(ctx, &addr);
+
+ acpigen_pop_len(ctx);
+}
diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 1198a52eca..da6b8ce1ec 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -136,7 +136,7 @@ static int boot_prep_linux(bootm_headers_t *images)
printf("Setup at %#08lx\n", images->ep);
ret = setup_zimage((void *)images->ep, cmd_line_dest,
0, images->rd_start,
- images->rd_end - images->rd_start);
+ images->rd_end - images->rd_start, 0);
if (ret) {
printf("## Setting up boot parameters failed ...\n");
diff --git a/arch/x86/lib/fsp/fsp_common.c b/arch/x86/lib/fsp/fsp_common.c
index ea52954725..4061fa244c 100644
--- a/arch/x86/lib/fsp/fsp_common.c
+++ b/arch/x86/lib/fsp/fsp_common.c
@@ -60,6 +60,22 @@ void board_final_init(void)
debug("OK\n");
}
+void board_final_cleanup(void)
+{
+ u32 status;
+
+ /* TODO(sjg@chromium.org): This causes Linux to crash */
+ return;
+
+ /* call into FspNotify */
+ debug("Calling into FSP (notify phase INIT_PHASE_END_FIRMWARE): ");
+ status = fsp_notify(NULL, INIT_PHASE_END_FIRMWARE);
+ if (status)
+ debug("fail, error code %x\n", status);
+ else
+ debug("OK\n");
+}
+
int fsp_save_s3_stack(void)
{
struct udevice *dev;
diff --git a/arch/x86/lib/fsp/fsp_dram.c b/arch/x86/lib/fsp/fsp_dram.c
index faa819fab4..a76497d4e0 100644
--- a/arch/x86/lib/fsp/fsp_dram.c
+++ b/arch/x86/lib/fsp/fsp_dram.c
@@ -12,6 +12,7 @@
#include <asm/mrccache.h>
#include <asm/mtrr.h>
#include <asm/post.h>
+#include <dm/ofnode.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -92,6 +93,8 @@ unsigned int install_e820_map(unsigned int max_entries,
unsigned int num_entries = 0;
const struct hob_header *hdr;
struct hob_res_desc *res_desc;
+ const fdt64_t *prop;
+ int size;
hdr = gd->arch.hob_list;
@@ -133,6 +136,20 @@ unsigned int install_e820_map(unsigned int max_entries,
num_entries++;
}
+ prop = ofnode_read_chosen_prop("e820-entries", &size);
+ if (prop) {
+ int count = size / (sizeof(u64) * 3);
+ int i;
+
+ if (num_entries + count >= max_entries)
+ return -ENOSPC;
+ for (i = 0; i < count; i++, num_entries++, prop += 3) {
+ entries[num_entries].addr = fdt64_to_cpu(prop[0]);
+ entries[num_entries].size = fdt64_to_cpu(prop[1]);
+ entries[num_entries].type = fdt64_to_cpu(prop[2]);
+ }
+ }
+
return num_entries;
}
diff --git a/arch/x86/lib/fsp/fsp_graphics.c b/arch/x86/lib/fsp/fsp_graphics.c
index e8c1e07af1..858d7942fe 100644
--- a/arch/x86/lib/fsp/fsp_graphics.c
+++ b/arch/x86/lib/fsp/fsp_graphics.c
@@ -3,14 +3,19 @@
* Copyright (C) 2017, Bin Meng <bmeng.cn@gmail.com>
*/
+#define LOG_CATEGORY UCLASS_VIDEO
+
#include <common.h>
#include <dm.h>
#include <init.h>
#include <log.h>
#include <vbe.h>
#include <video.h>
+#include <acpi/acpi_table.h>
#include <asm/fsp/fsp_support.h>
+#include <asm/intel_opregion.h>
#include <asm/mtrr.h>
+#include <dm/acpi.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -127,6 +132,32 @@ static int fsp_video_bind(struct udevice *dev)
return 0;
}
+#ifdef CONFIG_INTEL_GMA_ACPI
+static int fsp_video_acpi_write_tables(const struct udevice *dev,
+ struct acpi_ctx *ctx)
+{
+ struct igd_opregion *opregion;
+ int ret;
+
+ printf("ACPI: * IGD OpRegion\n");
+ opregion = (struct igd_opregion *)ctx->current;
+
+ ret = intel_gma_init_igd_opregion((struct udevice *)dev, opregion);
+ if (ret)
+ return ret;
+
+ acpi_inc_align(ctx, sizeof(struct igd_opregion));
+
+ return 0;
+}
+#endif
+
+struct acpi_ops fsp_video_acpi_ops = {
+#ifdef CONFIG_INTEL_GMA_ACPI
+ .write_tables = fsp_video_acpi_write_tables,
+#endif
+};
+
static const struct udevice_id fsp_video_ids[] = {
{ .compatible = "fsp-fb" },
{ }
@@ -139,6 +170,7 @@ U_BOOT_DRIVER(fsp_video) = {
.bind = fsp_video_bind,
.probe = fsp_video_probe,
.flags = DM_FLAG_PRE_RELOC,
+ ACPI_OPS_PTR(&fsp_video_acpi_ops)
};
static struct pci_device_id fsp_video_supported[] = {
diff --git a/arch/x86/lib/fsp2/fsp_silicon_init.c b/arch/x86/lib/fsp2/fsp_silicon_init.c
index 0f221a864f..ead3493de8 100644
--- a/arch/x86/lib/fsp2/fsp_silicon_init.c
+++ b/arch/x86/lib/fsp2/fsp_silicon_init.c
@@ -26,8 +26,10 @@ int fsp_silicon_init(bool s3wake, bool use_spi_flash)
struct binman_entry entry;
struct udevice *dev;
ulong rom_offset = 0;
+ u32 init_addr;
int ret;
+ log_debug("Locating FSP\n");
ret = fsp_locate_fsp(FSP_S, &entry, use_spi_flash, &dev, &hdr,
&rom_offset);
if (ret)
@@ -44,7 +46,7 @@ int fsp_silicon_init(bool s3wake, bool use_spi_flash)
ret = fsps_update_config(dev, rom_offset, &upd);
if (ret)
return log_msg_ret("Could not setup config", ret);
- log_debug("Silicon init...");
+ log_debug("Silicon init @ %x...", init_addr);
bootstage_start(BOOTSTAGE_ID_ACCUM_FSP_S, "fsp-s");
func = (fsp_silicon_init_func)(hdr->img_base + hdr->fsp_silicon_init);
ret = func(&upd);
diff --git a/arch/x86/lib/fsp2/fsp_support.c b/arch/x86/lib/fsp2/fsp_support.c
index 3f2ca840dc..f220ef498b 100644
--- a/arch/x86/lib/fsp2/fsp_support.c
+++ b/arch/x86/lib/fsp2/fsp_support.c
@@ -35,7 +35,8 @@ int fsp_get_header(ulong offset, ulong size, bool use_spi_flash,
*
* You are in a maze of twisty little headers all alike.
*/
- debug("offset=%x buf=%x\n", (uint)offset, (uint)buf);
+ log_debug("offset=%x buf=%x, use_spi_flash=%d\n", (uint)offset,
+ (uint)buf, use_spi_flash);
if (use_spi_flash) {
ret = uclass_first_device_err(UCLASS_SPI_FLASH, &dev);
if (ret)
@@ -52,16 +53,16 @@ int fsp_get_header(ulong offset, ulong size, bool use_spi_flash,
fv = ptr;
/* Check the FV signature, _FVH */
- debug("offset=%x sign=%x\n", (uint)offset, (uint)fv->sign);
+ log_debug("offset=%x sign=%x\n", (uint)offset, (uint)fv->sign);
if (fv->sign != EFI_FVH_SIGNATURE)
return log_msg_ret("Base FV signature", -EINVAL);
/* Go to the end of the FV header and align the address */
- debug("fv->ext_hdr_off = %x\n", fv->ext_hdr_off);
+ log_debug("fv->ext_hdr_off = %x\n", fv->ext_hdr_off);
ptr += fv->ext_hdr_off;
exhdr = ptr;
ptr += ALIGN(exhdr->ext_hdr_size, 8);
- debug("ptr=%x\n", ptr - (void *)buf);
+ log_debug("ptr=%x\n", ptr - (void *)buf);
/* Check the FFS GUID */
file_hdr = ptr;
@@ -71,7 +72,7 @@ int fsp_get_header(ulong offset, ulong size, bool use_spi_flash,
ptr = file_hdr + 1;
raw = ptr;
- debug("raw->type = %x\n", raw->type);
+ log_debug("raw->type = %x\n", raw->type);
if (raw->type != EFI_SECTION_RAW)
return log_msg_ret("Section type not RAW", -ENOEXEC);
@@ -80,13 +81,18 @@ int fsp_get_header(ulong offset, ulong size, bool use_spi_flash,
fsp = ptr;
/* Check the FSPH header */
- debug("fsp %x\n", (uint)fsp);
+ log_debug("fsp %x, fsp-buf=%x, si=%x\n", (uint)fsp, ptr - (void *)buf,
+ (void *)&fsp->fsp_silicon_init - (void *)buf);
if (fsp->sign != EFI_FSPH_SIGNATURE)
return log_msg_ret("Base FSPH signature", -EACCES);
base = (void *)fsp->img_base;
- debug("Image base %x\n", (uint)base);
- debug("Image addr %x\n", (uint)fsp->fsp_mem_init);
+ log_debug("image base %x\n", (uint)base);
+ if (fsp->fsp_mem_init)
+ log_debug("mem_init offset %x\n", (uint)fsp->fsp_mem_init);
+ else if (fsp->fsp_silicon_init)
+ log_debug("silicon_init offset %x\n",
+ (uint)fsp->fsp_silicon_init);
if (use_spi_flash) {
ret = spi_flash_read_dm(dev, offset, size, base);
if (ret)
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index d2b6002008..a00964cc8d 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -45,6 +45,42 @@
#define COMMAND_LINE_SIZE 2048
+/**
+ * struct zboot_state - Current state of the boot
+ *
+ * @bzimage_addr: Address of the bzImage to boot
+ * @bzimage_size: Size of the bzImage, or 0 to detect this
+ * @initrd_addr: Address of the initial ramdisk, or 0 if none
+ * @initrd_size: Size of the initial ramdisk, or 0 if none
+ * @load_address: Address where the bzImage is moved before booting, either
+ * BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR
+ * @base_ptr: Pointer to the boot parameters, typically at address
+ * DEFAULT_SETUP_BASE
+ * @cmdline: Address of 'override' command line, or 0 to use the one in the
+ * setup block
+ */
+struct zboot_state {
+ ulong bzimage_addr;
+ ulong bzimage_size;
+ ulong initrd_addr;
+ ulong initrd_size;
+ ulong load_address;
+ struct boot_params *base_ptr;
+ ulong cmdline;
+} state;
+
+enum {
+ ZBOOT_STATE_START = BIT(0),
+ ZBOOT_STATE_LOAD = BIT(1),
+ ZBOOT_STATE_SETUP = BIT(2),
+ ZBOOT_STATE_INFO = BIT(3),
+ ZBOOT_STATE_GO = BIT(4),
+
+ /* This one doesn't execute automatically, so stop the count before 5 */
+ ZBOOT_STATE_DUMP = BIT(5),
+ ZBOOT_STATE_COUNT = 5,
+};
+
static void build_command_line(char *command_line, int auto_boot)
{
char *env_command_line;
@@ -85,21 +121,23 @@ static int kernel_magic_ok(struct setup_header *hdr)
}
}
-static int get_boot_protocol(struct setup_header *hdr)
+static int get_boot_protocol(struct setup_header *hdr, bool verbose)
{
if (hdr->header == KERNEL_V2_MAGIC) {
- printf("Magic signature found\n");
+ if (verbose)
+ printf("Magic signature found\n");
return hdr->version;
} else {
/* Very old kernel */
- printf("Magic signature not found\n");
+ if (verbose)
+ printf("Magic signature not found\n");
return 0x0100;
}
}
static int setup_device_tree(struct setup_header *hdr, const void *fdt_blob)
{
- int bootproto = get_boot_protocol(hdr);
+ int bootproto = get_boot_protocol(hdr, false);
struct setup_data *sd;
int size;
@@ -129,10 +167,24 @@ static int setup_device_tree(struct setup_header *hdr, const void *fdt_blob)
return 0;
}
+static const char *get_kernel_version(struct boot_params *params,
+ void *kernel_base)
+{
+ struct setup_header *hdr = &params->hdr;
+ int bootproto;
+
+ bootproto = get_boot_protocol(hdr, false);
+ if (bootproto < 0x0200 || hdr->setup_sects < 15)
+ return NULL;
+
+ return kernel_base + hdr->kernel_version + 0x200;
+}
+
struct boot_params *load_zimage(char *image, unsigned long kernel_size,
ulong *load_addressp)
{
struct boot_params *setup_base;
+ const char *version;
int setup_size;
int bootproto;
int big_image;
@@ -160,21 +212,16 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
printf("Error: Setup is too large (%d bytes)\n", setup_size);
/* determine boot protocol version */
- bootproto = get_boot_protocol(hdr);
+ bootproto = get_boot_protocol(hdr, true);
printf("Using boot protocol version %x.%02x\n",
(bootproto & 0xff00) >> 8, bootproto & 0xff);
- if (bootproto >= 0x0200) {
- if (hdr->setup_sects >= 15) {
- printf("Linux kernel version %s\n",
- (char *)params +
- hdr->kernel_version + 0x200);
- } else {
- printf("Setup Sectors < 15 - "
- "Cannot print kernel version.\n");
- }
- }
+ version = get_kernel_version(params, image);
+ if (version)
+ printf("Linux kernel version %s\n", version);
+ else
+ printf("Setup Sectors < 15 - Cannot print kernel version\n");
/* Determine image type */
big_image = (bootproto >= 0x0200) &&
@@ -240,10 +287,10 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
}
int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
- unsigned long initrd_addr, unsigned long initrd_size)
+ ulong initrd_addr, ulong initrd_size, ulong cmdline_force)
{
struct setup_header *hdr = &setup_base->hdr;
- int bootproto = get_boot_protocol(hdr);
+ int bootproto = get_boot_protocol(hdr, false);
setup_base->e820_entries = install_e820_map(
ARRAY_SIZE(setup_base->e820_map), setup_base->e820_map);
@@ -253,8 +300,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
setup_base->screen_info.cl_offset = COMMAND_LINE_OFFSET;
}
if (bootproto >= 0x0200) {
- hdr->type_of_loader = 8;
-
+ hdr->type_of_loader = 0x80; /* U-Boot version 0 */
if (initrd_addr) {
printf("Initial RAM disk at linear address "
"0x%08lx, size %ld bytes\n",
@@ -282,40 +328,33 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
}
/* build command line at COMMAND_LINE_OFFSET */
- build_command_line(cmd_line, auto_boot);
+ if (cmdline_force)
+ strcpy(cmd_line, (char *)cmdline_force);
+ else
+ build_command_line(cmd_line, auto_boot);
}
-#ifdef CONFIG_INTEL_MID
- if (bootproto >= 0x0207)
+ if (IS_ENABLED(CONFIG_INTEL_MID) && bootproto >= 0x0207)
hdr->hardware_subarch = X86_SUBARCH_INTEL_MID;
-#endif
-#ifdef CONFIG_GENERATE_ACPI_TABLE
- setup_base->acpi_rsdp_addr = acpi_get_rsdp_addr();
-#endif
+ if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE))
+ setup_base->acpi_rsdp_addr = acpi_get_rsdp_addr();
setup_device_tree(hdr, (const void *)env_get_hex("fdtaddr", 0));
setup_video(&setup_base->screen_info);
-#ifdef CONFIG_EFI_STUB
- setup_efi_info(&setup_base->efi_info);
-#endif
+ if (IS_ENABLED(CONFIG_EFI_STUB))
+ setup_efi_info(&setup_base->efi_info);
return 0;
}
-int do_zboot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
{
- struct boot_params *base_ptr;
- void *bzImage_addr = NULL;
- ulong load_address;
- char *s;
- ulong bzImage_size = 0;
- ulong initrd_addr = 0;
- ulong initrd_size = 0;
-
- disable_interrupts();
+ const char *s;
+ memset(&state, '\0', sizeof(state));
if (argc >= 2) {
/* argv[1] holds the address of the bzImage */
s = argv[1];
@@ -324,39 +363,361 @@ int do_zboot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
if (s)
- bzImage_addr = (void *)simple_strtoul(s, NULL, 16);
+ state.bzimage_addr = simple_strtoul(s, NULL, 16);
if (argc >= 3) {
/* argv[2] holds the size of the bzImage */
- bzImage_size = simple_strtoul(argv[2], NULL, 16);
+ state.bzimage_size = simple_strtoul(argv[2], NULL, 16);
}
if (argc >= 4)
- initrd_addr = simple_strtoul(argv[3], NULL, 16);
+ state.initrd_addr = simple_strtoul(argv[3], NULL, 16);
if (argc >= 5)
- initrd_size = simple_strtoul(argv[4], NULL, 16);
+ state.initrd_size = simple_strtoul(argv[4], NULL, 16);
+ if (argc >= 6) {
+ /*
+ * When the base_ptr is passed in, we assume that the image is
+ * already loaded at the address given by argv[1] and therefore
+ * the original bzImage is somewhere else, or not accessible.
+ * In any case, we don't need access to the bzImage since all
+ * the processing is assumed to be done.
+ *
+ * So set the base_ptr to the given address, use this arg as the
+ * load address and set bzimage_addr to 0 so we know that it
+ * cannot be proceesed (or processed again).
+ */
+ state.base_ptr = (void *)simple_strtoul(argv[5], NULL, 16);
+ state.load_address = state.bzimage_addr;
+ state.bzimage_addr = 0;
+ }
+ if (argc >= 7)
+ state.cmdline = simple_strtoul(argv[6], NULL, 16);
+
+ return 0;
+}
+
+static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct boot_params *base_ptr;
+
+ if (state.base_ptr) {
+ struct boot_params *from = (struct boot_params *)state.base_ptr;
+
+ base_ptr = (struct boot_params *)DEFAULT_SETUP_BASE;
+ printf("Building boot_params at 0x%8.8lx\n", (ulong)base_ptr);
+ memset(base_ptr, '\0', sizeof(*base_ptr));
+ base_ptr->hdr = from->hdr;
+ } else {
+ base_ptr = load_zimage((void *)state.bzimage_addr, state.bzimage_size,
+ &state.load_address);
+ if (!base_ptr) {
+ puts("## Kernel loading failed ...\n");
+ return CMD_RET_FAILURE;
+ }
+ }
+ state.base_ptr = base_ptr;
+ if (env_set_hex("zbootbase", (ulong)base_ptr) ||
+ env_set_hex("zbootaddr", state.load_address))
+ return CMD_RET_FAILURE;
- /* Lets look for */
- base_ptr = load_zimage(bzImage_addr, bzImage_size, &load_address);
+ return 0;
+}
+
+static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct boot_params *base_ptr = state.base_ptr;
+ int ret;
if (!base_ptr) {
- puts("## Kernel loading failed ...\n");
- return -1;
+ printf("base is not set: use 'zboot load' first\n");
+ return CMD_RET_FAILURE;
}
- if (setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET,
- 0, initrd_addr, initrd_size)) {
+ ret = setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET,
+ 0, state.initrd_addr, state.initrd_size,
+ state.cmdline);
+ if (ret) {
puts("Setting up boot parameters failed ...\n");
- return -1;
+ return CMD_RET_FAILURE;
}
+ return 0;
+}
+
+static int do_zboot_info(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ printf("Kernel loaded at %08lx, setup_base=%p\n",
+ state.load_address, state.base_ptr);
+
+ return 0;
+}
+
+static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ int ret;
+
+ disable_interrupts();
+
/* we assume that the kernel is in place */
- return boot_linux_kernel((ulong)base_ptr, load_address, false);
+ ret = boot_linux_kernel((ulong)state.base_ptr, state.load_address,
+ false);
+ printf("Kernel returned! (err=%d)\n", ret);
+
+ return CMD_RET_FAILURE;
+}
+
+static void print_num(const char *name, ulong value)
+{
+ printf("%-20s: %lx\n", name, value);
+}
+
+static void print_num64(const char *name, u64 value)
+{
+ printf("%-20s: %llx\n", name, value);
+}
+
+static const char *const e820_type_name[E820_COUNT] = {
+ [E820_RAM] = "RAM",
+ [E820_RESERVED] = "Reserved",
+ [E820_ACPI] = "ACPI",
+ [E820_NVS] = "ACPI NVS",
+ [E820_UNUSABLE] = "Unusable",
+};
+
+static const char *const bootloader_id[] = {
+ "LILO",
+ "Loadlin",
+ "bootsect-loader",
+ "Syslinux",
+ "Etherboot/gPXE/iPXE",
+ "ELILO",
+ "undefined",
+ "GRUB",
+ "U-Boot",
+ "Xen",
+ "Gujin",
+ "Qemu",
+ "Arcturus Networks uCbootloader",
+ "kexec-tools",
+ "Extended",
+ "Special",
+ "Reserved",
+ "Minimal Linux Bootloader",
+ "OVMF UEFI virtualization stack",
+};
+
+struct flag_info {
+ uint bit;
+ const char *name;
+};
+
+static struct flag_info load_flags[] = {
+ { LOADED_HIGH, "loaded-high" },
+ { QUIET_FLAG, "quiet" },
+ { KEEP_SEGMENTS, "keep-segments" },
+ { CAN_USE_HEAP, "can-use-heap" },
+};
+
+static struct flag_info xload_flags[] = {
+ { XLF_KERNEL_64, "64-bit-entry" },
+ { XLF_CAN_BE_LOADED_ABOVE_4G, "can-load-above-4gb" },
+ { XLF_EFI_HANDOVER_32, "32-efi-handoff" },
+ { XLF_EFI_HANDOVER_64, "64-efi-handoff" },
+ { XLF_EFI_KEXEC, "kexec-efi-runtime" },
+};
+
+static void print_flags(struct flag_info *flags, int count, uint value)
+{
+ int i;
+
+ printf("%-20s:", "");
+ for (i = 0; i < count; i++) {
+ uint mask = flags[i].bit;
+
+ if (value & mask)
+ printf(" %s", flags[i].name);
+ }
+ printf("\n");
+}
+
+static void show_loader(struct setup_header *hdr)
+{
+ bool version_valid = false;
+ int type, version;
+ const char *name;
+
+ type = hdr->type_of_loader >> 4;
+ version = hdr->type_of_loader & 0xf;
+ if (type == 0xe)
+ type = 0x10 + hdr->ext_loader_type;
+ version |= hdr->ext_loader_ver << 4;
+ if (!hdr->type_of_loader) {
+ name = "pre-2.00 bootloader";
+ } else if (hdr->type_of_loader == 0xff) {
+ name = "unknown";
+ } else if (type < ARRAY_SIZE(bootloader_id)) {
+ name = bootloader_id[type];
+ version_valid = true;
+ } else {
+ name = "undefined";
+ }
+ printf("%20s %s", "", name);
+ if (version_valid)
+ printf(", version %x", version);
+ printf("\n");
+}
+
+int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ struct boot_params *base_ptr = state.base_ptr;
+ struct setup_header *hdr;
+ const char *version;
+ int i;
+
+ if (argc > 1)
+ base_ptr = (void *)simple_strtoul(argv[1], NULL, 16);
+ if (!base_ptr) {
+ printf("No zboot setup_base\n");
+ return CMD_RET_FAILURE;
+ }
+ printf("Setup located at %p:\n\n", base_ptr);
+ print_num64("ACPI RSDP addr", base_ptr->acpi_rsdp_addr);
+
+ printf("E820: %d entries\n", base_ptr->e820_entries);
+ if (base_ptr->e820_entries) {
+ printf("%18s %16s %s\n", "Addr", "Size", "Type");
+ for (i = 0; i < base_ptr->e820_entries; i++) {
+ struct e820_entry *entry = &base_ptr->e820_map[i];
+
+ printf("%12llx %10llx %s\n", entry->addr, entry->size,
+ entry->type < E820_COUNT ?
+ e820_type_name[entry->type] :
+ simple_itoa(entry->type));
+ }
+ }
+
+ hdr = &base_ptr->hdr;
+ print_num("Setup sectors", hdr->setup_sects);
+ print_num("Root flags", hdr->root_flags);
+ print_num("Sys size", hdr->syssize);
+ print_num("RAM size", hdr->ram_size);
+ print_num("Video mode", hdr->vid_mode);
+ print_num("Root dev", hdr->root_dev);
+ print_num("Boot flag", hdr->boot_flag);
+ print_num("Jump", hdr->jump);
+ print_num("Header", hdr->header);
+ if (hdr->header == KERNEL_V2_MAGIC)
+ printf("%-20s %s\n", "", "Kernel V2");
+ else
+ printf("%-20s %s\n", "", "Ancient kernel, using version 100");
+ print_num("Version", hdr->version);
+ print_num("Real mode switch", hdr->realmode_swtch);
+ print_num("Start sys", hdr->start_sys);
+ print_num("Kernel version", hdr->kernel_version);
+ version = get_kernel_version(base_ptr, (void *)state.bzimage_addr);
+ if (version)
+ printf(" @%p: %s\n", version, version);
+ print_num("Type of loader", hdr->type_of_loader);
+ show_loader(hdr);
+ print_num("Load flags", hdr->loadflags);
+ print_flags(load_flags, ARRAY_SIZE(load_flags), hdr->loadflags);
+ print_num("Setup move size", hdr->setup_move_size);
+ print_num("Code32 start", hdr->code32_start);
+ print_num("Ramdisk image", hdr->ramdisk_image);
+ print_num("Ramdisk size", hdr->ramdisk_size);
+ print_num("Bootsect kludge", hdr->bootsect_kludge);
+ print_num("Heap end ptr", hdr->heap_end_ptr);
+ print_num("Ext loader ver", hdr->ext_loader_ver);
+ print_num("Ext loader type", hdr->ext_loader_type);
+ print_num("Command line ptr", hdr->cmd_line_ptr);
+ if (hdr->cmd_line_ptr) {
+ printf(" ");
+ /* Use puts() to avoid limits from CONFIG_SYS_PBSIZE */
+ puts((char *)(ulong)hdr->cmd_line_ptr);
+ printf("\n");
+ }
+ print_num("Initrd addr max", hdr->initrd_addr_max);
+ print_num("Kernel alignment", hdr->kernel_alignment);
+ print_num("Relocatable kernel", hdr->relocatable_kernel);
+ print_num("Min alignment", hdr->min_alignment);
+ if (hdr->min_alignment)
+ printf("%-20s: %x\n", "", 1 << hdr->min_alignment);
+ print_num("Xload flags", hdr->xloadflags);
+ print_flags(xload_flags, ARRAY_SIZE(xload_flags), hdr->xloadflags);
+ print_num("Cmdline size", hdr->cmdline_size);
+ print_num("Hardware subarch", hdr->hardware_subarch);
+ print_num64("HW subarch data", hdr->hardware_subarch_data);
+ print_num("Payload offset", hdr->payload_offset);
+ print_num("Payload length", hdr->payload_length);
+ print_num64("Setup data", hdr->setup_data);
+ print_num64("Pref address", hdr->pref_address);
+ print_num("Init size", hdr->init_size);
+ print_num("Handover offset", hdr->handover_offset);
+ if (get_boot_protocol(hdr, false) >= 0x215)
+ print_num("Kernel info offset", hdr->kernel_info_offset);
+
+ return 0;
+}
+
+/* Note: This defines the complete_zboot() function */
+U_BOOT_SUBCMDS(zboot,
+ U_BOOT_CMD_MKENT(start, 8, 1, do_zboot_start, "", ""),
+ U_BOOT_CMD_MKENT(load, 1, 1, do_zboot_load, "", ""),
+ U_BOOT_CMD_MKENT(setup, 1, 1, do_zboot_setup, "", ""),
+ U_BOOT_CMD_MKENT(info, 1, 1, do_zboot_info, "", ""),
+ U_BOOT_CMD_MKENT(go, 1, 1, do_zboot_go, "", ""),
+ U_BOOT_CMD_MKENT(dump, 2, 1, do_zboot_dump, "", ""),
+)
+
+int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[], int state_mask)
+{
+ int i;
+
+ for (i = 0; i < ZBOOT_STATE_COUNT; i++) {
+ struct cmd_tbl *cmd = &zboot_subcmds[i];
+ int mask = 1 << i;
+ int ret;
+
+ if (mask & state_mask) {
+ ret = cmd->cmd(cmd, flag, argc, argv);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+int do_zboot_parent(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[], int *repeatable)
+{
+ /* determine if we have a sub command */
+ if (argc > 1) {
+ char *endp;
+
+ simple_strtoul(argv[1], &endp, 16);
+ /*
+ * endp pointing to nul means that argv[1] was just a valid
+ * number, so pass it along to the normal processing
+ */
+ if (*endp)
+ return do_zboot(cmdtp, flag, argc, argv, repeatable);
+ }
+
+ do_zboot_states(cmdtp, flag, argc, argv, ZBOOT_STATE_START |
+ ZBOOT_STATE_LOAD | ZBOOT_STATE_SETUP |
+ ZBOOT_STATE_INFO | ZBOOT_STATE_GO);
+
+ return CMD_RET_FAILURE;
}
-U_BOOT_CMD(
- zboot, 5, 0, do_zboot,
- "Boot bzImage",
- "[addr] [size] [initrd addr] [initrd size]\n"
+U_BOOT_CMDREP_COMPLETE(
+ zboot, 8, do_zboot_parent, "Boot bzImage",
+ "[addr] [size] [initrd addr] [initrd size] [setup] [cmdline]\n"
" addr - The optional starting address of the bzimage.\n"
" If not set it defaults to the environment\n"
" variable \"fileaddr\".\n"
@@ -364,4 +725,17 @@ U_BOOT_CMD(
" zero.\n"
" initrd addr - The address of the initrd image to use, if any.\n"
" initrd size - The size of the initrd image to use, if any.\n"
+ " setup - The address of the kernel setup region, if this\n"
+ " is not at addr\n"
+ " cmdline - The address of the kernel command line, to\n"
+ " override U-Boot's normal cmdline generation\n"
+ "\n"
+ "Sub-commands to do part of the zboot sequence:\n"
+ "\tstart [addr [arg ...]] - specify arguments\n"
+ "\tload - load OS image\n"
+ "\tsetup - set up table\n"
+ "\tinfo - show summary info\n"
+ "\tgo - start OS\n"
+ "\tdump [addr] - dump info (optional address of boot params)",
+ complete_zboot
);