Skip to contentSkip to conversation

x86: Add initial support for 64-bit U-Boot

PATCH New Simon Glass 4 participants 135 messages Sep 26, 2016 – Nov 25, 2016

Subsystems (10)
x86 USB Kbuild PCI +6 more subsystems
lore
Share & tools
lore
#0 lore raw

cover x86: Add initial support for 64-bit U-Boot

At present U-Boot runs entirely in 32-bit mode on x86, except for the initial switch from 16-bit mode. On 64-bit machines it is possible to run in 64-bit mode. This series starts the process of adding this support.

The main benefit of 64-bit mode for a boot loader is direct access to all available memory. There are also more registers, but this makes very little difference.

This feature is implemented by putting all of the 32-bit code in an SPL build. SPL then runs through all the init that has to be done in 32-bit mode, changes to 64-bit mode and then jumps to U-Boot proper.

Typically the total code size increases slightly. For example, on link in 32-bit mode, U-Boot has around 480KB of code (admittedly with a large number of features enabled). In 64-bit mode, U-Boot falls to around 460KB, but SPL adds another 60KB, for a net increase of 40KB. Partly this is due to code duplication and partly it is due to the worse code density of 64-bit code on x86.

Many major features are not implemented yet, for example:
- SDRAM sizing
- Booting linux
- FSP support
- EFI support
- SCSI device init
- Running video ROMs

Still, this is a big step forward towards full 64-bit support. To enable it, select CONFIG_X86_RUN_64BIT.

This series is available at u-boot-x86/64-working

Simon Glass (82):
WIP: x86: Fix up types in smbios code
Add _image_binary_end section declaration
bios_emulator: Fix cast for 64-bit compilation
board_f: Drop the extra fdtdec_prepare_fdt()
console: Don't enable CONFIG-CONSOLE_MUX, etc. in SPL
elf: Add the Elf64_Rela type
mmc: Fix cast for 64-bit compilation
rtc: Use CONFIG_X86 instead of __I386__
spl: spi: Add a debug message if loading fails
spl: Makefile: Define SPL_ earlier
spl: Allow CPU drivers to be used in SPL
spl: Allow PCI drivers to be used in SPL
spl: Allow RTC drivers to be used in SPL
spl: Allow timer drivers to be used in SPL
spl: Allow PCH drivers to be used in SPL
spl: Don't create a BSS padding when it is separate
tpm: Tidy up use of size_t
usb: pci: Fix cast for 64-bit compilation
video: Use ulong for video frame buffer address
x86: Allow interrupts to be disabled in 64-bit mode
x86: Correct address casts in cpu code
x86: Correct address casts in interrupt code
x86: Use unsigned long for address in table generation
WIP: x86: Update mpspec to build on 64-bit machines
x86: Add basic support for U-Boot as a 64-bit EFI application
x86: ivybridge: Declare global data where it is used
x86: i2c: Fix cast of address to 32-bit value
x86: Don't export interrupt handlers with x86_64
x86: ivybridge: Add more debugging for failures
x86: ivybridge: Fix types for 64-bit compilation
x86: ivybridge: Fix PCH power setup
x86: ivybridge: Tidy up enable_clock_gating() for 64-bit
x86: dts: Mark serial as needed before relocation
x86: fsp: Fix cast for 64-bit compilation
x86: Drop unused init_helper functions
x86: lib: Fix types and casts for 64-bit compilation
x86: mrccache: Fix error handling in mrccache_get_region()
x86: Add Kconfig options to build 64-bit U-Boot
x86: Kconfig: Add location options for 16/32-bit init
x86: Use X86_16BIT_INIT instead of X86_RESET_VECTOR
x86: Use X86_32BIT_INIT instead of X86_RESET_VECTOR
x86: ivybridge: Allow 32-bit init to move to SPL
x86: Add 64-bit start-up code
x86: board_f: Update init sequence for 64-bit startup
x86: board_r: Set the global data pointer after relocation
x86: Do relocation before clearing BSS
x86: Refactor relocation to prepare for 64-bit
x86: Add support for 64-bit relocation
x86: Tidy up use of size_t in relocation
x86: Add an SPL implementation
x86: Move the i386 code into its own directory
x86: Add cpu code for x86_64
x86: Support global_data on x86_64
x86: Fix up CONFIG_X86_64 check
x86: Add a link script for 64-bit x86
x86: Add a link script for SPL
x86: Add SPL build rules for start-up code
x86: Fix up byteorder.h for x86_64
x86: Drop flag_is_changable() on x86_64
x86: Fix up type sizes for 64-bit
x86: Mention the MRC region in the README
x86: ivybridge: Only do graphics init in 32-bit mode
x86: ivybridge: Skipt SATA init in SPL
x86: ivybridge: Provide a dummy SDRAM init for 64-bit
x86: Don't try to run the VGA BIOS in 64-bit mode
x86: Don't build call64 and setjmp on 64-bit
x86: Don't build cpu files which are not supported on 64-bit
x86: Don't try to boot Linux from SPL
x86: Drop interrupt support in 64-bit mode
x86: Support jumping from SPL to U-Boot
x86: Move pirq_routing_table to global_data
x86: Move turbo_state to global_data
x86: Change irq_already_routed to a local variable
x86: Move call64 to the i386 directory
x86: Move setjmp to the i386 directory
x86: Add a dummy setjmp implementation for x86_64
x86: link: Add a text base for 64-bit U-Boot
x86: link: Add SPL declarations to the binman image
x86: link: Set up device tree for SPL
x86: link: Add build options for SPL
x86: Update compile/link flags to support 64-bit U-Boot
x86: link: Switch to 64-bit U-Boot

 Makefile                                        |   7 +-
 arch/x86/Kconfig                                |  85 ++++
 arch/x86/Makefile                               |   9 +-
 arch/x86/config.mk                              |  30 +-
 arch/x86/cpu/Makefile                           |  24 +-
 arch/x86/cpu/config.mk                          |   8 +-
 arch/x86/cpu/cpu.c                              | 506 --------------------
 arch/x86/cpu/efi/elf_x86_64_efi.lds             |   3 +
 arch/x86/cpu/i386/Makefile                      |   9 +
 arch/x86/cpu/{ => i386}/call64.S                |   3 +
 arch/x86/cpu/i386/cpu.c                         | 599 ++++++++++++++++++++++++
 arch/x86/cpu/{interrupts.c => i386/interrupt.c} |  13 +-
 arch/x86/cpu/{ => i386}/setjmp.S                |   0
 arch/x86/cpu/intel_common/Makefile              |  10 +-
 arch/x86/cpu/irq.c                              |  14 +-
 arch/x86/cpu/ivybridge/Makefile                 |  11 +-
 arch/x86/cpu/ivybridge/bd82x6x.c                |   6 +
 arch/x86/cpu/ivybridge/cpu.c                    |   4 +-
 arch/x86/cpu/ivybridge/gma.c                    |   4 +-
 arch/x86/cpu/ivybridge/lpc.c                    |  18 +-
 arch/x86/cpu/ivybridge/model_206ax.c            |   2 +
 arch/x86/cpu/ivybridge/northbridge.c            |   2 +
 arch/x86/cpu/ivybridge/sata.c                   |   4 +-
 arch/x86/cpu/ivybridge/sdram.c                  |  36 +-
 arch/x86/cpu/ivybridge/sdram_nop.c              |  29 ++
 arch/x86/cpu/start64.S                          |  39 ++
 arch/x86/cpu/turbo.c                            |   8 +-
 arch/x86/cpu/u-boot-64.lds                      |  76 +++
 arch/x86/cpu/u-boot-spl.lds                     |  74 +++
 arch/x86/cpu/u-boot.lds                         |   2 +-
 arch/x86/cpu/x86_64/Makefile                    |   6 +
 arch/x86/cpu/x86_64/cpu.c                       |  48 ++
 arch/x86/cpu/x86_64/interrupts.c                |  30 ++
 arch/x86/cpu/x86_64/setjmp.c                    |  20 +
 arch/x86/dts/binman.dtsi                        |  19 +
 arch/x86/dts/chromebook_link.dts                |  15 +-
 arch/x86/dts/serial.dtsi                        |   1 +
 arch/x86/include/asm/acpi_table.h               |   2 +-
 arch/x86/include/asm/byteorder.h                |  17 +-
 arch/x86/include/asm/cpu.h                      |  12 +
 arch/x86/include/asm/fsp/fsp_hob.h              |   2 +-
 arch/x86/include/asm/global_data.h              |   8 +-
 arch/x86/include/asm/init_helpers.h             |   2 -
 arch/x86/include/asm/mp.h                       |   3 +
 arch/x86/include/asm/mpspec.h                   |  10 +-
 arch/x86/include/asm/posix_types.h              |   5 +
 arch/x86/include/asm/sfi.h                      |   2 +-
 arch/x86/include/asm/smbios.h                   |   4 +-
 arch/x86/include/asm/spl.h                      |   8 +
 arch/x86/include/asm/tables.h                   |   2 +-
 arch/x86/include/asm/types.h                    |   5 +
 arch/x86/lib/Makefile                           |   9 +
 arch/x86/lib/acpi_table.c                       |   4 +-
 arch/x86/lib/bios.c                             |   4 +-
 arch/x86/lib/bootm.c                            |   2 +
 arch/x86/lib/init_helpers.c                     |  12 +-
 arch/x86/lib/interrupts.c                       |   5 +
 arch/x86/lib/mpspec.c                           |  14 +-
 arch/x86/lib/mrccache.c                         |   8 +-
 arch/x86/lib/pinctrl_ich6.c                     |   2 +-
 arch/x86/lib/pirq_routing.c                     |  14 +-
 arch/x86/lib/reloc_x86_64.c                     |  90 ++++
 arch/x86/lib/relocate.c                         | 102 +++-
 arch/x86/lib/sfi.c                              |   6 +-
 arch/x86/lib/smbios.c                           |  22 +-
 arch/x86/lib/spl.c                              | 149 ++++++
 arch/x86/lib/tables.c                           |   2 +-
 arch/x86/lib/zimage.c                           |   2 +-
 board/google/chromebook_link/Kconfig            |   3 +-
 common/board_f.c                                |  17 +-
 common/board_r.c                                |   5 +
 common/console.c                                |  30 +-
 common/spl/Kconfig                              |  47 ++
 common/spl/spl_spi.c                            |   4 +-
 configs/chromebook_link_defconfig               |  22 +-
 doc/README.x86                                  |   1 +
 drivers/Makefile                                |   5 +
 drivers/bios_emulator/atibios.c                 |   2 +-
 drivers/i2c/intel_i2c.c                         |   6 +-
 drivers/misc/qfw.c                              |   4 +-
 drivers/mmc/pci_mmc.c                           |   2 +-
 drivers/pci/pci_rom.c                           |   2 +-
 drivers/rtc/mc146818.c                          |   2 +-
 drivers/tpm/tpm_tis_lpc.c                       |   4 +-
 drivers/usb/host/ehci-pci.c                     |   4 +-
 include/_exports.h                              |   2 +-
 include/asm-generic/sections.h                  |   1 +
 include/configs/chromebook_link.h               |   9 +
 include/elf.h                                   |   6 +
 include/video_fb.h                              |   2 +-
 scripts/Makefile.spl                            |  18 +-
 91 files changed, 1796 insertions(+), 705 deletions(-)
 create mode 100644 arch/x86/cpu/i386/Makefile
 rename arch/x86/cpu/{ => i386}/call64.S (98%)
 create mode 100644 arch/x86/cpu/i386/cpu.c
 rename arch/x86/cpu/{interrupts.c => i386/interrupt.c} (98%)
 rename arch/x86/cpu/{ => i386}/setjmp.S (100%)
 create mode 100644 arch/x86/cpu/ivybridge/sdram_nop.c
 create mode 100644 arch/x86/cpu/start64.S
 create mode 100644 arch/x86/cpu/u-boot-64.lds
 create mode 100644 arch/x86/cpu/u-boot-spl.lds
 create mode 100644 arch/x86/cpu/x86_64/Makefile
 create mode 100644 arch/x86/cpu/x86_64/cpu.c
 create mode 100644 arch/x86/cpu/x86_64/interrupts.c
 create mode 100644 arch/x86/cpu/x86_64/setjmp.c
 create mode 100644 arch/x86/include/asm/spl.h
 create mode 100644 arch/x86/lib/reloc_x86_64.c
 create mode 100644 arch/x86/lib/spl.c
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH 1/82 WIP: x86: Fix up types in smbios code

This gives warnings with 64-bit compilation at present. Fix these up.

Note that this is a placeholder patch while we wait for this patch to be applied:

https://patchwork.ozlabs.org/patch/660592/

---

 arch/x86/include/asm/smbios.h |  2 +-
 arch/x86/lib/smbios.c         | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)
arch/x86/include/asm/smbios.h +1 -1
index 623a703..fd13f2d 100644
@@ -221,7 +221,7 @@ static inline void fill_smbios_header(void *table, int type,
  * @handle:	the structure's handle, a unique 16-bit number
  * @return:	size of the structure
  */
-typedef int (*smbios_write_type)(u32 *addr, int handle);
+typedef int (*smbios_write_type)(ulong *addr, int handle);
 
 /**
  * write_smbios_table() - Write SMBIOS table
arch/x86/lib/smbios.c +10 -10
index 9f30550..c338b82 100644
@@ -69,7 +69,7 @@ static int smbios_string_table_len(char *start)
 	return len + 1;
 }
 
-static int smbios_write_type0(u32 *current, int handle)
+static int smbios_write_type0(ulong *current, int handle)
 {
 	struct smbios_type0 *t = (struct smbios_type0 *)*current;
 	int len = sizeof(struct smbios_type0);
@@ -98,7 +98,7 @@ static int smbios_write_type0(u32 *current, int handle)
 	return len;
 }
 
-static int smbios_write_type1(u32 *current, int handle)
+static int smbios_write_type1(ulong *current, int handle)
 {
 	struct smbios_type1 *t = (struct smbios_type1 *)*current;
 	int len = sizeof(struct smbios_type1);
@@ -114,7 +114,7 @@ static int smbios_write_type1(u32 *current, int handle)
 	return len;
 }
 
-static int smbios_write_type2(u32 *current, int handle)
+static int smbios_write_type2(ulong *current, int handle)
 {
 	struct smbios_type2 *t = (struct smbios_type2 *)*current;
 	int len = sizeof(struct smbios_type2);
@@ -132,7 +132,7 @@ static int smbios_write_type2(u32 *current, int handle)
 	return len;
 }
 
-static int smbios_write_type3(u32 *current, int handle)
+static int smbios_write_type3(ulong *current, int handle)
 {
 	struct smbios_type3 *t = (struct smbios_type3 *)*current;
 	int len = sizeof(struct smbios_type3);
@@ -152,7 +152,7 @@ static int smbios_write_type3(u32 *current, int handle)
 	return len;
 }
 
-static int smbios_write_type4(u32 *current, int handle)
+static int smbios_write_type4(ulong *current, int handle)
 {
 	struct smbios_type4 *t = (struct smbios_type4 *)*current;
 	int len = sizeof(struct smbios_type4);
@@ -185,7 +185,7 @@ static int smbios_write_type4(u32 *current, int handle)
 	return len;
 }
 
-static int smbios_write_type32(u32 *current, int handle)
+static int smbios_write_type32(ulong *current, int handle)
 {
 	struct smbios_type32 *t = (struct smbios_type32 *)*current;
 	int len = sizeof(struct smbios_type32);
@@ -198,7 +198,7 @@ static int smbios_write_type32(u32 *current, int handle)
 	return len;
 }
 
-static int smbios_write_type127(u32 *current, int handle)
+static int smbios_write_type127(ulong *current, int handle)
 {
 	struct smbios_type127 *t = (struct smbios_type127 *)*current;
 	int len = sizeof(struct smbios_type127);
@@ -224,7 +224,7 @@ static smbios_write_type smbios_write_funcs[] = {
 u32 write_smbios_table(u32 addr)
 {
 	struct smbios_entry *se;
-	u32 tables;
+	ulong tables;
 	int len = 0;
 	int max_struct_size = 0;
 	int handle = 0;
@@ -235,7 +235,7 @@ u32 write_smbios_table(u32 addr)
 	/* 16 byte align the table address */
 	addr = ALIGN(addr, 16);
 
-	se = (struct smbios_entry *)addr;
+	se = (struct smbios_entry *)(uintptr_t)addr;
 	memset(se, 0, sizeof(struct smbios_entry));
 
 	addr += sizeof(struct smbios_entry);
@@ -244,7 +244,7 @@ u32 write_smbios_table(u32 addr)
 
 	/* populate minimum required tables */
 	for (i = 0; i < ARRAY_SIZE(smbios_write_funcs); i++) {
-		int tmp = smbios_write_funcs[i](&addr, handle++);
+		int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++);
 		max_struct_size = max(max_struct_size, tmp);
 		len += tmp;
 	}
Signature · 1 line
2.8.0.rc3.226.g39d4020
#2 lore raw

PATCH 2/82 Add _image_binary_end section declaration

In reply to Simon Glass

This is used in some link scripts, so add a declaration for it.

---

 include/asm-generic/sections.h | 1 +
 1 file changed, 1 insertion(+)
include/asm-generic/sections.h +1 -0
index 54ccac9..daf021b 100644
@@ -84,6 +84,7 @@ extern ulong __data_end;
 extern ulong __rel_dyn_start;
 extern ulong __rel_dyn_end;
 extern ulong __bss_end;
+extern ulong _image_binary_end;
 
 extern ulong _TEXT_BASE;	/* code start */
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#4 lore raw

PATCH 2/82 Add _image_binary_end section declaration

Quoted 11 lines · Bin Meng
Quoted 8 lines · Simon Glass

This is used in some link scripts, so add a declaration for it.

---

 include/asm-generic/sections.h | 1 +
 1 file changed, 1 insertion(+)

applied to u-boot-x86, thanks!

#5 lore raw

PATCH 3/82 bios_emulator: Fix cast for 64-bit compilation

In reply to Simon Glass

Fix a cast that causes warnings on 64-bit machines.

---

 drivers/bios_emulator/atibios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bios_emulator/atibios.c +1 -1
index 7717246..2d5b5dc 100644
@@ -599,7 +599,7 @@ int biosemu_run(pci_dev_t pcidev, uchar *bios_rom, int bios_len,
 	if (clean_up) {
 		BE_exit();
 		if (vga_info->BIOSImage &&
-		    (u32)(vga_info->BIOSImage) != 0xc0000)
+		    (ulong)(vga_info->BIOSImage) != 0xc0000)
 			free(vga_info->BIOSImage);
 		free(vga_info);
 		vga_info = NULL;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#7 lore raw

PATCH 3/82 bios_emulator: Fix cast for 64-bit compilation

Quoted 11 lines · Bin Meng
Quoted 8 lines · Simon Glass

Fix a cast that causes warnings on 64-bit machines.

---

 drivers/bios_emulator/atibios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

applied to u-boot-x86, thanks!

#8 lore raw

PATCH 4/82 board_f: Drop the extra fdtdec_prepare_fdt()

In reply to Simon Glass

This is already called earlier, from fdtdec_setup(), so drop this unnecessary call from the init sequence.

---

 common/board_f.c | 3 ---
 1 file changed, 3 deletions(-)
common/board_f.c +0 -3
index 2c88595..e3179a1 100644
@@ -912,9 +912,6 @@ static init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_SANDBOX
 	sandbox_early_getopt_check,
 #endif
-#ifdef CONFIG_OF_CONTROL
-	fdtdec_prepare_fdt,
-#endif
 	display_options,	/* say that we are here */
 	display_text_info,	/* show debugging info if required */
 #if defined(CONFIG_MPC8260)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#10 lore raw

PATCH 4/82 board_f: Drop the extra fdtdec_prepare_fdt()

Quoted 4 lines · Bin Meng
Quoted 3 lines · Simon Glass

This is already called earlier, from fdtdec_setup(), so drop this unnecessary call from the init sequence.

Quoted 8 lines
Quoted 6 lines

---

 common/board_f.c | 3 ---
 1 file changed, 3 deletions(-)

applied to u-boot-x86, thanks!

#11 lore raw

PATCH 5/82 console: Don't enable CONFIG-CONSOLE_MUX, etc. in SPL

In reply to Simon Glass

CONFIG_CONSOLE_MUX and CONFIG_SYS_CONSOLE_IS_IN_ENV are not applicable for SPL. Update the console code to use CONFIG_IS_ENABLED(), so that these options will be inactive in SPL.

---

 common/console.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
common/console.c +15 -15
index 31a9b3e..4d56ed7 100644
@@ -40,14 +40,14 @@ static int on_console(const char *name, const char *value, enum env_op op,
 	case env_op_create:
 	case env_op_overwrite:
 
-#ifdef CONFIG_CONSOLE_MUX
+#if CONFIG_IS_ENABLED(CONSOLE_MUX)
 		if (iomux_doenv(console, value))
 			return 1;
 #else
 		/* Try assigning specified device */
 		if (console_assign(console, value) < 0)
 			return 1;
-#endif /* CONFIG_CONSOLE_MUX */
+#endif
 		return 0;
 
 	case env_op_delete:
@@ -84,7 +84,7 @@ static int on_silent(const char *name, const char *value, enum env_op op,
 U_BOOT_ENV_CALLBACK(silent, on_silent);
 #endif
 
-#ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV
+#if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
 /*
  * if overwrite_console returns 1, the stdin, stderr and stdout
  * are switched to the serial port, else the settings in the
@@ -97,7 +97,7 @@ extern int overwrite_console(void);
 #define OVERWRITE_CONSOLE 0
 #endif /* CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE */
 
-#endif /* CONFIG_SYS_CONSOLE_IS_IN_ENV */
+#endif /* CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) */
 
 static int console_setfile(int file, struct stdio_dev * dev)
 {
@@ -144,7 +144,7 @@ static int console_setfile(int file, struct stdio_dev * dev)
 	return error;
 }
 
-#if defined(CONFIG_CONSOLE_MUX)
+#if CONFIG_IS_ENABLED(CONSOLE_MUX)
 /** Console I/O multiplexing *******************************************/
 
 static struct stdio_dev *tstcdev;
@@ -264,7 +264,7 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
 {
 	console_setfile(file, dev);
 }
-#endif /* defined(CONFIG_CONSOLE_MUX) */
+#endif /* CONIFIG_IS_ENABLED(CONSOLE_MUX) */
 
 /** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************/
 
@@ -289,7 +289,7 @@ int serial_printf(const char *fmt, ...)
 int fgetc(int file)
 {
 	if (file < MAX_FILES) {
-#if defined(CONFIG_CONSOLE_MUX)
+#if CONFIG_IS_ENABLED(CONSOLE_MUX)
 		/*
 		 * Effectively poll for input wherever it may be available.
 		 */
@@ -727,7 +727,7 @@ void stdio_print_current_devices(void)
 	}
 }
 
-#ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV
+#if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
 /* Called after the relocation - use desired console functions */
 int console_init_r(void)
 {
@@ -736,7 +736,7 @@ int console_init_r(void)
 #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
 	int i;
 #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */
-#ifdef CONFIG_CONSOLE_MUX
+#if CONFIG_IS_ENABLED(CONSOLE_MUX)
 	int iomux_err = 0;
 #endif
 
@@ -757,7 +757,7 @@ int console_init_r(void)
 		inputdev  = search_device(DEV_FLAGS_INPUT,  stdinname);
 		outputdev = search_device(DEV_FLAGS_OUTPUT, stdoutname);
 		errdev    = search_device(DEV_FLAGS_OUTPUT, stderrname);
-#ifdef CONFIG_CONSOLE_MUX
+#if CONFIG_IS_ENABLED(CONSOLE_MUX)
 		iomux_err = iomux_doenv(stdin, stdinname);
 		iomux_err += iomux_doenv(stdout, stdoutname);
 		iomux_err += iomux_doenv(stderr, stderrname);
@@ -790,7 +790,7 @@ int console_init_r(void)
 		console_doenv(stdin, inputdev);
 	}
 
-#ifdef CONFIG_CONSOLE_MUX
+#if CONFIG_IS_ENABLED(CONSOLE_MUX)
 done:
 #endif
 
@@ -820,7 +820,7 @@ done:
 	return 0;
 }
 
-#else /* CONFIG_SYS_CONSOLE_IS_IN_ENV */
+#else /* !CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) */
 
 /* Called after the relocation - use desired console functions */
 int console_init_r(void)
@@ -862,7 +862,7 @@ int console_init_r(void)
 	if (outputdev != NULL) {
 		console_setfile(stdout, outputdev);
 		console_setfile(stderr, outputdev);
-#ifdef CONFIG_CONSOLE_MUX
+#if CONFIG_IS_ENABLED(CONSOLE_MUX)
 		console_devices[stdout][0] = outputdev;
 		console_devices[stderr][0] = outputdev;
 #endif
@@ -871,7 +871,7 @@ int console_init_r(void)
 	/* Initializes input console */
 	if (inputdev != NULL) {
 		console_setfile(stdin, inputdev);
-#ifdef CONFIG_CONSOLE_MUX
+#if CONFIG_IS_ENABLED(CONSOLE_MUX)
 		console_devices[stdin][0] = inputdev;
 #endif
 	}
@@ -896,4 +896,4 @@ int console_init_r(void)
 	return 0;
 }
 
-#endif /* CONFIG_SYS_CONSOLE_IS_IN_ENV */
+#endif /* CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) */
Signature · 1 line
2.8.0.rc3.226.g39d4020
#12 lore raw

PATCH 5/82 console: Don't enable CONFIG-CONSOLE_MUX, etc. in SPL

Hi Simon,

Typo of CONFIG-CONSOLE_MUX in the commit title.

Quoted 3 lines · Simon Glass

CONFIG_CONSOLE_MUX and CONFIG_SYS_CONSOLE_IS_IN_ENV are not applicable for SPL. Update the console code to use CONFIG_IS_ENABLED(), so that these options will be inactive in SPL.

I don't understand, what's the difference between CONFIG_IS_ENABLE() and #ifdef?

Quoted 7 lines

---

 common/console.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

[snip]

Regards,
Bin

#13 lore raw

PATCH 5/82 console: Don't enable CONFIG-CONSOLE_MUX, etc. in SPL

Hi Bin,

Quoted 10 lines · Bin Meng

Hi Simon,

Typo of CONFIG-CONSOLE_MUX in the commit title.

Quoted 3 lines · Simon Glass

CONFIG_CONSOLE_MUX and CONFIG_SYS_CONSOLE_IS_IN_ENV are not applicable for SPL. Update the console code to use CONFIG_IS_ENABLED(), so that these options will be inactive in SPL.

I don't understand, what's the difference between CONFIG_IS_ENABLE() and #ifdef?

CONFIG_IS_ENABLED() can have a different value for SPL and U-Boot proper. It uses CONFIG_xxx or CONFIG_SPL_xxx depending on which is being built.

Quoted 7 lines
Quoted 7 lines

---

 common/console.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

Regards,
Simon

#14 lore raw

PATCH 6/82 elf: Add the Elf64_Rela type

In reply to Simon Glass

Add this so that we can support 64-bit relocation on x86.

---

 include/elf.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/elf.h +6 -0
index a35e085..bcc5eb7 100644
@@ -394,6 +394,12 @@ typedef struct {
 	Elf64_Xword r_info;	/* index and type of relocation */
 } Elf64_Rel;
 
+typedef struct {
+	Elf64_Addr r_offset;    /* Location at which to apply the action */
+	Elf64_Xword r_info;     /* index and type of relocation */
+	Elf64_Sxword r_addend;  /* Constant addend used to compute value */
+} Elf64_Rela;
+
 /* Extract relocation info - r_info */
 #define ELF32_R_SYM(i)		((i) >> 8)
 #define ELF32_R_TYPE(i)		((unsigned char) (i))
Signature · 1 line
2.8.0.rc3.226.g39d4020
#17 lore raw

PATCH 7/82 mmc: Fix cast for 64-bit compilation

In reply to Simon Glass

Fix a cast that causes warnings on 64-bit machines.

---

 drivers/mmc/pci_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/pci_mmc.c +1 -1
index 340eef6..3d587cc 100644
@@ -30,7 +30,7 @@ int pci_mmc_init(const char *name, struct pci_device_id *mmc_supported)
 
 		mmc_host->name = name;
 		dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
-		mmc_host->ioaddr = (void *)iobase;
+		mmc_host->ioaddr = (void *)(ulong)iobase;
 		mmc_host->quirks = 0;
 		ret = add_sdhci(mmc_host, 0, 0);
 		if (ret)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#18 lore raw

PATCH 7/82 mmc: Fix cast for 64-bit compilation

Hi Simon, Bin,

Quoted 1 line · Simon Glass

Fix a cast that causes warnings on 64-bit machines.

If you are ok, I will pick this. how about?

Best Regards,
Jaehoon Chung

Quoted 21 lines

---

 drivers/mmc/pci_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/pci_mmc.c +1 -1
index 340eef6..3d587cc 100644
@@ -30,7 +30,7 @@ int pci_mmc_init(const char *name, struct pci_device_id *mmc_supported)
 
 		mmc_host->name = name;
 		dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
-		mmc_host->ioaddr = (void *)iobase;
+		mmc_host->ioaddr = (void *)(ulong)iobase;
 		mmc_host->quirks = 0;
 		ret = add_sdhci(mmc_host, 0, 0);
 		if (ret)
#19 lore raw

PATCH 7/82 mmc: Fix cast for 64-bit compilation

Hi Jaehoon,

Quoted 7 lines · Jaehoon Chung

Hi Simon, Bin,

Quoted 1 line · Simon Glass

Fix a cast that causes warnings on 64-bit machines.

If you are ok, I will pick this. how about?

I am OK with that. thanks!

Regards,
Bin

#21 lore raw

PATCH 7/82 mmc: Fix cast for 64-bit compilation

Quoted 11 lines · Bin Meng
Quoted 8 lines · Simon Glass

Fix a cast that causes warnings on 64-bit machines.

---

 drivers/mmc/pci_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied on u-boot-mmc. Thanks!

Best Regards,
Jaehoon Chung

Quoted 3 lines
#22 lore raw

PATCH 8/82 rtc: Use CONFIG_X86 instead of __I386__

In reply to Simon Glass

For 64-bit x86, __I386__ should perhaps not be defined. It is not clear from the definition, but let's use CONFIG_X86 to be sure.

---

 drivers/rtc/mc146818.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/mc146818.c +1 -1
index da804d5..4df9eda 100644
@@ -14,7 +14,7 @@
 #include <dm.h>
 #include <rtc.h>
 
-#if defined(__I386__) || defined(CONFIG_MALTA)
+#if defined(CONFIG_X86) || defined(CONFIG_MALTA)
 #include <asm/io.h>
 #define in8(p) inb(p)
 #define out8(p, v) outb(v, p)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#23 lore raw

PATCH 8/82 rtc: Use CONFIG_X86 instead of __I386__

Quoted 9 lines · Simon Glass

For 64-bit x86, __I386__ should perhaps not be defined. It is not clear from the definition, but let's use CONFIG_X86 to be sure.

---

 drivers/rtc/mc146818.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#24 lore raw

PATCH 8/82 rtc: Use CONFIG_X86 instead of __I386__

Quoted 4 lines · Bin Meng
Quoted 3 lines · Simon Glass

For 64-bit x86, __I386__ should perhaps not be defined. It is not clear from the definition, but let's use CONFIG_X86 to be sure.

Quoted 8 lines
Quoted 6 lines

---

 drivers/rtc/mc146818.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

applied to u-boot-x86, thanks!

#25 lore raw

PATCH 9/82 spl: spi: Add a debug message if loading fails

In reply to Simon Glass

This currently fails silently. Add a debug message to aid debugging.

---

 common/spl/spl_spi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
common/spl/spl_spi.c +3 -1
index a3caafb..3f400eb 100644
@@ -96,8 +96,10 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 		/* Load u-boot, mkimage header is 64 bytes. */
 		err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
 				     (void *)header);
-		if (err)
+		if (err) {
+			debug("%s: Failed to read from SPI flash\n", __func__);
 			return err;
+		}
 
 		if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
 			struct spl_load_info load;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#26 lore raw

PATCH 9/82 spl: spi: Add a debug message if loading fails

Hi Simon,

Quoted 13 lines · Simon Glass

This currently fails silently. Add a debug message to aid debugging.

---

 common/spl/spl_spi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
common/spl/spl_spi.c +0 -0
index a3caafb..3f400eb 100644

common/spl/spl_spi.c static int spl_spi_load_image(struct spl_image_info *spl_image, · line 100

Quoted 6 lines
common/spl/spl_spi.c +2 -1
@@ -96,8 +96,10 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
                /* Load u-boot, mkimage header is 64 bytes. */
                err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
                                     (void *)header);
-               if (err)
+               if (err) {
+                       debug("%s: Failed to read from SPI flash\n", __func__);

How about output the err num as well?

common/spl/spl_spi.c static int spl_spi_load_image(struct spl_image_info *spl_image,

Quoted 6 lines
common/spl/spl_spi.c +1 -1
                        return err;
+               }
 
                if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
                        struct spl_load_info load;
--

Regards,
Bin

#27 lore raw

PATCH 10/82 spl: Makefile: Define SPL_ earlier

In reply to Simon Glass

This Makefile variable can be used in the architecture's main Makefile but at present it is not set up until later. Set it just before this Makefile is included.

---

 scripts/Makefile.spl | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/Makefile.spl +6 -0
index a5e0423..4a961f7 100644
@@ -35,6 +35,12 @@ else
 SPL_BIN := u-boot-spl
 endif
 
+ifdef CONFIG_SPL_BUILD
+SPL_ := SPL_
+else
+SPL_ :=
+endif
+
 include $(srctree)/config.mk
 include $(srctree)/arch/$(ARCH)/Makefile
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#28 lore raw

PATCH 11/82 spl: Allow CPU drivers to be used in SPL

In reply to Simon Glass

Add a new Kconfig option to allow CPU drivers to be used in SPL.

---

 common/spl/Kconfig | 10 ++++++++++
 drivers/Makefile   |  1 +
 2 files changed, 11 insertions(+)
common/spl/Kconfig +10 -0
index 84670b1..3c33c9e 100644
@@ -123,6 +123,16 @@ config SPL_SHA256_SUPPORT
 	  SHA256 variant is supported: SHA512 and others are not currently
 	  supported in U-Boot.
 
+config SPL_CPU_SUPPORT
+	bool "Support CPU drivers"
+	depends on SPL
+	help
+	  Enable this to support CPU drivers in SPL. These drivers can set
+	  up CPUs and provide information about them such as the model and
+	  name. This can be useful in SPL since setting up the CPUs earlier
+	  may improve boot performance. Enable this option to build the
+	  drivers in drivers/cpu as part of an SPL build.
+
 config SPL_CRYPTO_SUPPORT
 	bool "Support crypto drivers"
 	depends on SPL
drivers/Makefile +1 -0
index ca98273..b4fd0c4 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_$(SPL_)RAM)	+= ram/
 
 ifdef CONFIG_SPL_BUILD
 
+obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/
 obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/
 obj-$(CONFIG_SPL_I2C_SUPPORT) += i2c/
 obj-$(CONFIG_SPL_GPIO_SUPPORT) += gpio/
Signature · 1 line
2.8.0.rc3.226.g39d4020
#29 lore raw

PATCH 12/82 spl: Allow PCI drivers to be used in SPL

In reply to Simon Glass

Add a new Kconfig option to allow PCI drivers to be used in SPL.

---

 common/spl/Kconfig | 9 +++++++++
 drivers/Makefile   | 1 +
 2 files changed, 10 insertions(+)
common/spl/Kconfig +9 -0
index 3c33c9e..0c83ff1 100644
@@ -378,6 +378,15 @@ config SPL_ONENAND_SUPPORT
 	  load U-Boot from supported devices. This enables the drivers in
 	  drivers/mtd/onenand as part of an SPL build.
 
+config SPL_PCI_SUPPORT
+	bool "Support PCI drivers"
+	depends on SPL
+	help
+	  Enable support for PCI in SPL. For platforms that need PCI to boot,
+	  or must perform some init using PCI in SPL, this provides the
+	  necessary driver support. This enables the drivers in drivers/pci
+	  as part of an SPL build.
+
 config SPL_POST_MEM_SUPPORT
 	bool "Support POST drivers"
 	depends on SPL
drivers/Makefile +1 -0
index b4fd0c4..ae3c76a 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_USBETH_SUPPORT) += net/phy/
+obj-$(CONFIG_SPL_PCI_SUPPORT) += pci/
 obj-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += usb/musb-new/
 obj-$(CONFIG_SPL_USBETH_SUPPORT) += usb/gadget/
 obj-$(CONFIG_SPL_WATCHDOG_SUPPORT) += watchdog/
Signature · 1 line
2.8.0.rc3.226.g39d4020
#30 lore raw

PATCH 13/82 spl: Allow RTC drivers to be used in SPL

In reply to Simon Glass

Add a new Kconfig option to allow RTC drivers to be used in SPL.

---

 common/spl/Kconfig | 10 ++++++++++
 drivers/Makefile   |  1 +
 2 files changed, 11 insertions(+)
common/spl/Kconfig +10 -0
index 0c83ff1..6e0637a 100644
@@ -410,6 +410,16 @@ config SPL_POWER_SUPPORT
 	  in drivers/power, drivers/power/pmic and drivers/power/regulator
 	  as part of an SPL build.
 
+config SPL_RTC_SUPPORT
+	bool "Support RTC drivers"
+	depends on SPL
+	help
+	  Enable RTC (Real-time Clock) support in SPL. This includes support
+	  for reading and setting the time. Some RTC devices also have some
+	  non-volatile (battery-backed) memory which is accessible if
+	  needed. This enables the drivers in drivers/rtc as part of an SPL
+	  build.
+
 config SPL_SATA_SUPPORT
 	bool "Support loading from SATA"
 	depends on SPL
drivers/Makefile +1 -0
index ae3c76a..0351eaf 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_USBETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_PCI_SUPPORT) += pci/
+obj-$(CONFIG_SPL_RTC_SUPPORT) += rtc/
 obj-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += usb/musb-new/
 obj-$(CONFIG_SPL_USBETH_SUPPORT) += usb/gadget/
 obj-$(CONFIG_SPL_WATCHDOG_SUPPORT) += watchdog/
Signature · 1 line
2.8.0.rc3.226.g39d4020
#31 lore raw

PATCH 14/82 spl: Allow timer drivers to be used in SPL

In reply to Simon Glass

Add a new Kconfig option to allow timer drivers to be used in SPL.

---

 common/spl/Kconfig | 9 +++++++++
 drivers/Makefile   | 1 +
 2 files changed, 10 insertions(+)
common/spl/Kconfig +9 -0
index 6e0637a..260387c 100644
@@ -463,6 +463,15 @@ config SPL_SPI_SUPPORT
 	  enable SPI drivers that are needed for other purposes also, such
 	  as a SPI PMIC.
 
+config SPL_TIMER_SUPPORT
+	bool "Support timer drivers"
+	depends on SPL
+	help
+	  Enable support for timer drivers in SPL. These can be used to get
+	  a timer value when in SPL, or perhaps for implementing a delay
+	  function. This enables the drivers in drivers/timer as part of an
+	  SPL build.
+
 config SPL_USBETH_SUPPORT
 	bool "Support USB Ethernet drivers"
 	depends on SPL
drivers/Makefile +1 -0
index 0351eaf..4149836 100644
@@ -35,6 +35,7 @@ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_USBETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_PCI_SUPPORT) += pci/
 obj-$(CONFIG_SPL_RTC_SUPPORT) += rtc/
+obj-$(CONFIG_SPL_TIMER_SUPPORT) += timer/
 obj-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += usb/musb-new/
 obj-$(CONFIG_SPL_USBETH_SUPPORT) += usb/gadget/
 obj-$(CONFIG_SPL_WATCHDOG_SUPPORT) += watchdog/
Signature · 1 line
2.8.0.rc3.226.g39d4020
#32 lore raw

PATCH 15/82 spl: Allow PCH drivers to be used in SPL

In reply to Simon Glass

Add an option for building Platorm Controller Hub drivers in SPL.

---

 common/spl/Kconfig | 9 +++++++++
 drivers/Makefile   | 1 +
 2 files changed, 10 insertions(+)
common/spl/Kconfig +9 -0
index 260387c..64459e5 100644
@@ -387,6 +387,15 @@ config SPL_PCI_SUPPORT
 	  necessary driver support. This enables the drivers in drivers/pci
 	  as part of an SPL build.
 
+config SPL_PCH_SUPPORT
+	bool "Support PCH drivers"
+	depends on SPL
+	help
+	  Enable support for PCH (Platform Controller Hub) devices in SPL.
+	  These are used to set up GPIOs and the SPI peripheral early in
+	  boot. This enables the drivers in drivers/pch as part of an SPL
+	  build.
+
 config SPL_POST_MEM_SUPPORT
 	bool "Support POST drivers"
 	depends on SPL
drivers/Makefile +1 -0
index 4149836..5d6acc3 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_USBETH_SUPPORT) += net/phy/
 obj-$(CONFIG_SPL_PCI_SUPPORT) += pci/
+obj-$(CONFIG_SPL_PCH_SUPPORT) += pch/
 obj-$(CONFIG_SPL_RTC_SUPPORT) += rtc/
 obj-$(CONFIG_SPL_TIMER_SUPPORT) += timer/
 obj-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += usb/musb-new/
Signature · 1 line
2.8.0.rc3.226.g39d4020
#33 lore raw

PATCH 16/82 spl: Don't create a BSS padding when it is separate

In reply to Simon Glass

When BSS does not immediate follow the SPL image we don't need padding before the device tree. Remove it in this case.

---

 scripts/Makefile.spl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/Makefile.spl +2 -1
index 4a961f7..bd1f392 100644
@@ -188,7 +188,8 @@ quiet_cmd_copy = COPY    $@
       cmd_copy = cp $< $@
 
 ifeq ($(CONFIG_SPL_OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_SPL_OF_PLATDATA),yy)
-$(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin $(obj)/$(SPL_BIN)-pad.bin \
+$(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \
+		$(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
 		$(obj)/$(SPL_BIN).dtb FORCE
 	$(call if_changed,cat)
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#34 lore raw

PATCH 17/82 tpm: Tidy up use of size_t

In reply to Simon Glass

We should consistently use %z with size_t, and avoid passing a uint32_t as a size_t value. Fix these issues to avoid warnings on 64-bit machines.

---

 drivers/tpm/tpm_tis_lpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tpm/tpm_tis_lpc.c +2 -2
index 257d035..b4efbb5 100644
@@ -204,7 +204,7 @@ static int tis_senddata(struct udevice *dev, const u8 *data, size_t len)
 		/* Wait till the device is ready to accept more data. */
 		while (!burst) {
 			if (max_cycles++ == MAX_DELAY_US) {
-				printf("%s:%d failed to feed %d bytes of %d\n",
+				printf("%s:%d failed to feed %zd bytes of %zd\n",
 				       __FILE__, __LINE__, len - offset, len);
 				return -ETIMEDOUT;
 			}
@@ -224,7 +224,7 @@ static int tis_senddata(struct udevice *dev, const u8 *data, size_t len)
 		 * changes to zero exactly after the last byte is fed into the
 		 * FIFO.
 		 */
-		count = min((u32)burst, len - offset - 1);
+		count = min((size_t)burst, len - offset - 1);
 		while (count--)
 			tpm_write_byte(priv, data[offset++],
 				       &regs[locality].data);
Signature · 1 line
2.8.0.rc3.226.g39d4020
#35 lore raw

PATCH 17/82 tpm: Tidy up use of size_t

Quoted 9 lines · Simon Glass

We should consistently use %z with size_t, and avoid passing a uint32_t as a size_t value. Fix these issues to avoid warnings on 64-bit machines.

---

 drivers/tpm/tpm_tis_lpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#36 lore raw

PATCH 17/82 tpm: Tidy up use of size_t

Quoted 4 lines · Bin Meng
Quoted 3 lines · Simon Glass

We should consistently use %z with size_t, and avoid passing a uint32_t as a size_t value. Fix these issues to avoid warnings on 64-bit machines.

Quoted 8 lines
Quoted 6 lines

---

 drivers/tpm/tpm_tis_lpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

applied to u-boot-x86, thanks!

#37 lore raw

PATCH 18/82 usb: pci: Fix cast for 64-bit compilation

In reply to Simon Glass

Fix a cast that causes warnings on 64-bit machines.

---

 drivers/usb/host/ehci-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/ehci-pci.c +2 -2
index 6fc2479..f20fc33 100644
@@ -32,8 +32,8 @@ static void ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
 	hcor = (struct ehci_hcor *)((uintptr_t) hccr +
 			HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
 
-	debug("EHCI-PCI init hccr 0x%x and hcor 0x%x hc_length %d\n",
-	      (u32)hccr, (u32)hcor,
+	debug("EHCI-PCI init hccr %#lx and hcor %#lx hc_length %d\n",
+	      (ulong)hccr, (ulong)hcor,
 	      (u32)HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
 
 	*ret_hccr = hccr;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#39 lore raw

PATCH 18/82 usb: pci: Fix cast for 64-bit compilation

Quoted 11 lines · Bin Meng
Quoted 8 lines · Simon Glass

Fix a cast that causes warnings on 64-bit machines.

---

 drivers/usb/host/ehci-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

applied to u-boot-x86, thanks!

#40 lore raw

PATCH 19/82 video: Use ulong for video frame buffer address

In reply to Simon Glass

Change this type from int to ulong to avoid warnings on 64-bit machines.

---

 include/video_fb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/video_fb.h +1 -1
index b008853..4a4fd5f 100644
@@ -38,7 +38,7 @@ typedef struct graphic_device {
     unsigned int dprBase;
     unsigned int vprBase;
     unsigned int cprBase;
-    unsigned int frameAdrs;
+    unsigned long frameAdrs;
     unsigned int memSize;
     unsigned int mode;
     unsigned int gdfIndex;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#41 lore raw

PATCH 19/82 video: Use ulong for video frame buffer address

Quoted 13 lines · Simon Glass

Change this type from int to ulong to avoid warnings on 64-bit machines.

---

 include/video_fb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/video_fb.h +0 -0
index b008853..4a4fd5f 100644

include/video_fb.h typedef struct graphic_device {

Quoted 9 lines
include/video_fb.h +1 -2
@@ -38,7 +38,7 @@ typedef struct graphic_device {
     unsigned int dprBase;
     unsigned int vprBase;
     unsigned int cprBase;
-    unsigned int frameAdrs;
+    unsigned long frameAdrs;
     unsigned int memSize;
     unsigned int mode;
     unsigned int gdfIndex;
--

I suspect this patch is not needed after this series:
http://lists.denx.de/pipermail/u-boot/2016-October/269561.html

Regards,
Bin

#42 lore raw

PATCH 20/82 x86: Allow interrupts to be disabled in 64-bit mode

In reply to Simon Glass

Update the code to support both 32-bit and 64-bit modes.

---

 arch/x86/cpu/interrupts.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/cpu/interrupts.c +4 -1
index dd2819a..46babe0 100644
@@ -238,8 +238,11 @@ int disable_interrupts(void)
 {
 	long flags;
 
+#ifdef CONFIG_X86_64
+	asm volatile ("pushfq ; popq %0 ; cli\n" : "=g" (flags) : );
+#else
 	asm volatile ("pushfl ; popl %0 ; cli\n" : "=g" (flags) : );
-
+#endif
 	return flags & X86_EFLAGS_IF;
 }
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#44 lore raw

PATCH 20/82 x86: Allow interrupts to be disabled in 64-bit mode

Quoted 11 lines · Bin Meng
Quoted 8 lines · Simon Glass

Update the code to support both 32-bit and 64-bit modes.

---

 arch/x86/cpu/interrupts.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

applied to u-boot-x86, thanks!

#45 lore raw

PATCH 21/82 x86: Correct address casts in cpu code

In reply to Simon Glass

We should cast an address to unsigned long, not u32.

---

 arch/x86/cpu/cpu.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
arch/x86/cpu/cpu.c +4 -6
index 269043d..7c1d6de 100644
@@ -135,7 +135,7 @@ static void load_gdt(const u64 *boot_gdt, u16 num_entries)
 	struct gdt_ptr gdt;
 
 	gdt.len = (num_entries * X86_GDT_ENTRY_SIZE) - 1;
-	gdt.ptr = (u32)boot_gdt;
+	gdt.ptr = (ulong)boot_gdt;
 
 	asm volatile("lgdtl %0\n" : : "m" (gdt));
 }
@@ -630,13 +630,11 @@ static void build_pagetable(uint32_t *pgtable)
 	memset(pgtable, '\0', PAGETABLE_SIZE);
 
 	/* Level 4 needs a single entry */
-	pgtable[0] = (uint32_t)&pgtable[1024] + 7;
+	pgtable[0] = (ulong)&pgtable[1024] + 7;
 
 	/* Level 3 has one 64-bit entry for each GiB of memory */
-	for (i = 0; i < 4; i++) {
-		pgtable[1024 + i * 2] = (uint32_t)&pgtable[2048] +
-							0x1000 * i + 7;
-	}
+	for (i = 0; i < 4; i++)
+		pgtable[1024 + i * 2] = (ulong)&pgtable[2048] + 0x1000 * i + 7;
 
 	/* Level 2 has 2048 64-bit entries, each repesenting 2MiB */
 	for (i = 0; i < 2048; i++)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#47 lore raw

PATCH 21/82 x86: Correct address casts in cpu code

Quoted 11 lines · Bin Meng
Quoted 8 lines · Simon Glass

We should cast an address to unsigned long, not u32.

---

 arch/x86/cpu/cpu.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

applied to u-boot-x86, thanks!

#48 lore raw

PATCH 22/82 x86: Correct address casts in interrupt code

In reply to Simon Glass

We should cast an address to unsigned long, not u32.

---

 arch/x86/cpu/interrupts.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/cpu/interrupts.c +2 -2
index 46babe0..5f6cdd3 100644
@@ -182,8 +182,8 @@ static inline void load_idt(const struct desc_ptr *dtr)
 
 void set_vector(u8 intnum, void *routine)
 {
-	idt[intnum].base_high = (u16)((u32)(routine) >> 16);
-	idt[intnum].base_low = (u16)((u32)(routine) & 0xffff);
+	idt[intnum].base_high = (u16)((ulong)(routine) >> 16);
+	idt[intnum].base_low = (u16)((ulong)(routine) & 0xffff);
 }
 
 /*
Signature · 1 line
2.8.0.rc3.226.g39d4020
#50 lore raw

PATCH 22/82 x86: Correct address casts in interrupt code

Quoted 11 lines · Bin Meng
Quoted 8 lines · Simon Glass

We should cast an address to unsigned long, not u32.

---

 arch/x86/cpu/interrupts.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

applied to u-boot-x86, thanks!

#51 lore raw

PATCH 23/82 x86: Use unsigned long for address in table generation

In reply to Simon Glass

We should use unsigned long rather than u32 for addresses. Update this so that the table-generation code builds correctly on 64-bit machines.

---

 arch/x86/cpu/irq.c                | 2 +-
 arch/x86/include/asm/acpi_table.h | 2 +-
 arch/x86/include/asm/mpspec.h     | 2 +-
 arch/x86/include/asm/sfi.h        | 2 +-
 arch/x86/include/asm/smbios.h     | 2 +-
 arch/x86/include/asm/tables.h     | 2 +-
 arch/x86/lib/acpi_table.c         | 4 ++--
 arch/x86/lib/mpspec.c             | 2 +-
 arch/x86/lib/sfi.c                | 2 +-
 arch/x86/lib/smbios.c             | 2 +-
 arch/x86/lib/tables.c             | 2 +-
 drivers/misc/qfw.c                | 4 ++--
 12 files changed, 14 insertions(+), 14 deletions(-)
arch/x86/cpu/irq.c +1 -1
index df3cd0a..516d84a 100644
@@ -263,7 +263,7 @@ int irq_router_probe(struct udevice *dev)
 	return irq_router_common_init(dev);
 }
 
-u32 write_pirq_routing_table(u32 addr)
+ulong write_pirq_routing_table(ulong addr)
 {
 	if (!pirq_routing_table)
 		return addr;
arch/x86/include/asm/acpi_table.h +1 -1
index caff4d8..bbd80a1 100644
@@ -316,4 +316,4 @@ int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi,
 			       u8 cpu, u16 flags, u8 lint);
 u32 acpi_fill_madt(u32 current);
 void acpi_create_gnvs(struct acpi_global_nvs *gnvs);
-u32 write_acpi_tables(u32 start);
+ulong write_acpi_tables(ulong start);
arch/x86/include/asm/mpspec.h +1 -1
index ad8eba9..146a4b0 100644
@@ -456,6 +456,6 @@ int mp_determine_pci_dstirq(int bus, int dev, int func, int pirq);
  * @addr:	start address to write MP table
  * @return:	end address of MP table
  */
-u32 write_mp_table(u32 addr);
+ulong write_mp_table(ulong addr);
 
 #endif /* __ASM_MPSPEC_H */
arch/x86/include/asm/sfi.h +1 -1
index d1f0f0c..d6c44c9 100644
@@ -132,6 +132,6 @@ typedef int (*sfi_table_handler) (struct sfi_table_header *table);
  * @base:	Address to write table to
  * @return address to use for the next table
  */
-u32 write_sfi_table(u32 base);
+ulong write_sfi_table(ulong base);
 
 #endif /*_LINUX_SFI_H */
arch/x86/include/asm/smbios.h +1 -1
index fd13f2d..4e508c3 100644
@@ -231,6 +231,6 @@ typedef int (*smbios_write_type)(ulong *addr, int handle);
  * @addr:	start address to write SMBIOS table
  * @return:	end address of SMBIOS table
  */
-u32 write_smbios_table(u32 addr);
+ulong write_smbios_table(ulong addr);
 
 #endif /* _SMBIOS_H_ */
arch/x86/include/asm/tables.h +1 -1
index ae9f0d0..6154dd1 100644
@@ -63,6 +63,6 @@ void write_tables(void);
  * @start:	start address to write PIRQ routing table
  * @return:	end address of PIRQ routing table
  */
-u32 write_pirq_routing_table(u32 start);
+ulong write_pirq_routing_table(ulong start);
 
 #endif /* _X86_TABLES_H_ */
arch/x86/lib/acpi_table.c +2 -2
index 7001e8b..355456d 100644
@@ -327,7 +327,7 @@ static void enter_acpi_mode(int pm1_cnt)
  * QEMU's version of write_acpi_tables is defined in
  * arch/x86/cpu/qemu/acpi_table.c
  */
-u32 write_acpi_tables(u32 start)
+ulong write_acpi_tables(ulong start)
 {
 	u32 current;
 	struct acpi_rsdp *rsdp;
@@ -345,7 +345,7 @@ u32 write_acpi_tables(u32 start)
 	/* Align ACPI tables to 16 byte */
 	current = ALIGN(current, 16);
 
-	debug("ACPI: Writing ACPI tables at %x\n", start);
+	debug("ACPI: Writing ACPI tables at %lx\n", start);
 
 	/* We need at least an RSDP and an RSDT Table */
 	rsdp = (struct acpi_rsdp *)current;
arch/x86/lib/mpspec.c +1 -1
index 6ab43f1..516d7b3 100644
@@ -365,7 +365,7 @@ static void mptable_add_lintsrc(struct mp_config_table *mc, int bus_isa)
 			 bus_isa, 0, MP_APIC_ALL, 1);
 }
 
-u32 write_mp_table(u32 addr)
+ulong write_mp_table(ulong addr)
 {
 	struct mp_config_table *mc;
 	int ioapic_id, ioapic_ver;
arch/x86/lib/sfi.c +1 -1
index 3d36580..9564853 100644
@@ -131,7 +131,7 @@ static int sfi_write_xsdt(struct table_info *tab)
 	return 0;
 }
 
-u32 write_sfi_table(u32 base)
+ulong write_sfi_table(ulong base)
 {
 	struct table_info table;
 
arch/x86/lib/smbios.c +1 -1
index c338b82..975bbf2 100644
@@ -221,7 +221,7 @@ static smbios_write_type smbios_write_funcs[] = {
 	smbios_write_type127
 };
 
-u32 write_smbios_table(u32 addr)
+ulong write_smbios_table(ulong addr)
 {
 	struct smbios_entry *se;
 	ulong tables;
arch/x86/lib/tables.c +1 -1
index f92111e..351fc44 100644
@@ -18,7 +18,7 @@
  * @addr:	start address to write the table
  * @return:	end address of the table
  */
-typedef u32 (*table_write)(u32 addr);
+typedef ulong (*table_write)(ulong addr);
 
 static table_write table_write_funcs[] = {
 #ifdef CONFIG_GENERATE_PIRQ_TABLE
drivers/misc/qfw.c +2 -2
index d43d1d3..a8af9e0 100644
@@ -32,7 +32,7 @@ static LIST_HEAD(fw_list);
  *          be ignored.
  * @return: 0 on success, or negative value on failure
  */
-static int bios_linker_allocate(struct bios_linker_entry *entry, u32 *addr)
+static int bios_linker_allocate(struct bios_linker_entry *entry, ulong *addr)
 {
 	uint32_t size, align;
 	struct fw_file *file;
@@ -147,7 +147,7 @@ static int bios_linker_add_checksum(struct bios_linker_entry *entry)
 }
 
 /* This function loads and patches ACPI tables provided by QEMU */
-u32 write_acpi_tables(u32 addr)
+ulong write_acpi_tables(ulong addr)
 {
 	int i, ret = 0;
 	struct fw_file *file;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#52 lore raw

PATCH 24/82 WIP: x86: Update mpspec to build on 64-bit machines

In reply to Simon Glass

At present this uses u32 to store an address. We should use unsigned long and avoid special types in function return values and parameters unless necessary. This makes the code more portable.

I believe Alex Graf has a patch to correct all of these, so this is just a WIP patch.

---

 arch/x86/include/asm/mpspec.h |  8 ++++----
 arch/x86/lib/mpspec.c         | 12 ++++++------
 2 files changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/mpspec.h +4 -4
index 146a4b0..30dbdca 100644
@@ -224,9 +224,9 @@ struct mp_ext_compat_address_space {
  * @mc:		configuration table header address
  * @return:	configuration table end address
  */
-static inline u32 mp_next_mpc_entry(struct mp_config_table *mc)
+static inline ulong mp_next_mpc_entry(struct mp_config_table *mc)
 {
-	return (u32)mc + mc->mpc_length;
+	return (ulong)mc + mc->mpc_length;
 }
 
 /**
@@ -254,9 +254,9 @@ static inline void mp_add_mpc_entry(struct mp_config_table *mc, uint length)
  * @mc:		configuration table header address
  * @return:	configuration table end address
  */
-static inline u32 mp_next_mpe_entry(struct mp_config_table *mc)
+static inline ulong mp_next_mpe_entry(struct mp_config_table *mc)
 {
-	return (u32)mc + mc->mpc_length + mc->mpe_length;
+	return (ulong)mc + mc->mpc_length + mc->mpe_length;
 }
 
 /**
arch/x86/lib/mpspec.c +6 -6
index 516d7b3..17e977c 100644
@@ -25,10 +25,10 @@ static bool isa_irq_occupied[16];
 
 struct mp_config_table *mp_write_floating_table(struct mp_floating_table *mf)
 {
-	u32 mc;
+	ulong mc;
 
 	memcpy(mf->mpf_signature, MPF_SIGNATURE, 4);
-	mf->mpf_physptr = (u32)mf + sizeof(struct mp_floating_table);
+	mf->mpf_physptr = (ulong)mf + sizeof(struct mp_floating_table);
 	mf->mpf_length = 1;
 	mf->mpf_spec = MPSPEC_V14;
 	mf->mpf_checksum = 0;
@@ -41,7 +41,7 @@ struct mp_config_table *mp_write_floating_table(struct mp_floating_table *mf)
 	mf->mpf_feature5 = 0;
 	mf->mpf_checksum = table_compute_checksum(mf, mf->mpf_length * 16);
 
-	mc = (u32)mf + sizeof(struct mp_floating_table);
+	mc = (ulong)mf + sizeof(struct mp_floating_table);
 	return (struct mp_config_table *)mc;
 }
 
@@ -219,14 +219,14 @@ void mp_write_compat_address_space(struct mp_config_table *mc, int busid,
 
 u32 mptable_finalize(struct mp_config_table *mc)
 {
-	u32 end;
+	ulong end;
 
 	mc->mpe_checksum = table_compute_checksum((void *)mp_next_mpc_entry(mc),
 						  mc->mpe_length);
 	mc->mpc_checksum = table_compute_checksum(mc, mc->mpc_length);
 	end = mp_next_mpe_entry(mc);
 
-	debug("Write the MP table at: %x - %x\n", (u32)mc, end);
+	debug("Write the MP table at: %lx - %lx\n", (ulong)mc, end);
 
 	return end;
 }
@@ -371,7 +371,7 @@ ulong write_mp_table(ulong addr)
 	int ioapic_id, ioapic_ver;
 	int bus_isa = 0xff;
 	int ret;
-	u32 end;
+	ulong end;
 
 	/* 16 byte align the table address */
 	addr = ALIGN(addr, 16);
Signature · 1 line
2.8.0.rc3.226.g39d4020
#53 lore raw

PATCH 25/82 x86: Add basic support for U-Boot as a 64-bit EFI application

In reply to Simon Glass

Add a link script and relocation code for building 64-bit EFI applications. This can be used for the EFI stub.

---

 arch/x86/cpu/efi/elf_x86_64_efi.lds |  3 ++
 arch/x86/lib/reloc_x86_64.c         | 90 +++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+)
 create mode 100644 arch/x86/lib/reloc_x86_64.c
arch/x86/cpu/efi/elf_x86_64_efi.lds +3 -0
index 9d9f057..68c4522 100644
@@ -56,6 +56,9 @@ SECTIONS
 		*(SORT(.u_boot_list*));
 		. = ALIGN(8);
 		*(.dtb*);
+		/* Keep U-Boot payload */
+		. = ALIGN(8);
+		KEEP(*(.u_boot_bin.*));
 	}
 
 	. = ALIGN(4096);
arch/x86/lib/reloc_x86_64.c new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3.226.g39d4020
#54 lore raw

PATCH 26/82 x86: ivybridge: Declare global data where it is used

In reply to Simon Glass

Some files are missing this declaration. Add it to avoid build errors when we actually need the declaration.

---

 arch/x86/cpu/ivybridge/bd82x6x.c     | 2 ++
 arch/x86/cpu/ivybridge/gma.c         | 2 ++
 arch/x86/cpu/ivybridge/lpc.c         | 2 ++
 arch/x86/cpu/ivybridge/model_206ax.c | 2 ++
 arch/x86/cpu/ivybridge/northbridge.c | 2 ++
 5 files changed, 10 insertions(+)
arch/x86/cpu/ivybridge/bd82x6x.c +2 -0
index 5b58d6c..3c5e159 100644
@@ -21,6 +21,8 @@
 #include <asm/arch/pch.h>
 #include <asm/arch/sandybridge.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define GPIO_BASE	0x48
 #define BIOS_CTRL	0xdc
 
arch/x86/cpu/ivybridge/gma.c +2 -0
index 37e2e6e..59866bd 100644
@@ -19,6 +19,8 @@
 #include <asm/arch/pch.h>
 #include <asm/arch/sandybridge.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 struct gt_powermeter {
 	u16 reg;
 	u32 value;
arch/x86/cpu/ivybridge/lpc.c +2 -0
index 4e0be2a..0b4343a 100644
@@ -20,6 +20,8 @@
 #include <asm/pci.h>
 #include <asm/arch/pch.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define NMI_OFF				0
 
 #define ENABLE_ACPI_MODE_IN_COREBOOT	0
arch/x86/cpu/ivybridge/model_206ax.c +2 -0
index 38e244b..ae7c540 100644
@@ -23,6 +23,8 @@
 #include <asm/arch/bd82x6x.h>
 #include <asm/arch/model_206ax.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static void enable_vmx(void)
 {
 	struct cpuid_result regs;
arch/x86/cpu/ivybridge/northbridge.c +2 -0
index 491f289..94f31c4 100644
@@ -19,6 +19,8 @@
 #include <asm/arch/model_206ax.h>
 #include <asm/arch/sandybridge.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int bridge_silicon_revision(struct udevice *dev)
 {
 	struct cpuid_result result;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#55 lore raw

PATCH 26/82 x86: ivybridge: Declare global data where it is used

Quoted 4 lines · Simon Glass

Some files are missing this declaration. Add it to avoid build errors when we actually need the declaration.

Quoted 9 lines

---

 arch/x86/cpu/ivybridge/bd82x6x.c     | 2 ++
 arch/x86/cpu/ivybridge/gma.c         | 2 ++
 arch/x86/cpu/ivybridge/lpc.c         | 2 ++
 arch/x86/cpu/ivybridge/model_206ax.c | 2 ++
 arch/x86/cpu/ivybridge/northbridge.c | 2 ++
 5 files changed, 10 insertions(+)
Quoted 18 lines
arch/x86/cpu/ivybridge/bd82x6x.c +2 -0
index 5b58d6c..3c5e159 100644
@@ -21,6 +21,8 @@
 #include <asm/arch/pch.h>
 #include <asm/arch/sandybridge.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define GPIO_BASE      0x48
 #define BIOS_CTRL      0xdc
 
arch/x86/cpu/ivybridge/gma.c +0 -0
index 37e2e6e..59866bd 100644

arch/x86/cpu/ivybridge/gma.c line 23

Quoted 5 lines
arch/x86/cpu/ivybridge/gma.c +2 -0
@@ -19,6 +19,8 @@
 #include <asm/arch/pch.h>
 #include <asm/arch/sandybridge.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+

But I think this is not needed since gma.c has been dropped due to DM video conversion.

Quoted 34 lines
arch/x86/cpu/ivybridge/gma.c +0 -0
 struct gt_powermeter {
        u16 reg;
        u32 value;
arch/x86/cpu/ivybridge/lpc.c +2 -0
index 4e0be2a..0b4343a 100644
@@ -20,6 +20,8 @@
 #include <asm/pci.h>
 #include <asm/arch/pch.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define NMI_OFF                                0
 
 #define ENABLE_ACPI_MODE_IN_COREBOOT   0
arch/x86/cpu/ivybridge/model_206ax.c +2 -0
index 38e244b..ae7c540 100644
@@ -23,6 +23,8 @@
 #include <asm/arch/bd82x6x.h>
 #include <asm/arch/model_206ax.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static void enable_vmx(void)
 {
        struct cpuid_result regs;
arch/x86/cpu/ivybridge/northbridge.c +0 -0
index 491f289..94f31c4 100644

arch/x86/cpu/ivybridge/northbridge.c

Quoted 9 lines
arch/x86/cpu/ivybridge/northbridge.c +2 -1
@@ -19,6 +19,8 @@
 #include <asm/arch/model_206ax.h>
 #include <asm/arch/sandybridge.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int bridge_silicon_revision(struct udevice *dev)
 {
        struct cpuid_result result;
--

Regards,
Bin

#56 lore raw

PATCH 27/82 x86: i2c: Fix cast of address to 32-bit value

In reply to Simon Glass

This gives a build warning on 64-bit x86. Fix it.

---

 drivers/i2c/intel_i2c.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/intel_i2c.c +3 -3
index a0182dc..550a728 100644
@@ -248,11 +248,11 @@ static int intel_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
 static int intel_i2c_probe(struct udevice *dev)
 {
 	struct intel_i2c *priv = dev_get_priv(dev);
-	u32 base;
+	ulong base;
 
 	/* Save base address from PCI BAR */
-	priv->base = (u32)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_4,
-					 PCI_REGION_IO);
+	priv->base = (ulong)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_4,
+					   PCI_REGION_IO);
 	base = priv->base;
 
 	/* Set SMBus enable. */
Signature · 1 line
2.8.0.rc3.226.g39d4020
#57 lore raw

PATCH 27/82 x86: i2c: Fix cast of address to 32-bit value

Hello Simon,

Am 26.09.2016 um 05:33 schrieb Simon Glass:

Quoted 7 lines

This gives a build warning on 64-bit x86. Fix it.

---

  drivers/i2c/intel_i2c.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

bye,
Heiko

Quoted 21 lines
drivers/i2c/intel_i2c.c +3 -3
index a0182dc..550a728 100644
@@ -248,11 +248,11 @@ static int intel_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
  static int intel_i2c_probe(struct udevice *dev)
  {
  	struct intel_i2c *priv = dev_get_priv(dev);
-	u32 base;
+	ulong base;
 
  	/* Save base address from PCI BAR */
-	priv->base = (u32)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_4,
-					 PCI_REGION_IO);
+	priv->base = (ulong)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_4,
+					   PCI_REGION_IO);
  	base = priv->base;
 
  	/* Set SMBus enable. */
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#59 lore raw

PATCH 27/82 x86: i2c: Fix cast of address to 32-bit value

Quoted 11 lines · Bin Meng
Quoted 8 lines · Simon Glass

This gives a build warning on 64-bit x86. Fix it.

---

 drivers/i2c/intel_i2c.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

applied to u-boot-x86, thanks!

#60 lore raw

PATCH 28/82 x86: Don't export interrupt handlers with x86_64

In reply to Simon Glass

We don't have a way of adjusting these at present so it is best to refuse to export these functions. This can be implemented later if the API is required.

---

 include/_exports.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/_exports.h +1 -1
index 11beeb2..0b30c9e 100644
@@ -13,7 +13,7 @@
 	EXPORT_FUNC(putc, void, putc, const char)
 	EXPORT_FUNC(puts, void, puts, const char *)
 	EXPORT_FUNC(printf, int, printf, const char*, ...)
-#if defined(CONFIG_X86) || defined(CONFIG_PPC)
+#if (defined(CONFIG_X86) && !defined(CONFIG_X86_64)) || defined(CONFIG_PPC)
 	EXPORT_FUNC(irq_install_handler, void, install_hdlr,
 		    int, interrupt_handler_t, void*)
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#61 lore raw

PATCH 28/82 x86: Don't export interrupt handlers with x86_64

Quoted 9 lines · Simon Glass

We don't have a way of adjusting these at present so it is best to refuse to export these functions. This can be implemented later if the API is required.

---

 include/_exports.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#62 lore raw

PATCH 28/82 x86: Don't export interrupt handlers with x86_64

Quoted 4 lines · Bin Meng
Quoted 3 lines · Simon Glass

We don't have a way of adjusting these at present so it is best to refuse to export these functions. This can be implemented later if the API is required.

Quoted 8 lines
Quoted 6 lines

---

 include/_exports.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

applied to u-boot-x86, thanks!

#63 lore raw

PATCH 29/82 x86: ivybridge: Add more debugging for failures

In reply to Simon Glass

Add various debug() messages in places where errors occur. This aids with debugging.

---

 arch/x86/cpu/ivybridge/cpu.c   |  4 +++-
 arch/x86/cpu/ivybridge/sdram.c | 36 +++++++++++++++++++++++++++---------
 2 files changed, 30 insertions(+), 10 deletions(-)
arch/x86/cpu/ivybridge/cpu.c +3 -1
index 85e361a..9d7c21d 100644
@@ -169,8 +169,10 @@ int print_cpuinfo(void)
 
 	/* Enable SPD ROMs and DDR-III DRAM */
 	ret = uclass_first_device_err(UCLASS_I2C, &dev);
-	if (ret)
+	if (ret) {
+		debug("%s: Failed to get I2C\n", __func__);
 		return ret;
+	}
 
 	/* Prepare USB controller early in S3 resume */
 	if (boot_mode == PEI_BOOT_RESUME) {
arch/x86/cpu/ivybridge/sdram.c +27 -9
index e0b06b5..eef6d78 100644
@@ -207,8 +207,10 @@ static int copy_spd(struct udevice *dev, struct pei_data *peid)
 	int ret;
 
 	ret = mrc_locate_spd(dev, sizeof(peid->spd_data[0]), &data);
-	if (ret)
+	if (ret) {
+		debug("%s: Could not locate SPD\n", __func__);
 		return ret;
+	}
 
 	memcpy(peid->spd_data[0], data, sizeof(peid->spd_data[0]));
 
@@ -460,18 +462,26 @@ int dram_init(void)
 
 	/* We need the pinctrl set up early */
 	ret = syscon_get_by_driver_data(X86_SYSCON_PINCONF, &dev);
-	if (ret)
+	if (ret) {
+		debug("%s: Could not get pinconf\n", __func__);
 		return ret;
+	}
 
 	ret = uclass_first_device_err(UCLASS_NORTHBRIDGE, &dev);
-	if (ret)
+	if (ret) {
+		debug("%s: Could not get northbridge\n", __func__);
 		return ret;
+	}
 	ret = syscon_get_by_driver_data(X86_SYSCON_ME, &me_dev);
-	if (ret)
+	if (ret) {
+		debug("%s: Could not get ME\n", __func__);
 		return ret;
+	}
 	ret = copy_spd(dev, pei_data);
-	if (ret)
+	if (ret) {
+		debug("%s: Could not get SPD\n", __func__);
 		return ret;
+	}
 	pei_data->boot_mode = gd->arch.pei_boot_mode;
 	debug("Boot mode %d\n", gd->arch.pei_boot_mode);
 	debug("mrc_input %p\n", pei_data->mrc_input);
@@ -498,19 +508,27 @@ int dram_init(void)
 
 	/* Wait for ME to be ready */
 	ret = intel_early_me_init(me_dev);
-	if (ret)
+	if (ret) {
+		debug("%s: Could not init ME\n", __func__);
 		return ret;
+	}
 	ret = intel_early_me_uma_size(me_dev);
-	if (ret < 0)
+	if (ret < 0) {
+		debug("%s: Could not get UMA size\n", __func__);
 		return ret;
+	}
 
 	ret = mrc_common_init(dev, pei_data, false);
-	if (ret)
+	if (ret) {
+		debug("%s: mrc_common_init() failed\n", __func__);
 		return ret;
+	}
 
 	ret = sdram_find(dev);
-	if (ret)
+	if (ret) {
+		debug("%s: sdram_find() failed\n", __func__);
 		return ret;
+	}
 	gd->ram_size = gd->arch.meminfo.total_32bit_memory;
 
 	debug("MRC output data length %#x at %p\n", pei_data->mrc_output_len,
Signature · 1 line
2.8.0.rc3.226.g39d4020
#64 lore raw

PATCH 29/82 x86: ivybridge: Add more debugging for failures

Hi Simon,

Quoted 96 lines · Simon Glass

Add various debug() messages in places where errors occur. This aids with debugging.

---

 arch/x86/cpu/ivybridge/cpu.c   |  4 +++-
 arch/x86/cpu/ivybridge/sdram.c | 36 +++++++++++++++++++++++++++---------
 2 files changed, 30 insertions(+), 10 deletions(-)
arch/x86/cpu/ivybridge/cpu.c +3 -1
index 85e361a..9d7c21d 100644
@@ -169,8 +169,10 @@ int print_cpuinfo(void)
 
        /* Enable SPD ROMs and DDR-III DRAM */
        ret = uclass_first_device_err(UCLASS_I2C, &dev);
-       if (ret)
+       if (ret) {
+               debug("%s: Failed to get I2C\n", __func__);
                return ret;
+       }
 
        /* Prepare USB controller early in S3 resume */
        if (boot_mode == PEI_BOOT_RESUME) {
arch/x86/cpu/ivybridge/sdram.c +24 -8
index e0b06b5..eef6d78 100644
@@ -207,8 +207,10 @@ static int copy_spd(struct udevice *dev, struct pei_data *peid)
        int ret;
 
        ret = mrc_locate_spd(dev, sizeof(peid->spd_data[0]), &data);
-       if (ret)
+       if (ret) {
+               debug("%s: Could not locate SPD\n", __func__);
                return ret;
+       }
 
        memcpy(peid->spd_data[0], data, sizeof(peid->spd_data[0]));
 
@@ -460,18 +462,26 @@ int dram_init(void)
 
        /* We need the pinctrl set up early */
        ret = syscon_get_by_driver_data(X86_SYSCON_PINCONF, &dev);
-       if (ret)
+       if (ret) {
+               debug("%s: Could not get pinconf\n", __func__);
                return ret;
+       }
 
        ret = uclass_first_device_err(UCLASS_NORTHBRIDGE, &dev);
-       if (ret)
+       if (ret) {
+               debug("%s: Could not get northbridge\n", __func__);
                return ret;
+       }
        ret = syscon_get_by_driver_data(X86_SYSCON_ME, &me_dev);
-       if (ret)
+       if (ret) {
+               debug("%s: Could not get ME\n", __func__);
                return ret;
+       }
        ret = copy_spd(dev, pei_data);
-       if (ret)
+       if (ret) {
+               debug("%s: Could not get SPD\n", __func__);
                return ret;
+       }
        pei_data->boot_mode = gd->arch.pei_boot_mode;
        debug("Boot mode %d\n", gd->arch.pei_boot_mode);
        debug("mrc_input %p\n", pei_data->mrc_input);
@@ -498,19 +508,27 @@ int dram_init(void)
 
        /* Wait for ME to be ready */
        ret = intel_early_me_init(me_dev);
-       if (ret)
+       if (ret) {
+               debug("%s: Could not init ME\n", __func__);
                return ret;
+       }
        ret = intel_early_me_uma_size(me_dev);
-       if (ret < 0)
+       if (ret < 0) {
+               debug("%s: Could not get UMA size\n", __func__);
                return ret;
+       }
 
        ret = mrc_common_init(dev, pei_data, false);
-       if (ret)
+       if (ret) {
+               debug("%s: mrc_common_init() failed\n", __func__);
                return ret;
+       }
 

arch/x86/cpu/ivybridge/sdram.c int dram_init(void)

Quoted 10 lines
arch/x86/cpu/ivybridge/sdram.c +3 -2
        ret = sdram_find(dev);
-       if (ret)
+       if (ret) {
+               debug("%s: sdram_find() failed\n", __func__);
                return ret;
+       }
        gd->ram_size = gd->arch.meminfo.total_32bit_memory;
 
        debug("MRC output data length %#x at %p\n", pei_data->mrc_output_len,
--

How about output the return value as well?

Regards,
Bin

#65 lore raw

PATCH 30/82 x86: ivybridge: Fix types for 64-bit compilation

In reply to Simon Glass

Fix a few types that causes warnings on 64-bit machines.

---

 arch/x86/cpu/ivybridge/gma.c  | 2 +-
 arch/x86/cpu/ivybridge/sata.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/cpu/ivybridge/gma.c +1 -1
index 59866bd..cf0c91d 100644
@@ -831,7 +831,7 @@ int gma_func0_init(struct udevice *dev)
 	mtrr_add_request(MTRR_TYPE_WRCOMB, base, 256 << 20);
 	mtrr_commit(true);
 
-	gtt_bar = (void *)dm_pci_read_bar32(dev, 0);
+	gtt_bar = (void *)(ulong)dm_pci_read_bar32(dev, 0);
 	debug("GT bar %p\n", gtt_bar);
 	ret = gma_pm_init_pre_vbios(gtt_bar, rev);
 	if (ret)
arch/x86/cpu/ivybridge/sata.c +2 -2
index 1ce8195..bf11d48 100644
@@ -54,7 +54,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)
 
 	mode = fdt_getprop(blob, node, "intel,sata-mode", NULL);
 	if (!mode || !strcmp(mode, "ahci")) {
-		u32 abar;
+		ulong abar;
 
 		debug("SATA: Controller in AHCI mode\n");
 
@@ -73,7 +73,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)
 
 		/* Initialize AHCI memory-mapped space */
 		abar = dm_pci_read_bar32(dev, 5);
-		debug("ABAR: %08X\n", abar);
+		debug("ABAR: %08lx\n", abar);
 		/* CAP (HBA Capabilities) : enable power management */
 		reg32 = readl(abar + 0x00);
 		reg32 |= 0x0c006000;  /* set PSC+SSC+SALP+SSS */
Signature · 1 line
2.8.0.rc3.226.g39d4020
#66 lore raw

PATCH 30/82 x86: ivybridge: Fix types for 64-bit compilation

Hi Simon,

Quoted 36 lines · Simon Glass

Fix a few types that causes warnings on 64-bit machines.

---

 arch/x86/cpu/ivybridge/gma.c  | 2 +-
 arch/x86/cpu/ivybridge/sata.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/cpu/ivybridge/gma.c +1 -1
index 59866bd..cf0c91d 100644
@@ -831,7 +831,7 @@ int gma_func0_init(struct udevice *dev)
        mtrr_add_request(MTRR_TYPE_WRCOMB, base, 256 << 20);
        mtrr_commit(true);
 
-       gtt_bar = (void *)dm_pci_read_bar32(dev, 0);
+       gtt_bar = (void *)(ulong)dm_pci_read_bar32(dev, 0);
        debug("GT bar %p\n", gtt_bar);
        ret = gma_pm_init_pre_vbios(gtt_bar, rev);
        if (ret)
arch/x86/cpu/ivybridge/sata.c +1 -1
index 1ce8195..bf11d48 100644
@@ -54,7 +54,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)
 
        mode = fdt_getprop(blob, node, "intel,sata-mode", NULL);
        if (!mode || !strcmp(mode, "ahci")) {
-               u32 abar;
+               ulong abar;
 
                debug("SATA: Controller in AHCI mode\n");
 

arch/x86/cpu/ivybridge/sata.c static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)

Quoted 9 lines
arch/x86/cpu/ivybridge/sata.c +1 -2
@@ -73,7 +73,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)
 
                /* Initialize AHCI memory-mapped space */
                abar = dm_pci_read_bar32(dev, 5);
-               debug("ABAR: %08X\n", abar);
+               debug("ABAR: %08lx\n", abar);
                /* CAP (HBA Capabilities) : enable power management */
                reg32 = readl(abar + 0x00);
                reg32 |= 0x0c006000;  /* set PSC+SSC+SALP+SSS */
--

This patch does not apply due to DM video conversion on Ivybridge.

Regards,
Bin

#67 lore raw

PATCH 31/82 x86: ivybridge: Fix PCH power setup

In reply to Simon Glass

At present pch_power_options() has the arguments to writel() around the wrong way. Fix this and update it to compile on 64-bit machines.

---

 arch/x86/cpu/ivybridge/lpc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/cpu/ivybridge/lpc.c +4 -4
index 0b4343a..c564713 100644
@@ -215,10 +215,10 @@ static int pch_power_options(struct udevice *pch)
 	dm_pci_read_config16(pch, 0x40, &pmbase);
 	pmbase &= 0xfffe;
 
-	writel(pmbase + GPE0_EN, fdtdec_get_int(blob, node,
-						"intel,gpe0-enable", 0));
-	writew(pmbase + ALT_GP_SMI_EN, fdtdec_get_int(blob, node,
-						"intel,alt-gp-smi-enable", 0));
+	writel(fdtdec_get_int(blob, node, "intel,gpe0-enable", 0),
+	       (ulong)pmbase + GPE0_EN);
+	writew(fdtdec_get_int(blob, node, "intel,alt-gp-smi-enable", 0),
+	       (ulong)pmbase + ALT_GP_SMI_EN);
 
 	/* Set up power management block and determine sleep mode */
 	reg32 = inl(pmbase + 0x04); /* PM1_CNT */
Signature · 1 line
2.8.0.rc3.226.g39d4020
#68 lore raw

PATCH 31/82 x86: ivybridge: Fix PCH power setup

Quoted 9 lines · Simon Glass

At present pch_power_options() has the arguments to writel() around the wrong way. Fix this and update it to compile on 64-bit machines.

---

 arch/x86/cpu/ivybridge/lpc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
#69 lore raw

PATCH 31/82 x86: ivybridge: Fix PCH power setup

Quoted 4 lines · Bin Meng
Quoted 3 lines · Simon Glass

At present pch_power_options() has the arguments to writel() around the wrong way. Fix this and update it to compile on 64-bit machines.

Quoted 8 lines
Quoted 6 lines

---

 arch/x86/cpu/ivybridge/lpc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

applied to u-boot-x86, thanks!

#70 lore raw

PATCH 32/82 x86: ivybridge: Tidy up enable_clock_gating() for 64-bit

In reply to Simon Glass

Fix the hex case and remove unused brackets. Use -0U instead of ~0UL to allow compilation on 64-bit machines.

---

 arch/x86/cpu/ivybridge/lpc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/cpu/ivybridge/lpc.c +4 -4
index c564713..aef1206 100644
@@ -357,10 +357,10 @@ static void enable_clock_gating(struct udevice *pch)
 	reg16 |= (1 << 2) | (1 << 11);
 	dm_pci_write_config16(pch, GEN_PMCON_1, reg16);
 
-	pch_iobp_update(pch, 0xEB007F07, ~0UL, (1 << 31));
-	pch_iobp_update(pch, 0xEB004000, ~0UL, (1 << 7));
-	pch_iobp_update(pch, 0xEC007F07, ~0UL, (1 << 31));
-	pch_iobp_update(pch, 0xEC004000, ~0UL, (1 << 7));
+	pch_iobp_update(pch, 0xeb007f07, ~0U, 1 << 31);
+	pch_iobp_update(pch, 0xeb004000, ~0U, 1 << 7);
+	pch_iobp_update(pch, 0xec007f07, ~0U, 1 << 31);
+	pch_iobp_update(pch, 0xec004000, ~0U, 1 << 7);
 
 	reg32 = readl(RCB_REG(CG));
 	reg32 |= (1 << 31);
Signature · 1 line
2.8.0.rc3.226.g39d4020
#71 lore raw

PATCH 32/82 x86: ivybridge: Tidy up enable_clock_gating() for 64-bit

Hi Simon,

Quoted 1 line · Simon Glass

Fix the hex case and remove unused brackets. Use -0U instead of ~0UL to

Should be: ~0U

Quoted 18 lines

allow compilation on 64-bit machines.

---

 arch/x86/cpu/ivybridge/lpc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/cpu/ivybridge/lpc.c +0 -2
index c564713..aef1206 100644
@@ -357,10 +357,10 @@ static void enable_clock_gating(struct udevice *pch)
        reg16 |= (1 << 2) | (1 << 11);
        dm_pci_write_config16(pch, GEN_PMCON_1, reg16);
 
-       pch_iobp_update(pch, 0xEB007F07, ~0UL, (1 << 31));
-       pch_iobp_update(pch, 0xEB004000, ~0UL, (1 << 7));

arch/x86/cpu/ivybridge/lpc.c static void enable_clock_gating(struct udevice *pch)

Quoted 10 lines
arch/x86/cpu/ivybridge/lpc.c +4 -3
-       pch_iobp_update(pch, 0xEC007F07, ~0UL, (1 << 31));
-       pch_iobp_update(pch, 0xEC004000, ~0UL, (1 << 7));
+       pch_iobp_update(pch, 0xeb007f07, ~0U, 1 << 31);
+       pch_iobp_update(pch, 0xeb004000, ~0U, 1 << 7);
+       pch_iobp_update(pch, 0xec007f07, ~0U, 1 << 31);
+       pch_iobp_update(pch, 0xec004000, ~0U, 1 << 7);
 
        reg32 = readl(RCB_REG(CG));
        reg32 |= (1 << 31);
--
#72 lore raw

PATCH 32/82 x86: ivybridge: Tidy up enable_clock_gating() for 64-bit

Quoted 6 lines · Bin Meng

Hi Simon,

Quoted 1 line · Simon Glass

Fix the hex case and remove unused brackets. Use -0U instead of ~0UL to

Should be: ~0U

Fixed this, and

Quoted 26 lines
Quoted 26 lines

allow compilation on 64-bit machines.

---

 arch/x86/cpu/ivybridge/lpc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/cpu/ivybridge/lpc.c +4 -4
index c564713..aef1206 100644
@@ -357,10 +357,10 @@ static void enable_clock_gating(struct udevice *pch)
        reg16 |= (1 << 2) | (1 << 11);
        dm_pci_write_config16(pch, GEN_PMCON_1, reg16);
 
-       pch_iobp_update(pch, 0xEB007F07, ~0UL, (1 << 31));
-       pch_iobp_update(pch, 0xEB004000, ~0UL, (1 << 7));
-       pch_iobp_update(pch, 0xEC007F07, ~0UL, (1 << 31));
-       pch_iobp_update(pch, 0xEC004000, ~0UL, (1 << 7));
+       pch_iobp_update(pch, 0xeb007f07, ~0U, 1 << 31);
+       pch_iobp_update(pch, 0xeb004000, ~0U, 1 << 7);
+       pch_iobp_update(pch, 0xec007f07, ~0U, 1 << 31);
+       pch_iobp_update(pch, 0xec004000, ~0U, 1 << 7);
 
Quoted 5 lines

arch/x86/cpu/ivybridge/lpc.c static void enable_clock_gating(struct udevice *pch)

Quoted 3 lines
arch/x86/cpu/ivybridge/lpc.c +0 -1
        reg32 = readl(RCB_REG(CG));
        reg32 |= (1 << 31);
--

applied to u-boot-x86, thanks!

#73 lore raw

PATCH 33/82 x86: dts: Mark serial as needed before relocation

In reply to Simon Glass

We almost always need the serial port before relocation, so mark it as such. This will ensure that it appears in the device tree for SPL, if used.

---

 arch/x86/dts/serial.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/x86/dts/serial.dtsi +1 -0
index 54c3faf..22f7b54 100644
@@ -1,5 +1,6 @@
 / {
 	serial: serial {
+		u-boot,dm-pre-reloc;
 		compatible = "ns16550";
 		reg = <0x3f8 8>;
 		reg-shift = <0>;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#74 lore raw

PATCH 33/82 x86: dts: Mark serial as needed before relocation

Hi Simon,

Quoted 14 lines · Simon Glass

We almost always need the serial port before relocation, so mark it as such. This will ensure that it appears in the device tree for SPL, if used.

---

 arch/x86/dts/serial.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/x86/dts/serial.dtsi +0 -0
index 54c3faf..22f7b54 100644

arch/x86/dts/serial.dtsi line 3

Quoted 3 lines
arch/x86/dts/serial.dtsi +1 -0
@@ -1,5 +1,6 @@
 / {
        serial: serial {
+               u-boot,dm-pre-reloc;

The ns16550 driver already has the pre-relocation flag, why is this still needed?

arch/x86/dts/serial.dtsi

Quoted 4 lines
arch/x86/dts/serial.dtsi +0 -1
                compatible = "ns16550";
                reg = <0x3f8 8>;
                reg-shift = <0>;
--

Regards,
Bin

#75 lore raw

PATCH 33/82 x86: dts: Mark serial as needed before relocation

Hi Bin,

Quoted 12 lines · Bin Meng

Hi Simon,

Quoted 9 lines · Simon Glass

We almost always need the serial port before relocation, so mark it as such. This will ensure that it appears in the device tree for SPL, if used.

---

 arch/x86/dts/serial.dtsi | 1 +
 1 file changed, 1 insertion(+)
Quoted 11 lines

arch/x86/dts/serial.dtsi line 3

Quoted 8 lines
arch/x86/dts/serial.dtsi +1 -0
index 54c3faf..22f7b54 100644
@@ -1,5 +1,6 @@
 / {
        serial: serial {
+               u-boot,dm-pre-reloc;

The ns16550 driver already has the pre-relocation flag, why is this still needed?

Without this, it will not appear in the SPL device tree (fdtgrep will drop it). So we need it here.

Quoted 5 lines

arch/x86/dts/serial.dtsi

Quoted 5 lines
arch/x86/dts/serial.dtsi +0 -1
                compatible = "ns16550";
                reg = <0x3f8 8>;
                reg-shift = <0>;
--

Regards,
Simon

#76 lore raw

PATCH 34/82 x86: fsp: Fix cast for 64-bit compilation

In reply to Simon Glass

Fix a cast in get_next_hob() that causes warnings on 64-bit machines.

---

 arch/x86/include/asm/fsp/fsp_hob.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/fsp/fsp_hob.h +1 -1
index 3fb3546..4a82f63 100644
@@ -139,7 +139,7 @@ struct hob_guid {
  */
 static inline const struct hob_header *get_next_hob(const struct hob_header *hdr)
 {
-	return (const struct hob_header *)((u32)hdr + hdr->len);
+	return (const struct hob_header *)((uintptr_t)hdr + hdr->len);
 }
 
 /**
Signature · 1 line
2.8.0.rc3.226.g39d4020
#77 lore raw

PATCH 34/82 x86: fsp: Fix cast for 64-bit compilation

Hi Simon,

Quoted 8 lines · Simon Glass

Fix a cast in get_next_hob() that causes warnings on 64-bit machines.

---

 arch/x86/include/asm/fsp/fsp_hob.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

What about get_guid_hob_data() in the same file? I think it will cause building warning too.

Regards,
Bin

#78 lore raw

PATCH 35/82 x86: Drop unused init_helper functions

In reply to Simon Glass

Drop init_bd_struct_r() which is no-longer used. Also drop the declaration for init_func_spi() since this is now handled by generic board init.

---

 arch/x86/include/asm/init_helpers.h |  2 --
 arch/x86/lib/init_helpers.c         | 10 ----------
 2 files changed, 12 deletions(-)
arch/x86/include/asm/init_helpers.h +0 -2
index c689a63..ef05ac4 100644
@@ -9,7 +9,5 @@
 #define _INIT_HELPERS_H_
 
 int init_cache_f_r(void);
-int init_bd_struct_r(void);
-int init_func_spi(void);
 
 #endif	/* !_INIT_HELPERS_H_ */
arch/x86/lib/init_helpers.c +0 -10
index bac671d..2a186fc 100644
@@ -30,13 +30,3 @@ int init_cache_f_r(void)
 	/* Initialise the CPU cache(s) */
 	return init_cache();
 }
-
-bd_t bd_data;
-
-int init_bd_struct_r(void)
-{
-	gd->bd = &bd_data;
-	memset(gd->bd, 0, sizeof(bd_t));
-
-	return 0;
-}
Signature · 1 line
2.8.0.rc3.226.g39d4020
#79 lore raw

PATCH 35/82 x86: Drop unused init_helper functions

Quoted 10 lines · Simon Glass

Drop init_bd_struct_r() which is no-longer used. Also drop the declaration for init_func_spi() since this is now handled by generic board init.

---

 arch/x86/include/asm/init_helpers.h |  2 --
 arch/x86/lib/init_helpers.c         | 10 ----------
 2 files changed, 12 deletions(-)
#80 lore raw

PATCH 35/82 x86: Drop unused init_helper functions

Quoted 7 lines · Bin Meng
Quoted 6 lines · Simon Glass

Drop init_bd_struct_r() which is no-longer used. Also drop the declaration for init_func_spi() since this is now handled by generic board init.

---

Quoted 6 lines
Quoted 4 lines
 arch/x86/include/asm/init_helpers.h |  2 --
 arch/x86/lib/init_helpers.c         | 10 ----------
 2 files changed, 12 deletions(-)

applied to u-boot-x86, thanks!

#81 lore raw

PATCH 36/82 x86: lib: Fix types and casts for 64-bit compilation

In reply to Simon Glass

Fix various compiler warnings in the x86 library code.

---

 arch/x86/lib/bios.c         | 4 ++--
 arch/x86/lib/pinctrl_ich6.c | 2 +-
 arch/x86/lib/pirq_routing.c | 4 ++--
 arch/x86/lib/sfi.c          | 4 ++--
 arch/x86/lib/zimage.c       | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)
arch/x86/lib/bios.c +2 -2
index 9324bdb..66d7629 100644
@@ -157,7 +157,7 @@ static void setup_realmode_idt(void)
 	 for (i = 0; i < 256; i++) {
 		idts[i].cs = 0;
 		idts[i].offset = 0x1000 + (i * __idt_handler_size);
-		write_idt_stub((void *)((u32)idts[i].offset), i);
+		write_idt_stub((void *)((ulong)idts[i].offset), i);
 	}
 
 	/*
@@ -227,7 +227,7 @@ static void vbe_set_graphics(int vesa_mode, struct vbe_mode_info *mode_info)
 	mode_info->video_mode = (1 << 14) | vesa_mode;
 	vbe_get_mode_info(mode_info);
 
-	framebuffer = (unsigned char *)mode_info->vesa.phys_base_ptr;
+	framebuffer = (unsigned char *)(ulong)mode_info->vesa.phys_base_ptr;
 	debug("VBE: resolution:  %dx%d@%d\n",
 	      le16_to_cpu(mode_info->vesa.x_resolution),
 	      le16_to_cpu(mode_info->vesa.y_resolution),
arch/x86/lib/pinctrl_ich6.c +1 -1
index 3f94cdf..fb2d294 100644
@@ -104,7 +104,7 @@ static int ich6_pinctrl_cfg_pin(s32 gpiobase, s32 iobase, int pin_node)
 
 	/* if iobase is present, let's configure the pad */
 	if (iobase != -1) {
-		int iobase_addr;
+		ulong iobase_addr;
 
 		/*
 		 * The offset for the same pin for the IOBASE and GPIOBASE are
arch/x86/lib/pirq_routing.c +2 -2
index a93d355..c98526d 100644
@@ -114,14 +114,14 @@ u32 copy_pirq_routing_table(u32 addr, struct irq_routing_table *rt)
 	addr = ALIGN(addr, 16);
 
 	debug("Copying Interrupt Routing Table to 0x%x\n", addr);
-	memcpy((void *)addr, rt, rt->size);
+	memcpy((void *)(uintptr_t)addr, rt, rt->size);
 
 	/*
 	 * We do the sanity check here against the copied table after memcpy,
 	 * as something might go wrong after the memcpy, which is normally
 	 * due to the F segment decode is not turned on to systeam RAM.
 	 */
-	rom_rt = (struct irq_routing_table *)addr;
+	rom_rt = (struct irq_routing_table *)(uintptr_t)addr;
 	if (rom_rt->signature != PIRQ_SIGNATURE ||
 	    rom_rt->version != PIRQ_VERSION || rom_rt->size % 16) {
 		printf("Interrupt Routing Table not valid\n");
arch/x86/lib/sfi.c +2 -2
index 9564853..507e037 100644
@@ -38,14 +38,14 @@ static void *get_entry_start(struct table_info *tab)
 	tab->table[tab->count] = tab->entry_start;
 	tab->entry_start += sizeof(struct sfi_table_header);
 
-	return (void *)tab->entry_start;
+	return (void *)(uintptr_t)tab->entry_start;
 }
 
 static void finish_table(struct table_info *tab, const char *sig, void *entry)
 {
 	struct sfi_table_header *hdr;
 
-	hdr = (struct sfi_table_header *)(tab->base + tab->ptr);
+	hdr = (struct sfi_table_header *)(uintptr_t)(tab->base + tab->ptr);
 	strcpy(hdr->sig, sig);
 	hdr->len = sizeof(*hdr) + ((ulong)entry - tab->entry_start);
 	hdr->rev = 1;
arch/x86/lib/zimage.c +1 -1
index 1b33c77..b6b0f2b 100644
@@ -165,7 +165,7 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
 		 * A very old kernel MUST have its real-mode code
 		 * loaded at 0x90000
 		 */
-		if ((u32)setup_base != 0x90000) {
+		if ((ulong)setup_base != 0x90000) {
 			/* Copy the real-mode kernel */
 			memmove((void *)0x90000, setup_base, setup_size);
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#82 lore raw

PATCH 36/82 x86: lib: Fix types and casts for 64-bit compilation

Hi Simon,

Quoted 39 lines · Simon Glass

Fix various compiler warnings in the x86 library code.

---

 arch/x86/lib/bios.c         | 4 ++--
 arch/x86/lib/pinctrl_ich6.c | 2 +-
 arch/x86/lib/pirq_routing.c | 4 ++--
 arch/x86/lib/sfi.c          | 4 ++--
 arch/x86/lib/zimage.c       | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)
arch/x86/lib/bios.c +2 -2
index 9324bdb..66d7629 100644
@@ -157,7 +157,7 @@ static void setup_realmode_idt(void)
         for (i = 0; i < 256; i++) {
                idts[i].cs = 0;
                idts[i].offset = 0x1000 + (i * __idt_handler_size);
-               write_idt_stub((void *)((u32)idts[i].offset), i);
+               write_idt_stub((void *)((ulong)idts[i].offset), i);
        }
 
        /*
@@ -227,7 +227,7 @@ static void vbe_set_graphics(int vesa_mode, struct vbe_mode_info *mode_info)
        mode_info->video_mode = (1 << 14) | vesa_mode;
        vbe_get_mode_info(mode_info);
 
-       framebuffer = (unsigned char *)mode_info->vesa.phys_base_ptr;
+       framebuffer = (unsigned char *)(ulong)mode_info->vesa.phys_base_ptr;
        debug("VBE: resolution:  %dx%d@%d\n",
              le16_to_cpu(mode_info->vesa.x_resolution),
              le16_to_cpu(mode_info->vesa.y_resolution),
arch/x86/lib/pinctrl_ich6.c +0 -0
index 3f94cdf..fb2d294 100644

arch/x86/lib/pinctrl_ich6.c static int ich6_pinctrl_cfg_pin(s32 gpiobase, s32 iobase, int pin_node) · line 110

Quoted 8 lines
arch/x86/lib/pinctrl_ich6.c +1 -1
@@ -104,7 +104,7 @@ static int ich6_pinctrl_cfg_pin(s32 gpiobase, s32 iobase, int pin_node)
 
        /* if iobase is present, let's configure the pad */
        if (iobase != -1) {
-               int iobase_addr;
+               ulong iobase_addr;
 
                /*
                 * The offset for the same pin for the IOBASE and GPIOBASE are
Quoted 47 lines
arch/x86/lib/pirq_routing.c +2 -2
index a93d355..c98526d 100644
@@ -114,14 +114,14 @@ u32 copy_pirq_routing_table(u32 addr, struct irq_routing_table *rt)
        addr = ALIGN(addr, 16);
 
        debug("Copying Interrupt Routing Table to 0x%x\n", addr);
-       memcpy((void *)addr, rt, rt->size);
+       memcpy((void *)(uintptr_t)addr, rt, rt->size);
 
        /*
         * We do the sanity check here against the copied table after memcpy,
         * as something might go wrong after the memcpy, which is normally
         * due to the F segment decode is not turned on to systeam RAM.
         */
-       rom_rt = (struct irq_routing_table *)addr;
+       rom_rt = (struct irq_routing_table *)(uintptr_t)addr;
        if (rom_rt->signature != PIRQ_SIGNATURE ||
            rom_rt->version != PIRQ_VERSION || rom_rt->size % 16) {
                printf("Interrupt Routing Table not valid\n");
arch/x86/lib/sfi.c +2 -2
index 9564853..507e037 100644
@@ -38,14 +38,14 @@ static void *get_entry_start(struct table_info *tab)
        tab->table[tab->count] = tab->entry_start;
        tab->entry_start += sizeof(struct sfi_table_header);
 
-       return (void *)tab->entry_start;
+       return (void *)(uintptr_t)tab->entry_start;
 }
 
 static void finish_table(struct table_info *tab, const char *sig, void *entry)
 {
        struct sfi_table_header *hdr;
 
-       hdr = (struct sfi_table_header *)(tab->base + tab->ptr);
+       hdr = (struct sfi_table_header *)(uintptr_t)(tab->base + tab->ptr);
        strcpy(hdr->sig, sig);
        hdr->len = sizeof(*hdr) + ((ulong)entry - tab->entry_start);
        hdr->rev = 1;
arch/x86/lib/zimage.c +0 -0
index 1b33c77..b6b0f2b 100644

arch/x86/lib/zimage.c struct boot_params *load_zimage(char *image, unsigned long kernel_size,

Quoted 9 lines
arch/x86/lib/zimage.c +1 -2
@@ -165,7 +165,7 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
                 * A very old kernel MUST have its real-mode code
                 * loaded at 0x90000
                 */
-               if ((u32)setup_base != 0x90000) {
+               if ((ulong)setup_base != 0x90000) {
                        /* Copy the real-mode kernel */
                        memmove((void *)0x90000, setup_base, setup_size);
 
--

Can the above 3 changes merged into patch#23: x86: Use unsigned long for address in table generation, since they are all table related changes?

Regards,
Bin

#83 lore raw

PATCH 37/82 x86: mrccache: Fix error handling in mrccache_get_region()

In reply to Simon Glass

This should return normal errors, not device-tree errors. Fix it.

---

 arch/x86/lib/mrccache.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/x86/lib/mrccache.c +5 -3
index 67bace4..eca88ac 100644
@@ -198,11 +198,13 @@ int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)
 
 	/* Find the flash chip within the SPI controller node */
 	node = fdtdec_next_compatible(blob, 0, COMPAT_GENERIC_SPI_FLASH);
-	if (node < 0)
+	if (node < 0) {
+		debug("%s: Cannot find SPI flash\n", __func__);
 		return -ENOENT;
+	}
 
 	if (fdtdec_get_int_array(blob, node, "memory-map", reg, 2))
-		return -FDT_ERR_NOTFOUND;
+		return -EINVAL;
 	entry->base = reg[0];
 
 	/* Find the place where we put the MRC cache */
@@ -211,7 +213,7 @@ int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)
 		return -EPERM;
 
 	if (fdtdec_get_int_array(blob, mrc_node, "reg", reg, 2))
-		return -FDT_ERR_NOTFOUND;
+		return -EINVAL;
 	entry->offset = reg[0];
 	entry->length = reg[1];
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#84 lore raw

PATCH 37/82 x86: mrccache: Fix error handling in mrccache_get_region()

Quoted 29 lines · Simon Glass

This should return normal errors, not device-tree errors. Fix it.

---

 arch/x86/lib/mrccache.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/x86/lib/mrccache.c +4 -2
index 67bace4..eca88ac 100644
@@ -198,11 +198,13 @@ int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)
 
        /* Find the flash chip within the SPI controller node */
        node = fdtdec_next_compatible(blob, 0, COMPAT_GENERIC_SPI_FLASH);
-       if (node < 0)
+       if (node < 0) {
+               debug("%s: Cannot find SPI flash\n", __func__);
                return -ENOENT;
+       }
 
        if (fdtdec_get_int_array(blob, node, "memory-map", reg, 2))
-               return -FDT_ERR_NOTFOUND;
+               return -EINVAL;
        entry->base = reg[0];
 
        /* Find the place where we put the MRC cache */

arch/x86/lib/mrccache.c int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)

Quoted 9 lines
arch/x86/lib/mrccache.c +1 -2
@@ -211,7 +213,7 @@ int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)
                return -EPERM;
 
        if (fdtdec_get_int_array(blob, mrc_node, "reg", reg, 2))
-               return -FDT_ERR_NOTFOUND;
+               return -EINVAL;
        entry->offset = reg[0];
        entry->length = reg[1];
 
--
#85 lore raw

PATCH 37/82 x86: mrccache: Fix error handling in mrccache_get_region()

Quoted 38 lines · Bin Meng
Quoted 37 lines · Simon Glass

This should return normal errors, not device-tree errors. Fix it.

---

 arch/x86/lib/mrccache.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/x86/lib/mrccache.c +5 -3
index 67bace4..eca88ac 100644
@@ -198,11 +198,13 @@ int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)
 
        /* Find the flash chip within the SPI controller node */
        node = fdtdec_next_compatible(blob, 0, COMPAT_GENERIC_SPI_FLASH);
-       if (node < 0)
+       if (node < 0) {
+               debug("%s: Cannot find SPI flash\n", __func__);
                return -ENOENT;
+       }
 
        if (fdtdec_get_int_array(blob, node, "memory-map", reg, 2))
-               return -FDT_ERR_NOTFOUND;
+               return -EINVAL;
        entry->base = reg[0];
 
        /* Find the place where we put the MRC cache */
@@ -211,7 +213,7 @@ int mrccache_get_region(struct udevice **devp, struct mrc_region *entry)
                return -EPERM;
 
        if (fdtdec_get_int_array(blob, mrc_node, "reg", reg, 2))
-               return -FDT_ERR_NOTFOUND;
+               return -EINVAL;
        entry->offset = reg[0];
        entry->length = reg[1];
 
Quoted 3 lines
Quoted 1 line

--

applied to u-boot-x86, thanks!

#86 lore raw

PATCH 38/82 x86: Add Kconfig options to build 64-bit U-Boot

In reply to Simon Glass

Add a new CONFIG_X86_64 option which will eventually cause U-Boot to be built as a 64-bit application, with SPL doing the 16/32-bit init.

---

 arch/x86/Kconfig | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
arch/x86/Kconfig +46 -0
index 5193ee7..0505f97 100644
@@ -5,6 +5,52 @@ config SYS_ARCH
 	default "x86"
 
 choice
+	prompt "Run U-Boot in 32/64-bit mode"
+	default X86_RUN_32BIT
+	help
+	  U-Boot can be built as a 32-bit binary which runs in 32-bit mode
+	  even on 64-bit machines. In this case SPL is not used, and U-Boot
+	  runs directly from the reset vector (via 16-bit start-up).
+
+	  Alternatively it can be run as a 64-bit binary, thus requiring a
+	  64-bit machine. In this case SPL runs in 32-bit mode (via 16-bit
+	  start-up) then jumps to U-Boot in 64-bit mode.
+
+	  For now, 32-bit mode is recommended, as 64-bit is still
+	  experimental and is missing a lot of features.
+
+config X86_RUN_32BIT
+	bool "32-bit"
+        help
+	  Build U-Boot as a 32-bit binary with no SPL. This is the currently
+	  supported normal setup. U-Boot will stay in 32-bit mode even on
+	  64-bit machines. When booting a 64-bit kernel, U-Boot will switch
+	  to 64-bit just before starting the kernel. Only the bottom 4GB of
+	  memory can be accessed through normal means, although
+	  arch_phys_memset() can be used for basic access to other memory.
+
+config X86_RUN_64BIT
+	bool "64-bit"
+	select X86_64
+	select SUPPORT_SPL
+	select SPL
+	select SPL_SEPARATE_BSS
+	help
+	  Build U-Boot as a 64-bit binary with a 32-bit SPL. This is
+	  experimental and many features are missing. U-Boot SPL starts up,
+	  runs through the 16-bit and 32-bit init, then switches to 64-bit
+	  mode and jumps to U-Boot proper.
+
+endchoice
+
+config X86_64
+	bool
+
+config SPL_X86_64
+	bool
+	depends on SPL
+
+choice
 	prompt "Mainboard vendor"
 	default VENDOR_EMULATION
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#87 lore raw

PATCH 39/82 x86: Kconfig: Add location options for 16/32-bit init

In reply to Simon Glass

At present all 16/32-bit init is controlled by CONFIG_X86_RESET_VECTOR. If this is enabled, then U-Boot is the 'first' boot loader and handles execution from the reset vector through to U-Boot's command prompt. If it is not enabled then U-Boot starts at the 32-bit entry and skips most of its init, assuming that the previous boot loader has done this already.

With the move to suport 64-bit operation, we have more cases to consider. The 16-bit and 32-bit init may be in SPL rather than in U-Boot proper.

Add Kconfig options which control the location of the 16-bit and the 32-bit init. These are not intended to be user-setting except for experimentation. Their values should be determined by whether 64-bit U-Boot is used.

---

 arch/x86/Kconfig | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
arch/x86/Kconfig +39 -0
index 0505f97..24d8f4f 100644
@@ -135,6 +135,45 @@ config X86_RESET_VECTOR
 	bool
 	default n
 
+# The following options control where the 16-bit and 32-bit init lies
+# If SPL is enabled then it normally holds this init code, and U-Boot proper
+# is normally a 64-bit build.
+#
+# The 16-bit init refers to the reset vector and the small amount of code to
+# get the processor into 32-bit mode. It may be in SPL or in U-Boot proper,
+# or missing altogether if U-Boot is started from EFI or coreboot.
+#
+# The 32-bit init refers to processor init, running binary blobs including
+# FSP, setting up interrupts and anything else that needs to be done in
+# 32-bit code. It is normally in the same place as 32-bit init.
+config X86_16BIT_INIT
+	bool
+	depends on X86_RESET_VECTOR
+	default y if X86_RESET_VECTOR && !SPL
+	help
+	  This is enabled when 16-bit init is in U-Boot proper
+
+config SPL_X86_16BIT_INIT
+	bool
+	depends on X86_RESET_VECTOR
+	default y if X86_RESET_VECTOR && SPL
+	help
+	  This is enabled when 16-bit init is in SPL
+
+config X86_32BIT_INIT
+	bool
+	depends on X86_RESET_VECTOR
+	default y if X86_RESET_VECTOR && !SPL
+	help
+	  This is enabled when 32-bit init is in U-Boot proper
+
+config SPL_X86_32BIT_INIT
+	bool
+	depends on X86_RESET_VECTOR
+	default y if X86_RESET_VECTOR && SPL
+	help
+	  This is enabled when 32-bit init is in SPL
+
 config RESET_SEG_START
 	hex
 	depends on X86_RESET_VECTOR
Signature · 1 line
2.8.0.rc3.226.g39d4020
#88 lore raw

PATCH 40/82 x86: Use X86_16BIT_INIT instead of X86_RESET_VECTOR

In reply to Simon Glass

Use this new option to control the location of 16-bit init. This will allow us to place this in SPL if needed.

---

 Makefile                | 7 ++++---
 arch/x86/Makefile       | 6 ++----
 arch/x86/cpu/Makefile   | 2 +-
 arch/x86/cpu/u-boot.lds | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)
Makefile +4 -3
index 64aab44..cc39128 100644
@@ -863,7 +863,7 @@ u-boot.hex u-boot.srec: u-boot FORCE
 	$(call if_changed,objcopy)
 
 OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \
-		$(if $(CONFIG_X86_RESET_VECTOR),-R .start16 -R .resetvec)
+		$(if $(CONFIG_X86_16BIT_INIT),-R .start16 -R .resetvec)
 
 binary_size_check: u-boot-nodtb.bin FORCE
 	@file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print $$1}') ; \
@@ -1072,8 +1072,9 @@ quiet_cmd_ldr = LD      $@
 cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \
 	       $(filter-out FORCE,$^) -o $@
 
-u-boot.rom: u-boot-x86-16bit.bin u-boot.bin FORCE \
-		$(if $(CONFIG_HAVE_REFCODE),refcode.bin)
+u-boot.rom: u-boot-x86-16bit.bin u-boot.bin \
+		$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
+		$(if $(CONFIG_HAVE_REFCODE),refcode.bin) FORCE
 	$(call if_changed,binman)
 
 OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec
arch/x86/Makefile +2 -4
index d104a49..dd0e22f 100644
@@ -5,10 +5,8 @@
 ifeq ($(CONFIG_EFI_APP),)
 head-y := arch/x86/cpu/start.o
 endif
-ifeq ($(CONFIG_SPL_BUILD),y)
-head-y += arch/x86/cpu/start16.o
-head-y += arch/x86/cpu/resetvec.o
-endif
+head-$(CONFIG_$(SPL_)X86_16BIT_INIT) += arch/x86/cpu/start16.o
+head-$(CONFIG_$(SPL_)X86_16BIT_INIT) += arch/x86/cpu/resetvec.o
 
 libs-y += arch/x86/cpu/
 libs-y += arch/x86/lib/
arch/x86/cpu/Makefile +1 -1
index f5b8c9e..fd81310 100644
@@ -9,7 +9,7 @@
 #
 
 extra-y	= start.o
-obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
+extra-$(CONFIG_$(SPL_)X86_16BIT_INIT) += resetvec.o start16.o
 obj-y	+= interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
arch/x86/cpu/u-boot.lds +1 -1
index cca536b..186718d 100644
@@ -103,7 +103,7 @@ SECTIONS
 	/DISCARD/ : { *(.interp*) }
 	/DISCARD/ : { *(.gnu*) }
 
-#ifdef CONFIG_X86_RESET_VECTOR
+#ifdef CONFIG_X86_16BIT_INIT
 	/*
 	 * The following expressions place the 16-bit Real-Mode code and
 	 * Reset Vector at the end of the Flash ROM
Signature · 1 line
2.8.0.rc3.226.g39d4020
#89 lore raw

PATCH 41/82 x86: Use X86_32BIT_INIT instead of X86_RESET_VECTOR

In reply to Simon Glass

Use this new option to control the location of 32-bit init. This will allow us to place this in SPL if needed.

---

 arch/x86/cpu/intel_common/Makefile | 10 ++++++----
 arch/x86/lib/init_helpers.c        |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
arch/x86/cpu/intel_common/Makefile +6 -4
index 804c539..1145e78 100644
@@ -4,13 +4,15 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_HAVE_MRC) += car.o
+ifdef CONFIG_HAVE_MRC
+obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += car.o
+obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += me_status.o
+obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += report_platform.o
+obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += mrc.o
+endif
 obj-y += cpu.o
 obj-y += lpc.o
-obj-$(CONFIG_HAVE_MRC) += me_status.o
 ifndef CONFIG_TARGET_EFI
 obj-y += microcode.o
 endif
 obj-y += pch.o
-obj-$(CONFIG_HAVE_MRC) += report_platform.o
-obj-$(CONFIG_HAVE_MRC) += mrc.o
arch/x86/lib/init_helpers.c +1 -1
index 2a186fc..420393b 100644
@@ -19,7 +19,7 @@ __weak ulong board_get_usable_ram_top(ulong total_size)
 
 int init_cache_f_r(void)
 {
-#if defined(CONFIG_X86_RESET_VECTOR) & !defined(CONFIG_HAVE_FSP)
+#if CONFIG_IS_ENABLED(X86_32BIT_INIT) && !defined(CONFIG_HAVE_FSP)
 	int ret;
 
 	ret = mtrr_commit(false);
Signature · 1 line
2.8.0.rc3.226.g39d4020
#90 lore raw

PATCH 42/82 x86: ivybridge: Allow 32-bit init to move to SPL

In reply to Simon Glass

Update the Makefile so that some 32-bit init can be built into SPL rather than U-Boot proper.

---

 arch/x86/cpu/ivybridge/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/cpu/ivybridge/Makefile +2 -2
index 9cdb07b..a853e45 100644
@@ -7,13 +7,13 @@
 ifdef CONFIG_HAVE_FSP
 obj-y += fsp_configs.o ivybridge.o
 else
-obj-y += cpu.o
+obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += cpu.o
 obj-y += early_me.o
 obj-y += gma.o
 obj-y += lpc.o
 obj-y += model_206ax.o
 obj-y += northbridge.o
 obj-y += sata.o
-obj-y += sdram.o
+obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += sdram.o
 endif
 obj-y += bd82x6x.o
Signature · 1 line
2.8.0.rc3.226.g39d4020
#91 lore raw

PATCH 43/82 x86: Add 64-bit start-up code

In reply to Simon Glass

Add code to start up U-Boot in 64-bit mode. It is fairly simple since we are running from RAM and SPL has done the low-level init.

---

 arch/x86/Makefile      |  5 +++++
 arch/x86/cpu/Makefile  |  4 ++++
 arch/x86/cpu/start64.S | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)
 create mode 100644 arch/x86/cpu/start64.S
arch/x86/Makefile +5 -0
index dd0e22f..4be1c35 100644
@@ -3,8 +3,13 @@
 #
 
 ifeq ($(CONFIG_EFI_APP),)
+ifdef CONFIG_$(SPL_)X86_64
+head-y := arch/x86/cpu/start64.o
+else
 head-y := arch/x86/cpu/start.o
 endif
+endif
+
 head-$(CONFIG_$(SPL_)X86_16BIT_INIT) += arch/x86/cpu/start16.o
 head-$(CONFIG_$(SPL_)X86_16BIT_INIT) += arch/x86/cpu/resetvec.o
 
arch/x86/cpu/Makefile +4 -0
index fd81310..97b26b0 100644
@@ -8,7 +8,11 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+ifeq ($(CONFIG_$(SPL_)X86_64),y)
+extra-y	= start64.o
+else
 extra-y	= start.o
+endif
 extra-$(CONFIG_$(SPL_)X86_16BIT_INIT) += resetvec.o start16.o
 obj-y	+= interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
 
arch/x86/cpu/start64.S new file +39 -0
new file mode 100644
index 0000000..9eadc35
@@ -0,0 +1,39 @@
+/*
+ * 64-bit x86 Startup Code
+ *
+ * (C) Copyright 216 Google, Inc
+ * Written by Simon Glass <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <config.h>
+#include <asm/global_data.h>
+#include <asm/post.h>
+#include <asm/processor.h>
+#include <asm/processor-flags.h>
+#include <generated/generic-asm-offsets.h>
+#include <generated/asm-offsets.h>
+
+.section .text
+.code64
+.globl _start
+.type _start, @function
+_start:
+	/* Set up memory using the existing stack */
+	mov	%rsp, %rdi
+	call	board_init_f_alloc_reserve
+	mov	%rax, %rsp
+
+	call	board_init_f_init_reserve
+
+	callq	board_init_f
+	callq	board_init_f_r
+
+	/* Should not return here */
+	jmp	.
+
+	/* If the debug UART is being used, it is already set up by SPL */
+	.globl board_debug_uart_init
+board_debug_uart_init:
+	ret
Signature · 1 line
2.8.0.rc3.226.g39d4020
#92 lore raw

PATCH 44/82 x86: board_f: Update init sequence for 64-bit startup

In reply to Simon Glass

Adjust the code so that 64-bit startup works. Since we don't need to do CAR changes in U-Boot proper anymore (they are done in SPL) we can simplify the flow and return normally from board_init_f().

---

 common/board_f.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
common/board_f.c +8 -4
index e3179a1..28a63a6 100644
@@ -767,7 +767,8 @@ static int setup_reloc(void)
 }
 
 /* ARM calls relocate_code from its crt0.S */
-#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
+		!CONFIG_IS_ENABLED(X86_64)
 
 static int jump_to_copy(void)
 {
@@ -1045,7 +1046,8 @@ static init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_XTENSA)
 	clear_bss,
 #endif
-#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
+		!CONFIG_IS_ENABLED(X86_64)
 	jump_to_copy,
 #endif
 	NULL,
@@ -1079,7 +1081,7 @@ void board_init_f(ulong boot_flags)
 		hang();
 
 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
-		!defined(CONFIG_EFI_APP)
+		!defined(CONFIG_EFI_APP) && !CONFIG_IS_ENABLED(X86_64)
 	/* NOTREACHED - jump_to_copy() does not return */
 	hang();
 #endif
@@ -1103,8 +1105,10 @@ void board_init_f(ulong boot_flags)
  * NOTE: At present only x86 uses this route, but it is intended that
  * all archs will move to this when generic relocation is implemented.
  */
-static init_fnc_t init_sequence_f_r[] = {
+static const init_fnc_t init_sequence_f_r[] = {
+#if !CONFIG_IS_ENABLED(X86_64)
 	init_cache_f_r,
+#endif
 
 	NULL,
 };
Signature · 1 line
2.8.0.rc3.226.g39d4020
#93 lore raw

PATCH 45/82 x86: board_r: Set the global data pointer after relocation

In reply to Simon Glass

Since 'gd' is just a normal variable on 64-bit x86, it is relocated by the time we get to board_init_r(). The old 'gd' variable is passed in as parameter to board_init_r(), presumably for this situation.

Assign it on 64-bit x86 so that gd points to the correct data.

Options to improve this:
- Make gd a fixed register and remove the board_init_r() parameter
- Make all archs use this board_init_r() parameter

---

 common/board_r.c | 5 +++++
 1 file changed, 5 insertions(+)
common/board_r.c +5 -0
index d959ad3..02800ca 100644
@@ -974,6 +974,11 @@ init_fnc_t init_sequence_r[] = {
 
 void board_init_r(gd_t *new_gd, ulong dest_addr)
 {
+	/* Set up the new global data pointer */
+#if CONFIG_IS_ENABLED(X86_64)
+	arch_setup_gd(new_gd);
+#endif
+
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
 	int i;
 #endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
#94 lore raw

PATCH 46/82 x86: Do relocation before clearing BSS

In reply to Simon Glass

The BSS region may overlap with relocations. If we clear BSS we will overwrite the start of the relocation area. This doesn't matter when running from SPI flash, since it is read-only. But when relocating 64-bit U-Boot from one place in RAM to another, relocation will fail because some of its relocations have been zeroed.

To fix this, put the ELF fixup call before the BSS clearing call.

---

 common/board_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/board_f.c +1 -1
index 28a63a6..a06578c 100644
@@ -1040,8 +1040,8 @@ static init_fnc_t init_sequence_f[] = {
 	setup_reloc,
 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
 	copy_uboot_to_ram,
-	clear_bss,
 	do_elf_reloc_fixups,
+	clear_bss,
 #endif
 #if defined(CONFIG_XTENSA)
 	clear_bss,
Signature · 1 line
2.8.0.rc3.226.g39d4020
#95 lore raw

PATCH 47/82 x86: Refactor relocation to prepare for 64-bit

In reply to Simon Glass

Move the core relocation code into a separate function so that the checking code can be used for 64-bit relocation also.

---

 arch/x86/lib/relocate.c | 57 ++++++++++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 24 deletions(-)
arch/x86/lib/relocate.c +33 -24
index 0d683bf..21cd1db 100644
@@ -47,38 +47,18 @@ int clear_bss(void)
 	return 0;
 }
 
-/*
- * This function has more error checking than you might expect. Please see
- * the commit message for more informaiton.
- */
-int do_elf_reloc_fixups(void)
+static void do_elf_reloc_fixups32(unsigned int text_base, uintptr_t size,
+				  Elf32_Rel *re_src, Elf32_Rel *re_end)
 {
-	Elf32_Rel *re_src = (Elf32_Rel *)(&__rel_dyn_start);
-	Elf32_Rel *re_end = (Elf32_Rel *)(&__rel_dyn_end);
-
 	Elf32_Addr *offset_ptr_rom, *last_offset = NULL;
 	Elf32_Addr *offset_ptr_ram;
-	unsigned int text_base = 0;
-
-	/* The size of the region of u-boot that runs out of RAM. */
-	uintptr_t size = (uintptr_t)&__bss_end - (uintptr_t)&__text_start;
-
-	if (gd->flags & GD_FLG_SKIP_RELOC)
-		return 0;
-	if (re_src == re_end)
-		panic("No relocation data");
 
-#ifdef CONFIG_SYS_TEXT_BASE
-	text_base = CONFIG_SYS_TEXT_BASE;
-#else
-	panic("No CONFIG_SYS_TEXT_BASE");
-#endif
 	do {
 		/* Get the location from the relocation entry */
-		offset_ptr_rom = (Elf32_Addr *)re_src->r_offset;
+		offset_ptr_rom = (Elf32_Addr *)(uintptr_t)re_src->r_offset;
 
 		/* Check that the location of the relocation is in .text */
-		if (offset_ptr_rom >= (Elf32_Addr *)text_base &&
+		if (offset_ptr_rom >= (Elf32_Addr *)(uintptr_t)text_base &&
 		    offset_ptr_rom > last_offset) {
 
 			/* Switch to the in-RAM version */
@@ -103,6 +83,35 @@ int do_elf_reloc_fixups(void)
 		last_offset = offset_ptr_rom;
 
 	} while (++re_src < re_end);
+}
+
+/*
+ * This function has more error checking than you might expect. Please see
+ * the commit message for more informaiton.
+ */
+int do_elf_reloc_fixups(void)
+{
+	void *re_src = (void *)(&__rel_dyn_start);
+	void *re_end = (void *)(&__rel_dyn_end);
+	uint text_base;
+
+	/* The size of the region of u-boot that runs out of RAM. */
+	uintptr_t size = (uintptr_t)&__bss_end - (uintptr_t)&__text_start;
+
+	if (gd->flags & GD_FLG_SKIP_RELOC)
+		return 0;
+	if (re_src == re_end) {
+		printf("No relocation data %p %p", re_src, re_end);
+		while (1);
+		panic("No relocation data");
+	}
+
+#ifdef CONFIG_SYS_TEXT_BASE
+	text_base = CONFIG_SYS_TEXT_BASE;
+#else
+	panic("No CONFIG_SYS_TEXT_BASE");
+#endif
+	do_elf_reloc_fixups32(text_base, size, re_src, re_end);
 
 	return 0;
 }
Signature · 1 line
2.8.0.rc3.226.g39d4020
#96 lore raw

PATCH 48/82 x86: Add support for 64-bit relocation

In reply to Simon Glass

Add a 64-bit relocation function. SPL loads U-Boot into RAM at a fixed address and runs it. U-Boot then relocates itself to the top of RAM using this relocation function.

---

 arch/x86/lib/relocate.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
arch/x86/lib/relocate.c +45 -0
index 21cd1db..bac2fb6 100644
@@ -47,6 +47,46 @@ int clear_bss(void)
 	return 0;
 }
 
+#if CONFIG_IS_ENABLED(X86_64)
+static void do_elf_reloc_fixups64(unsigned int text_base, uintptr_t size,
+				  Elf64_Rela *re_src, Elf64_Rela *re_end)
+{
+	Elf64_Addr *offset_ptr_rom, *last_offset = NULL;
+	Elf64_Addr *offset_ptr_ram;
+
+	do {
+		/* Get the location from the relocation entry */
+		offset_ptr_rom = (Elf64_Addr *)(uintptr_t)re_src->r_offset;
+
+		/* Check that the location of the relocation is in .text */
+		if (offset_ptr_rom >= (Elf64_Addr *)(uintptr_t)text_base &&
+		    offset_ptr_rom > last_offset) {
+			/* Switch to the in-RAM version */
+			offset_ptr_ram = (Elf64_Addr *)((ulong)offset_ptr_rom +
+							gd->reloc_off);
+
+			/* Check that the target points into .text */
+			if (*offset_ptr_ram >= text_base &&
+			    *offset_ptr_ram <= text_base + size) {
+				*offset_ptr_ram = gd->reloc_off +
+							re_src->r_addend;
+			} else {
+				debug("   %p: %lx: rom reloc %lx, ram %p, value %lx, limit %"
+				      PRIXPTR "\n",
+				      re_src, (ulong)re_src->r_info,
+				      (ulong)re_src->r_offset, offset_ptr_ram,
+				      (ulong)*offset_ptr_ram, text_base + size);
+			}
+		} else {
+			debug("   %p: %lx: rom reloc %lx, last %p\n", re_src,
+			      (ulong)re_src->r_info, (ulong)re_src->r_offset,
+			      last_offset);
+		}
+		last_offset = offset_ptr_rom;
+
+	} while (++re_src < re_end);
+}
+#else
 static void do_elf_reloc_fixups32(unsigned int text_base, uintptr_t size,
 				  Elf32_Rel *re_src, Elf32_Rel *re_end)
 {
@@ -84,6 +124,7 @@ static void do_elf_reloc_fixups32(unsigned int text_base, uintptr_t size,
 
 	} while (++re_src < re_end);
 }
+#endif
 
 /*
  * This function has more error checking than you might expect. Please see
@@ -111,7 +152,11 @@ int do_elf_reloc_fixups(void)
 #else
 	panic("No CONFIG_SYS_TEXT_BASE");
 #endif
+#if CONFIG_IS_ENABLED(X86_64)
+	do_elf_reloc_fixups64(text_base, size, re_src, re_end);
+#else
 	do_elf_reloc_fixups32(text_base, size, re_src, re_end);
+#endif
 
 	return 0;
 }
Signature · 1 line
2.8.0.rc3.226.g39d4020
#97 lore raw

PATCH 49/82 x86: Tidy up use of size_t in relocation

In reply to Simon Glass

Addresses should not be cast to size_t. Use uintptr_t instead.

---

 arch/x86/lib/relocate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/lib/relocate.c +2 -2
index bac2fb6..ad47c7e 100644
@@ -26,7 +26,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int copy_uboot_to_ram(void)
 {
-	size_t len = (size_t)&__data_end - (size_t)&__text_start;
+	size_t len = (uintptr_t)&__data_end - (uintptr_t)&__text_start;
 
 	if (gd->flags & GD_FLG_SKIP_RELOC)
 		return 0;
@@ -38,7 +38,7 @@ int copy_uboot_to_ram(void)
 int clear_bss(void)
 {
 	ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
-	size_t len = (size_t)&__bss_end - (size_t)&__bss_start;
+	size_t len = (uintptr_t)&__bss_end - (uintptr_t)&__bss_start;
 
 	if (gd->flags & GD_FLG_SKIP_RELOC)
 		return 0;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#98 lore raw

PATCH 50/82 x86: Add an SPL implementation

In reply to Simon Glass

SPL needs to set up the machine ready for loading 64-bit U-Boot and jumping to it. Call the existing init routines in order to accomplish this.

---

 arch/x86/include/asm/spl.h |   8 +++
 arch/x86/lib/Makefile      |   3 +
 arch/x86/lib/spl.c         | 149 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+)
 create mode 100644 arch/x86/include/asm/spl.h
 create mode 100644 arch/x86/lib/spl.c
arch/x86/include/asm/spl.h new file +8 -0
new file mode 100644
index 0000000..a8bce98
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2014 Google, Inc
+ * Written by Simon Glass <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * This file is required for SPL to build, but is empty.
+ */
arch/x86/lib/Makefile +3 -0
index 1d9ebc0..1fa7f90 100644
@@ -12,7 +12,9 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y	+= cmd_boot.o
 obj-$(CONFIG_SEABIOS) += coreboot_table.o
 obj-$(CONFIG_EFI) += efi/
+ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_CMD_BOOTEFI_HELLO) += HelloWorld32.o
+endif
 obj-y	+= e820.o
 obj-y	+= gcc.o
 obj-y	+= init_helpers.o
@@ -39,6 +41,7 @@ endif
 obj-y	+= tables.o
 obj-$(CONFIG_CMD_ZBOOT)	+= zimage.o
 obj-$(CONFIG_HAVE_FSP) += fsp/
+obj-$(CONFIG_SPL_BUILD) += spl.o
 
 extra-$(CONFIG_USE_PRIVATE_LIBGCC) += lib.a
 
arch/x86/lib/spl.c new file +149 -0

149 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3.226.g39d4020
#99 lore raw

PATCH 51/82 x86: Move the i386 code into its own directory

In reply to Simon Glass

Much of the cpu and interrupt code cannot be compiled on 64-bit x86. Move it into its own directory and build it only in 32-bit mode.

---

 arch/x86/cpu/Makefile                           |   6 +-
 arch/x86/cpu/cpu.c                              | 504 ----------------------
 arch/x86/cpu/i386/Makefile                      |   7 +
 arch/x86/cpu/i386/cpu.c                         | 534 ++++++++++++++++++++++++
 arch/x86/cpu/{interrupts.c => i386/interrupt.c} |   4 -
 arch/x86/include/asm/mp.h                       |   3 +
 6 files changed, 549 insertions(+), 509 deletions(-)
 create mode 100644 arch/x86/cpu/i386/Makefile
 create mode 100644 arch/x86/cpu/i386/cpu.c
 rename arch/x86/cpu/{interrupts.c => i386/interrupt.c} (99%)
arch/x86/cpu/Makefile +5 -1
index 97b26b0..41ad481 100644
@@ -14,7 +14,7 @@ else
 extra-y	= start.o
 endif
 extra-$(CONFIG_$(SPL_)X86_16BIT_INIT) += resetvec.o start16.o
-obj-y	+= interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
+obj-y	+= cpu.o cpu_x86.o call64.o setjmp.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
 	$(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
@@ -37,3 +37,7 @@ obj-y += mtrr.o
 obj-$(CONFIG_PCI) += pci.o
 obj-$(CONFIG_SMP) += sipi_vector.o
 obj-y += turbo.o
+
+ifeq ($(CONFIG_$(SPL_)X86_64),)
+obj-y += i386/
+endif
arch/x86/cpu/cpu.c +0 -504

546 lines not on this page · raw message

arch/x86/cpu/i386/Makefile new file +7 -0
new file mode 100644
index 0000000..d336495
@@ -0,0 +1,7 @@
+#
+# (C) Copyright 2016 Google, Inc
+# Written by Simon Glass <[email protected]>
+#
+
+obj-y += cpu.o
+obj-y += interrupt.o
arch/x86/cpu/i386/cpu.c new file +534 -0

534 lines not on this page · raw message

arch/x86/cpu/i386/interrupt.c renamed from arch/x86/cpu/interrupts.c +0 -4
similarity index 99%
rename from arch/x86/cpu/interrupts.c
rename to arch/x86/cpu/i386/interrupt.c
index 5f6cdd3..8dfbb48 100644
@@ -13,16 +13,12 @@
 
 #include <common.h>
 #include <dm.h>
-#include <asm/cache.h>
 #include <asm/control_regs.h>
 #include <asm/i8259.h>
 #include <asm/interrupt.h>
 #include <asm/io.h>
 #include <asm/lapic.h>
-#include <asm/msr.h>
 #include <asm/processor-flags.h>
-#include <asm/processor.h>
-#include <asm/u-boot-x86.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
arch/x86/include/asm/mp.h +3 -0
index 2e6c312..83b99dc 100644
@@ -90,4 +90,7 @@ int mp_init(struct mp_params *params);
 /* Probes the CPU device */
 int mp_init_cpu(struct udevice *cpu, void *unused);
 
+/* Set up additional CPUs */
+int x86_mp_init(void);
+
 #endif /* _X86_MP_H_ */
Signature · 1 line
2.8.0.rc3.226.g39d4020
#100 lore raw

PATCH 52/82 x86: Add cpu code for x86_64

In reply to Simon Glass

There is not much needed at present, but set up a separate directory to put this code as it grows.

---

 arch/x86/cpu/Makefile            |  4 +++-
 arch/x86/cpu/x86_64/Makefile     |  6 ++++++
 arch/x86/cpu/x86_64/cpu.c        | 35 +++++++++++++++++++++++++++++++++++
 arch/x86/cpu/x86_64/interrupts.c | 30 ++++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/x86_64/Makefile
 create mode 100644 arch/x86/cpu/x86_64/cpu.c
 create mode 100644 arch/x86/cpu/x86_64/interrupts.c
arch/x86/cpu/Makefile +3 -1
index 41ad481..7f89ff0 100644
@@ -38,6 +38,8 @@ obj-$(CONFIG_PCI) += pci.o
 obj-$(CONFIG_SMP) += sipi_vector.o
 obj-y += turbo.o
 
-ifeq ($(CONFIG_$(SPL_)X86_64),)
+ifeq ($(CONFIG_$(SPL_)X86_64),y)
+obj-y += x86_64/
+else
 obj-y += i386/
 endif
arch/x86/cpu/x86_64/Makefile new file +6 -0
new file mode 100644
index 0000000..4b06386
@@ -0,0 +1,6 @@
+#
+# (C) Copyright 2016 Google, Inc
+# Written by Simon Glass <[email protected]>
+#
+
+obj-y += cpu.o interrupts.o
arch/x86/cpu/x86_64/cpu.c new file +35 -0
new file mode 100644
index 0000000..c1d3788
@@ -0,0 +1,35 @@
+/*
+ * (C) Copyright 2016 Google, Inc
+ * Written by Simon Glass <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <debug_uart.h>
+
+int cpu_has_64bit(void)
+{
+	return true;
+}
+
+void enable_caches(void)
+{
+	/* Not implemented */
+}
+
+void disable_caches(void)
+{
+	/* Not implemented */
+}
+
+int dcache_status(void)
+{
+	return true;
+}
+
+int x86_mp_init(void)
+{
+	/* Not implemented */
+	return 0;
+}
arch/x86/cpu/x86_64/interrupts.c new file +30 -0
new file mode 100644
index 0000000..d814b6a
@@ -0,0 +1,30 @@
+/*
+ * (C) Copyright 2016 Google, Inc
+ * Written by Simon Glass <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/processor-flags.h>
+
+void enable_interrupts(void)
+{
+	asm("sti\n");
+}
+
+int disable_interrupts(void)
+{
+	long flags;
+
+	asm volatile ("pushfq ; popq %0 ; cli\n" : "=g" (flags) : );
+
+	return flags & X86_EFLAGS_IF;
+}
+
+int interrupt_init(void)
+{
+	/* Nothing to do - this was already done in SPL */
+	return 0;
+}
+
Signature · 1 line
2.8.0.rc3.226.g39d4020
#101 lore raw

PATCH 53/82 x86: Support global_data on x86_64

In reply to Simon Glass

At present this is just an ordinary variable. We may consider making it a fixed register in the future.

---

 arch/x86/cpu/x86_64/cpu.c          | 13 +++++++++++++
 arch/x86/include/asm/global_data.h |  6 +++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
arch/x86/cpu/x86_64/cpu.c +13 -0
index c1d3788..da2ad11 100644
@@ -8,6 +8,19 @@
 #include <common.h>
 #include <debug_uart.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Global declaration of gd */
+struct global_data *global_data_ptr;
+
+void arch_setup_gd(gd_t *new_gd)
+{
+	global_data_ptr = new_gd;
+
+	/* TODO(sjg at chromium.org): Why is this needed? */
+	printch(' ');
+}
+
 int cpu_has_64bit(void)
 {
 	return true;
arch/x86/include/asm/global_data.h +5 -1
index 7434f77..ce9e5cc 100644
@@ -104,7 +104,7 @@ struct arch_global_data {
 #include <asm-generic/global_data.h>
 
 #ifndef __ASSEMBLY__
-# ifdef CONFIG_EFI_APP
+# if defined(CONFIG_EFI_APP) || CONFIG_IS_ENABLED(X86_64)
 
 #define gd global_data_ptr
 
@@ -114,7 +114,11 @@ static inline __attribute__((no_instrument_function)) gd_t *get_fs_gd_ptr(void)
 {
 	gd_t *gd_ptr;
 
+#if CONFIG_IS_ENABLED(X86_64)
+	asm volatile("fs mov 0, %0\n" : "=r" (gd_ptr));
+#else
 	asm volatile("fs movl 0, %0\n" : "=r" (gd_ptr));
+#endif
 
 	return gd_ptr;
 }
Signature · 1 line
2.8.0.rc3.226.g39d4020
#102 lore raw

PATCH 54/82 x86: Fix up CONFIG_X86_64 check

In reply to Simon Glass

When SPL and U-Boot proper have different settings for this flag, we need to use the correct one. Fix this up in the interrupt code.

---

 arch/x86/cpu/i386/interrupt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/cpu/i386/interrupt.c +1 -1
index 8dfbb48..a058303 100644
@@ -234,7 +234,7 @@ int disable_interrupts(void)
 {
 	long flags;
 
-#ifdef CONFIG_X86_64
+#if CONFIG_IS_ENABLED(X86_64)
 	asm volatile ("pushfq ; popq %0 ; cli\n" : "=g" (flags) : );
 #else
 	asm volatile ("pushfl ; popl %0 ; cli\n" : "=g" (flags) : );
Signature · 1 line
2.8.0.rc3.226.g39d4020
#103 lore raw

PATCH 55/82 x86: Add a link script for 64-bit x86

In reply to Simon Glass

This needs a different image format from 32-bit x86, so add a new link script.

---

 arch/x86/cpu/config.mk     |  6 ++++
 arch/x86/cpu/u-boot-64.lds | 76 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100644 arch/x86/cpu/u-boot-64.lds
arch/x86/cpu/config.mk +6 -0
index 1263221..4c99a35 100644
@@ -15,3 +15,9 @@ LDPPFLAGS += -DRESET_SEG_SIZE=$(CONFIG_RESET_SEG_SIZE)
 LDPPFLAGS += -DRESET_VEC_LOC=$(CONFIG_RESET_VEC_LOC)
 LDPPFLAGS += -DSTART_16=$(CONFIG_SYS_X86_START16)
 LDPPFLAGS += -DRESET_BASE="CONFIG_SYS_TEXT_BASE + (CONFIG_SYS_MONITOR_LEN - RESET_SEG_SIZE)"
+
+ifdef CONFIG_X86_64
+ifndef CONFIG_SPL_BUILD
+LDSCRIPT = $(srctree)/arch/x86/cpu/u-boot-64.lds
+endif
+endif
arch/x86/cpu/u-boot-64.lds new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3.226.g39d4020
#104 lore raw

PATCH 56/82 x86: Add a link script for SPL

In reply to Simon Glass

If SPL is used it is always build in 32-bit mode. Add a link script to handle the correct placement of the sections.

---

 arch/x86/cpu/u-boot-spl.lds | 74 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 arch/x86/cpu/u-boot-spl.lds
arch/x86/cpu/u-boot-spl.lds new file +74 -0
new file mode 100644
index 0000000..8a38d58
@@ -0,0 +1,74 @@
+/*
+ * (C) Copyright 2002
+ * Daniel Engstr?m, Omicron Ceti AB, daniel at omicron.se.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <config.h>
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+
+SECTIONS
+{
+#ifndef CONFIG_CMDLINE
+	/DISCARD/ : { *(.u_boot_list_2_cmd_*) }
+#endif
+
+	. = CONFIG_SPL_TEXT_BASE;	/* Location of bootcode in flash */
+	__text_start = .;
+	.text  : { *(.text*); }
+
+	. = ALIGN(4);
+
+	. = ALIGN(4);
+	.u_boot_list : {
+		KEEP(*(SORT(.u_boot_list*)));
+	}
+
+	. = ALIGN(4);
+	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
+
+	. = ALIGN(4);
+	.data : { *(.data*) }
+
+	. = ALIGN(4);
+	__data_end = .;
+	__init_end = .;
+
+        _image_binary_end = .;
+
+	. = 0x120000;
+	.bss (OVERLAY) : {
+		__bss_start = .;
+		*(.bss*)
+		*(COM*)
+		. = ALIGN(4);
+		__bss_end = .;
+	}
+	__bss_size = __bss_end - __bss_start;
+
+	/DISCARD/ : { *(.dynstr*) }
+	/DISCARD/ : { *(.dynamic*) }
+	/DISCARD/ : { *(.plt*) }
+	/DISCARD/ : { *(.interp*) }
+	/DISCARD/ : { *(.gnu*) }
+
+#ifdef CONFIG_SPL_X86_16BIT_INIT
+	/*
+	 * The following expressions place the 16-bit Real-Mode code and
+	 * Reset Vector at the end of the Flash ROM
+	 */
+	. = START_16 - RESET_SEG_START;
+	.start16 : AT (START_16) {
+		KEEP(*(.start16));
+	}
+
+	. = RESET_VEC_LOC - RESET_SEG_START;
+	.resetvec : AT (RESET_VEC_LOC) {
+		KEEP(*(.resetvec));
+	}
+#endif
+
+}
Signature · 1 line
2.8.0.rc3.226.g39d4020
#105 lore raw

PATCH 57/82 x86: Add SPL build rules for start-up code

In reply to Simon Glass

When SPL is used we need to build the 16-bit start-up code. Add Makefile rules to handle this.

---

 scripts/Makefile.spl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
scripts/Makefile.spl +8 -1
index bd1f392..8964699 100644
@@ -176,6 +176,8 @@ ifeq ($(CONFIG_SYS_SOC),"at91")
 ALL-y	+= boot.bin
 endif
 
+ALL-$(CONFIG_SPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-16bit-spl.bin
+
 ALL-$(CONFIG_ARCH_ZYNQ)		+= $(obj)/boot.bin
 ALL-$(CONFIG_ARCH_ZYNQMP)	+= $(obj)/boot.bin
 
@@ -280,11 +282,16 @@ endif
 quiet_cmd_objcopy = OBJCOPY $@
 cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
 
-OBJCOPYFLAGS_$(SPL_BIN)-nodtb.bin = $(SPL_OBJCFLAGS) -O binary
+OBJCOPYFLAGS_$(SPL_BIN)-nodtb.bin = $(SPL_OBJCFLAGS) -O binary \
+		$(if $(CONFIG_SPL_X86_16BIT_INIT),-R .start16 -R .resetvec)
 
 $(obj)/$(SPL_BIN)-nodtb.bin: $(obj)/$(SPL_BIN) FORCE
 	$(call if_changed,objcopy)
 
+OBJCOPYFLAGS_u-boot-x86-16bit-spl.bin := -O binary -j .start16 -j .resetvec
+$(obj)/u-boot-x86-16bit-spl.bin: $(obj)/u-boot-spl FORCE
+	$(call if_changed,objcopy)
+
 LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SPL_TEXT_BASE),)
 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#106 lore raw

PATCH 58/82 x86: Fix up byteorder.h for x86_64

In reply to Simon Glass

Remove the very old x86 code and add support for 64-bit.

---

 arch/x86/include/asm/byteorder.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
arch/x86/include/asm/byteorder.h +9 -8
index 7dfeb8b..a2d1fd8 100644
@@ -8,24 +8,25 @@
 
 static __inline__ __u32 ___arch__swab32(__u32 x)
 {
-#ifdef CONFIG_X86_BSWAP
 	__asm__("bswap %0" : "=r" (x) : "0" (x));
-#else
-	__asm__("xchgb %b0,%h0\n\t"	/* swap lower bytes	*/
-		"rorl $16,%0\n\t"	/* swap words		*/
-		"xchgb %b0,%h0"		/* swap higher bytes	*/
-		:"=q" (x)
-		: "0" (x));
-#endif
+
 	return x;
 }
 
+#define _constant_swab16(x) ((__u16)(				\
+	(((__u16)(x) & (__u16)0x00ffU) << 8) |			\
+	(((__u16)(x) & (__u16)0xff00U) >> 8)))
+
 static __inline__ __u16 ___arch__swab16(__u16 x)
 {
+#if CONFIG_IS_ENABLED(X86_64)
+	return _constant_swab16(x);
+#else
 	__asm__("xchgb %b0,%h0"		/* swap bytes		*/ \
 		: "=q" (x) \
 		:  "0" (x)); \
 		return x;
+#endif
 }
 
 #define __arch__swab32(x) ___arch__swab32(x)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#107 lore raw

PATCH 59/82 x86: Drop flag_is_changable() on x86_64

In reply to Simon Glass

This doesn't build at present and is not used in a 64-bit build. Disable it for now.

---

 arch/x86/include/asm/cpu.h | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/include/asm/cpu.h +3 -0
index 7892757..9a8ae2a 100644
@@ -160,6 +160,8 @@ static inline unsigned int cpuid_edx(unsigned int op)
 	return edx;
 }
 
+#if !CONFIG_IS_ENABLED(X86_64)
+
 /* Standard macro to see if a specific flag is changeable */
 static inline int flag_is_changeable_p(uint32_t flag)
 {
@@ -180,6 +182,7 @@ static inline int flag_is_changeable_p(uint32_t flag)
 		: "ir" (flag));
 	return ((f1^f2) & flag) != 0;
 }
+#endif
 
 static inline void mfence(void)
 {
Signature · 1 line
2.8.0.rc3.226.g39d4020
#108 lore raw

PATCH 60/82 x86: Fix up type sizes for 64-bit

In reply to Simon Glass

Adjust types as needed to support 64-bit compilation.

---

 arch/x86/include/asm/posix_types.h | 5 +++++
 arch/x86/include/asm/types.h       | 5 +++++
 2 files changed, 10 insertions(+)
arch/x86/include/asm/posix_types.h +5 -0
index 5529f32..717f6cb 100644
@@ -16,8 +16,13 @@ typedef int		__kernel_pid_t;
 typedef unsigned short	__kernel_ipc_pid_t;
 typedef unsigned short	__kernel_uid_t;
 typedef unsigned short	__kernel_gid_t;
+#if CONFIG_IS_ENABLED(X86_64)
+typedef unsigned long	__kernel_size_t;
+typedef long		__kernel_ssize_t;
+#else
 typedef unsigned int	__kernel_size_t;
 typedef int		__kernel_ssize_t;
+#endif
 typedef int		__kernel_ptrdiff_t;
 typedef long		__kernel_time_t;
 typedef long		__kernel_suseconds_t;
arch/x86/include/asm/types.h +5 -0
index 880dcb4..a47e581 100644
@@ -44,7 +44,12 @@ typedef __INT64_TYPE__ s64;
 typedef __UINT64_TYPE__ u64;
 #endif
 
+#if CONFIG_IS_ENABLED(X86_64)
+#define BITS_PER_LONG 64
+#else
 #define BITS_PER_LONG 32
+#endif
+
 /* Dma addresses are 32-bits wide.  */
 
 typedef u32 dma_addr_t;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#109 lore raw

PATCH 61/82 x86: Mention the MRC region in the README

In reply to Simon Glass

This is left out of the example memory map. Add it to avoid confusion.

---

 doc/README.x86 | 1 +
 1 file changed, 1 insertion(+)
doc/README.x86 +1 -0
index 9d3129a..44b7388 100644
@@ -308,6 +308,7 @@ Offset   Description         Controlling config
 6f0000   MRC cache           CONFIG_ENABLE_MRC_CACHE
 700000   u-boot-dtb.bin      CONFIG_SYS_TEXT_BASE
 790000   vga.bin             CONFIG_VGA_BIOS_ADDR
+7a0000   mrc.bin             CONFIG_X86_MRC_ADDR
 7c0000   fsp.bin             CONFIG_FSP_ADDR
 7f8000   <spare>             (depends on size of fsp.bin)
 7ff800   U-Boot 16-bit boot  CONFIG_SYS_X86_START16
Signature · 1 line
2.8.0.rc3.226.g39d4020
#110 lore raw

PATCH 62/82 x86: ivybridge: Only do graphics init in 32-bit mode

In reply to Simon Glass

It's not clear how we would handle graphics init in 64-bit mode. Probably we would need to change back to 32-bit or 16-bit to run the graphics ROM. For now, disable it in 64-bit mode.

---

 arch/x86/cpu/ivybridge/Makefile  | 2 +-
 arch/x86/cpu/ivybridge/bd82x6x.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
arch/x86/cpu/ivybridge/Makefile +1 -1
index a853e45..96185d2 100644
@@ -9,7 +9,7 @@ obj-y += fsp_configs.o ivybridge.o
 else
 obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += cpu.o
 obj-y += early_me.o
-obj-y += gma.o
+obj-$(CONFIG_X86_32BIT_INIT) += gma.o
 obj-y += lpc.o
 obj-y += model_206ax.o
 obj-y += northbridge.o
arch/x86/cpu/ivybridge/bd82x6x.c +4 -0
index 3c5e159..cdab365 100644
@@ -169,9 +169,13 @@ static int bd82x6x_probe(struct udevice *dev)
 	ret = syscon_get_by_driver_data(X86_SYSCON_GMA, &gma_dev);
 	if (ret)
 		return ret;
+
+	/* TODO(sjg at chromium.org): Handle graphics init in SPL or 64-bit mode */
+#ifndef CONFIG_X86_64
 	ret = gma_func0_init(gma_dev);
 	if (ret)
 		return ret;
+#endif
 
 	return 0;
 }
Signature · 1 line
2.8.0.rc3.226.g39d4020
#111 lore raw

PATCH 63/82 x86: ivybridge: Skipt SATA init in SPL

In reply to Simon Glass

This doesn't work at present. Disable it for now.

---

 arch/x86/cpu/ivybridge/Makefile | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/cpu/ivybridge/Makefile +2 -0
index 96185d2..8bebcf8 100644
@@ -13,7 +13,9 @@ obj-$(CONFIG_X86_32BIT_INIT) += gma.o
 obj-y += lpc.o
 obj-y += model_206ax.o
 obj-y += northbridge.o
+ifndef CONFIG_SPL_BUILD
 obj-y += sata.o
+endif
 obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += sdram.o
 endif
 obj-y += bd82x6x.o
Signature · 1 line
2.8.0.rc3.226.g39d4020
#112 lore raw

PATCH 64/82 x86: ivybridge: Provide a dummy SDRAM init for 64-bit

In reply to Simon Glass

We don't support SDRAM init in 64-bit mode since it is essentially impossible to get into that mode before SDRAM set up. Provide dummy functions for now. At some point we will need to pass the SDRAM parameters through from SPL.

---

 arch/x86/cpu/ivybridge/Makefile    |  3 +++
 arch/x86/cpu/ivybridge/sdram_nop.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 arch/x86/cpu/ivybridge/sdram_nop.c
arch/x86/cpu/ivybridge/Makefile +3 -0
index 8bebcf8..2de11fc 100644
@@ -17,5 +17,8 @@ ifndef CONFIG_SPL_BUILD
 obj-y += sata.o
 endif
 obj-$(CONFIG_$(SPL_)X86_32BIT_INIT) += sdram.o
+ifndef CONFIG_$(SPL_)X86_32BIT_INIT
+obj-y += sdram_nop.o
+endif
 endif
 obj-y += bd82x6x.o
arch/x86/cpu/ivybridge/sdram_nop.c new file +29 -0
new file mode 100644
index 0000000..edb3cb1
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016 Google, Inc
+ *
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int dram_init(void)
+{
+	gd->ram_size = 1ULL << 31;
+	gd->bd->bi_dram[0].start = 0;
+	gd->bd->bi_dram[0].size = gd->ram_size;
+
+	return 0;
+}
+
+int misc_init_r(void)
+{
+	return 0;
+}
+
+int print_cpuinfo(void)
+{
+	return 0;
+}
Signature · 1 line
2.8.0.rc3.226.g39d4020
#113 lore raw

PATCH 65/82 x86: Don't try to run the VGA BIOS in 64-bit mode

In reply to Simon Glass

This is not supported, so disable it for now.

---

 arch/x86/lib/Makefile | 2 ++
 drivers/pci/pci_rom.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/x86/lib/Makefile +2 -0
index 1fa7f90..ad3200a 100644
@@ -5,9 +5,11 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+ifndef CONFIG_X86_64
 obj-y += bios.o
 obj-y += bios_asm.o
 obj-y += bios_interrupts.o
+endif
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y	+= cmd_boot.o
 obj-$(CONFIG_SEABIOS) += coreboot_table.o
drivers/pci/pci_rom.c +1 -1
index 399055b..aa28752 100644
@@ -333,7 +333,7 @@ int dm_pci_run_vga_bios(struct udevice *dev, int (*int15_handler)(void),
 			goto err;
 #endif
 	} else {
-#ifdef CONFIG_X86
+#if defined(CONFIG_X86) && CONFIG_IS_ENABLED(X86_32BIT_INIT)
 		bios_set_interrupt_handler(0x15, int15_handler);
 
 		bios_run_on_x86(dev, (unsigned long)ram, vesa_mode,
Signature · 1 line
2.8.0.rc3.226.g39d4020
#114 lore raw

PATCH 66/82 x86: Don't build call64 and setjmp on 64-bit

In reply to Simon Glass

These are currently not supported. Calling 64-bit code from 64-bit U-Boot is much simpler, so this code is not needed. setjmp() is not yet implemented for 64-bit.

---

 arch/x86/cpu/Makefile | 6 +++++-
 arch/x86/lib/bootm.c  | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)
arch/x86/cpu/Makefile +5 -1
index 7f89ff0..f0135a7 100644
@@ -14,7 +14,11 @@ else
 extra-y	= start.o
 endif
 extra-$(CONFIG_$(SPL_)X86_16BIT_INIT) += resetvec.o start16.o
-obj-y	+= cpu.o cpu_x86.o call64.o setjmp.o
+ifndef CONFIG_$(SPL_)X86_64
+obj-y	+= call64.o setjmp.o
+endif
+
+obj-y	+= cpu.o cpu_x86.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
 	$(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
arch/x86/lib/bootm.c +2 -0
index 7cf9de4..b7ed1e6 100644
@@ -146,7 +146,9 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit)
 			puts("Cannot boot 64-bit kernel on 32-bit machine\n");
 			return -EFAULT;
 		}
+#if !CONFIG_IS_ENABLED(X86_64)
 		return cpu_jump_to_64bit(setup_base, load_address);
+#endif
 	} else {
 		/*
 		* Set %ebx, %ebp, and %edi to 0, %esi to point to the
Signature · 1 line
2.8.0.rc3.226.g39d4020
#115 lore raw

PATCH 67/82 x86: Don't build cpu files which are not supported on 64-bit

In reply to Simon Glass

Some files cannot be built with 64-bit and mostly don't make sense in that context. Disable them.

---

 arch/x86/cpu/Makefile | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
arch/x86/cpu/Makefile +8 -1
index f0135a7..6889df3 100644
@@ -20,11 +20,13 @@ endif
 
 obj-y	+= cpu.o cpu_x86.o
 
+ifndef CONFIG_$(SPL_)X86_64
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
 	$(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
 AFLAGS_call32.o := -fpic -fshort-wchar
 
 extra-y += call32.o
+endif
 
 obj-y += intel_common/
 obj-$(CONFIG_INTEL_BAYTRAIL) += baytrail/
@@ -35,11 +37,16 @@ obj-$(CONFIG_QEMU) += qemu/
 obj-$(CONFIG_NORTHBRIDGE_INTEL_IVYBRIDGE) += ivybridge/
 obj-$(CONFIG_INTEL_QUARK) += quark/
 obj-$(CONFIG_INTEL_QUEENSBAY) += queensbay/
-obj-y += irq.o lapic.o ioapic.o
+obj-y += lapic.o ioapic.o
+ifndef CONFIG_$(SPL_)X86_64
+obj-y += irq.o
 obj-$(CONFIG_SMP) += mp_init.o
+endif
 obj-y += mtrr.o
 obj-$(CONFIG_PCI) += pci.o
+ifndef CONFIG_$(SPL_)X86_64
 obj-$(CONFIG_SMP) += sipi_vector.o
+endif
 obj-y += turbo.o
 
 ifeq ($(CONFIG_$(SPL_)X86_64),y)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#116 lore raw

PATCH 68/82 x86: Don't try to boot Linux from SPL

In reply to Simon Glass

Booting into linux from 64-bit U-Boot is not yet supported. Avoid bringing in the bootm code until it is implemented.

Of course 32-bit U-Boot still supported booting into both 32- and 64-bit kernels.

---

 arch/x86/lib/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/lib/Makefile +4 -0
index ad3200a..7f6d12a 100644
@@ -10,7 +10,9 @@ obj-y += bios.o
 obj-y += bios_asm.o
 obj-y += bios_interrupts.o
 endif
+ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
+endif
 obj-y	+= cmd_boot.o
 obj-$(CONFIG_SEABIOS) += coreboot_table.o
 obj-$(CONFIG_EFI) += efi/
@@ -41,7 +43,9 @@ ifndef CONFIG_QEMU
 obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o
 endif
 obj-y	+= tables.o
+ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_CMD_ZBOOT)	+= zimage.o
+endif
 obj-$(CONFIG_HAVE_FSP) += fsp/
 obj-$(CONFIG_SPL_BUILD) += spl.o
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#117 lore raw

PATCH 69/82 x86: Drop interrupt support in 64-bit mode

In reply to Simon Glass

This is not currently supported, so drop the code.

---

 arch/x86/lib/interrupts.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/x86/lib/interrupts.c +5 -0
index dd08402..d3ae6d9 100644
@@ -33,6 +33,8 @@
 #include <common.h>
 #include <asm/interrupt.h>
 
+#if !CONFIG_IS_ENABLED(X86_64)
+
 struct irq_action {
 	interrupt_handler_t *handler;
 	void *arg;
@@ -118,10 +120,12 @@ void do_irq(int hw_irq)
 		}
 	}
 }
+#endif
 
 #if defined(CONFIG_CMD_IRQ)
 int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
+#if !CONFIG_IS_ENABLED(X86_64)
 	int irq;
 
 	printf("Spurious IRQ: %u, last unknown IRQ: %d\n",
@@ -139,6 +143,7 @@ int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 					irq_handlers[irq].count);
 		}
 	}
+#endif
 
 	return 0;
 }
Signature · 1 line
2.8.0.rc3.226.g39d4020
#118 lore raw

PATCH 70/82 x86: Support jumping from SPL to U-Boot

In reply to Simon Glass

Add a rough function to handle jumping from 32-bit SPL to 64-bit U-Boot. This still needs work to clean it up.

---

 arch/x86/cpu/call64.S      |  3 +++
 arch/x86/cpu/i386/cpu.c    | 65 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/cpu.h |  9 +++++++
 3 files changed, 77 insertions(+)
arch/x86/cpu/call64.S +3 -0
index 08dc473..970c461 100644
@@ -81,6 +81,9 @@ lret_target:
 	jmp	*%eax			/* Jump to the 64-bit target */
 
 	.data
+	.align	16
+	.globl	gdt64
+gdt64:
 gdt:
 	.word	gdt_end - gdt - 1
 	.long	gdt			/* Fixed up by code above */
arch/x86/cpu/i386/cpu.c +65 -0

71 lines not on this page · raw message

arch/x86/include/asm/cpu.h +9 -0
index 9a8ae2a..cd55201 100644
@@ -265,6 +265,15 @@ void cpu_call32(ulong code_seg32, ulong target, ulong table);
 int cpu_jump_to_64bit(ulong setup_base, ulong target);
 
 /**
+ * cpu_jump_to_64bit_uboot() - special function to jump from SPL to U-Boot
+ *
+ * This handles calling from 32-bit SPL to 64-bit U-Boot.
+ *
+ * @target:	Address of U-Boot in RAM
+ */
+int cpu_jump_to_64bit_uboot(ulong target);
+
+/**
  * cpu_get_family_model() - Get the family and model for the CPU
  *
  * @return the CPU ID masked with 0x0fff0ff0
Signature · 1 line
2.8.0.rc3.226.g39d4020
#119 lore raw

PATCH 71/82 x86: Move pirq_routing_table to global_data

In reply to Simon Glass

To avoid using BSS in SPL before SDRAM is set up, move this field to global_data.

---

 arch/x86/cpu/irq.c                 | 12 +++++-------
 arch/x86/include/asm/global_data.h |  1 +
 2 files changed, 6 insertions(+), 7 deletions(-)
arch/x86/cpu/irq.c +5 -7
index 516d84a..cfa3dd9 100644
@@ -17,8 +17,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static struct irq_routing_table *pirq_routing_table;
-
 bool pirq_check_irq_routed(struct udevice *dev, int link, u8 irq)
 {
 	struct irq_router *priv = dev_get_priv(dev);
@@ -218,7 +216,7 @@ static int create_pirq_routing_table(struct udevice *dev)
 	/* Fix up the table checksum */
 	rt->checksum = table_compute_checksum(rt, rt->size);
 
-	pirq_routing_table = rt;
+	gd->arch.pirq_routing_table = rt;
 
 	return 0;
 }
@@ -249,8 +247,8 @@ int irq_router_common_init(struct udevice *dev)
 		return ret;
 	}
 	/* Route PIRQ */
-	pirq_route_irqs(dev, pirq_routing_table->slots,
-			get_irq_slot_count(pirq_routing_table));
+	pirq_route_irqs(dev, gd->arch.pirq_routing_table->slots,
+			get_irq_slot_count(gd->arch.pirq_routing_table));
 
 	if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE))
 		irq_enable_sci(dev);
@@ -265,10 +263,10 @@ int irq_router_probe(struct udevice *dev)
 
 ulong write_pirq_routing_table(ulong addr)
 {
-	if (!pirq_routing_table)
+	if (!gd->arch.pirq_routing_table)
 		return addr;
 
-	return copy_pirq_routing_table(addr, pirq_routing_table);
+	return copy_pirq_routing_table(addr, gd->arch.pirq_routing_table);
 }
 
 static const struct udevice_id irq_router_ids[] = {
arch/x86/include/asm/global_data.h +1 -0
index ce9e5cc..e24cee7 100644
@@ -93,6 +93,7 @@ struct arch_global_data {
 	char *mrc_output;
 	unsigned int mrc_output_len;
 	ulong table;			/* Table pointer from previous loader */
+	struct irq_routing_table *pirq_routing_table;
 #ifdef CONFIG_SEABIOS
 	u32 high_table_ptr;
 	u32 high_table_limit;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#120 lore raw

PATCH 72/82 x86: Move turbo_state to global_data

In reply to Simon Glass

To avoid using BSS in SPL before SDRAM is set up, move this field to global_data.

---

 arch/x86/cpu/turbo.c               | 8 ++++----
 arch/x86/include/asm/global_data.h | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)
arch/x86/cpu/turbo.c +4 -4
index 254d0de..bbd255e 100644
@@ -12,6 +12,8 @@
 #include <asm/processor.h>
 #include <asm/turbo.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #if CONFIG_CPU_INTEL_TURBO_NOT_PACKAGE_SCOPED
 static inline int get_global_turbo_state(void)
 {
@@ -22,16 +24,14 @@ static inline void set_global_turbo_state(int state)
 {
 }
 #else
-static int g_turbo_state = TURBO_UNKNOWN;
-
 static inline int get_global_turbo_state(void)
 {
-	return g_turbo_state;
+	return gd->arch.turbo_state;
 }
 
 static inline void set_global_turbo_state(int state)
 {
-	g_turbo_state = state;
+	gd->arch.turbo_state = state;
 }
 #endif
 
arch/x86/include/asm/global_data.h +1 -0
index e24cee7..0fadfc6 100644
@@ -93,6 +93,7 @@ struct arch_global_data {
 	char *mrc_output;
 	unsigned int mrc_output_len;
 	ulong table;			/* Table pointer from previous loader */
+	int turbo_state;		/* Current turbo state */
 	struct irq_routing_table *pirq_routing_table;
 #ifdef CONFIG_SEABIOS
 	u32 high_table_ptr;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#121 lore raw

PATCH 73/82 x86: Change irq_already_routed to a local variable

In reply to Simon Glass

This avoids using BSS before SDRAM is set up in SPL.

---

 arch/x86/lib/pirq_routing.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/lib/pirq_routing.c +6 -4
index c98526d..5df3cab 100644
@@ -11,9 +11,8 @@
 #include <asm/pci.h>
 #include <asm/pirq_routing.h>
 
-static bool irq_already_routed[16];
-
-static u8 pirq_get_next_free_irq(struct udevice *dev, u8 *pirq, u16 bitmap)
+static u8 pirq_get_next_free_irq(struct udevice *dev, u8 *pirq, u16 bitmap,
+				 bool irq_already_routed[])
 {
 	int i, link;
 	u8 irq = 0;
@@ -55,9 +54,11 @@ void pirq_route_irqs(struct udevice *dev, struct irq_info *irq, int num)
 {
 	unsigned char irq_slot[MAX_INTX_ENTRIES];
 	unsigned char pirq[CONFIG_MAX_PIRQ_LINKS];
+	bool irq_already_routed[16];
 	int i, intx;
 
 	memset(pirq, 0, CONFIG_MAX_PIRQ_LINKS);
+	memset(irq_already_routed, '\0', sizeof(irq_already_routed));
 
 	/* Set PCI IRQs */
 	for (i = 0; i < num; i++) {
@@ -83,7 +84,8 @@ void pirq_route_irqs(struct udevice *dev, struct irq_info *irq, int num)
 
 			/* yet not routed */
 			if (!pirq[link]) {
-				irq = pirq_get_next_free_irq(dev, pirq, bitmap);
+				irq = pirq_get_next_free_irq(dev, pirq, bitmap,
+						irq_already_routed);
 				pirq[link] = irq;
 			} else {
 				irq = pirq[link];
Signature · 1 line
2.8.0.rc3.226.g39d4020
#122 lore raw

PATCH 74/82 x86: Move call64 to the i386 directory

In reply to Simon Glass

This code is only used in 32-bit mode. Move it so that it does not get built with 64-bit U-Boot.

---

 arch/x86/cpu/Makefile            | 2 +-
 arch/x86/cpu/i386/Makefile       | 1 +
 arch/x86/cpu/{ => i386}/call64.S | 0
 3 files changed, 2 insertions(+), 1 deletion(-)
 rename arch/x86/cpu/{ => i386}/call64.S (100%)
arch/x86/cpu/Makefile +1 -1
index 6889df3..2fda32d 100644
@@ -15,7 +15,7 @@ extra-y	= start.o
 endif
 extra-$(CONFIG_$(SPL_)X86_16BIT_INIT) += resetvec.o start16.o
 ifndef CONFIG_$(SPL_)X86_64
-obj-y	+= call64.o setjmp.o
+obj-y	+= setjmp.o
 endif
 
 obj-y	+= cpu.o cpu_x86.o
arch/x86/cpu/i386/Makefile +1 -0
index d336495..2547bba 100644
@@ -3,5 +3,6 @@
 # Written by Simon Glass <[email protected]>
 #
 
+obj-y += call64.o
 obj-y += cpu.o
 obj-y += interrupt.o
arch/x86/cpu/i386/call64.S renamed from arch/x86/cpu/call64.S +0 -0
similarity index 100%
rename from arch/x86/cpu/call64.S
rename to arch/x86/cpu/i386/call64.S
Signature · 1 line
2.8.0.rc3.226.g39d4020
#123 lore raw

PATCH 75/82 x86: Move setjmp to the i386 directory

In reply to Simon Glass

This code is only used in 32-bit mode. Move it so that it does not get built with 64-bit U-Boot.

---

 arch/x86/cpu/Makefile            | 3 ---
 arch/x86/cpu/i386/Makefile       | 1 +
 arch/x86/cpu/{ => i386}/setjmp.S | 0
 3 files changed, 1 insertion(+), 3 deletions(-)
 rename arch/x86/cpu/{ => i386}/setjmp.S (100%)
arch/x86/cpu/Makefile +0 -3
index 2fda32d..45f95ab 100644
@@ -14,9 +14,6 @@ else
 extra-y	= start.o
 endif
 extra-$(CONFIG_$(SPL_)X86_16BIT_INIT) += resetvec.o start16.o
-ifndef CONFIG_$(SPL_)X86_64
-obj-y	+= setjmp.o
-endif
 
 obj-y	+= cpu.o cpu_x86.o
 
arch/x86/cpu/i386/Makefile +1 -0
index 2547bba..0c47252 100644
@@ -6,3 +6,4 @@
 obj-y += call64.o
 obj-y += cpu.o
 obj-y += interrupt.o
+obj-y += setjmp.o
arch/x86/cpu/i386/setjmp.S renamed from arch/x86/cpu/setjmp.S +0 -0
similarity index 100%
rename from arch/x86/cpu/setjmp.S
rename to arch/x86/cpu/i386/setjmp.S
Signature · 1 line
2.8.0.rc3.226.g39d4020
#124 lore raw

PATCH 76/82 x86: Add a dummy setjmp implementation for x86_64

In reply to Simon Glass

We don't have the code for this yet. Add a dummy version for now, so that EFI builds correctly.

---

 arch/x86/cpu/x86_64/Makefile |  2 +-
 arch/x86/cpu/x86_64/setjmp.c | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/x86_64/setjmp.c
arch/x86/cpu/x86_64/Makefile +1 -1
index 4b06386..400f0ff 100644
@@ -3,4 +3,4 @@
 # Written by Simon Glass <[email protected]>
 #
 
-obj-y += cpu.o interrupts.o
+obj-y += cpu.o interrupts.o setjmp.o
arch/x86/cpu/x86_64/setjmp.c new file +20 -0
new file mode 100644
index 0000000..5321292
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#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)
+{
+	printf("WARNING: longjmp() is not supported\n");
+}
Signature · 1 line
2.8.0.rc3.226.g39d4020
#125 lore raw

PATCH 77/82 x86: link: Add a text base for 64-bit U-Boot

In reply to Simon Glass

Set up the 64-bit U-Boot text base if building for that target.

---

 board/google/chromebook_link/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/google/chromebook_link/Kconfig +2 -1
index fa12f33..5c57945 100644
@@ -13,7 +13,8 @@ config SYS_CONFIG_NAME
 	default "chromebook_link"
 
 config SYS_TEXT_BASE
-	default 0xfff00000
+	default 0xfff00000 if !SUPPORT_SPL
+	default 0x10000000 if SUPPORT_SPL
 
 config BOARD_SPECIFIC_OPTIONS # dummy
 	def_bool y
Signature · 1 line
2.8.0.rc3.226.g39d4020
#126 lore raw

PATCH 78/82 x86: link: Add SPL declarations to the binman image

In reply to Simon Glass

When building for 64-bit we need to put an SPL binary into the image. Update the binman image description to reflect this.

---

 arch/x86/dts/binman.dtsi | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/x86/dts/binman.dtsi +19 -0
index 724913f..35a7685 100644
@@ -21,9 +21,22 @@
 		intel-me {
 		};
 #endif
+#ifdef CONFIG_SPL
+		u-boot-spl-with-ucode-ptr {
+			pos = <CONFIG_SPL_TEXT_BASE>;
+		};
+
+		u-boot-dtb-with-ucode2 {
+			type = "u-boot-dtb-with-ucode";
+		};
+		u-boot {
+			pos = <0xfff00000>;
+		};
+#else
 		u-boot-with-ucode-ptr {
 			pos = <CONFIG_SYS_TEXT_BASE>;
 		};
+#endif
 		u-boot-dtb-with-ucode {
 		};
 		u-boot-ucode {
@@ -54,9 +67,15 @@
 			pos = <CONFIG_X86_REFCODE_ADDR>;
 		};
 #endif
+#ifdef CONFIG_SPL
+		x86-start16-spl {
+			pos = <CONFIG_SYS_X86_START16>;
+		};
+#else
 		x86-start16 {
 			pos = <CONFIG_SYS_X86_START16>;
 		};
+#endif
 	};
 };
 #endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
#127 lore raw

PATCH 79/82 x86: link: Set up device tree for SPL

In reply to Simon Glass

Add the correct pre-relocation tag so that the required device tree nodes are present in the SPL device tree.

On x86 it doesn't make a lot of sense to have a separate SPL device tree. Since everything is in the same ROM we might as well just use the main device tree in both SPL and U-Boot proper. But we haven't implemented that, so this is a good first step.

---

 arch/x86/dts/chromebook_link.dts | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
arch/x86/dts/chromebook_link.dts +14 -1
index 9deb56c..fad9a11 100644
@@ -26,12 +26,14 @@
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
+		u-boot,dm-pre-reloc;
 
 		cpu at 0 {
 			device_type = "cpu";
 			compatible = "intel,core-gen3";
 			reg = <0>;
 			intel,apic-id = <0>;
+			u-boot,dm-pre-reloc;
 		};
 
 		cpu at 1 {
@@ -39,6 +41,7 @@
 			compatible = "intel,core-gen3";
 			reg = <1>;
 			intel,apic-id = <1>;
+			u-boot,dm-pre-reloc;
 		};
 
 		cpu at 2 {
@@ -46,6 +49,7 @@
 			compatible = "intel,core-gen3";
 			reg = <2>;
 			intel,apic-id = <2>;
+			u-boot,dm-pre-reloc;
 		};
 
 		cpu at 3 {
@@ -53,6 +57,7 @@
 			compatible = "intel,core-gen3";
 			reg = <3>;
 			intel,apic-id = <3>;
+			u-boot,dm-pre-reloc;
 		};
 
 	};
@@ -229,14 +234,16 @@
 
 		northbridge at 0,0 {
 			reg = <0x00000000 0 0 0 0>;
+			u-boot,dm-pre-reloc;
 			compatible = "intel,bd82x6x-northbridge";
 			board-id-gpios = <&gpio_b 9 0>, <&gpio_b 10 0>,
 					<&gpio_b 11 0>, <&gpio_a 10 0>;
-			u-boot,dm-pre-reloc;
 			spd {
+				u-boot,dm-pre-reloc;
 				#address-cells = <1>;
 				#size-cells = <0>;
 				elpida_4Gb_1600_x16 {
+					u-boot,dm-pre-reloc;
 					reg = <0>;
 					data = [92 10 0b 03 04 19 02 02
 						03 52 01 08 0a 00 fe 00
@@ -272,6 +279,7 @@
 						00 00 00 00 00 00 00 00];
 				};
 				samsung_4Gb_1600_1.35v_x16 {
+					u-boot,dm-pre-reloc;
 					reg = <1>;
 					data = [92 11 0b 03 04 19 02 02
 						03 11 01 08 0a 00 fe 00
@@ -391,9 +399,11 @@
 				#address-cells = <1>;
 				#size-cells = <0>;
 				compatible = "intel,ich9-spi";
+				u-boot,dm-pre-reloc;
 				spi-flash at 0 {
 					#size-cells = <1>;
 					#address-cells = <1>;
+					u-boot,dm-pre-reloc;
 					reg = <0>;
 					compatible = "winbond,w25q64",
 							"spi-flash";
@@ -401,6 +411,7 @@
 					rw-mrc-cache {
 						label = "rw-mrc-cache";
 						reg = <0x003e0000 0x00010000>;
+						u-boot,dm-pre-reloc;
 					};
 				};
 			};
@@ -478,7 +489,9 @@
 	};
 
 	microcode {
+		u-boot,dm-pre-reloc;
 		update at 0 {
+			u-boot,dm-pre-reloc;
 #include "microcode/m12306a9_0000001b.dtsi"
 		};
 	};
Signature · 1 line
2.8.0.rc3.226.g39d4020
#128 lore raw

PATCH 80/82 x86: link: Add build options for SPL

In reply to Simon Glass

If SPL is used we want to use the generic SPL framework and boot from SPI via a board-specific means. Add these options to the board config file.

---

 configs/chromebook_link_defconfig | 21 ++++++++++++++++++++-
 include/configs/chromebook_link.h |  9 +++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
configs/chromebook_link_defconfig +20 -1
index 34ce36b..ff28fb8 100644
@@ -1,5 +1,12 @@
 CONFIG_X86=y
-CONFIG_SYS_MALLOC_F_LEN=0x1800
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_VIDEO=y
 CONFIG_VENDOR_GOOGLE=y
 CONFIG_DEFAULT_DEVICE_TREE="chromebook_link"
@@ -9,10 +16,18 @@ CONFIG_HAVE_MRC=y
 CONFIG_SMP=y
 CONFIG_HAVE_VGA_BIOS=y
 CONFIG_FIT=y
+CONFIG_SPL_LOAD_FIT=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_CPU_SUPPORT=y
+CONFIG_SPL_NET_SUPPORT=y
+CONFIG_SPL_PCI_SUPPORT=y
+CONFIG_SPL_PCH_SUPPORT=y
+CONFIG_SPL_RTC_SUPPORT=y
+CONFIG_SPL_TIMER_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_CPU=y
 # CONFIG_CMD_IMLS is not set
@@ -35,8 +50,12 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_SPL_DM=y
 CONFIG_REGMAP=y
+CONFIG_SPL_REGMAP=y
 CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
 CONFIG_CPU=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_INTEL=y
include/configs/chromebook_link.h +9 -0
index f2d798a..b116a27 100644
@@ -19,4 +19,13 @@
 #define CONFIG_ENV_SECT_SIZE		0x1000
 #define CONFIG_ENV_OFFSET		0x003f8000
 
+#define CONFIG_SPL_FRAMEWORK
+
+#define CONFIG_SPL_TEXT_BASE		0xfffd0000
+
+#define BOOT_DEVICE_SPI			10
+
+#define CONFIG_SPL_BOARD_LOAD_IMAGE
+#define BOOT_DEVICE_BOARD		11
+
 #endif	/* __CONFIG_H */
Signature · 1 line
2.8.0.rc3.226.g39d4020
#129 lore raw

PATCH 81/82 x86: Update compile/link flags to support 64-bit U-Boot

In reply to Simon Glass

Update config.mk settings to support both 32-bit and 64-bit U-Boot.

---

 arch/x86/config.mk     | 30 ++++++++++++++++++++++++++++--
 arch/x86/cpu/config.mk |  2 --
 2 files changed, 28 insertions(+), 4 deletions(-)
arch/x86/config.mk +28 -2
index d7addd8..cd6ddef 100644
@@ -15,11 +15,25 @@ PF_CPPFLAGS_X86   := $(call cc-option, -fno-toplevel-reorder, \
 
 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
 PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
+
+ifdef CONFIG_SPL_BUILD
+IS_32BIT := y
+else
+ifndef CONFIG_X86_64
+IS_32BIT := y
+endif
+endif
+
+ifeq ($(IS_32BIT),y)
 PLATFORM_CPPFLAGS += -march=i386 -m32
+else
+PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common
+endif
 
 PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
 
-PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions -m elf_i386
+PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
+PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
 
 LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
 LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
@@ -31,7 +45,9 @@ LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
 OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
 	-j .rel -j .rela -j .reloc
 
+ifeq ($(IS_32BIT),y)
 CFLAGS_NON_EFI := -mregparm=3
+endif
 CFLAGS_EFI := -fpic -fshort-wchar
 
 ifeq ($(CONFIG_EFI_STUB_64BIT),)
@@ -62,6 +78,16 @@ else
 
 PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
 PLATFORM_LDFLAGS += --emit-relocs
-LDFLAGS_FINAL += --gc-sections -pie
+LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
+
+endif
 
+ifdef CONFIG_X86_64
+ifndef CONFIG_SPL_BUILD
+PLATFORM_CPPFLAGS += -D__x86_64__
+else
+PLATFORM_CPPFLAGS += -D__I386__
+endif
+else
+PLATFORM_CPPFLAGS += -D__I386__
 endif
arch/x86/cpu/config.mk +0 -2
index 4c99a35..b519f43 100644
@@ -7,8 +7,6 @@
 
 CROSS_COMPILE ?= i386-linux-
 
-PLATFORM_CPPFLAGS += -D__I386__
-
 # DO NOT MODIFY THE FOLLOWING UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!
 LDPPFLAGS += -DRESET_SEG_START=$(CONFIG_RESET_SEG_START)
 LDPPFLAGS += -DRESET_SEG_SIZE=$(CONFIG_RESET_SEG_SIZE)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#130 lore raw

PATCH 82/82 x86: link: Switch to 64-bit U-Boot

In reply to Simon Glass

Change link to use 64-bit U-Boot. This is not fully functional but is it a start. Missing features:

- SDRAM sizing
- Booting linux
- EFI support
- SCSI device init
(and others)

---

 configs/chromebook_link_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/chromebook_link_defconfig +1 -0
index ff28fb8..2b94d1e 100644
@@ -8,6 +8,7 @@ CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_VIDEO=y
+CONFIG_X86_RUN_64BIT=y
 CONFIG_VENDOR_GOOGLE=y
 CONFIG_DEFAULT_DEVICE_TREE="chromebook_link"
 CONFIG_TARGET_CHROMEBOOK_LINK=y
Signature · 1 line
2.8.0.rc3.226.g39d4020
#131 lore raw

cover x86: Add initial support for 64-bit U-Boot

In reply to Simon Glass

Hi Simon,

Quoted 27 lines · Simon Glass

At present U-Boot runs entirely in 32-bit mode on x86, except for the initial switch from 16-bit mode. On 64-bit machines it is possible to run in 64-bit mode. This series starts the process of adding this support.

The main benefit of 64-bit mode for a boot loader is direct access to all available memory. There are also more registers, but this makes very little difference.

This feature is implemented by putting all of the 32-bit code in an SPL build. SPL then runs through all the init that has to be done in 32-bit mode, changes to 64-bit mode and then jumps to U-Boot proper.

Typically the total code size increases slightly. For example, on link in 32-bit mode, U-Boot has around 480KB of code (admittedly with a large number of features enabled). In 64-bit mode, U-Boot falls to around 460KB, but SPL adds another 60KB, for a net increase of 40KB. Partly this is due to code duplication and partly it is due to the worse code density of 64-bit code on x86.

Many major features are not implemented yet, for example:
- SDRAM sizing
- Booting linux
- FSP support
- EFI support
- SCSI device init
- Running video ROMs

Quoted 5 lines

Still, this is a big step forward towards full 64-bit support. To enable it, select CONFIG_X86_RUN_64BIT.

This series is available at u-boot-x86/64-working

Looks it requires a 64-bit toolchain to compile 64-bit U-Boot. For example, I used kernel.org i386 toolchain to compile 64-bit U-Boot, I got:

include/asm-generic/bitops/__fls.h: In function '__fls':
include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of type
if (!(word & (~0ul << 32))) {
^
include/asm-generic/bitops/__fls.h:19:3: warning: left shift count >= width of type
word <<= 32;
^
include/asm-generic/bitops/__fls.h:22:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
^
include/asm-generic/bitops/__fls.h:26:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
^
include/asm-generic/bitops/__fls.h:30:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
^
include/asm-generic/bitops/__fls.h:34:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
^
include/asm-generic/bitops/__fls.h:38:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-1))))
^
arch/x86/cpu/intel_common/microcode.c: In function 'microcode_read_rev':
arch/x86/cpu/intel_common/microcode.c:79:2: error: PIC register clobbered by 'ebx' in 'asm'
asm volatile (
^
make[2]: *** [arch/x86/cpu/intel_common/microcode.o] Error 1

After I switched to 64-bit toolchain from kernel.org (x86_64-linux), there was no such warnings/errors, but I still got build failure at last.

./tools/binman/binman -d u-boot.dtb -O . -I . -I
./board/google/chromebook_link u-boot-x86-16bit.bin Traceback (most recent call last):
File "./tools/binman/binman", line 31, in <module>
import control
File "./tools/binman/control.py", line 17, in <module>
from image import Image
File "./tools/binman/image.py", line 12, in <module>
import entry
File "./tools/binman/etype/entry.py", line 8, in <module>
import importlib
ImportError: No module named importlib
make: *** [u-boot.rom] Error 1

Regards,
Bin

#132 lore raw

cover x86: Add initial support for 64-bit U-Boot

Hi Bin,

Quoted 67 lines · Bin Meng

Hi Simon,

Quoted 27 lines · Simon Glass

At present U-Boot runs entirely in 32-bit mode on x86, except for the initial switch from 16-bit mode. On 64-bit machines it is possible to run in 64-bit mode. This series starts the process of adding this support.

The main benefit of 64-bit mode for a boot loader is direct access to all available memory. There are also more registers, but this makes very little difference.

This feature is implemented by putting all of the 32-bit code in an SPL build. SPL then runs through all the init that has to be done in 32-bit mode, changes to 64-bit mode and then jumps to U-Boot proper.

Typically the total code size increases slightly. For example, on link in 32-bit mode, U-Boot has around 480KB of code (admittedly with a large number of features enabled). In 64-bit mode, U-Boot falls to around 460KB, but SPL adds another 60KB, for a net increase of 40KB. Partly this is due to code duplication and partly it is due to the worse code density of 64-bit code on x86.

Many major features are not implemented yet, for example:
- SDRAM sizing
- Booting linux
- FSP support
- EFI support
- SCSI device init
- Running video ROMs

Quoted 5 lines

Still, this is a big step forward towards full 64-bit support. To enable it, select CONFIG_X86_RUN_64BIT.

This series is available at u-boot-x86/64-working

Looks it requires a 64-bit toolchain to compile 64-bit U-Boot. For example, I used kernel.org i386 toolchain to compile 64-bit U-Boot, I got:

include/asm-generic/bitops/__fls.h: In function '__fls':
include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of type
if (!(word & (~0ul << 32))) {
^
include/asm-generic/bitops/__fls.h:19:3: warning: left shift count >= width of type

   word <<= 32;
   ^

include/asm-generic/bitops/__fls.h:22:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
^
include/asm-generic/bitops/__fls.h:26:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
^
include/asm-generic/bitops/__fls.h:30:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
^
include/asm-generic/bitops/__fls.h:34:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
^
include/asm-generic/bitops/__fls.h:38:2: warning: left shift count >= width of type

Quoted 8 lines

if (!(word & (~0ul << (BITS_PER_LONG-1))))
^
arch/x86/cpu/intel_common/microcode.c: In function 'microcode_read_rev':
arch/x86/cpu/intel_common/microcode.c:79:2: error: PIC register clobbered by 'ebx' in 'asm'
asm volatile (
^
make[2]: *** [arch/x86/cpu/intel_common/microcode.o] Error 1

Yes, that is expected.

Quoted 5 lines

After I switched to 64-bit toolchain from kernel.org (x86_64-linux), there was no such warnings/errors, but I still got build failure at last.

Quoted 13 lines

./tools/binman/binman -d u-boot.dtb -O . -I . -I
./board/google/chromebook_link u-boot-x86-16bit.bin Traceback (most recent call last):
File "./tools/binman/binman", line 31, in <module>
import control
File "./tools/binman/control.py", line 17, in <module>
from image import Image
File "./tools/binman/image.py", line 12, in <module>
import entry
File "./tools/binman/etype/entry.py", line 8, in <module>
import importlib
ImportError: No module named importlib
make: *** [u-boot.rom] Error 1

What version of python do you use?

Regards,
Simon

#133 lore raw

cover x86: Add initial support for 64-bit U-Boot

Hi Simon,

Quoted 79 lines · Simon Glass

Hi Bin,

Quoted 67 lines · Bin Meng

Hi Simon,

Quoted 27 lines · Simon Glass

At present U-Boot runs entirely in 32-bit mode on x86, except for the initial switch from 16-bit mode. On 64-bit machines it is possible to run in 64-bit mode. This series starts the process of adding this support.

The main benefit of 64-bit mode for a boot loader is direct access to all available memory. There are also more registers, but this makes very little difference.

This feature is implemented by putting all of the 32-bit code in an SPL build. SPL then runs through all the init that has to be done in 32-bit mode, changes to 64-bit mode and then jumps to U-Boot proper.

Typically the total code size increases slightly. For example, on link in 32-bit mode, U-Boot has around 480KB of code (admittedly with a large number of features enabled). In 64-bit mode, U-Boot falls to around 460KB, but SPL adds another 60KB, for a net increase of 40KB. Partly this is due to code duplication and partly it is due to the worse code density of 64-bit code on x86.

Many major features are not implemented yet, for example:
- SDRAM sizing
- Booting linux
- FSP support
- EFI support
- SCSI device init
- Running video ROMs

Quoted 5 lines

Still, this is a big step forward towards full 64-bit support. To enable it, select CONFIG_X86_RUN_64BIT.

This series is available at u-boot-x86/64-working

Looks it requires a 64-bit toolchain to compile 64-bit U-Boot. For example, I used kernel.org i386 toolchain to compile 64-bit U-Boot, I got:

include/asm-generic/bitops/__fls.h: In function '__fls':
include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of type
if (!(word & (~0ul << 32))) {
^
include/asm-generic/bitops/__fls.h:19:3: warning: left shift count >= width of type

   word <<= 32;
   ^

include/asm-generic/bitops/__fls.h:22:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
^
include/asm-generic/bitops/__fls.h:26:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
^
include/asm-generic/bitops/__fls.h:30:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
^
include/asm-generic/bitops/__fls.h:34:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
^
include/asm-generic/bitops/__fls.h:38:2: warning: left shift count >= width of type

Quoted 8 lines

if (!(word & (~0ul << (BITS_PER_LONG-1))))
^
arch/x86/cpu/intel_common/microcode.c: In function 'microcode_read_rev':
arch/x86/cpu/intel_common/microcode.c:79:2: error: PIC register clobbered by 'ebx' in 'asm'
asm volatile (
^
make[2]: *** [arch/x86/cpu/intel_common/microcode.o] Error 1

Quoted 1 line

Yes, that is expected.

Can we make the i386 toolchain work? Linux 64-bit kernel build does not require the toolchain to be 64-bit.

Quoted 19 lines
Quoted 5 lines

After I switched to 64-bit toolchain from kernel.org (x86_64-linux), there was no such warnings/errors, but I still got build failure at last.

Quoted 13 lines

./tools/binman/binman -d u-boot.dtb -O . -I . -I
./board/google/chromebook_link u-boot-x86-16bit.bin Traceback (most recent call last):
File "./tools/binman/binman", line 31, in <module>
import control
File "./tools/binman/control.py", line 17, in <module>
from image import Image
File "./tools/binman/image.py", line 12, in <module>
import entry
File "./tools/binman/etype/entry.py", line 8, in <module>
import importlib
ImportError: No module named importlib
make: *** [u-boot.rom] Error 1

Quoted 1 line

What version of python do you use?

$ python -V
Python 2.7.12

Regards,
Bin

#134 lore raw

cover x86: Add initial support for 64-bit U-Boot

Hi Bin,

Quoted 82 lines · Bin Meng

Hi Simon,

Quoted 79 lines · Simon Glass

Hi Bin,

Quoted 75 lines · Bin Meng

Hi Simon,

Quoted 27 lines · Simon Glass

At present U-Boot runs entirely in 32-bit mode on x86, except for the initial switch from 16-bit mode. On 64-bit machines it is possible to run in 64-bit mode. This series starts the process of adding this support.

The main benefit of 64-bit mode for a boot loader is direct access to all available memory. There are also more registers, but this makes very little difference.

This feature is implemented by putting all of the 32-bit code in an SPL build. SPL then runs through all the init that has to be done in 32-bit mode, changes to 64-bit mode and then jumps to U-Boot proper.

Typically the total code size increases slightly. For example, on link in 32-bit mode, U-Boot has around 480KB of code (admittedly with a large number of features enabled). In 64-bit mode, U-Boot falls to around 460KB, but SPL adds another 60KB, for a net increase of 40KB. Partly this is due to code duplication and partly it is due to the worse code density of 64-bit code on x86.

Many major features are not implemented yet, for example:
- SDRAM sizing
- Booting linux
- FSP support
- EFI support
- SCSI device init
- Running video ROMs

Quoted 5 lines

Still, this is a big step forward towards full 64-bit support. To enable it, select CONFIG_X86_RUN_64BIT.

This series is available at u-boot-x86/64-working

Looks it requires a 64-bit toolchain to compile 64-bit U-Boot. For example, I used kernel.org i386 toolchain to compile 64-bit U-Boot, I got:

include/asm-generic/bitops/__fls.h: In function '__fls':
include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of type
if (!(word & (~0ul << 32))) {
^
include/asm-generic/bitops/__fls.h:19:3: warning: left shift count >= width of type

   word <<= 32;
   ^

include/asm-generic/bitops/__fls.h:22:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
^
include/asm-generic/bitops/__fls.h:26:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
^
include/asm-generic/bitops/__fls.h:30:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
^
include/asm-generic/bitops/__fls.h:34:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
^
include/asm-generic/bitops/__fls.h:38:2: warning: left shift count >= width of type
if (!(word & (~0ul << (BITS_PER_LONG-1))))
^
arch/x86/cpu/intel_common/microcode.c: In function 'microcode_read_rev':
arch/x86/cpu/intel_common/microcode.c:79:2: error: PIC register clobbered by 'ebx' in 'asm'
asm volatile (
^
make[2]: *** [arch/x86/cpu/intel_common/microcode.o] Error 1

Quoted 4 lines
Quoted 1 line

Yes, that is expected.

Can we make the i386 toolchain work? Linux 64-bit kernel build does not require the toolchain to be 64-bit.

I can fix the header file warnings, but things like pushq do not seem to be supported on the i386 toolchain. Perhaps this is something to look at later.

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines

After I switched to 64-bit toolchain from kernel.org (x86_64-linux), there was no such warnings/errors, but I still got build failure at last.

./tools/binman/binman -d u-boot.dtb -O . -I . -I
./board/google/chromebook_link u-boot-x86-16bit.bin Traceback (most recent call last):
File "./tools/binman/binman", line 31, in <module>
import control
File "./tools/binman/control.py", line 17, in <module>
from image import Image
File "./tools/binman/image.py", line 12, in <module>
import entry
File "./tools/binman/etype/entry.py", line 8, in <module>
import importlib
ImportError: No module named importlib
make: *** [u-boot.rom] Error 1

Quoted 4 lines
Quoted 1 line

What version of python do you use?

$ python -V
Python 2.7.12

I thought importlib was implemented in 2.7 (I am using 2.7.6 which is older). But I'll add a work-around for this as it seems I was wrong.

Regards,
Simon