summaryrefslogtreecommitdiff
path: root/lib_i386
diff options
context:
space:
mode:
authorMichael Brandt <Michael.Brandt@stericsson.com>2009-12-22 15:06:09 +0100
committerMichael Brandt <Michael.Brandt@stericsson.com>2009-12-22 15:06:09 +0100
commit257e7c347fd32438604da5e7996b902688d9611b (patch)
tree74fe0aa3fcaad4c9a3bd1c3dfc172531400cdd45 /lib_i386
parent0c9ff2faf4cf516dd6631ba18a4bcc5b739eb4c6 (diff)
parent87d93a1ba2ae23550e1370adb7a3b00af0831165 (diff)
Merge branch 'master' of http://git.denx.de/u-boot
Conflicts: include/usb/musb_udc.h
Diffstat (limited to 'lib_i386')
-rw-r--r--lib_i386/Makefile8
-rw-r--r--lib_i386/bios.S70
-rw-r--r--lib_i386/bios_pci.S2
-rw-r--r--lib_i386/bios_setup.c6
-rw-r--r--lib_i386/board.c169
-rw-r--r--lib_i386/interrupts.c8
-rw-r--r--lib_i386/pcat_interrupts.c33
-rw-r--r--lib_i386/pcat_timer.c2
-rw-r--r--lib_i386/realmode.c5
-rw-r--r--lib_i386/timer.c2
10 files changed, 184 insertions, 121 deletions
diff --git a/lib_i386/Makefile b/lib_i386/Makefile
index bb9b330ac..983850668 100644
--- a/lib_i386/Makefile
+++ b/lib_i386/Makefile
@@ -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))
diff --git a/lib_i386/bios.S b/lib_i386/bios.S
index d6ca3e315..48f1b8112 100644
--- a/lib_i386/bios.S
+++ b/lib_i386/bios.S
@@ -50,134 +50,200 @@
jmp realmode_reset
.globl rm_int00
+.hidden rm_int00
+.type rm_int00, @function
rm_int00:
pushw $0
jmp any_interrupt16
.globl rm_int01
+.hidden rm_int01
+.type rm_int01, @function
rm_int01:
pushw $1
jmp any_interrupt16
.globl rm_int02
+.hidden rm_int02
+.type rm_int02, @function
rm_int02:
pushw $2
jmp any_interrupt16
.globl rm_int03
+.hidden rm_int03
+.type rm_int03, @function
rm_int03:
pushw $3
jmp any_interrupt16
.globl rm_int04
+.hidden rm_int04
+.type rm_int04, @function
rm_int04:
pushw $4
jmp any_interrupt16
.globl rm_int05
+.hidden rm_int05
+.type rm_int05, @function
rm_int05:
pushw $5
jmp any_interrupt16
.globl rm_int06
+.hidden rm_int06
+.type rm_int06, @function
rm_int06:
pushw $6
jmp any_interrupt16
.globl rm_int07
+.hidden rm_int07
+.type rm_int07, @function
rm_int07:
pushw $7
jmp any_interrupt16
.globl rm_int08
+.hidden rm_int08
+.type rm_int08, @function
rm_int08:
pushw $8
jmp any_interrupt16
.globl rm_int09
+.hidden rm_int09
+.type rm_int09, @function
rm_int09:
pushw $9
jmp any_interrupt16
.globl rm_int0a
+.hidden rm_int0a
+.type rm_int0a, @function
rm_int0a:
pushw $10
jmp any_interrupt16
.globl rm_int0b
+.hidden rm_int0b
+.type rm_int0b, @function
rm_int0b:
pushw $11
jmp any_interrupt16
.globl rm_int0c
+.hidden rm_int0c
+.type rm_int0c, @function
rm_int0c:
pushw $12
jmp any_interrupt16
.globl rm_int0d
+.hidden rm_int0d
+.type rm_int0d, @function
rm_int0d:
pushw $13
jmp any_interrupt16
.globl rm_int0e
+.hidden rm_int0e
+.type rm_int0e, @function
rm_int0e:
pushw $14
jmp any_interrupt16
.globl rm_int0f
+.hidden rm_int0f
+.type rm_int0f, @function
rm_int0f:
pushw $15
jmp any_interrupt16
.globl rm_int10
+.hidden rm_int10
+.type rm_int10, @function
rm_int10:
pushw $16
jmp any_interrupt16
.globl rm_int11
+.hidden rm_int11
+.type rm_int11, @function
rm_int11:
pushw $17
jmp any_interrupt16
.globl rm_int12
+.hidden rm_int12
+.type rm_int12, @function
rm_int12:
pushw $18
jmp any_interrupt16
.globl rm_int13
+.hidden rm_int13
+.type rm_int13, @function
rm_int13:
pushw $19
jmp any_interrupt16
.globl rm_int14
+.hidden rm_int14
+.type rm_int14, @function
rm_int14:
pushw $20
jmp any_interrupt16
.globl rm_int15
+.hidden rm_int15
+.type rm_int15, @function
rm_int15:
pushw $21
jmp any_interrupt16
.globl rm_int16
+.hidden rm_int16
+.type rm_int16, @function
rm_int16:
pushw $22
jmp any_interrupt16
.globl rm_int17
+.hidden rm_int17
+.type rm_int17, @function
rm_int17:
pushw $23
jmp any_interrupt16
.globl rm_int18
+.hidden rm_int18
+.type rm_int18, @function
rm_int18:
pushw $24
jmp any_interrupt16
.globl rm_int19
+.hidden rm_int19
+.type rm_int19, @function
rm_int19:
pushw $25
jmp any_interrupt16
.globl rm_int1a
+.hidden rm_int1a
+.type rm_int1a, @function
rm_int1a:
pushw $26
jmp any_interrupt16
.globl rm_int1b
+.hidden rm_int1b
+.type rm_int1b, @function
rm_int1b:
pushw $27
jmp any_interrupt16
.globl rm_int1c
+.hidden rm_int1c
+.type rm_int1c, @function
rm_int1c:
pushw $28
jmp any_interrupt16
.globl rm_int1d
+.hidden rm_int1d
+.type rm_int1d, @function
rm_int1d:
pushw $29
jmp any_interrupt16
.globl rm_int1e
+.hidden rm_int1e
+.type rm_int1e, @function
rm_int1e:
pushw $30
jmp any_interrupt16
.globl rm_int1f
+.hidden rm_int1f
+.type rm_int1f, @function
rm_int1f:
pushw $31
jmp any_interrupt16
.globl rm_def_int
+.hidden rm_def_int
+.type rm_def_int, @function
rm_def_int:
iret
@@ -454,9 +520,13 @@ Lfunc_b1h:
.globl ram_in_64kb_chunks
+.hidden ram_in_64kb_chunks
+.type ram_in_64kb_chunks, @function
ram_in_64kb_chunks:
.word 0
.globl bios_equipment
+.hidden bios_equipment
+.type bios_equipment, @function
bios_equipment:
.word 0
diff --git a/lib_i386/bios_pci.S b/lib_i386/bios_pci.S
index 67fd00b83..9e412e5e4 100644
--- a/lib_i386/bios_pci.S
+++ b/lib_i386/bios_pci.S
@@ -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
diff --git a/lib_i386/bios_setup.c b/lib_i386/bios_setup.c
index 33c842c6a..6491e522e 100644
--- a/lib_i386/bios_setup.c
+++ b/lib_i386/bios_setup.c
@@ -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
diff --git a/lib_i386/board.c b/lib_i386/board.c
index 12ca20f60..f3b634855 100644
--- a/lib_i386/board.c
+++ b/lib_i386/board.c
@@ -38,6 +38,7 @@
#include <net.h>
#include <ide.h>
#include <asm/u-boot-i386.h>
+#include <elf.h>
#ifdef CONFIG_BITBANGMII
#include <miiphy.h>
@@ -45,53 +46,16 @@
DECLARE_GLOBAL_DATA_PTR;
-extern long _i386boot_start;
-extern long _i386boot_end;
-extern long _i386boot_romdata_start;
-extern long _i386boot_romdata_dest;
-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 */
-ulong i386boot_end = (ulong)&_i386boot_end; /* code end (in flash) */
-ulong i386boot_romdata_start = (ulong)&_i386boot_romdata_start; /* datasegment in flash (also code+rodata end) */
-ulong i386boot_romdata_dest = (ulong)&_i386boot_romdata_dest; /* data location segment in ram */
-ulong i386boot_romdata_size = (ulong)&_i386boot_romdata_size; /* size of data segment */
-ulong 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 */
-
-
+/* Exports from the Linker Script */
+extern ulong _i386boot_text_start;
+extern ulong _i386boot_rel_dyn_start;
+extern ulong _i386boot_rel_dyn_end;
+extern ulong _i386boot_bss_start;
+extern ulong _i386boot_bss_size;
+void ram_bootstrap (void *);
const char version_string[] =
U_BOOT_VERSION" (" U_BOOT_DATE " - " U_BOOT_TIME ")";
-static int mem_malloc_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;
-
- /* Use all available RAM for malloc() */
- mem_malloc_end = gd->ram_size;
-
- mem_malloc_brk = mem_malloc_start;
-
- return 0;
-}
-
/************************************************************************
* Init Utilities *
************************************************************************
@@ -115,6 +79,7 @@ static int display_banner (void)
{
printf ("\n\n%s\n\n", version_string);
+/*
printf ("U-Boot code: %08lX -> %08lX data: %08lX -> %08lX\n"
" BSS: %08lX -> %08lX stack: %08lX -> %08lX\n",
i386boot_start, i386boot_romdata_start-1,
@@ -123,6 +88,7 @@ static int display_banner (void)
i386boot_bss_start+i386boot_bss_size,
i386boot_bss_start+i386boot_bss_size+CONFIG_SYS_STACK_SIZE-1);
+*/
return (0);
}
@@ -154,7 +120,6 @@ static void display_flash_config (ulong size)
print_size (size, "\n");
}
-
/*
* Breath some life into the board...
*
@@ -166,6 +131,7 @@ static void display_flash_config (ulong size)
* can relocate the monitor code to RAM.
*/
+
/*
* All attempts to come up with a "common" initialization sequence
* that works for all boards and architectures failed: some of the
@@ -181,13 +147,12 @@ static void display_flash_config (ulong size)
typedef int (init_fnc_t) (void);
init_fnc_t *init_sequence[] = {
- cpu_init, /* basic cpu dependent setup */
- board_init, /* basic board dependent setup */
+ serial_init,
+ cpu_init_r, /* basic cpu dependent setup */
+ board_early_init_r, /* basic board dependent setup */
dram_init, /* configure available RAM banks */
- mem_malloc_init, /* dependant on dram_init */
interrupt_init, /* set up exceptions */
timer_init,
- serial_init,
env_init, /* initialize environment */
init_baudrate, /* initialze baudrate settings */
serial_init, /* serial communications setup */
@@ -199,21 +164,86 @@ init_fnc_t *init_sequence[] = {
gd_t *gd;
-void start_i386boot (void)
+/*
+ * Load U-Boot into RAM, initialize BSS, perform relocation adjustments
+ */
+void board_init_f (ulong stack_limit)
+{
+ void *text_start = &_i386boot_text_start;
+ void *u_boot_cmd_end = &__u_boot_cmd_end;
+ Elf32_Rel *rel_dyn_start = (Elf32_Rel *)&_i386boot_rel_dyn_start;
+ Elf32_Rel *rel_dyn_end = (Elf32_Rel *)&_i386boot_rel_dyn_end;
+ void *bss_start = &_i386boot_bss_start;
+ void *bss_size = &_i386boot_bss_size;
+
+ size_t uboot_size;
+ void *ram_start;
+ ulong rel_offset;
+ Elf32_Rel *re;
+
+ void (*start_func)(void *);
+
+ /* compiler optimization barrier needed for GCC >= 3.4 */
+ __asm__ __volatile__("": : :"memory");
+
+ uboot_size = (size_t)u_boot_cmd_end - (size_t)text_start;
+ ram_start = (void *)stack_limit - (uboot_size + (ulong)bss_size);
+ rel_offset = text_start - ram_start;
+ start_func = ram_bootstrap - rel_offset;
+
+ /* First stage CPU initialization */
+ if (cpu_init_f() != 0)
+ hang();
+
+ /* First stage Board initialization */
+ if (board_early_init_f() != 0)
+ hang();
+
+ /* Copy U-Boot into RAM */
+ memcpy(ram_start, text_start, (size_t)uboot_size);
+
+ /* Clear BSS */
+ memset(bss_start - rel_offset, 0, (size_t)bss_size);
+
+ /* Perform relocation adjustments */
+ for (re = rel_dyn_start; re < rel_dyn_end; re++)
+ {
+ if (re->r_offset >= TEXT_BASE)
+ if (*(ulong *)re->r_offset >= TEXT_BASE)
+ *(ulong *)(re->r_offset - rel_offset) -= (Elf32_Addr)rel_offset;
+ }
+
+ start_func(ram_start);
+
+ /* NOTREACHED - relocate_code() does not return */
+ while(1);
+}
+
+/*
+ * All attempts to jump straight from board_init_f() to board_init_r()
+ * have failed, hence this special 'bootstrap' function.
+ */
+void ram_bootstrap (void *ram_start)
+{
+ static gd_t gd_data;
+
+ /* compiler optimization barrier needed for GCC >= 3.4 */
+ __asm__ __volatile__("": : :"memory");
+
+ board_init_r(&gd_data, (ulong)ram_start);
+}
+
+void board_init_r(gd_t *id, ulong ram_start)
{
char *s;
int i;
ulong size;
- static gd_t gd_data;
static bd_t bd_data;
init_fnc_t **init_fnc_ptr;
-#ifndef CONFIG_SKIP_RELOCATE_UBOOT
- cmd_tbl_t *p;
-#endif
show_boot_progress(0x21);
- gd = &gd_data;
+ gd = id;
/* compiler optimization barrier needed for GCC >= 3.4 */
__asm__ __volatile__("": : :"memory");
@@ -224,10 +254,11 @@ void start_i386boot (void)
gd->baudrate = CONFIG_BAUDRATE;
-#ifndef CONFIG_SKIP_RELOCATE_UBOOT
- /* Need to set relocation offset here for interrupt initialization */
- gd->reloc_off = CONFIG_SYS_BL_START_RAM - TEXT_BASE;
-#endif
+ gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
+
+ mem_malloc_init((((ulong)ram_start - CONFIG_SYS_MALLOC_LEN)+3)&~3,
+ CONFIG_SYS_MALLOC_LEN);
+
for (init_fnc_ptr = init_sequence, i=0; *init_fnc_ptr; ++init_fnc_ptr, i++) {
show_boot_progress(0xa130|i);
@@ -237,26 +268,6 @@ void start_i386boot (void)
}
show_boot_progress(0x23);
-#ifndef CONFIG_SKIP_RELOCATE_UBOOT
- for (p = &__u_boot_cmd_start; p != &__u_boot_cmd_end; p++) {
- ulong addr;
- addr = (ulong) (p->cmd) + gd->reloc_off;
- p->cmd = (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
- addr = (ulong)(p->name) + gd->reloc_off;
- p->name = (char *)addr;
-
- if (p->usage != NULL) {
- addr = (ulong)(p->usage) + gd->reloc_off;
- p->usage = (char *)addr;
- }
- #ifdef CONFIG_SYS_LONGHELP
- if (p->help != NULL) {
- addr = (ulong)(p->help) + gd->reloc_off;
- p->help = (char *)addr;
- }
- #endif
- }
-#endif
/* configure available FLASH banks */
size = flash_init();
display_flash_config(size);
diff --git a/lib_i386/interrupts.c b/lib_i386/interrupts.c
index 3f3613a2f..51def5995 100644
--- a/lib_i386/interrupts.c
+++ b/lib_i386/interrupts.c
@@ -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;
@@ -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;
diff --git a/lib_i386/pcat_interrupts.c b/lib_i386/pcat_interrupts.c
index f01298e9c..67e6e97e3 100644
--- a/lib_i386/pcat_interrupts.c
+++ b/lib_i386/pcat_interrupts.c
@@ -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);
diff --git a/lib_i386/pcat_timer.c b/lib_i386/pcat_timer.c
index c351b23b6..1373fd125 100644
--- a/lib_i386/pcat_timer.c
+++ b/lib_i386/pcat_timer.c
@@ -71,7 +71,7 @@ static u16 read_pit(void)
}
/* this is not very exact */
-void udelay (unsigned long usec)
+void __udelay (unsigned long usec)
{
int counter;
int wraps;
diff --git a/lib_i386/realmode.c b/lib_i386/realmode.c
index 6cf273885..3c3c1fc96 100644
--- a/lib_i386/realmode.c
+++ b/lib_i386/realmode.c
@@ -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",
diff --git a/lib_i386/timer.c b/lib_i386/timer.c
index 58a0212ad..5cb1f54fb 100644
--- a/lib_i386/timer.c
+++ b/lib_i386/timer.c
@@ -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;
/*