i386 Relocation
v2 cover i386 Relocation
Version 2 of previously submitted patch set. The changes are minor (added missed hiding of irq_common_entry in patch 8 and added #define CONFIG_RELOC_FIXUP_WORKS and setting GD_FLG_RELOC in patch 10)
This patch series implements full relocation support for the i386 port of U-Boot.
The first 5 patches came about due to my toolchain upgrade (to gcc 4.4.1 and binutils 2.19) (patch 4 id really just a quick tidy-up)
Patch 6 is a standalone bug-fix to resolve a start-up race condition
Patch 7 sets up the i386 interupt handling to be relocation friendly
Patches 8 and 9 are a relocation setup patch - no functionality change
By the end of patch 9, the i386 port is still non-relocatable
Patch 10 is the actual Relocation Patch itself
Relocation is achieved by utilising the -pie ld command line option and minimal boot-up processing of the resulting .rel.dyn section. By not using gcc's -fpie flag, the overhead of .got and the call/pop in each function entry is avoided - This prevents bloat of .text and .got and avoids the performance penalty of GOT lookups
This relocation scheme is possibly usable on many other arches
Many thanks to Joakim Tjernlund and Bill Campbell for their invaluable assistance and references.
Size analysis:
Non-Reloc Reloc
-------------------------------------
.text 0x00011970 0x00011850
.plt 0x00000000
.rodata 0x00005bae 0x00005b49
.data 0x00000a5c 0x00000a3c
.interp 0x00000013
.dynsym 0x000000f0
.dynstr 0x00000113
.hash 0x00000050
.got 0x00000000 0x00000000
.got.plt 0x0000000c
.dynamic 0x00000080
.u_boot_cmd 0x000003c0 0x000003c0
.rel.dyn 0x00004190
.bss 0x00001a34 0x00001a34
.realmode 0x00000166 0x00000166
.bios 0x0000053e 0x0000053e
.start16 0x000000bc 0x000000bc
.resetvec 0x00000010 0x00000010
=====================================
0x0001a4de 0x0001e7bb~17kB increase in binary image size (of which ~16kb is .rel.dyn which is not copied to RAM). Post processing of .rel.dyn could reduce the overhead by a further ~8kB - Speed improvement would be negligble and the only saving would be in image size, not RAM utilisation.
PATCH v2 1/10 Fix dlmalloc compile warning
--- board/eNET/config.mk | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
board/eNET/config.mk +1 -0
@@ -22,3 +22,4 @@ # TEXT_BASE = 0x38040000 +CFLAGS_dlmalloc.o += -Wa,--no-warn -fno-strict-aliasing
Signature · 1 line
1.6.4.1.174.g32f4c
Wolfgang Denk
AppliedPATCH v2 1/10 Fix dlmalloc compile warning
Dear Graeme Russ,
Quoted 5 lines · In message <[email protected]> you wrote:
Signed-off-by Graeme Russ <[email protected]>--- board/eNET/config.mk | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Not one hundred percent efficient, of course ... but nothing ever is. -- Kirk, "Metamorphosis", stardate 3219.8
PATCH v2 2/10 Fix i386 malloc initialisation
In reply to Graeme Russ--- common/dlmalloc.c | 6 ------ include/configs/eNET.h | 2 +- include/configs/sc520_cdp.h | 2 +- include/configs/sc520_spunk.h | 2 +- lib_i386/board.c | 15 +++++++-------- 5 files changed, 10 insertions(+), 17 deletions(-)
common/dlmalloc.c +0 -6
@@ -1522,11 +1522,6 @@ void *sbrk(ptrdiff_t increment)return (void *)old; } -#ifndef CONFIG_X86 -/* -* x86 boards use a slightly different init sequence thus they implement -* their own version of mem_malloc_init() -*/ void mem_malloc_init (ulong start,ulong size) { mem_malloc_start = start;
@@ -1535,7 +1530,6 @@ void mem_malloc_init(ulong start, ulong size)memset ((void *)mem_malloc_start,0 , size); } -#endif /* field-extraction macros */
include/configs/eNET.h +1 -1
@@ -61,7 +61,7 @@/* * Size of malloc() pool */ -#define CONFIG_MALLOC_SIZE (CONFIG_SYS_ENV_SIZE + 128*1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024)#define CONFIG_BAUDRATE 9600
include/configs/sc520_cdp.h +1 -1
@@ -65,7 +65,7 @@/* * Size of malloc() pool */ -#define CONFIG_MALLOC_SIZE (CONFIG_ENV_SIZE + 128*1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024)#define CONFIG_BAUDRATE 9600
include/configs/sc520_spunk.h +1 -1
@@ -63,7 +63,7 @@/* * Size of malloc() pool */ -#define CONFIG_MALLOC_SIZE (CONFIG_ENV_SIZE + 128*1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024)#define CONFIG_BAUDRATE 9600
lib_i386/board.c +7 -8
@@ -77,17 +77,16 @@ ulong i386boot_bios_size = (ulong)&_i386boot_bios_size; /* size of BIOSconst char version_string[] =U_BOOT_VERSION " (" U_BOOT_DATE " - " U_BOOT_TIME ")" ; -static int mem_malloc_init (void ) +static int heap_init (void ) {/* start malloc area right after the stack */ - mem_malloc_start = i386boot_bss_start + - i386boot_bss_size +CONFIG_SYS_STACK_SIZE ; - mem_malloc_start = (mem_malloc_start+3 )&~3 ; +ulong start = i386boot_bss_start + i386boot_bss_size + +CONFIG_SYS_STACK_SIZE ; -/* Use all available RAM for malloc() */ - mem_malloc_end = gd->ram_size; +/* 4-byte aligned */ + start = (start+3 )&~3 ; - mem_malloc_brk = mem_malloc_start; +mem_malloc_init (start,CONFIG_SYS_MALLOC_LEN );return 0 ; }
@@ -184,7 +183,7 @@ init_fnc_t *init_sequence[] = { cpu_init,/* basic cpu dependent setup */ board_init,/* basic board dependent setup */ dram_init,/* configure available RAM banks */ - mem_malloc_init,/* dependant on dram_init */ + heap_init,/* dependant on dram_init */ interrupt_init,/* set up exceptions */ timer_init, serial_init,
Signature · 1 line
1.6.4.1.174.g32f4c
Wolfgang Denk
AppliedPATCH v2 2/10 Fix i386 malloc initialisation
Dear Graeme Russ,
Quoted 9 lines · In message <[email protected]> you wrote:
Signed-off-by Graeme Russ <[email protected]>--- common/dlmalloc.c | 6 ------ include/configs/eNET.h | 2 +- include/configs/sc520_cdp.h | 2 +- include/configs/sc520_spunk.h | 2 +- lib_i386/board.c | 15 +++++++-------- 5 files changed, 10 insertions(+), 17 deletions(-)
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de America has been discovered before, but it has always been hushed up. - Oscar Wilde
PATCH v2 3/10 Fix link collisions resulting from gcc4.4.1 upgrade
In reply to Graeme Russ--- board/eNET/config.mk | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
board/eNET/config.mk +1 -0
@@ -23,3 +23,4 @@ TEXT_BASE = 0x38040000 CFLAGS_dlmalloc.o += -Wa,--no-warn -fno-strict-aliasing +PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
Signature · 1 line
1.6.4.1.174.g32f4c
Wolfgang Denk
AppliedPATCH v2 3/10 Fix link collisions resulting from gcc4.4.1 upgrade
Dear Graeme Russ,
Quoted 5 lines · In message <[email protected]> you wrote:
Signed-off-by Graeme Russ <[email protected]>--- board/eNET/config.mk | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Q: How many DEC repairman does it take to fix a flat ? A: Five; four to hold the car up and one to swap tires.
PATCH v2 4/10 Reorder source objects in lib_i386 Makefile
In reply to Graeme Russ--- lib_i386/Makefile | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
lib_i386/Makefile +4 -4
@@ -32,16 +32,16 @@ SOBJS-y += realmode_switch.o COBJS-y += bios_setup.o COBJS-y += board.o COBJS-y += bootm.o +COBJS-y += interrupts.o +COBJS-$(CONFIG_SYS_PCAT_INTERRUPTS) += pcat_interrupts.o +COBJS-$(CONFIG_SYS_GENERIC_TIMER) += pcat_timer.o COBJS-$(CONFIG_PCI) += pci.o COBJS-$(CONFIG_PCI) += pci_type1.o COBJS-y += realmode.o +COBJS-y += timer.o COBJS-y += video_bios.o COBJS-y += video.o COBJS-y += zimage.o -COBJS-y += interrupts.o -COBJS-y += timer.o -COBJS-$(CONFIG_SYS_PCAT_INTERRUPTS) += pcat_interrupts.o -COBJS-$(CONFIG_SYS_GENERIC_TIMER) += pcat_timer.o SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
Signature · 1 line
1.6.4.1.174.g32f4c
Wolfgang Denk
AppliedPATCH v2 4/10 Reorder source objects in lib_i386 Makefile
Dear Graeme Russ,
Quoted 5 lines · In message <[email protected]> you wrote:
Signed-off-by Graeme Russ <[email protected]>--- lib_i386/Makefile | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A list is only as strong as its weakest link. -- Don Knuth
PATCH v2 5/10 Fix global label in inline asm compile error
In reply to Graeme Russ--- include/configs/eNET.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/configs/eNET.h +2 -2
@@ -234,8 +234,8 @@#ifndef __ASSEMBLER__extern unsigned long ip; -#define PRINTIP asm ("call next_line\n" \ - "next_line:\n" \ +#define PRINTIP asm ("call 0\n" \ + "0:\n" \ "pop %%eax\n" \ "movl %%eax, %0\n" \ :"=r"(ip) \
Signature · 1 line
1.6.4.1.174.g32f4c
PATCH v2 6/10 Fix race condition when using SC520 timers
In reply to Graeme Russ--- cpu/i386/sc520/sc520_timer.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
cpu/i386/sc520/sc520_timer.c +6 -5
@@ -35,6 +35,12 @@ void sc520_timer_isr(void)int timer_init (void ) { +/* Register the SC520 specific timer interrupt handler */ +register_timer_isr (sc520_timer_isr); + +/* Install interrupt handler for GP Timer 1 */ +irq_install_handler (0 , timer_isr,NULL ); +/* Map GP Timer 1 to Master PIC IR0 */ sc520_mmcr->gp_tmr_int_map[1 ] =0x01 ;
@@ -54,11 +60,6 @@ int timer_init(void) sc520_mmcr->gptmr1maxcmpa =100 ; sc520_mmcr->gptmr1ctl =0xe009 ; -/* Register the SC520 specific timer interrupt handler */ -register_timer_isr (sc520_timer_isr); - -/* Install interrupt handler for GP Timer 1 */ -irq_install_handler (0 , timer_isr,NULL );unmask_irq (0 );/* Clear the GP Timer 1 status register to get the show rolling*/
Signature · 1 line
1.6.4.1.174.g32f4c
Wolfgang Denk
AppliedPATCH v2 6/10 Fix race condition when using SC520 timers
Dear Graeme Russ,
Quoted 5 lines · In message <[email protected]> you wrote:
Signed-off-by Graeme Russ <[email protected]>--- cpu/i386/sc520/sc520_timer.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Microsoft Compatibility:
your old Windows 3.11 application crash exactly as the new ones.PATCH v2 7/10 Rearrange i386 Interupt Handling
In reply to Graeme RussIn preperation for full relocation
--- cpu/i386/Makefile | 2 +- cpu/i386/cpu.c | 1 - cpu/i386/exceptions.c | 229 --------------------- cpu/i386/interrupts.c | 431 ++++++++++++++++++++++++++++++++++++++-- include/asm-i386/interrupt.h | 27 --- include/asm-i386/u-boot-i386.h | 3 - lib_i386/interrupts.c | 4 +- lib_i386/pcat_interrupts.c | 33 --- 8 files changed, 420 insertions(+), 310 deletions(-) delete mode 100644 cpu/i386/exceptions.c
cpu/i386/Makefile +1 -1
@@ -29,7 +29,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(CPU).a START = start.o start16.o resetvec.o -COBJS = serial.o interrupts.o exceptions.o cpu.o +COBJS = serial.o interrupts.o cpu.o SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
cpu/i386/cpu.c +0 -1
@@ -48,7 +48,6 @@ int cpu_init(void)/* Initialize core interrupt and exception functionality of CPU */ cpu_init_interrupts (); -cpu_init_exceptions ();return 0 ; }
cpu/i386/exceptions.c deleted +0 -229
229 lines not on this page · raw message
cpu/i386/interrupts.c +416 -15
479 lines not on this page · raw message
include/asm-i386/interrupt.h +0 -27
@@ -43,31 +43,4 @@ extern char exception_stack[];#define __isr__ void __attribute__ ((regparm(0))) -#define DECLARE_INTERRUPT (x) \ - asm(".globl irq_"#x"\n" \ - "irq_"#x":\n" \ - "pusha \n" \ - "pushl $"#x"\n" \ - "pushl $irq_return\n" \ - "jmp do_irq\n"); \ - __isr__ irq_##x(void) - -#define DECLARE_EXCEPTION (x, f) \ - asm(".globl exp_"#x"\n" \ - "exp_"#x":\n" \ - "pusha \n" \ - "movl %esp, %ebx\n" \ - "movl $exception_stack, %eax\n" \ - "movl %eax, %esp \n" \ - "pushl %ebx\n" \ - "movl 32(%esp), %ebx\n" \ - "xorl %edx, %edx\n" \ - "movw 36(%esp), %dx\n" \ - "pushl %edx\n" \ - "pushl %ebx\n" \ - "pushl $"#x"\n" \ - "pushl $exp_return\n" \ - "jmp "#f"\n"); \ - __isr__ exp_##x(void) -#endif
include/asm-i386/u-boot-i386.h +0 -3
@@ -55,9 +55,6 @@ int timer_init(void);/* cpu/.../interrupts.c */ int cpu_init_interrupts (void ); -/* cpu/.../exceptions.c */ -int cpu_init_exceptions (void ); -/* board/.../... */ int board_init (void );int dram_init (void );
lib_i386/interrupts.c +3 -1
@@ -109,8 +109,10 @@ void irq_free_handler(int irq)return ; } -__isr__ do_irq (int irq) +void do_irq (int hw_irq) { +int irq = hw_irq -0x20 ; +if (irq <0 || irq >=CONFIG_SYS_NUM_IRQS ) {printf ("do_irq: bad irq number %d\n" , irq);return ;
lib_i386/pcat_interrupts.c +0 -33
@@ -40,45 +40,12 @@#error "CONFIG_SYS_NUM_IRQS must equal 16 if CONFIG_SYS_NUM_IRQS is defined"#endif -DECLARE_INTERRUPT (0 ); -DECLARE_INTERRUPT (1 ); -DECLARE_INTERRUPT (3 ); -DECLARE_INTERRUPT (4 ); -DECLARE_INTERRUPT (5 ); -DECLARE_INTERRUPT (6 ); -DECLARE_INTERRUPT (7 ); -DECLARE_INTERRUPT (8 ); -DECLARE_INTERRUPT (9 ); -DECLARE_INTERRUPT (10 ); -DECLARE_INTERRUPT (11 ); -DECLARE_INTERRUPT (12 ); -DECLARE_INTERRUPT (13 ); -DECLARE_INTERRUPT (14 ); -DECLARE_INTERRUPT (15 ); -int interrupt_init (void ) {u8 i;disable_interrupts (); -/* Setup interrupts */ -set_vector (0x20 , irq_0); -set_vector (0x21 , irq_1); -set_vector (0x23 , irq_3); -set_vector (0x24 , irq_4); -set_vector (0x25 , irq_5); -set_vector (0x26 , irq_6); -set_vector (0x27 , irq_7); -set_vector (0x28 , irq_8); -set_vector (0x29 , irq_9); -set_vector (0x2a , irq_10); -set_vector (0x2b , irq_11); -set_vector (0x2c , irq_12); -set_vector (0x2d , irq_13); -set_vector (0x2e , irq_14); -set_vector (0x2f , irq_15); -/* Mask all interrupts */ outb (0xff ,MASTER_PIC +IMR );outb (0xff ,SLAVE_PIC +IMR );
Signature · 1 line
1.6.4.1.174.g32f4c
Wolfgang Denk
AppliedPATCH v2 7/10 Rearrange i386 Interupt Handling
Dear Graeme Russ,
Quoted 5 lines · In message <[email protected]> you wrote:
--===============1692275119==
In preperation for full relocation
Signed-off-by Graeme Russ <[email protected]>
Quoted 11 lines
--- cpu/i386/Makefile | 2 +- cpu/i386/cpu.c | 1 - cpu/i386/exceptions.c | 229 --------------------- cpu/i386/interrupts.c | 431 ++++++++++++++++++++++++++++++++++++++-- include/asm-i386/interrupt.h | 27 --- include/asm-i386/u-boot-i386.h | 3 - lib_i386/interrupts.c | 4 +- lib_i386/pcat_interrupts.c | 33 --- 8 files changed, 420 insertions(+), 310 deletions(-) delete mode 100644 cpu/i386/exceptions.c
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de When you say "I wrote a program that crashed Windows", people just stare at you blankly and say "Hey, I got those with the system, *for free*". - Linus Torvalds in <[email protected]>
PATCH v2 8/10 Remove inline asm symbols from .dynsym
In reply to Graeme Russ--- board/eNET/eNET_start16.S | 2 + cpu/i386/cpu.c | 2 + cpu/i386/interrupts.c | 4 ++ lib_i386/bios.S | 70 +++++++++++++++++++++++++++++++++++++++++++++ lib_i386/bios_pci.S | 2 + 5 files changed, 80 insertions(+), 0 deletions(-)
board/eNET/eNET_start16.S +2 -0
@@ -71,6 +71,8 @@ board_init16: .section .bios, "ax" .code16 .globl realmode_reset +.hidden realmode_reset +.type realmode_reset, @function realmode_reset: /* Alias MMCR to 0xdf000 */ movw $0xfffc, %dx
cpu/i386/cpu.c +2 -0
@@ -73,6 +73,8 @@ void __attribute__ ((regparm(0))) generate_gpf(void);/* segment 0x70 is an arbitrary segment which does not exist */ asm(".globl generate_gpf\n" +".hidden generate_gpf\n" +".type generate_gpf, @function\n" "generate_gpf:\n" "ljmp $0x70, $0x47114711\n" );
cpu/i386/interrupts.c +4 -0
@@ -29,6 +29,8 @@#define DECLARE_INTERRUPT (x) \ ".globl irq_"#x"\n" \ + ".hidden irq_"#x"\n" \ + ".type irq_"#x", @function\n" \ "irq_"#x":\n" \ "pushl %ebp\n" \ "movl %esp,%ebp\n" \
@@ -229,6 +231,8 @@ __isr__ irq_llsr(int ip, int seg, int irq)* the easiest way I could do it. Maybe it can be made better later. */ asm(".globl irq_common_entry\n" \ +".hidden irq_common_entry\n" \ +".type irq_common_entry, @function\n" \"irq_common_entry:\n" \"pushl $0\n" \ "pushl $0\n" \
lib_i386/bios.S +70 -0
213 lines not on this page · raw message
lib_i386/bios_pci.S +2 -0
@@ -34,6 +34,8 @@ .section .bios, "ax" .code16 .globl realmode_pci_bios_call_entry +.hidden realmode_pci_bios_call_entry +.type realmode_pci_bios_call_entry, @function realmode_pci_bios_call_entry: MAKE_BIOS_STACK call realmode_pci_bios
Signature · 1 line
1.6.4.1.174.g32f4c
Wolfgang Denk
AppliedPATCH v2 8/10 Remove inline asm symbols from .dynsym
Dear Graeme Russ,
Quoted 9 lines · In message <[email protected]> you wrote:
Signed-off-by Graeme Russ <[email protected]>--- board/eNET/eNET_start16.S | 2 + cpu/i386/cpu.c | 2 + cpu/i386/interrupts.c | 4 ++ lib_i386/bios.S | 70 +++++++++++++++++++++++++++++++++++++++++++++ lib_i386/bios_pci.S | 2 + 5 files changed, 80 insertions(+), 0 deletions(-)
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I'm a programmer: I don't buy software, I write it.
-- Tom ChristiansenPATCH v2 9/10 Move references to link script exports
In reply to Graeme Russ--- include/asm-i386/u-boot-i386.h | 6 ------ lib_i386/bios_setup.c | 6 ++++++ lib_i386/board.c | 11 ----------- lib_i386/realmode.c | 5 +++++ 4 files changed, 11 insertions(+), 17 deletions(-)
include/asm-i386/u-boot-i386.h +0 -6
@@ -35,12 +35,6 @@ extern ulong i386boot_bss_size; /* bss size */extern ulong i386boot_stack_end;/* first usable RAM address after bss and stack */ extern ulong i386boot_ram_end;/* end of ram */ -extern ulong i386boot_realmode;/* start of realmode entry code */ -extern ulong i386boot_realmode_size;/* size of realmode entry code */ -extern ulong i386boot_bios;/* start of BIOS emulation code */ -extern ulong i386boot_bios_size;/* size of BIOS emulation code */ - -/* cpu/.../cpu.c */ int cpu_init (void );
lib_i386/bios_setup.c +6 -0
@@ -45,6 +45,9 @@ DECLARE_GLOBAL_DATA_PTR;#define BIOS_BASE ((char*)0xf0000)#define BIOS_CS 0xf000 +extern ulong _i386boot_bios; +extern ulong _i386boot_bios_size; +/* these are defined in a 16bit segment and needs * to be accessed with the RELOC_16_xxxx() macros below */
@@ -138,6 +141,9 @@ static void setvector(int vector, u16 segment, void *handler)int bios_setup (void ) { +ulong i386boot_bios = (ulong)&_i386boot_bios; +ulong i386boot_bios_size = (ulong)&_i386boot_bios_size; +static int done=0 ;int vector;#ifdef CONFIG_PCI
lib_i386/board.c +0 -11
@@ -53,11 +53,6 @@ extern long _i386boot_romdata_size;extern long _i386boot_bss_start;extern long _i386boot_bss_size; -extern long _i386boot_realmode; -extern long _i386boot_realmode_size; -extern long _i386boot_bios; -extern long _i386boot_bios_size; -/* The symbols defined by the linker script becomes pointers * which is somewhat inconveient ... */ ulong i386boot_start = (ulong)&_i386boot_start;/* code start (in flash) defined in start.S */
@@ -68,12 +63,6 @@ ulong i386boot_romdata_size = (ulong)&_i386boot_romdata_size; /* size of dataulong i386boot_bss_start = (ulong)&_i386boot_bss_start;/* bss start */ ulong i386boot_bss_size = (ulong)&_i386boot_bss_size;/* bss size */ -ulong i386boot_realmode = (ulong)&_i386boot_realmode;/* start of realmode entry code */ -ulong i386boot_realmode_size = (ulong)&_i386boot_realmode_size;/* size of realmode entry code */ -ulong i386boot_bios = (ulong)&_i386boot_bios;/* start of BIOS emulation code */ -ulong i386boot_bios_size = (ulong)&_i386boot_bios_size;/* size of BIOS emulation code */ - -const char version_string[] =U_BOOT_VERSION " (" U_BOOT_DATE " - " U_BOOT_TIME ")" ;
lib_i386/realmode.c +5 -0
@@ -31,10 +31,15 @@#define REALMODE_MAILBOX ((char*)0xe00) +extern ulong _i386boot_realmode; +extern ulong _i386boot_realmode_size;extern char realmode_enter;int realmode_setup (void ) { +ulong i386boot_realmode = (ulong)&_i386boot_realmode; +ulong i386boot_realmode_size = (ulong)&_i386boot_realmode_size; +/* copy the realmode switch code */ if (i386boot_realmode_size > (REALMODE_MAILBOX -REALMODE_BASE )) { printf("realmode switch too large (%ld bytes, max is %d)\n",
Signature · 1 line
1.6.4.1.174.g32f4c
Wolfgang Denk
AppliedPATCH v2 9/10 Move references to link script exports
Dear Graeme Russ,
Quoted 8 lines · In message <[email protected]> you wrote:
Signed-off-by Graeme Russ <[email protected]>--- include/asm-i386/u-boot-i386.h | 6 ------ lib_i386/bios_setup.c | 6 ++++++ lib_i386/board.c | 11 ----------- lib_i386/realmode.c | 5 +++++ 4 files changed, 11 insertions(+), 17 deletions(-)
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Every living thing wants to survive. -- Spock, "The Ultimate Computer", stardate 4731.3
PATCH v2 10/10 Final i386 Relocation
In reply to Graeme Russ--- board/eNET/config.mk | 2 + board/eNET/eNET.c | 17 +++-- board/eNET/u-boot.lds | 34 +++++++-- cpu/i386/cpu.c | 12 ++- cpu/i386/interrupts.c | 4 +- cpu/i386/start.S | 132 ++++------------------------------ include/asm-i386/u-boot-i386.h | 14 +--- include/configs/eNET.h | 2 + lib_i386/board.c | 157 +++++++++++++++++++++++----------------- lib_i386/interrupts.c | 4 +- lib_i386/timer.c | 2 +- 11 files changed, 163 insertions(+), 217 deletions(-)
board/eNET/config.mk +2 -0
@@ -23,4 +23,6 @@ TEXT_BASE = 0x38040000 CFLAGS_dlmalloc.o += -Wa,--no-warn -fno-strict-aliasing +PLATFORM_RELFLAGS += -fvisibility=hidden PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm +PLATFORM_LDFLAGS += -pic --emit-relocs -Bsymbolic -Bsymbolic-functions
board/eNET/eNET.c +12 -5
@@ -47,7 +47,6 @@ void init_sc520_enet (void) {/* Set CPU Speed to 100MHz */ sc520_mmcr->cpuctl =0x01 ; - gd->cpu_clk =100000000 ;/* wait at least one millisecond */ asm("movl $0x2000,%%ecx\n"
@@ -67,7 +66,7 @@ void init_sc520_enet (void)/* * Miscellaneous platform dependent initializations */ -int board_init (void ) +int board_early_init_f (void ) {init_sc520_enet ();
@@ -117,12 +116,20 @@ int board_init(void) sc520_mmcr->sysarbctl =0x06 ; sc520_mmcr->sysarbmenb =0x0003 ; -/* Crystal is 33.000MHz */ - gd->bus_clk =33000000 ; -return 0 ; } +int board_early_init_r (void ) +{ +/* CPU Speed to 100MHz */ + gd->cpu_clk =100000000 ; + +/* Crystal is 33.000MHz */ + gd->bus_clk =33000000 ; + +return 0 ; +} +int dram_init (void ) {init_sc520_dram ();
board/eNET/u-boot.lds +27 -7
@@ -28,28 +28,48 @@ ENTRY(_start) SECTIONS { . = 0x38040000; /* Location of bootcode in flash */ + _i386boot_text_start = .; .text : { *(.text); } . = ALIGN(4); .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } _i386boot_text_size = SIZEOF(.text) + SIZEOF(.rodata); + . = ALIGN(4); + + .data : { *(.data) } + . = ALIGN(4); + + .interp : { *(.interp) } + . = ALIGN(4); + + .dynsym : { *(.dynsym) } + . = ALIGN(4); - . = 0x03FF0000; /* Ram data segment to use */ - _i386boot_romdata_dest = ABSOLUTE(.); - .data : AT ( LOADADDR(.rodata) + SIZEOF(.rodata) ) { *(.data) } - _i386boot_romdata_start = LOADADDR(.data); + .dynstr : { *(.dynstr) } + . = ALIGN(4); + + .hash : { *(.hash) } + . = ALIGN(4); + .got : { *(.got) } . = ALIGN(4); - .got : AT ( LOADADDR(.data) + SIZEOF(.data) ) { *(.got) } + .got.plt : { *(.got.plt) } . = ALIGN(4); + + .dynamic (NOLOAD) : { *(.dynamic) } + . = ALIGN(4); + __u_boot_cmd_start = .; .u_boot_cmd : { *(.u_boot_cmd) } + . = ALIGN(4); __u_boot_cmd_end = .; _i386boot_cmd_start = LOADADDR(.u_boot_cmd); - _i386boot_romdata_size = SIZEOF(.data) + SIZEOF(.got) + SIZEOF(.u_boot_cmd); + _i386boot_rel_dyn_start = .; + .rel.dyn : { *(.rel.dyn) } + _i386boot_rel_dyn_end = .; . = ALIGN(4); _i386boot_bss_start = ABSOLUTE(.);
@@ -57,7 +77,7 @@ SECTIONS _i386boot_bss_size = SIZEOF(.bss); /* 16bit realmode trampoline code */ - .realmode 0x7c0 : AT ( LOADADDR(.got) + SIZEOF(.got) + SIZEOF(.u_boot_cmd)) { *(.realmode) } + .realmode 0x7c0 : AT ( LOADADDR(.rel.dyn) + SIZEOF(.rel.dyn) ) { *(.realmode) } _i386boot_realmode = LOADADDR(.realmode); _i386boot_realmode_size = SIZEOF(.realmode);
cpu/i386/cpu.c +8 -4
@@ -37,7 +37,7 @@#include <command.h> #include <asm/interrupt.h> -int cpu_init (void ) +int cpu_init_f (void ) {/* initialize FPU, reset EM, set MP and NE */ asm ("fninit\n" \
@@ -46,12 +46,16 @@ int cpu_init(void)"orl $0x22, %eax\n" \ "movl %eax, %cr0\n" ); -/* Initialize core interrupt and exception functionality of CPU */ -cpu_init_interrupts (); -return 0 ; } +int cpu_init_r (void ) +{ +/* Initialize core interrupt and exception functionality of CPU */ +cpu_init_interrupts (); +return 0 ; +} +int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) {printf ("resetting ...\n" );
cpu/i386/interrupts.c +2 -2
@@ -63,8 +63,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 + gd->reloc_off) >>16 ); - idt[intnum].base_low = (u16)((u32)(routine + gd->reloc_off) &0xffff ); + idt[intnum].base_high = (u16)((u32)(routine) >>16 ); + idt[intnum].base_low = (u16)((u32)(routine) &0xffff ); }void irq_0 (void );
cpu/i386/start.S +15 -117
159 lines not on this page · raw message
include/asm-i386/u-boot-i386.h +2 -12
@@ -24,19 +24,9 @@#ifndef _U_BOOT_I386_H_#define _U_BOOT_I386_H_ 1 -/* for the following variables, see start.S */ -extern ulong i386boot_start;/* code start (in flash) */ -extern ulong i386boot_end;/* code end (in flash) */ -extern ulong i386boot_romdata_start;/* datasegment in flash (also code+rodata end) */ -extern ulong i386boot_romdata_dest;/* data location segment in ram */ -extern ulong i386boot_romdata_size;/* size of data segment */ -extern ulong i386boot_bss_start;/* bss start */ -extern ulong i386boot_bss_size;/* bss size */ -extern ulong i386boot_stack_end;/* first usable RAM address after bss and stack */ -extern ulong i386boot_ram_end;/* end of ram */ -/* cpu/.../cpu.c */ -int cpu_init (void ); +int cpu_init_r (void ); +int cpu_init_f (void );/* cpu/.../timer.c */ void timer_isr (void *);
include/configs/eNET.h +2 -0
@@ -28,6 +28,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#define CONFIG_RELOC_FIXUP_WORKS +/* * Stuff still to be dealt with - */
lib_i386/board.c +90 -67
232 lines not on this page · raw message
lib_i386/interrupts.c +2 -2
@@ -70,12 +70,12 @@ void irq_install_handler(int irq, interrupt_handler_t *handler, void *arg)if (irq_handlers[irq].handler !=NULL )printf ("irq_install_handler: 0x%08lx replacing 0x%08lx\n" , - (ulong ) handler + gd->reloc_off, + (ulong ) handler, (ulong ) irq_handlers[irq].handler); status =disable_interrupts (); - irq_handlers[irq].handler = handler + gd->reloc_off; + irq_handlers[irq].handler = handler; irq_handlers[irq].arg = arg; irq_handlers[irq].count =0 ;
lib_i386/timer.c +1 -1
@@ -51,7 +51,7 @@ int register_timer_isr (timer_fnc_t *isr_func)if (new_func ==NULL )return 1 ; - new_func->isr_func = isr_func + gd->reloc_off; + new_func->isr_func = isr_func; new_func->next =NULL ;/*
Signature · 1 line
1.6.4.1.174.g32f4c
Wolfgang Denk
AppliedPATCH v2 10/10 Final i386 Relocation
Dear Graeme Russ,
Quoted 15 lines · In message <[email protected]> you wrote:
Signed-off-by Graeme Russ <[email protected]>--- board/eNET/config.mk | 2 + board/eNET/eNET.c | 17 +++-- board/eNET/u-boot.lds | 34 +++++++-- cpu/i386/cpu.c | 12 ++- cpu/i386/interrupts.c | 4 +- cpu/i386/start.S | 132 ++++------------------------------ include/asm-i386/u-boot-i386.h | 14 +--- include/configs/eNET.h | 2 + lib_i386/board.c | 157 +++++++++++++++++++++++----------------- lib_i386/interrupts.c | 4 +- lib_i386/timer.c | 2 +- 11 files changed, 163 insertions(+), 217 deletions(-)
Applied to "next", thanks.
Note that this patch was not clean:
Applying: i386: Final Relocation /home/wd/git/u-boot/next/.git/rebase-apply/patch:62: space before tab in indent.
/* Crystal is 33.000MHz */
/home/wd/git/u-boot/next/.git/rebase-apply/patch:63: space before tab in indent.
gd->bus_clk = 33000000;
/home/wd/git/u-boot/next/.git/rebase-apply/patch:65: space before tab in indent.
return 0;
/home/wd/git/u-boot/next/.git/rebase-apply/patch:88: space before tab in indent.
.data : { *(.data) }
/home/wd/git/u-boot/next/.git/rebase-apply/patch:89: space before tab in indent.
. = ALIGN(4);warning: squelched 10 whitespace errors
warning: 15 lines applied after fixing whitespace errors.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de At the source of every error which is blamed on the computer you will find at least two human errors, including the error of blaming it on the computer.