Skip to contentSkip to conversation

Various x86 patches

PATCH New Graeme Russ 4 participants 20 messages Apr 29, 2012 – Nov 28, 2012 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Various x86 patches

These have been floating around for a while waiting for 2012.04

The first patch touches on the common makefiles, but it is only examples/standalone/Makefile that really needs to be checked for cross-platform issues

Graeme Russ (5):
x86: Fix compilation on 64-built built machines
x86: Forward declate gd_t
x86: Put global data on the stack
x86: Remove duplicate PCI init
x86: Add ilog2 to bitops

 Makefile                            |    1 +
 arch/x86/cpu/config.mk              |    3 +-
 arch/x86/cpu/cpu.c                  |    6 ---
 arch/x86/cpu/start.S                |   67 +++++++++++++++++++++++++++++++----
 arch/x86/include/asm/bitops.h       |    5 +++
 arch/x86/include/asm/global_data.h  |    5 ++-
 arch/x86/include/asm/init_helpers.h |    1 -
 arch/x86/include/asm/processor.h    |    1 +
 arch/x86/lib/board.c                |    5 +--
 arch/x86/lib/init_helpers.c         |   37 +-------------------
 examples/standalone/Makefile        |    2 +-
 include/configs/eNET.h              |    6 ---
 12 files changed, 75 insertions(+), 64 deletions(-)
Signature · 1 line
1.7.7.6
#1 lore raw

PATCH 1/5 x86: Fix compilation on 64-built built machines

---
 Makefile                     |    1 +
 arch/x86/cpu/config.mk       |    3 ++-
 examples/standalone/Makefile |    2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)
Makefile +1 -0
index cdd4294..4f5cb60 100644
@@ -35,6 +35,7 @@ VERSION_FILE = $(obj)include/generated/version_autogenerated.h
 
 HOSTARCH := $(shell uname -m | \
 	sed -e s/i.86/x86/ \
+	    -e s/x86_64/x86/ \
 	    -e s/sun4u/sparc64/ \
 	    -e s/arm.*/arm/ \
 	    -e s/sa110/arm/ \
arch/x86/cpu/config.mk +2 -1
index c00f867..092de68 100644
@@ -23,7 +23,8 @@
 
 CROSS_COMPILE ?= i386-linux-
 
-PLATFORM_CPPFLAGS += -DCONFIG_X86 -D__I386__ -march=i386 -Werror
+PLATFORM_CPPFLAGS += -DCONFIG_X86 -D__I386__ -march=i386 -Werror -m32
+PLATFORM_LDFLAGS += -m elf_i386
 
 # DO NOT MODIFY THE FOLLOWING UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!
 LDPPFLAGS += -DRESET_SEG_START=0xffff0000
examples/standalone/Makefile +1 -1
index baaa2fb..7c1ea5c 100644
@@ -98,7 +98,7 @@ $(ELF):
 $(obj)%:	$(obj)%.o $(LIB)
 		$(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
 			-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
-			-L$(gcclibdir) -lgcc
+			-L$(USE_PRIVATE_LIBGCC) -lgcc
 
 $(SREC):
 $(obj)%.srec:	$(obj)%
Signature · 1 line
1.7.7.6
#3 lore raw

PATCH 2/5 x86: Forward declate gd_t

In reply to Graeme Russ

So it can be used as a type in struct global_data and remove an ugly typecast

---
 arch/x86/cpu/cpu.c                 |    2 +-
 arch/x86/include/asm/global_data.h |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
arch/x86/cpu/cpu.c +1 -1
index e9bb0d7..67de6bc 100644
@@ -92,7 +92,7 @@ static void load_gdt(const u64 *boot_gdt, u16 num_entries)
 
 void init_gd(gd_t *id, u64 *gdt_addr)
 {
-	id->gd_addr = (ulong)id;
+	id->gd_addr = id;
 	setup_gdt(id, gdt_addr);
 }
 
arch/x86/include/asm/global_data.h +3 -1
index 908a02c..8a8896e 100644
@@ -35,9 +35,11 @@
 
 #ifndef __ASSEMBLY__
 
+typedef struct global_data gd_t;
+
 typedef	struct global_data {
 	/* NOTE: gd_addr MUST be first member of struct global_data! */
-	unsigned long	gd_addr;	/* Location of Global Data */
+	gd_t		*gd_addr;	/* Location of Global Data */
 	bd_t		*bd;
 	unsigned long	flags;
 	unsigned long	baudrate;
Signature · 1 line
1.7.7.6
#4 lore raw

PATCH 2/5 x86: Forward declate gd_t

Dear Graeme Russ,

Quoted 30 lines

So it can be used as a type in struct global_data and remove an ugly typecast

---
 arch/x86/cpu/cpu.c                 |    2 +-
 arch/x86/include/asm/global_data.h |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
arch/x86/cpu/cpu.c +1 -1
index e9bb0d7..67de6bc 100644
@@ -92,7 +92,7 @@ static void load_gdt(const u64 *boot_gdt, u16
 num_entries)
 
 void init_gd(gd_t *id, u64 *gdt_addr)
 {
-	id->gd_addr = (ulong)id;
+	id->gd_addr = id;
 	setup_gdt(id, gdt_addr);
 }
(quoted diff) +0 -0

b/arch/x86/include/asm/global_data.h index 908a02c..8a8896e 100644

arch/x86/include/asm/global_data.h +0 -0
@@ -35,9 +35,11 @@
 
 #ifndef __ASSEMBLY__

arch/x86/include/asm/global_data.h line 45

Quoted 10 lines
arch/x86/include/asm/global_data.h +3 -1
 
+typedef struct global_data gd_t;
+
 typedef	struct global_data {
 	/* NOTE: gd_addr MUST be first member of struct global_data! */
-	unsigned long	gd_addr;	/* Location of Global Data */
+	gd_t		*gd_addr;	/* Location of Global Data */
 	bd_t		*bd;
 	unsigned long	flags;
 	unsigned long	baudrate;

Best regards,
Marek Vasut

#5 lore raw

PATCH 2/5 x86: Forward declate gd_t

Hi,

Quoted 10 lines · Marek Vasut

Dear Graeme Russ,

Quoted 8 lines

So it can be used as a type in struct global_data and remove an ugly typecast

---
 arch/x86/cpu/cpu.c                 |    2 +-
 arch/x86/include/asm/global_data.h |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

I had to modify this slightly to get it to build (added the same cast fix to sdram.c as you did to cpu.c). Then, applied to x86/next.

Regards,
Simon

#6 lore raw

PATCH 2/5 x86: Forward declate gd_t

Dear Simon Glass,

Quoted 11 lines

Hi,

Quoted 8 lines · Marek Vasut

Dear Graeme Russ,

Quoted 6 lines

So it can be used as a type in struct global_data and remove an ugly typecast

---

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
 arch/x86/cpu/cpu.c                 |    2 +-
 arch/x86/include/asm/global_data.h |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

I had to modify this slightly to get it to build (added the same cast fix to sdram.c as you did to cpu.c). Then, applied to x86/next.

It'd be really nice if you could possibly take over the x86 custodianship from Graeme, it seems this arch is rotting :(

Best regards,
Marek Vasut

#7 lore raw

PATCH 2/5 x86: Forward declate gd_t

Hi Marek,

Quoted 17 lines · Marek Vasut

Dear Simon Glass,

Quoted 15 lines

Hi,

Quoted 11 lines · Marek Vasut

Dear Graeme Russ,

Quoted 9 lines

So it can be used as a type in struct global_data and remove an ugly typecast

---

 arch/x86/cpu/cpu.c                 |    2 +-
 arch/x86/include/asm/global_data.h |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 2 lines

I had to modify this slightly to get it to build (added the same cast fix to sdram.c as you did to cpu.c). Then, applied to x86/next.

It'd be really nice if you could possibly take over the x86 custodianship from Graeme, it seems this arch is rotting :(

Your wish is my command :-)

Regards,
Simon

Quoted 3 lines

Best regards,
Marek Vasut

#8 lore raw

PATCH 2/5 x86: Forward declate gd_t

Dear Simon Glass,

Quoted 20 lines

Hi Marek,

Quoted 17 lines · Marek Vasut

Dear Simon Glass,

Quoted 15 lines

Hi,

Quoted 11 lines · Marek Vasut

Dear Graeme Russ,

Quoted 9 lines

So it can be used as a type in struct global_data and remove an ugly typecast

---

 arch/x86/cpu/cpu.c                 |    2 +-
 arch/x86/include/asm/global_data.h |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I had to modify this slightly to get it to build (added the same cast fix to sdram.c as you did to cpu.c). Then, applied to x86/next.

It'd be really nice if you could possibly take over the x86 custodianship from Graeme, it seems this arch is rotting :(

Your wish is my command :-)

Not so fast, this stuff is better discussed with both of those guys (CCed)

Best regards,
Marek Vasut

#9 lore raw

PATCH 2/5 x86: Forward declate gd_t

Hi Marek,

Quoted 27 lines · Marek Vasut

Dear Simon Glass,

Quoted 11 lines

Hi Marek,

Quoted 8 lines · Marek Vasut

Dear Simon Glass,

Quoted 6 lines

Hi,

Quoted 3 lines · Marek Vasut

Dear Graeme Russ,

Quoted 1 line

So it can be used as a type in struct global_data and remove an

ugly

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

typecast

---

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
 arch/x86/cpu/cpu.c                 |    2 +-
 arch/x86/include/asm/global_data.h |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

I had to modify this slightly to get it to build (added the same cast fix to sdram.c as you did to cpu.c). Then, applied to x86/next.

It'd be really nice if you could possibly take over the x86

Quoted 8 lines

custodianship

Quoted 3 lines
Quoted 1 line

from Graeme, it seems this arch is rotting :(

Your wish is my command :-)

Not so fast, this stuff is better discussed with both of those guys (CCed)

You've either had too much beer or too little sleep (or both) - Simon took

over several weeks ago :)

Regards,

Graeme

#10 lore raw

PATCH 2/5 x86: Forward declate gd_t

Dear Graeme Russ,

Quoted 40 lines

Hi Marek,

Quoted 37 lines · Marek Vasut

Dear Simon Glass,

Quoted 11 lines

Hi Marek,

Quoted 8 lines · Marek Vasut

Dear Simon Glass,

Quoted 6 lines

Hi,

Quoted 3 lines · Marek Vasut

Dear Graeme Russ,

Quoted 1 line

So it can be used as a type in struct global_data and remove an

ugly

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

typecast

---

 arch/x86/cpu/cpu.c                 |    2 +-
 arch/x86/include/asm/global_data.h |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

I had to modify this slightly to get it to build (added the same cast fix to sdram.c as you did to cpu.c). Then, applied to x86/next.

It'd be really nice if you could possibly take over the x86

custodianship

Quoted 3 lines
Quoted 1 line

from Graeme, it seems this arch is rotting :(

Your wish is my command :-)

Quoted 7 lines
Quoted 5 lines

Not so fast, this stuff is better discussed with both of those guys (CCed)

You've either had too much beer or too little sleep (or both) - Simon took

over several weeks ago :)

I completely missed that, sorry :-(

Best regards,
Marek Vasut

#11 lore raw

PATCH 3/5 x86: Put global data on the stack

In reply to Graeme Russ

Putting global data on the stack simplifies the init process (and makes it slightly quicker). During the 'flash' stage of the init sequence, global data is in the CAR stack. After SDRAM is initialised, global data is copied from CAR to the SDRAM stack

---
 arch/x86/cpu/cpu.c                  |    6 ---
 arch/x86/cpu/start.S                |   67 +++++++++++++++++++++++++++++++----
 arch/x86/include/asm/global_data.h  |    1 -
 arch/x86/include/asm/init_helpers.h |    1 -
 arch/x86/include/asm/processor.h    |    1 +
 arch/x86/lib/board.c                |    2 +-
 arch/x86/lib/init_helpers.c         |   37 +-------------------
 include/configs/eNET.h              |    6 ---
 8 files changed, 63 insertions(+), 58 deletions(-)
arch/x86/cpu/cpu.c +0 -6
index 67de6bc..9c2db9f 100644
@@ -90,12 +90,6 @@ static void load_gdt(const u64 *boot_gdt, u16 num_entries)
 	asm volatile("lgdtl %0\n" : : "m" (gdt));
 }
 
-void init_gd(gd_t *id, u64 *gdt_addr)
-{
-	id->gd_addr = id;
-	setup_gdt(id, gdt_addr);
-}
-
 void setup_gdt(gd_t *id, u64 *gdt_addr)
 {
 	/* CS: code, read/execute, 4 GB, base 0 */
arch/x86/cpu/start.S +60 -7

82 lines not on this page · raw message

arch/x86/include/asm/global_data.h +0 -1
index 8a8896e..c55543e 100644
@@ -56,7 +56,6 @@ typedef	struct global_data {
 	unsigned long	relocaddr;	/* Start address of U-Boot in RAM */
 	unsigned long	start_addr_sp;	/* start_addr_stackpointer */
 	unsigned long	gdt_addr;	/* Location of GDT */
-	unsigned long	new_gd_addr;	/* New location of Global Data */
 	phys_size_t	ram_size;	/* RAM size */
 	unsigned long	reset_status;	/* reset status register at boot */
 	void		**jt;		/* jump table */
arch/x86/include/asm/init_helpers.h +0 -1
index 192f18e..d11d35a 100644
@@ -29,7 +29,6 @@ int display_dram_config(void);
 int init_baudrate_f(void);
 int calculate_relocation_address(void);
 
-int copy_gd_to_ram_f_r(void);
 int init_cache_f_r(void);
 
 int set_reloc_flag_r(void);
arch/x86/include/asm/processor.h +1 -0
index 6eb5180..17f27cb 100644
@@ -41,6 +41,7 @@ enum {
 #else
 /* NOTE: If the above enum is modified, this define must be checked */
 #define X86_GDT_ENTRY_32BIT_DS	3
+#define X86_GDT_NUM_ENTRIES	7
 #endif
 
 #define X86_GDT_SIZE		(X86_GDT_NUM_ENTRIES * X86_GDT_ENTRY_SIZE)
arch/x86/lib/board.c +1 -1
index 5f0b62c..100ac1e 100644
@@ -36,6 +36,7 @@
 #include <stdio_dev.h>
 #include <asm/u-boot-x86.h>
 #include <asm/relocate.h>
+#include <asm/processor.h>
 
 #include <asm/init_helpers.h>
 #include <asm/init_wrappers.h>
@@ -121,7 +122,6 @@ init_fnc_t *init_sequence_f[] = {
  * initialise the CPU caches (to speed up the relocation process)
  */
 init_fnc_t *init_sequence_f_r[] = {
-	copy_gd_to_ram_f_r,
 	init_cache_f_r,
 	copy_uboot_to_ram,
 	clear_bss,
arch/x86/lib/init_helpers.c +1 -36
index 9f4dee0..d228906 100644
@@ -83,18 +83,8 @@ int calculate_relocation_address(void)
 	 *       requirements
 	 */
 
-	/* Global Data is at top of available memory */
+	/* Stack is at top of available memory */
 	dest_addr = gd->ram_size;
-	dest_addr -= GENERATED_GBL_DATA_SIZE;
-	dest_addr &= ~15;
-	gd->new_gd_addr = dest_addr;
-
-	/* GDT is below Global Data */
-	dest_addr -= X86_GDT_SIZE;
-	dest_addr &= ~15;
-	gd->gdt_addr = dest_addr;
-
-	/* Stack is below GDT */
 	gd->start_addr_sp = dest_addr;
 
 	/* U-Boot is below the stack */
@@ -107,31 +97,6 @@ int calculate_relocation_address(void)
 	return 0;
 }
 
-int copy_gd_to_ram_f_r(void)
-{
-	gd_t *ram_gd;
-
-	/*
-	 * Global data is still in temporary memory (the CPU cache).
-	 * calculate_relocation_address() has set gd->new_gd_addr to
-	 * where the global data lives in RAM but getting it there
-	 * safely is a bit tricky due to the 'F-Segment Hack' that
-	 * we need to use for x86
-	 */
-	ram_gd = (gd_t *)gd->new_gd_addr;
-	memcpy((void *)ram_gd, gd, sizeof(gd_t));
-
-	/*
-	 * Reload the Global Descriptor Table so FS points to the
-	 * in-RAM copy of Global Data (calculate_relocation_address()
-	 * has already calculated the in-RAM location of the GDT)
-	 */
-	ram_gd->gd_addr = (ulong)ram_gd;
-	init_gd(ram_gd, (u64 *)gd->gdt_addr);
-
-	return 0;
-}
-
 int init_cache_f_r(void)
 {
 	/* Initialise the CPU cache(s) */
include/configs/eNET.h +0 -6
index d5c9cad..3c6c6f1 100644
@@ -169,16 +169,10 @@
 #define CONFIG_SYS_STACK_SIZE			(32 * 1024)
 #define CONFIG_SYS_CAR_ADDR			0x19200000
 #define CONFIG_SYS_CAR_SIZE			(16 * 1024)
-#define CONFIG_SYS_INIT_SP_ADDR			(CONFIG_SYS_CAR_ADDR + \
-						 CONFIG_SYS_CAR_SIZE)
 #define CONFIG_SYS_MONITOR_BASE			CONFIG_SYS_TEXT_BASE
 #define CONFIG_SYS_MONITOR_LEN			(256 * 1024)
 #define CONFIG_SYS_MALLOC_LEN			(CONFIG_ENV_SECT_SIZE + \
 						 128*1024)
-/* Address of temporary Global Data */
-#define CONFIG_SYS_INIT_GD_ADDR			CONFIG_SYS_CAR_ADDR
-
-
 /* allow to overwrite serial and ethaddr */
 #define CONFIG_ENV_OVERWRITE
 
Signature · 1 line
1.7.7.6
#12 lore raw

PATCH 3/5 x86: Put global data on the stack

Hi Graham,

Quoted 6 lines · Graeme Russ

Putting global data on the stack simplifies the init process (and makes it slightly quicker). During the 'flash' stage of the init sequence, global data is in the CAR stack. After SDRAM is initialised, global data is copied from CAR to the SDRAM stack

As it is this changes breaks coreboot. It just needs the CAR defines added to coreboot.h also, so I have done this and pulled it into x86/next. I hope that is ok.

Regards,
Simon

#13 lore raw

PATCH 4/5 x86: Remove duplicate PCI init

In reply to Graeme Russ
---
 arch/x86/lib/board.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
arch/x86/lib/board.c +0 -3
index 100ac1e..8c8b6fe 100644
@@ -169,9 +169,6 @@ init_fnc_t *init_sequence_r[] = {
 #ifdef CONFIG_MISC_INIT_R
 	misc_init_r,
 #endif
-#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
-	pci_init_r,
-#endif
 #if defined(CONFIG_CMD_KGDB)
 	kgdb_init_r,
 #endif
Signature · 1 line
1.7.7.6
#15 lore raw

PATCH 5/5 x86: Add ilog2 to bitops

In reply to Graeme Russ

ilog2 is required by AHCI driver

---
 arch/x86/include/asm/bitops.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/include/asm/bitops.h +5 -0
index c7a38f2..5a7e4cb 100644
@@ -351,6 +351,11 @@ static __inline__ int ffs(int x)
 }
 #define PLATFORM_FFS
 
+static inline int __ilog2(unsigned int x)
+{
+	return generic_fls(x) - 1;
+}
+
 /**
  * hweightN - returns the hamming weight of a N-bit word
  * @x: the word to weigh
Signature · 1 line
1.7.7.6
#17 lore raw

cover Various x86 patches

In reply to Graeme Russ

Hi Graeme,

Quoted 2 lines

Graeme Russ (5):
x86: Fix compilation on 64-built built machines

Shouldn't this be 64-bit build machines?

Regards,

Andy.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#19 lore raw

cover Various x86 patches

Hi Andy,

Quoted 6 lines · Andy Pont

Hi Graeme,

Quoted 2 lines

Graeme Russ (5):
x86: Fix compilation on 64-built built machines

Shouldn't this be 64-bit build machines?

Yep - Thanks

Regards,

Graeme

#20 lore raw

cover Various x86 patches

Hi,

Quoted 11 lines · Graeme Russ

Hi Andy,

Quoted 6 lines · Andy Pont

Hi Graeme,

Quoted 2 lines

Graeme Russ (5):
x86: Fix compilation on 64-built built machines

Shouldn't this be 64-bit build machines?

Yep - Thanks

I found this series in patchwork so am bringing it into x86/next.

I updated it as above.

Regards,
Simon

Quoted 8 lines

Regards,

Graeme
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot