summaryrefslogtreecommitdiff
path: root/arch/x86/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/cpu')
-rw-r--r--arch/x86/cpu/Makefile2
-rw-r--r--arch/x86/cpu/baytrail/Kconfig6
-rw-r--r--arch/x86/cpu/baytrail/valleyview.c3
-rw-r--r--arch/x86/cpu/cpu.c2
-rw-r--r--arch/x86/cpu/efi/Kconfig11
-rw-r--r--arch/x86/cpu/efi/Makefile9
-rw-r--r--arch/x86/cpu/efi/app.c (renamed from arch/x86/cpu/efi/efi.c)2
-rw-r--r--arch/x86/cpu/efi/car.S9
-rw-r--r--arch/x86/cpu/efi/payload.c170
-rw-r--r--arch/x86/cpu/intel_common/Makefile2
-rw-r--r--arch/x86/cpu/qemu/Makefile5
-rw-r--r--arch/x86/cpu/qemu/qemu.c4
-rw-r--r--arch/x86/cpu/x86_64/setjmp.S49
-rw-r--r--arch/x86/cpu/x86_64/setjmp.c19
14 files changed, 257 insertions, 36 deletions
diff --git a/arch/x86/cpu/Makefile b/arch/x86/cpu/Makefile
index af9e26caab..f862d8c071 100644
--- a/arch/x86/cpu/Makefile
+++ b/arch/x86/cpu/Makefile
@@ -29,7 +29,7 @@ obj-$(CONFIG_INTEL_BAYTRAIL) += baytrail/
obj-$(CONFIG_INTEL_BRASWELL) += braswell/
obj-$(CONFIG_INTEL_BROADWELL) += broadwell/
obj-$(CONFIG_SYS_COREBOOT) += coreboot/
-obj-$(CONFIG_EFI_APP) += efi/
+obj-$(CONFIG_EFI) += efi/
obj-$(CONFIG_QEMU) += qemu/
obj-$(CONFIG_NORTHBRIDGE_INTEL_IVYBRIDGE) += ivybridge/
obj-$(CONFIG_INTEL_QUARK) += quark/
diff --git a/arch/x86/cpu/baytrail/Kconfig b/arch/x86/cpu/baytrail/Kconfig
index 022a9f2e51..d2c3473d6a 100644
--- a/arch/x86/cpu/baytrail/Kconfig
+++ b/arch/x86/cpu/baytrail/Kconfig
@@ -4,10 +4,10 @@
config INTEL_BAYTRAIL
bool
- select HAVE_FSP if !EFI
- select ARCH_MISC_INIT if !EFI
+ select HAVE_FSP
+ select ARCH_MISC_INIT
select CPU_INTEL_TURBO_NOT_PACKAGE_SCOPED
- imply HAVE_INTEL_ME if !EFI
+ imply HAVE_INTEL_ME
imply ENABLE_MRC_CACHE
imply AHCI_PCI
imply ICH_SPI
diff --git a/arch/x86/cpu/baytrail/valleyview.c b/arch/x86/cpu/baytrail/valleyview.c
index 3194f8c653..b7d481ac56 100644
--- a/arch/x86/cpu/baytrail/valleyview.c
+++ b/arch/x86/cpu/baytrail/valleyview.c
@@ -17,7 +17,6 @@
#define BYT_TRIG_LVL BIT(24)
#define BYT_TRIG_POS BIT(25)
-#ifndef CONFIG_EFI_APP
int arch_cpu_init(void)
{
post_code(POST_CPU_INIT);
@@ -57,8 +56,6 @@ int arch_misc_init(void)
return 0;
}
-#endif
-
void reset_cpu(ulong addr)
{
/* cold reset */
diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index db36553d05..6aefa12a7c 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -193,7 +193,7 @@ void show_boot_progress(int val)
outb(val, POST_PORT);
}
-#ifndef CONFIG_SYS_COREBOOT
+#if !defined(CONFIG_SYS_COREBOOT) && !defined(CONFIG_EFI_STUB)
/*
* Implement a weak default function for boards that optionally
* need to clean up the system before jumping to the kernel.
diff --git a/arch/x86/cpu/efi/Kconfig b/arch/x86/cpu/efi/Kconfig
new file mode 100644
index 0000000000..e0975d34d3
--- /dev/null
+++ b/arch/x86/cpu/efi/Kconfig
@@ -0,0 +1,11 @@
+if EFI
+
+config SYS_CAR_ADDR
+ hex
+ default 0x100000
+
+config SYS_CAR_SIZE
+ hex
+ default 0x20000
+
+endif
diff --git a/arch/x86/cpu/efi/Makefile b/arch/x86/cpu/efi/Makefile
index 06d0480440..9716a4ebe0 100644
--- a/arch/x86/cpu/efi/Makefile
+++ b/arch/x86/cpu/efi/Makefile
@@ -2,5 +2,12 @@
#
# Copyright (c) 2015 Google, Inc
-obj-y += efi.o
+ifdef CONFIG_EFI_APP
+obj-y += app.o
obj-y += sdram.o
+endif
+
+ifdef CONFIG_EFI_STUB
+obj-y += car.o
+obj-y += payload.o
+endif
diff --git a/arch/x86/cpu/efi/efi.c b/arch/x86/cpu/efi/app.c
index cda4fabe15..ba7c02bd7e 100644
--- a/arch/x86/cpu/efi/efi.c
+++ b/arch/x86/cpu/efi/app.c
@@ -9,7 +9,7 @@
int arch_cpu_init(void)
{
- return 0;
+ return x86_cpu_init_f();
}
int checkcpu(void)
diff --git a/arch/x86/cpu/efi/car.S b/arch/x86/cpu/efi/car.S
new file mode 100644
index 0000000000..488dcde66c
--- /dev/null
+++ b/arch/x86/cpu/efi/car.S
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+.globl car_init
+car_init:
+ jmp car_init_ret
diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c
new file mode 100644
index 0000000000..4649bfe86e
--- /dev/null
+++ b/arch/x86/cpu/efi/payload.c
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <efi.h>
+#include <errno.h>
+#include <usb.h>
+#include <asm/post.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * This function looks for the highest region of memory lower than 4GB which
+ * has enough space for U-Boot where U-Boot is aligned on a page boundary.
+ * It overrides the default implementation found elsewhere which simply
+ * picks the end of ram, wherever that may be. The location of the stack,
+ * the relocation address, and how far U-Boot is moved by relocation are
+ * set in the global data structure.
+ */
+ulong board_get_usable_ram_top(ulong total_size)
+{
+ struct efi_mem_desc *desc, *end;
+ struct efi_entry_memmap *map;
+ int ret, size;
+ uintptr_t dest_addr = 0;
+ struct efi_mem_desc *largest = NULL;
+
+ /*
+ * Find largest area of memory below 4GB. We could
+ * call efi_build_mem_table() for a more accurate picture since it
+ * merges areas together where possible. But that function uses more
+ * pre-relocation memory, and it's not critical that we find the
+ * absolute largest region.
+ */
+ ret = efi_info_get(EFIET_MEMORY_MAP, (void **)&map, &size);
+ if (ret) {
+ /* We should have stopped in dram_init(), something is wrong */
+ debug("%s: Missing memory map\n", __func__);
+ goto err;
+ }
+
+ end = (struct efi_mem_desc *)((ulong)map + size);
+ desc = map->desc;
+ for (; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
+ if (desc->type != EFI_CONVENTIONAL_MEMORY ||
+ desc->physical_start >= 1ULL << 32)
+ continue;
+ if (!largest || desc->num_pages > largest->num_pages)
+ largest = desc;
+ }
+
+ /* If no suitable area was found, return an error. */
+ assert(largest);
+ if (!largest || (largest->num_pages << EFI_PAGE_SHIFT) < (2 << 20))
+ goto err;
+
+ dest_addr = largest->physical_start + (largest->num_pages <<
+ EFI_PAGE_SHIFT);
+
+ return (ulong)dest_addr;
+err:
+ panic("No available memory found for relocation");
+ return 0;
+}
+
+int dram_init(void)
+{
+ struct efi_mem_desc *desc, *end;
+ struct efi_entry_memmap *map;
+ int size, ret;
+
+ ret = efi_info_get(EFIET_MEMORY_MAP, (void **)&map, &size);
+ if (ret) {
+ printf("Cannot find EFI memory map tables, ret=%d\n", ret);
+
+ return -ENODEV;
+ }
+
+ end = (struct efi_mem_desc *)((ulong)map + size);
+ gd->ram_size = 0;
+ desc = map->desc;
+ for (; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
+ if (desc->type < EFI_MMAP_IO)
+ gd->ram_size += desc->num_pages << EFI_PAGE_SHIFT;
+ }
+
+ return 0;
+}
+
+int dram_init_banksize(void)
+{
+ struct efi_mem_desc *desc, *end;
+ struct efi_entry_memmap *map;
+ int ret, size;
+ int num_banks;
+
+ ret = efi_info_get(EFIET_MEMORY_MAP, (void **)&map, &size);
+ if (ret) {
+ /* We should have stopped in dram_init(), something is wrong */
+ debug("%s: Missing memory map\n", __func__);
+ return -ENXIO;
+ }
+ end = (struct efi_mem_desc *)((ulong)map + size);
+ desc = map->desc;
+ for (num_banks = 0;
+ desc < end && num_banks < CONFIG_NR_DRAM_BANKS;
+ desc = efi_get_next_mem_desc(map, desc)) {
+ /*
+ * We only use conventional memory and ignore
+ * anything less than 1MB.
+ */
+ if (desc->type != EFI_CONVENTIONAL_MEMORY ||
+ (desc->num_pages << EFI_PAGE_SHIFT) < 1 << 20)
+ continue;
+ gd->bd->bi_dram[num_banks].start = desc->physical_start;
+ gd->bd->bi_dram[num_banks].size = desc->num_pages <<
+ EFI_PAGE_SHIFT;
+ num_banks++;
+ }
+
+ return 0;
+}
+
+int arch_cpu_init(void)
+{
+ post_code(POST_CPU_INIT);
+
+ return x86_cpu_init_f();
+}
+
+int checkcpu(void)
+{
+ return 0;
+}
+
+int print_cpuinfo(void)
+{
+ return default_print_cpuinfo();
+}
+
+/* Find any available tables and copy them to a safe place */
+int reserve_arch(void)
+{
+ struct efi_info_hdr *hdr;
+
+ debug("table=%lx\n", gd->arch.table);
+ if (!gd->arch.table)
+ return 0;
+
+ hdr = (struct efi_info_hdr *)gd->arch.table;
+
+ gd->start_addr_sp -= hdr->total_size;
+ memcpy((void *)gd->start_addr_sp, hdr, hdr->total_size);
+ debug("Stashing EFI table at %lx to %lx, size %x\n",
+ gd->arch.table, gd->start_addr_sp, hdr->total_size);
+ gd->arch.table = gd->start_addr_sp;
+
+ return 0;
+}
+
+int last_stage_init(void)
+{
+ /* start usb so that usb keyboard can be used as input device */
+ usb_init();
+
+ return 0;
+}
diff --git a/arch/x86/cpu/intel_common/Makefile b/arch/x86/cpu/intel_common/Makefile
index c0fcf0ce78..bf798c287f 100644
--- a/arch/x86/cpu/intel_common/Makefile
+++ b/arch/x86/cpu/intel_common/Makefile
@@ -10,7 +10,7 @@ obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += mrc.o
endif
obj-y += cpu.o
obj-y += lpc.o
-ifndef CONFIG_TARGET_EFI
+ifndef CONFIG_TARGET_EFI_APP
obj-y += microcode.o
endif
obj-y += pch.o
diff --git a/arch/x86/cpu/qemu/Makefile b/arch/x86/cpu/qemu/Makefile
index e5ea92545e..b7dd5bd46c 100644
--- a/arch/x86/cpu/qemu/Makefile
+++ b/arch/x86/cpu/qemu/Makefile
@@ -2,8 +2,9 @@
#
# Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
-ifndef CONFIG_EFI_STUB
-obj-y += car.o dram.o
+ifndef CONFIG_$(SPL_)X86_64
+obj-y += car.o
endif
+obj-y += dram.o
obj-y += qemu.o
obj-$(CONFIG_QFW) += cpu.o e820.o
diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c
index 1fdb11cc60..ca4b3f0833 100644
--- a/arch/x86/cpu/qemu/qemu.c
+++ b/arch/x86/cpu/qemu/qemu.c
@@ -143,10 +143,6 @@ int arch_cpu_init(void)
return x86_cpu_init_f();
}
-#endif
-
-#if !CONFIG_IS_ENABLED(EFI_STUB) && \
- !CONFIG_IS_ENABLED(SPL_X86_32BIT_INIT)
int checkcpu(void)
{
diff --git a/arch/x86/cpu/x86_64/setjmp.S b/arch/x86/cpu/x86_64/setjmp.S
new file mode 100644
index 0000000000..97b812854c
--- /dev/null
+++ b/arch/x86/cpu/x86_64/setjmp.S
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 Intel Corporation
+ *
+ * See arch/x86/include/asm/setjmp.h for jmp_buf format
+ */
+
+#include <linux/linkage.h>
+
+.text
+.align 8
+
+ENTRY(setjmp)
+
+ pop %rcx
+ movq %rcx, (%rdi) /* Return address */
+ movq %rsp, 8(%rdi)
+ movq %rbp, 16(%rdi)
+ movq %rbx, 24(%rdi)
+ movq %r12, 32(%rdi)
+ movq %r13, 40(%rdi)
+ movq %r14, 48(%rdi)
+ movq %r15, 56(%rdi)
+ xorq %rax, %rax /* Direct invocation returns 0 */
+ jmpq *%rcx
+
+ENDPROC(setjmp)
+
+.align 8
+
+ENTRY(longjmp)
+
+ movq (%rdi), %rcx /* Return address */
+ movq 8(%rdi), %rsp
+ movq 16(%rdi), %rbp
+ movq 24(%rdi), %rbx
+ movq 32(%rdi), %r12
+ movq 40(%rdi), %r13
+ movq 48(%rdi), %r14
+ movq 56(%rdi), %r15
+
+ movq %rsi, %rax /* Value to be returned by setjmp() */
+ testq %rax, %rax /* cannot be 0 in this case */
+ jnz 1f
+ incq %rax /* Return 1 instead */
+1:
+ jmpq *%rcx
+
+ENDPROC(longjmp)
diff --git a/arch/x86/cpu/x86_64/setjmp.c b/arch/x86/cpu/x86_64/setjmp.c
deleted file mode 100644
index 5d4a74a571..0000000000
--- a/arch/x86/cpu/x86_64/setjmp.c
+++ /dev/null
@@ -1,19 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 2016 Google, Inc
- */
-
-#include <common.h>
-#include <asm/setjmp.h>
-
-int setjmp(struct jmp_buf_data *jmp_buf)
-{
- printf("WARNING: setjmp() is not supported\n");
-
- return 0;
-}
-
-void longjmp(struct jmp_buf_data *jmp_buf, int val)
-{
- printf("WARNING: longjmp() is not supported\n");
-}