Browse Source

Merge branch 'master' of git://git.denx.de/u-boot-x86

Tom Rini 12 years ago
parent
commit
a661b99dbc

+ 1 - 1
arch/x86/cpu/Makefile

@@ -30,7 +30,7 @@ LIB	= $(obj)lib$(CPU).o
 
 START-y	= start.o
 START-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
-COBJS	= interrupts.o cpu.o timer.o
+COBJS	= interrupts.o cpu.o
 
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))

+ 13 - 0
arch/x86/cpu/coreboot/coreboot.c

@@ -26,6 +26,7 @@
 #include <asm/u-boot-x86.h>
 #include <flash.h>
 #include <netdev.h>
+#include <ns16550.h>
 #include <asm/msr.h>
 #include <asm/cache.h>
 #include <asm/io.h>
@@ -90,6 +91,9 @@ void show_boot_progress(int val)
 
 int last_stage_init(void)
 {
+	if (gd->flags & GD_FLG_COLD_BOOT)
+		timestamp_add_to_bootstage();
+
 	return 0;
 }
 
@@ -135,3 +139,12 @@ int board_final_cleanup(void)
 
 	return 0;
 }
+
+void panic_puts(const char *str)
+{
+	NS16550_t port = (NS16550_t)0x3f8;
+
+	NS16550_init(port, 1);
+	while (*str)
+		NS16550_putc(port, *str++);
+}

+ 41 - 1
arch/x86/cpu/coreboot/timestamp.c

@@ -39,7 +39,9 @@ static struct timestamp_table *ts_table  __attribute__((section(".data")));
 void timestamp_init(void)
 {
 	ts_table = lib_sysinfo.tstamp_table;
-	timer_set_tsc_base(ts_table->base_time);
+#ifdef CONFIG_SYS_X86_TSC_TIMER
+	timer_set_base(ts_table->base_time);
+#endif
 	timestamp_add_now(TS_U_BOOT_INITTED);
 }
 
@@ -59,3 +61,41 @@ void timestamp_add_now(enum timestamp_id id)
 {
 	timestamp_add(id, rdtsc());
 }
+
+int timestamp_add_to_bootstage(void)
+{
+	uint i;
+
+	if (!ts_table)
+		return -1;
+
+	for (i = 0; i < ts_table->num_entries; i++) {
+		struct timestamp_entry *tse = &ts_table->entries[i];
+		const char *name = NULL;
+
+		switch (tse->entry_id) {
+		case TS_START_ROMSTAGE:
+			name = "start-romstage";
+			break;
+		case TS_BEFORE_INITRAM:
+			name = "before-initram";
+			break;
+		case TS_DEVICE_INITIALIZE:
+			name = "device-initialize";
+			break;
+		case TS_DEVICE_DONE:
+			name = "device-done";
+			break;
+		case TS_SELFBOOT_JUMP:
+			name = "selfboot-jump";
+			break;
+		}
+		if (name) {
+			bootstage_add_record(0, name, BOOTSTAGEF_ALLOC,
+					     tse->entry_stamp /
+							get_tbclk_mhz());
+		}
+	}
+
+	return 0;
+}

+ 5 - 0
arch/x86/cpu/cpu.c

@@ -120,6 +120,11 @@ void setup_gdt(gd_t *id, u64 *gdt_addr)
 
 int __weak x86_cleanup_before_linux(void)
 {
+#ifdef CONFIG_BOOTSTAGE_STASH
+	bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH,
+			CONFIG_BOOTSTAGE_STASH_SIZE);
+#endif
+
 	return 0;
 }
 

+ 2 - 0
arch/x86/cpu/interrupts.c

@@ -37,6 +37,8 @@
 #include <asm/msr.h>
 #include <asm/u-boot-x86.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define DECLARE_INTERRUPT(x) \
 	".globl irq_"#x"\n" \
 	".hidden irq_"#x"\n" \

+ 0 - 17
arch/x86/cpu/timer.c

@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- */
-
-#include <common.h>
-
-unsigned long timer_get_us(void)
-{
-	printf("timer_get_us used but not implemented.\n");
-	return 0;
-}

+ 0 - 12
arch/x86/cpu/u-boot.lds

@@ -79,18 +79,6 @@ SECTIONS
 	/DISCARD/ : { *(.interp*) }
 	/DISCARD/ : { *(.gnu*) }
 
-	/* 16bit realmode trampoline code */
-	.realmode REALMODE_BASE : AT ( LOADADDR(.rel.dyn) + SIZEOF(.rel.dyn) ) { KEEP(*(.realmode)) }
-
-	__realmode_start = LOADADDR(.realmode);
-	__realmode_size = SIZEOF(.realmode);
-
-	/* 16bit BIOS emulation code (just enough to boot Linux) */
-	.bios 0 : AT ( LOADADDR(.realmode) + SIZEOF(.realmode) ) { KEEP(*(.bios)) }
-
-	__bios_start = LOADADDR(.bios);
-	__bios_size = SIZEOF(.bios);
-
 #ifdef CONFIG_X86_RESET_VECTOR
 
 	/*

+ 7 - 0
arch/x86/include/asm/arch-coreboot/timestamp.h

@@ -49,4 +49,11 @@ void timestamp_init(void);
 void timestamp_add(enum timestamp_id id, uint64_t ts_time);
 void timestamp_add_now(enum timestamp_id id);
 
+/**
+ * timestamp_add_to_bootstage - Add important coreboot timestamps to bootstage
+ *
+ * @return 0 if ok, -1 if no timestamps were found
+ */
+int timestamp_add_to_bootstage(void);
+
 #endif

+ 0 - 9
arch/x86/include/asm/init_helpers.h

@@ -24,19 +24,10 @@
 #ifndef _INIT_HELPERS_H_
 #define _INIT_HELPERS_H_
 
-int display_banner(void);
-int display_dram_config(void);
-int init_baudrate_f(void);
 int calculate_relocation_address(void);
 
 int init_cache_f_r(void);
-
-int set_reloc_flag_r(void);
-int mem_malloc_init_r(void);
 int init_bd_struct_r(void);
-int flash_init_r(void);
-int status_led_set_r(void);
-int set_load_addr_r(void);
 int init_func_spi(void);
 int find_fdt(void);
 int prepare_fdt(void);

+ 0 - 42
arch/x86/include/asm/init_wrappers.h

@@ -1,42 +0,0 @@
-/*
- * (C) Copyright 2011
- * Graeme Russ, <graeme.russ@gmail.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef _INIT_WRAPPERS_H_
-#define _INIT_WRAPPERS_H_
-
-int serial_initialize_r(void);
-int env_relocate_r(void);
-int pci_init_r(void);
-int jumptable_init_r(void);
-int pcmcia_init_r(void);
-int kgdb_init_r(void);
-int enable_interrupts_r(void);
-int eth_initialize_r(void);
-int reset_phy_r(void);
-int ide_init_r(void);
-int scsi_init_r(void);
-int doc_init_r(void);
-int bb_miiphy_init_r(void);
-int post_run_r(void);
-
-#endif	/* !_INIT_WRAPPERS_H_ */

+ 0 - 4
arch/x86/include/asm/pci.h

@@ -30,8 +30,4 @@
 	const struct pci_device_id _table[]
 
 void pci_setup_type1(struct pci_controller *hose);
-int pci_enable_legacy_video_ports(struct pci_controller* hose);
-int pci_shadow_rom(pci_dev_t dev, unsigned char *dest);
-void pci_remove_rom_window(struct pci_controller* hose, u32 addr);
-u32 pci_get_rom_window(struct pci_controller* hose, int size);
 #endif

+ 4 - 0
arch/x86/include/asm/u-boot-x86.h

@@ -33,11 +33,15 @@ void init_gd(gd_t *id, u64 *gdt_addr);
 void setup_gdt(gd_t *id, u64 *gdt_addr);
 int init_cache(void);
 int cleanup_before_linux(void);
+void panic_puts(const char *str);
 
 /* cpu/.../timer.c */
 void timer_isr(void *);
 typedef void (timer_fnc_t) (void);
 int register_timer_isr (timer_fnc_t *isr_func);
+unsigned long get_tbclk_mhz(void);
+void timer_set_base(uint64_t base);
+int pcat_timer_init(void);
 
 /* Architecture specific - can be in arch/x86/cpu/, arch/x86/lib/, or $(BOARD)/ */
 int dram_init_f(void);

+ 0 - 32
arch/x86/include/asm/u-boot.h

@@ -36,40 +36,8 @@
 #ifndef _U_BOOT_H_
 #define _U_BOOT_H_	1
 
-#include <config.h>
-#include <compiler.h>
-
-#ifdef CONFIG_SYS_GENERIC_BOARD
 /* Use the generic board which requires a unified bd_info */
 #include <asm-generic/u-boot.h>
-#else
-
-#ifndef __ASSEMBLY__
-
-typedef struct bd_info {
-	unsigned long	bi_memstart;	/* start of DRAM memory */
-	phys_size_t	bi_memsize;	/* size	 of DRAM memory in bytes */
-	unsigned long	bi_flashstart;	/* start of FLASH memory */
-	unsigned long	bi_flashsize;	/* size	 of FLASH memory */
-	unsigned long	bi_flashoffset; /* reserved area for startup monitor */
-	unsigned long	bi_sramstart;	/* start of SRAM memory */
-	unsigned long	bi_sramsize;	/* size	 of SRAM memory */
-	unsigned long	bi_bootflags;	/* boot / reboot flag (for LynxOS) */
-	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
-	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
-	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
-	unsigned int	bi_baudrate;	/* Console Baudrate */
-	unsigned long   bi_boot_params;	/* where this board expects params */
-	struct				/* RAM configuration */
-	{
-		ulong start;
-		ulong size;
-	}bi_dram[CONFIG_NR_DRAM_BANKS];
-} bd_t;
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* !CONFIG_SYS_GENERIC_BOARD */
 
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_I386

+ 2 - 8
arch/x86/lib/Makefile

@@ -25,24 +25,18 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(ARCH).o
 
-ifeq ($(CONFIG_SYS_GENERIC_BOARD),)
-COBJS-y	+= board.o
-endif
-
 COBJS-y	+= bootm.o
 COBJS-y	+= cmd_boot.o
 COBJS-y	+= gcc.o
 COBJS-y	+= init_helpers.o
-COBJS-y	+= init_wrappers.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_SYS_PCAT_TIMER) += pcat_timer.o
 COBJS-$(CONFIG_PCI) += pci_type1.o
 COBJS-y	+= relocate.o
 COBJS-y += physmem.o
 COBJS-y	+= string.o
-COBJS-$(CONFIG_SYS_X86_ISR_TIMER)	+= timer.o
+COBJS-$(CONFIG_SYS_X86_TSC_TIMER)	+= tsc_timer.o
 COBJS-$(CONFIG_VIDEO_VGA)	+= video.o
 COBJS-$(CONFIG_CMD_ZBOOT)	+= zimage.o
 

+ 0 - 170
arch/x86/lib/bios.h

@@ -1,170 +0,0 @@
-/*
- * (C) Copyright 2002
- * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef _BIOS_H_
-#define _BIOS_H_
-
-#define OFFS_ES		0	/* 16bit */
-#define OFFS_GS		2	/* 16bit */
-#define OFFS_DS		4	/* 16bit */
-#define OFFS_EDI	6	/* 32bit */
-#define OFFS_DI		6	/* low 16 bits of EDI */
-#define OFFS_ESI	10	/* 32bit */
-#define OFFS_SI		10	/* low 16 bits of ESI */
-#define OFFS_EBP	14	/* 32bit */
-#define OFFS_BP		14	/* low 16 bits of EBP */
-#define OFFS_ESP	18	/* 32bit */
-#define OFFS_SP		18	/* low 16 bits of ESP */
-#define OFFS_EBX	22	/* 32bit */
-#define OFFS_BX		22	/* low 16 bits of EBX */
-#define OFFS_BL		22	/* low  8 bits of BX */
-#define OFFS_BH		23	/* high 8 bits of BX */
-#define OFFS_EDX	26	/* 32bit */
-#define OFFS_DX		26	/* low 16 bits of EBX */
-#define OFFS_DL		26	/* low  8 bits of BX */
-#define OFFS_DH		27	/* high 8 bits of BX */
-#define OFFS_ECX	30	/* 32bit */
-#define OFFS_CX		30	/* low 16 bits of EBX */
-#define OFFS_CL		30	/* low  8 bits of BX */
-#define OFFS_CH		31	/* high 8 bits of BX */
-#define OFFS_EAX	34	/* 32bit */
-#define OFFS_AX		34	/* low 16 bits of EBX */
-#define OFFS_AL		34	/* low  8 bits of BX */
-#define OFFS_AH		35	/* high 8 bits of BX */
-#define OFFS_VECTOR	38	/* 16bit */
-#define OFFS_IP		40	/* 16bit */
-#define OFFS_CS		42	/* 16bit */
-#define OFFS_FLAGS	44	/* 16bit */
-
-/* stack at 0x40:0x800 -> 0x800 */
-#define SEGMENT		0x40
-#define STACK		0x800
-
-/*
- * save general registers
- * save some segments
- * save callers stack segment
- * setup BIOS segments
- * setup BIOS stackpointer
- */
-#define MAKE_BIOS_STACK		\
-	pushal;			\
-	pushw	%ds;		\
-	pushw	%gs;		\
-	pushw	%es;		\
-	pushw	%ss;		\
-	popw	%gs;		\
-	movw	$SEGMENT, %ax;	\
-	movw	%ax, %ds;	\
-	movw	%ax, %es;	\
-	movw	%ax, %ss;	\
-	movw	%sp, %bp;	\
-	movw	$STACK, %sp
-
-/*
- * restore callers stack segment
- * restore some segments
- * restore general registers
- */
-#define RESTORE_CALLERS_STACK	\
-	pushw	%gs;		\
-	popw	%ss;		\
-	movw	%bp, %sp;	\
-	popw	%es;		\
-	popw	%gs;		\
-	popw	%ds;		\
-	popal
-
-#ifndef __ASSEMBLY__
-#define BIOS_DATA	((char *)0x400)
-#define BIOS_DATA_SIZE	256
-#define BIOS_BASE	((char *)0xf0000)
-#define BIOS_CS		0xf000
-
-extern ulong __bios_start;
-extern ulong __bios_size;
-
-/* these are defined in a 16bit segment and needs
- * to be accessed with the RELOC_16_xxxx() macros below
- */
-extern u16 ram_in_64kb_chunks;
-extern u16 bios_equipment;
-extern u8  pci_last_bus;
-
-extern void *rm_int00;
-extern void *rm_int01;
-extern void *rm_int02;
-extern void *rm_int03;
-extern void *rm_int04;
-extern void *rm_int05;
-extern void *rm_int06;
-extern void *rm_int07;
-extern void *rm_int08;
-extern void *rm_int09;
-extern void *rm_int0a;
-extern void *rm_int0b;
-extern void *rm_int0c;
-extern void *rm_int0d;
-extern void *rm_int0e;
-extern void *rm_int0f;
-extern void *rm_int10;
-extern void *rm_int11;
-extern void *rm_int12;
-extern void *rm_int13;
-extern void *rm_int14;
-extern void *rm_int15;
-extern void *rm_int16;
-extern void *rm_int17;
-extern void *rm_int18;
-extern void *rm_int19;
-extern void *rm_int1a;
-extern void *rm_int1b;
-extern void *rm_int1c;
-extern void *rm_int1d;
-extern void *rm_int1e;
-extern void *rm_int1f;
-extern void *rm_def_int;
-
-#define RELOC_16_LONG(seg, off) (*(u32 *)(seg << 4 | (u32)&off))
-#define RELOC_16_WORD(seg, off) (*(u16 *)(seg << 4 | (u32)&off))
-#define RELOC_16_BYTE(seg, off) (*(u8 *)(seg << 4 | (u32)&off))
-
-#ifdef PCI_BIOS_DEBUG
-extern u32 num_pci_bios_present;
-extern u32 num_pci_bios_find_device;
-extern u32 num_pci_bios_find_class;
-extern u32 num_pci_bios_generate_special_cycle;
-extern u32 num_pci_bios_read_cfg_byte;
-extern u32 num_pci_bios_read_cfg_word;
-extern u32 num_pci_bios_read_cfg_dword;
-extern u32 num_pci_bios_write_cfg_byte;
-extern u32 num_pci_bios_write_cfg_word;
-extern u32 num_pci_bios_write_cfg_dword;
-extern u32 num_pci_bios_get_irq_routing;
-extern u32 num_pci_bios_set_irq;
-extern u32 num_pci_bios_unknown_function;
-#endif
-
-#endif
-
-#endif

+ 0 - 266
arch/x86/lib/board.c

@@ -1,266 +0,0 @@
-/*
- * (C) Copyright 2008-2011
- * Graeme Russ, <graeme.russ@gmail.com>
- *
- * (C) Copyright 2002
- * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
- *
- * (C) Copyright 2002
- * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
- *
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#include <common.h>
-#include <fdtdec.h>
-#include <watchdog.h>
-#include <stdio_dev.h>
-#include <asm/u-boot-x86.h>
-#include <asm/relocate.h>
-#include <asm/processor.h>
-#include <asm/sections.h>
-
-#include <asm/init_helpers.h>
-#include <asm/init_wrappers.h>
-
-/*
- * Breath some life into the board...
- *
- * Getting the board up and running is a three-stage process:
- *  1) Execute from Flash, SDRAM Uninitialised
- *     At this point, there is a limited amount of non-SDRAM memory
- *     (typically the CPU cache, but can also be SRAM or even a buffer of
- *     of some peripheral). This limited memory is used to hold:
- *      - The initial copy of the Global Data Structure
- *      - A temporary stack
- *      - A temporary x86 Global Descriptor Table
- *      - The pre-console buffer (if enabled)
- *
- *     The following is performed during this phase of execution:
- *      - Core low-level CPU initialisation
- *      - Console initialisation
- *      - SDRAM initialisation
- *
- *  2) Execute from Flash, SDRAM Initialised
- *     At this point we copy Global Data from the initial non-SDRAM
- *     memory and set up the permanent stack in SDRAM. The CPU cache is no
- *     longer being used as temporary memory, so we can now fully enable
- *     it.
- *
- *     The following is performed during this phase of execution:
- *      - Create final stack in SDRAM
- *      - Copy Global Data from temporary memory to SDRAM
- *      - Enabling of CPU cache(s),
- *      - Copying of U-Boot code and data from Flash to RAM
- *      - Clearing of the BSS
- *      - ELF relocation adjustments
- *
- *  3) Execute from SDRAM
- *     The following is performed during this phase of execution:
- *      - All remaining initialisation
- */
-
-/*
- * The requirements for any new initalization function is simple: it is
- * a function with no parameters which returns an integer return code,
- * where 0 means "continue" and != 0 means "fatal error, hang the system"
- */
-typedef int (init_fnc_t) (void);
-
-/*
- * init_sequence_f is the list of init functions which are run when U-Boot
- * is executing from Flash with a limited 'C' environment. The following
- * limitations must be considered when implementing an '_f' function:
- *  - 'static' variables are read-only
- *  - Global Data (gd->xxx) is read/write
- *  - Stack space is limited
- *
- * The '_f' sequence must, as a minimum, initialise SDRAM. It _should_
- * also initialise the console (to provide early debug output)
- */
-init_fnc_t *init_sequence_f[] = {
-	cpu_init_f,
-	board_early_init_f,
-#ifdef CONFIG_OF_CONTROL
-	find_fdt,
-	fdtdec_check_fdt,
-#endif
-	env_init,
-	init_baudrate_f,
-	serial_init,
-	console_init_f,
-#ifdef CONFIG_OF_CONTROL
-	prepare_fdt,
-#endif
-	dram_init_f,
-	calculate_relocation_address,
-
-	NULL,
-};
-
-/*
- * init_sequence_f_r is the list of init functions which are run when
- * U-Boot is executing from Flash with a semi-limited 'C' environment.
- * The following limitations must be considered when implementing an
- * '_f_r' function:
- *  - 'static' variables are read-only
- *  - Global Data (gd->xxx) is read/write
- *
- * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if
- * supported).  It _should_, if possible, copy global data to RAM and
- * initialise the CPU caches (to speed up the relocation process)
- */
-init_fnc_t *init_sequence_f_r[] = {
-	init_cache_f_r,
-	copy_uboot_to_ram,
-	copy_fdt_to_ram,
-	clear_bss,
-	do_elf_reloc_fixups,
-
-	NULL,
-};
-
-/*
- * init_sequence_r is the list of init functions which are run when U-Boot
- * is executing from RAM with a full 'C' environment. There are no longer
- * any limitations which must be considered when implementing an '_r'
- * function, (i.e.'static' variables are read/write)
- *
- * If not already done, the '_r' sequence must copy global data to RAM and
- * (should) initialise the CPU caches.
- */
-init_fnc_t *init_sequence_r[] = {
-	set_reloc_flag_r,
-	init_bd_struct_r,
-	mem_malloc_init_r,
-	cpu_init_r,
-	board_early_init_r,
-	dram_init,
-	interrupt_init,
-	timer_init,
-	display_banner,
-	display_dram_config,
-	serial_initialize_r,
-#ifndef CONFIG_SYS_NO_FLASH
-	flash_init_r,
-#endif
-#ifdef CONFIG_PCI
-	pci_init_r,
-#endif
-#ifdef CONFIG_SPI
-	init_func_spi,
-#endif
-	env_relocate_r,
-	stdio_init,
-	jumptable_init_r,
-	console_init_r,
-#ifdef CONFIG_MISC_INIT_R
-	misc_init_r,
-#endif
-#if defined(CONFIG_CMD_KGDB)
-	kgdb_init_r,
-#endif
-	enable_interrupts_r,
-#ifdef CONFIG_STATUS_LED
-	status_led_set_r,
-#endif
-	set_load_addr_r,
-#if defined(CONFIG_CMD_IDE)
-	ide_init_r,
-#endif
-#if defined(CONFIG_CMD_SCSI)
-	scsi_init_r,
-#endif
-#if defined(CONFIG_CMD_DOC)
-	doc_init_r,
-#endif
-#ifdef CONFIG_BITBANGMII
-	bb_miiphy_init_r,
-#endif
-#if defined(CONFIG_CMD_NET)
-	eth_initialize_r,
-#ifdef CONFIG_RESET_PHY_R
-	reset_phy_r,
-#endif
-#endif
-#ifdef CONFIG_LAST_STAGE_INIT
-	last_stage_init,
-#endif
-	NULL,
-};
-
-static void do_init_loop(init_fnc_t **init_fnc_ptr)
-{
-	for (; *init_fnc_ptr; ++init_fnc_ptr) {
-		WATCHDOG_RESET();
-		if ((*init_fnc_ptr)() != 0)
-			hang();
-	}
-}
-
-void board_init_f(ulong boot_flags)
-{
-	gd->fdt_blob = gd->new_fdt = NULL;
-	gd->flags = boot_flags;
-
-	do_init_loop(init_sequence_f);
-
-	/*
-	 * SDRAM and console are now initialised. The final stack can now
-	 * be setup in SDRAM. Code execution will continue in Flash, but
-	 * with the stack in SDRAM and Global Data in temporary memory
-	 * (CPU cache)
-	 */
-	board_init_f_r_trampoline(gd->start_addr_sp);
-
-	/* NOTREACHED - board_init_f_r_trampoline() does not return */
-	while (1)
-		;
-}
-
-void board_init_f_r(void)
-{
-	do_init_loop(init_sequence_f_r);
-
-	/*
-	 * U-Boot has been copied into SDRAM, the BSS has been cleared etc.
-	 * Transfer execution from Flash to RAM by calculating the address
-	 * of the in-RAM copy of board_init_r() and calling it
-	 */
-	(board_init_r + gd->reloc_off)(gd, gd->relocaddr);
-
-	/* NOTREACHED - board_init_r() does not return */
-	while (1)
-		;
-}
-
-void board_init_r(gd_t *id, ulong dest_addr)
-{
-	do_init_loop(init_sequence_r);
-
-	/* main_loop() can return to retry autoboot, if so just run it again. */
-	for (;;)
-		main_loop();
-
-	/* NOTREACHED - no way out of command loop except booting */
-}

+ 0 - 8
arch/x86/lib/bootm.c

@@ -93,14 +93,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
 		goto error;
 	}
 
-#ifdef DEBUG
-	printf("## Transferring control to Linux (at address %08x) ...\n",
-		(u32)base_ptr);
-#endif
-
-	/* we assume that the kernel is in place */
-	printf("\nStarting kernel ...\n\n");
-
 	boot_zimage(base_ptr, load_address);
 	/* does not return */
 

+ 2 - 0
arch/x86/lib/cmd_boot.c

@@ -36,6 +36,8 @@
 #include <malloc.h>
 #include <asm/u-boot-x86.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 unsigned long do_go_exec(ulong (*entry)(int, char * const []),
 			 int argc, char * const argv[])
 {

+ 0 - 98
arch/x86/lib/init_helpers.c

@@ -21,60 +21,12 @@
  * MA 02111-1307 USA
  */
 #include <common.h>
-#include <command.h>
 #include <fdtdec.h>
-#include <stdio_dev.h>
-#include <version.h>
-#include <malloc.h>
-#include <net.h>
-#include <ide.h>
-#include <serial.h>
 #include <spi.h>
-#include <status_led.h>
-#include <asm/processor.h>
 #include <asm/sections.h>
-#include <asm/u-boot-x86.h>
-#include <linux/compiler.h>
-
-#include <asm/init_helpers.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/************************************************************************
- * Init Utilities							*
- ************************************************************************
- * Some of this code should be moved into the core functions,
- * or dropped completely,
- * but let's get it working (again) first...
- */
-
-int display_banner(void)
-{
-	printf("\n\n%s\n\n", version_string);
-
-	return 0;
-}
-
-int display_dram_config(void)
-{
-	int i;
-
-	puts("DRAM Configuration:\n");
-
-	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-		printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
-		print_size(gd->bd->bi_dram[i].size, "\n");
-	}
-
-	return 0;
-}
-
-int init_baudrate_f(void)
-{
-	gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
-	return 0;
-}
-
 /* Get the top of usable RAM */
 __weak ulong board_get_usable_ram_top(ulong total_size)
 {
@@ -134,21 +86,6 @@ int init_cache_f_r(void)
 	return init_cache();
 }
 
-int set_reloc_flag_r(void)
-{
-	gd->flags = GD_FLG_RELOC;
-
-	return 0;
-}
-
-int mem_malloc_init_r(void)
-{
-	mem_malloc_init(((gd->relocaddr - CONFIG_SYS_MALLOC_LEN)+3)&~3,
-			CONFIG_SYS_MALLOC_LEN);
-
-	return 0;
-}
-
 bd_t bd_data;
 
 int init_bd_struct_r(void)
@@ -159,39 +96,6 @@ int init_bd_struct_r(void)
 	return 0;
 }
 
-#ifndef CONFIG_SYS_NO_FLASH
-int flash_init_r(void)
-{
-	ulong size;
-
-	puts("Flash: ");
-
-	/* configure available FLASH banks */
-	size = flash_init();
-
-	print_size(size, "\n");
-
-	return 0;
-}
-#endif
-
-#ifdef CONFIG_STATUS_LED
-int status_led_set_r(void)
-{
-	status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
-
-	return 0;
-}
-#endif
-
-int set_load_addr_r(void)
-{
-	/* Initialize from environment */
-	load_addr = getenv_ulong("loadaddr", 16, load_addr);
-
-	return 0;
-}
-
 int init_func_spi(void)
 {
 	puts("SPI:   ");
@@ -200,7 +104,6 @@ int init_func_spi(void)
 	return 0;
 }
 
-#ifdef CONFIG_OF_CONTROL
 int find_fdt(void)
 {
 #ifdef CONFIG_OF_EMBED
@@ -227,4 +130,3 @@ int prepare_fdt(void)
 
 	return 0;
 }
-#endif

+ 0 - 164
arch/x86/lib/init_wrappers.c

@@ -1,164 +0,0 @@
-/*
- * (C) Copyright 2011
- * Graeme Russ, <graeme.russ@gmail.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-#include <common.h>
-#include <environment.h>
-#include <fdtdec.h>
-#include <serial.h>
-#include <kgdb.h>
-#include <scsi.h>
-#include <post.h>
-#include <miiphy.h>
-
-#include <asm/init_wrappers.h>
-
-int serial_initialize_r(void)
-{
-	serial_initialize();
-
-	return 0;
-}
-
-/*
- * Tell if it's OK to load the environment early in boot.
- *
- * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
- * if this is OK (defaulting to saying it's not OK).
- *
- * NOTE: Loading the environment early can be a bad idea if security is
- *       important, since no verification is done on the environment.
- *
- * @return 0 if environment should not be loaded, !=0 if it is ok to load
- */
-static int should_load_env(void)
-{
-#ifdef CONFIG_OF_CONTROL
-	return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 0);
-#elif defined CONFIG_DELAY_ENVIRONMENT
-	return 0;
-#else
-	return 1;
-#endif
-}
-
-int env_relocate_r(void)
-{
-	/* initialize environment */
-	if (should_load_env())
-		env_relocate();
-	else
-		set_default_env(NULL);
-
-	return 0;
-}
-
-
-int pci_init_r(void)
-{
-	/* Do pci configuration */
-	pci_init();
-
-	return 0;
-}
-
-int jumptable_init_r(void)
-{
-	jumptable_init();
-
-	return 0;
-}
-
-int pcmcia_init_r(void)
-{
-	puts("PCMCIA:");
-	pcmcia_init();
-
-	return 0;
-}
-
-int kgdb_init_r(void)
-{
-	puts("KGDB:  ");
-	kgdb_init();
-
-	return 0;
-}
-
-int enable_interrupts_r(void)
-{
-	/* enable exceptions */
-	enable_interrupts();
-
-	return 0;
-}
-
-int eth_initialize_r(void)
-{
-	puts("Net:   ");
-	eth_initialize(gd->bd);
-
-	return 0;
-}
-
-int reset_phy_r(void)
-{
-#ifdef DEBUG
-	puts("Reset Ethernet PHY\n");
-#endif
-	reset_phy();
-
-	return 0;
-}
-
-int ide_init_r(void)
-{
-	puts("IDE:   ");
-	ide_init();
-
-	return 0;
-}
-
-int scsi_init_r(void)
-{
-	puts("SCSI:  ");
-	scsi_init();
-
-	return 0;
-}
-
-#ifdef CONFIG_BITBANGMII
-int bb_miiphy_init_r(void)
-{
-	bb_miiphy_init();
-
-	return 0;
-}
-#endif
-
-#ifdef CONFIG_POST
-int post_run_r(void)
-{
-	post_run(NULL, POST_RAM | post_bootmode_get(0));
-
-	return 0;
-}
-#endif

+ 3 - 66
arch/x86/lib/pcat_timer.c

@@ -24,83 +24,20 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/i8254.h>
-#include <asm/ibmpc.h>
-#include <asm/interrupt.h>
 
-#define TIMER0_VALUE 0x04aa /* 1kHz 1.9318MHz / 1000 */
 #define TIMER2_VALUE 0x0a8e /* 440Hz */
 
-static int timer_init_done;
-
-int timer_init(void)
+int pcat_timer_init(void)
 {
-	/* initialize timer 0 and 2
-	 *
-	 * Timer 0 is used to increment system_tick 1000 times/sec
-	 * Timer 1 was used for DRAM refresh in early PC's
-	 * Timer 2 is used to drive the speaker
+	/*
+	 * initialize 2, used to drive the speaker
 	 * (to start a beep: write 3 to port 0x61,
 	 * to stop it again: write 0)
 	 */
-	outb(PIT_CMD_CTR0 | PIT_CMD_BOTH | PIT_CMD_MODE2,
-			PIT_BASE + PIT_COMMAND);
-	outb(TIMER0_VALUE & 0xff, PIT_BASE + PIT_T0);
-	outb(TIMER0_VALUE >> 8, PIT_BASE + PIT_T0);
-
 	outb(PIT_CMD_CTR2 | PIT_CMD_BOTH | PIT_CMD_MODE3,
 			PIT_BASE + PIT_COMMAND);
 	outb(TIMER2_VALUE & 0xff, PIT_BASE + PIT_T2);
 	outb(TIMER2_VALUE >> 8, PIT_BASE + PIT_T2);
 
-	irq_install_handler(0, timer_isr, NULL);
-	unmask_irq(0);
-
-	timer_init_done = 1;
-
 	return 0;
 }
-
-static u16 read_pit(void)
-{
-	u8 low;
-
-	outb(PIT_CMD_LATCH, PIT_BASE + PIT_COMMAND);
-	low = inb(PIT_BASE + PIT_T0);
-
-	return (inb(PIT_BASE + PIT_T0) << 8) | low;
-}
-
-/* this is not very exact */
-void __udelay(unsigned long usec)
-{
-	int counter;
-	int wraps;
-
-	if (timer_init_done) {
-		counter = read_pit();
-		wraps = usec / 1000;
-		usec = usec % 1000;
-
-		usec *= 1194;
-		usec /= 1000;
-		usec += counter;
-
-		while (usec > 1194) {
-			usec -= 1194;
-			wraps++;
-		}
-
-		while (1) {
-			int new_count = read_pit();
-
-			if (((new_count < usec) && !wraps) || wraps < 0)
-				break;
-
-			if (new_count > counter)
-				wraps--;
-
-			counter = new_count;
-		}
-	}
-
-}

+ 0 - 188
arch/x86/lib/pci.c

@@ -1,188 +0,0 @@
-/*
- * (C) Copyright 2002
- * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#include <common.h>
-#include <pci.h>
-#include <asm/io.h>
-#include <asm/pci.h>
-
-#undef PCI_ROM_SCAN_VERBOSE
-
-int pci_shadow_rom(pci_dev_t dev, unsigned char *dest)
-{
-	struct pci_controller *hose;
-	int res = -1;
-	int i;
-
-	u32 rom_addr;
-	u32 addr_reg;
-	u32 size;
-
-	u16 vendor;
-	u16 device;
-	u32 class_code;
-
-	u32 pci_data;
-
-	hose = pci_bus_to_hose(PCI_BUS(dev));
-
-	debug("pci_shadow_rom() asked to shadow device %x to %x\n",
-	       dev, (u32)dest);
-
-	pci_read_config_word(dev, PCI_VENDOR_ID, &vendor);
-	pci_read_config_word(dev, PCI_DEVICE_ID, &device);
-	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_code);
-
-	class_code &= 0xffffff00;
-	class_code >>= 8;
-
-	debug("PCI Header Vendor %04x device %04x class %06x\n",
-	       vendor, device, class_code);
-
-	/* Enable the rom addess decoder */
-	pci_write_config_dword(dev, PCI_ROM_ADDRESS, (u32)PCI_ROM_ADDRESS_MASK);
-	pci_read_config_dword(dev, PCI_ROM_ADDRESS, &addr_reg);
-
-	if (!addr_reg) {
-		/* register unimplemented */
-		printf("pci_chadow_rom: device do not seem to have a rom\n");
-		return -1;
-	}
-
-	size = (~(addr_reg&PCI_ROM_ADDRESS_MASK)) + 1;
-
-	debug("ROM is %d bytes\n", size);
-
-	rom_addr = pci_get_rom_window(hose, size);
-
-	debug("ROM mapped at %x\n", rom_addr);
-
-	pci_write_config_dword(dev, PCI_ROM_ADDRESS,
-			       pci_phys_to_mem(dev, rom_addr)
-			       |PCI_ROM_ADDRESS_ENABLE);
-
-
-	for (i = rom_addr; i < rom_addr + size; i += 512) {
-		if (readw(i) == 0xaa55) {
-#ifdef PCI_ROM_SCAN_VERBOSE
-			printf("ROM signature found\n");
-#endif
-			pci_data = readw(0x18 + i);
-			pci_data += i;
-
-			if (0 == memcmp((void *)pci_data, "PCIR", 4)) {
-#ifdef PCI_ROM_SCAN_VERBOSE
-				printf("Fount PCI rom image at offset %d\n",
-				       i - rom_addr);
-				printf("Vendor %04x device %04x class %06x\n",
-				       readw(pci_data + 4), readw(pci_data + 6),
-				       readl(pci_data + 0x0d) & 0xffffff);
-				printf("%s\n",
-				       (readw(pci_data + 0x15) & 0x80) ?
-				       "Last image" : "More images follow");
-				switch	(readb(pci_data + 0x14)) {
-				case 0:
-					printf("X86 code\n");
-					break;
-				case 1:
-					printf("Openfirmware code\n");
-					break;
-				case 2:
-					printf("PARISC code\n");
-					break;
-				}
-				printf("Image size %d\n",
-				       readw(pci_data + 0x10) * 512);
-#endif
-				/*
-				 * FixMe: I think we should compare the class
-				 * code bytes as well but I have no reference
-				 * on the exact order of these bytes in the PCI
-				 * ROM header
-				 */
-				if (readw(pci_data + 4) == vendor &&
-				    readw(pci_data + 6) == device &&
-				    readb(pci_data + 0x14) == 0) {
-#ifdef PCI_ROM_SCAN_VERBOSE
-					printf("Suitable ROM image found\n");
-#endif
-					memmove(dest, (void *)rom_addr,
-						readw(pci_data + 0x10) * 512);
-					res = 0;
-					break;
-
-				}
-
-				if (readw(pci_data + 0x15) & 0x80)
-					break;
-			}
-		}
-
-	}
-
-#ifdef PCI_ROM_SCAN_VERBOSE
-	if (res)
-		printf("No suitable image found\n");
-#endif
-	/* disable PAR register and PCI device ROM address devocer */
-	pci_remove_rom_window(hose, rom_addr);
-
-	pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0);
-
-	return res;
-}
-
-#ifdef PCI_BIOS_DEBUG
-
-void print_bios_bios_stat(void)
-{
-	printf("16 bit functions:\n");
-	printf("pci_bios_present:                %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_present));
-	printf("pci_bios_find_device:            %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_find_device));
-	printf("pci_bios_find_class:             %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_find_class));
-	printf("pci_bios_generate_special_cycle: %d\n",
-			RELOC_16_LONG(0xf000,
-				      num_pci_bios_generate_special_cycle));
-	printf("pci_bios_read_cfg_byte:          %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_read_cfg_byte));
-	printf("pci_bios_read_cfg_word:          %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_read_cfg_word));
-	printf("pci_bios_read_cfg_dword:         %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_read_cfg_dword));
-	printf("pci_bios_write_cfg_byte:         %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_write_cfg_byte));
-	printf("pci_bios_write_cfg_word:         %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_write_cfg_word));
-	printf("pci_bios_write_cfg_dword:        %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_write_cfg_dword));
-	printf("pci_bios_get_irq_routing:        %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_get_irq_routing));
-	printf("pci_bios_set_irq:                %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_set_irq));
-	printf("pci_bios_unknown_function:       %d\n",
-			RELOC_16_LONG(0xf000, num_pci_bios_unknown_function));
-}
-#endif

+ 2 - 0
arch/x86/lib/physmem.c

@@ -12,6 +12,8 @@
 #include <physmem.h>
 #include <linux/compiler.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Large pages are 2MB. */
 #define LARGE_PAGE_SIZE ((1 << 20) * 2)
 

+ 2 - 0
arch/x86/lib/relocate.c

@@ -39,6 +39,8 @@
 #include <asm/sections.h>
 #include <elf.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int copy_uboot_to_ram(void)
 {
 	size_t len = (size_t)&__data_end - (size_t)&__text_start;

+ 0 - 116
arch/x86/lib/timer.c

@@ -1,116 +0,0 @@
-/*
- * (C) Copyright 2008,2009
- * Graeme Russ, <graeme.russ@gmail.com>
- *
- * (C) Copyright 2002
- * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#include <common.h>
-#include <malloc.h>
-#include <asm/io.h>
-#include <asm/i8254.h>
-#include <asm/ibmpc.h>
-
-struct timer_isr_function {
-	struct timer_isr_function *next;
-	timer_fnc_t *isr_func;
-};
-
-static struct timer_isr_function *first_timer_isr;
-static unsigned long system_ticks;
-
-/*
- * register_timer_isr() allows multiple architecture and board specific
- * functions to be called every millisecond. Keep the execution time of
- * each function as low as possible
- */
-int register_timer_isr(timer_fnc_t *isr_func)
-{
-	struct timer_isr_function *new_func;
-	struct timer_isr_function *temp;
-	int flag;
-
-	new_func = malloc(sizeof(struct timer_isr_function));
-
-	if (new_func == NULL)
-		return 1;
-
-	new_func->isr_func = isr_func;
-	new_func->next = NULL;
-
-	/*
-	 *  Don't allow timer interrupts while the
-	 *  linked list is being modified
-	 */
-	flag = disable_interrupts();
-
-	if (first_timer_isr == NULL) {
-		first_timer_isr = new_func;
-	} else {
-		temp = first_timer_isr;
-		while (temp->next != NULL)
-			temp = temp->next;
-		temp->next = new_func;
-	}
-
-	if (flag)
-		enable_interrupts();
-
-	return 0;
-}
-
-/*
- * timer_isr() MUST be the registered interrupt handler for
- */
-void timer_isr(void *unused)
-{
-	struct timer_isr_function *temp = first_timer_isr;
-
-	system_ticks++;
-
-	/* Execute each registered function */
-	while (temp != NULL) {
-		temp->isr_func();
-		temp = temp->next;
-	}
-}
-
-ulong get_timer(ulong base)
-{
-	return system_ticks - base;
-}
-
-void timer_set_tsc_base(uint64_t new_base)
-{
-	gd->arch.tsc_base = new_base;
-}
-
-uint64_t timer_get_tsc(void)
-{
-	uint64_t time_now;
-
-	time_now = rdtsc();
-	if (!gd->arch.tsc_base)
-		gd->arch.tsc_base = time_now;
-
-	return time_now - gd->arch.tsc_base;
-}

+ 107 - 0
arch/x86/lib/tsc_timer.c

@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <asm/io.h>
+#include <asm/i8254.h>
+#include <asm/ibmpc.h>
+#include <asm/msr.h>
+#include <asm/u-boot-x86.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void timer_set_base(u64 base)
+{
+	gd->arch.tsc_base = base;
+}
+
+/*
+ * Get the number of CPU time counter ticks since it was read first time after
+ * restart. This yields a free running counter guaranteed to take almost 6
+ * years to wrap around even at 100GHz clock rate.
+ */
+u64 get_ticks(void)
+{
+	u64 now_tick = rdtsc();
+
+	/* We assume that 0 means the base hasn't been set yet */
+	if (!gd->arch.tsc_base)
+		panic("No tick base available");
+	return now_tick - gd->arch.tsc_base;
+}
+
+#define PLATFORM_INFO_MSR 0xce
+
+/* Get the speed of the TSC timer in MHz */
+unsigned long get_tbclk_mhz(void)
+{
+	u32 ratio;
+	u64 platform_info = native_read_msr(PLATFORM_INFO_MSR);
+
+	/* 100MHz times Max Non Turbo ratio */
+	ratio = (platform_info >> 8) & 0xff;
+	return 100 * ratio;
+}
+
+unsigned long get_tbclk(void)
+{
+	return get_tbclk_mhz() * 1000 * 1000;
+}
+
+static ulong get_ms_timer(void)
+{
+	return (get_ticks() * 1000) / get_tbclk();
+}
+
+ulong get_timer(ulong base)
+{
+	return get_ms_timer() - base;
+}
+
+ulong timer_get_us(void)
+{
+	return get_ticks() / get_tbclk_mhz();
+}
+
+ulong timer_get_boot_us(void)
+{
+	return timer_get_us();
+}
+
+void __udelay(unsigned long usec)
+{
+	u64 now = get_ticks();
+	u64 stop;
+
+	stop = now + usec * get_tbclk_mhz();
+
+	while ((int64_t)(stop - get_ticks()) > 0)
+		;
+}
+
+int timer_init(void)
+{
+#ifdef CONFIG_SYS_PCAT_TIMER
+	/* Set up the PCAT timer if required */
+	pcat_timer_init();
+#endif
+
+	return 0;
+}

+ 7 - 4
arch/x86/lib/zimage.c

@@ -283,6 +283,13 @@ __weak void board_final_cleanup(void)
 
 void boot_zimage(void *setup_base, void *load_address)
 {
+	debug("## Transferring control to Linux (at address %08x) ...\n",
+	      (u32)setup_base);
+
+	bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
+#ifdef CONFIG_BOOTSTAGE_REPORT
+	bootstage_report();
+#endif
 	board_final_cleanup();
 
 	printf("\nStarting kernel ...\n\n");
@@ -363,10 +370,6 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		return -1;
 	}
 
-	printf("## Transferring control to Linux "
-	       "(at address %08x) ...\n",
-	       (u32)base_ptr);
-
 	/* we assume that the kernel is in place */
 	boot_zimage(base_ptr, load_address);
 	/* does not return */

+ 1 - 0
common/board_r.c

@@ -765,6 +765,7 @@ init_fnc_t init_sequence_r[] = {
 #endif
 	initr_barrier,
 	initr_malloc,
+	bootstage_relocate,
 #ifdef CONFIG_ARCH_EARLY_INIT_R
 	arch_early_init_r,
 #endif

+ 44 - 0
common/bootstage.c

@@ -30,6 +30,8 @@
 
 #include <common.h>
 #include <libfdt.h>
+#include <malloc.h>
+#include <linux/compiler.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -56,6 +58,21 @@ struct bootstage_hdr {
 	uint32_t magic;		/* Unused */
 };
 
+int bootstage_relocate(void)
+{
+	int i;
+
+	/*
+	 * Duplicate all strings.  They may point to an old location in the
+	 * program .text section that can eventually get trashed.
+	 */
+	for (i = 0; i < BOOTSTAGE_ID_COUNT; i++)
+		if (record[i].name)
+			record[i].name = strdup(record[i].name);
+
+	return 0;
+}
+
 ulong bootstage_add_record(enum bootstage_id id, const char *name,
 			   int flags, ulong mark)
 {
@@ -102,6 +119,33 @@ ulong bootstage_mark_name(enum bootstage_id id, const char *name)
 	return bootstage_add_record(id, name, flags, timer_get_boot_us());
 }
 
+ulong bootstage_mark_code(const char *file, const char *func, int linenum)
+{
+	char *str, *p;
+	__maybe_unused char *end;
+	int len = 0;
+
+	/* First work out the length we need to allocate */
+	if (linenum != -1)
+		len = 11;
+	if (func)
+		len += strlen(func);
+	if (file)
+		len += strlen(file);
+
+	str = malloc(len + 1);
+	p = str;
+	end = p + len;
+	if (file)
+		p += snprintf(p, end - p, "%s,", file);
+	if (linenum != -1)
+		p += snprintf(p, end - p, "%d", linenum);
+	if (func)
+		p += snprintf(p, end - p, ": %s", func);
+
+	return bootstage_mark_name(BOOTSTAGE_ID_ALLOC, str);
+}
+
 uint32_t bootstage_start(enum bootstage_id id, const char *name)
 {
 	struct bootstage_record *rec = &record[id];

+ 2 - 0
common/cmd_ximg.c

@@ -58,7 +58,9 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 	const void	*fit_data;
 	size_t		fit_len;
 #endif
+#ifdef CONFIG_GZIP
 	uint		unc_len = CONFIG_SYS_XIMG_LEN;
+#endif
 	uint8_t		comp;
 
 	verify = getenv_yesno("verify");

+ 54 - 0
include/bootstage.h

@@ -236,6 +236,16 @@ void show_boot_progress(int val);
 #if defined(CONFIG_BOOTSTAGE) && !defined(CONFIG_SPL_BUILD)
 /* This is the full bootstage implementation */
 
+/**
+ * Relocate existing bootstage records
+ *
+ * Call this after relocation has happened and after malloc has been initted.
+ * We need to copy any pointers in bootstage records that were added pre-
+ * relocation, since memory can be overritten later.
+ * @return Always returns 0, to indicate success
+ */
+int bootstage_relocate(void);
+
 /**
  * Add a new bootstage record
  *
@@ -256,6 +266,19 @@ ulong bootstage_error(enum bootstage_id id);
 
 ulong bootstage_mark_name(enum bootstage_id id, const char *name);
 
+/**
+ * Mark a time stamp in the given function and line number
+ *
+ * See BOOTSTAGE_MARKER() for a convenient macro.
+ *
+ * @param file		Filename to record (NULL if none)
+ * @param func		Function name to record
+ * @param linenum	Line number to record
+ * @return recorded time stamp
+ */
+ulong bootstage_mark_code(const char *file, const char *func,
+			  int linenum);
+
 /**
  * Mark the start of a bootstage activity. The end will be marked later with
  * bootstage_accum() and at that point we accumulate the time taken. Calling
@@ -315,11 +338,22 @@ int bootstage_stash(void *base, int size);
 int bootstage_unstash(void *base, int size);
 
 #else
+static inline ulong bootstage_add_record(enum bootstage_id id,
+		const char *name, int flags, ulong mark)
+{
+	return 0;
+}
+
 /*
  * This is a dummy implementation which just calls show_boot_progress(),
  * and won't even do that unless CONFIG_SHOW_BOOT_PROGRESS is defined
  */
 
+static inline int bootstage_relocate(void)
+{
+	return 0;
+}
+
 static inline ulong bootstage_mark(enum bootstage_id id)
 {
 	show_boot_progress(id);
@@ -337,6 +371,22 @@ static inline ulong bootstage_mark_name(enum bootstage_id id, const char *name)
 	return 0;
 }
 
+static inline ulong bootstage_mark_code(const char *file, const char *func,
+					int linenum)
+{
+	return 0;
+}
+
+static inline uint32_t bootstage_start(enum bootstage_id id, const char *name)
+{
+	return 0;
+}
+
+static inline uint32_t bootstage_accum(enum bootstage_id id)
+{
+	return 0;
+}
+
 static inline int bootstage_stash(void *base, int size)
 {
 	return 0;	/* Pretend to succeed */
@@ -348,4 +398,8 @@ static inline int bootstage_unstash(void *base, int size)
 }
 #endif /* CONFIG_BOOTSTAGE */
 
+/* Helper macro for adding a bootstage to a line of code */
+#define BOOTSTAGE_MARKER()	\
+		bootstage_mark_code(__FILE__, __func__, __LINE__)
+
 #endif

+ 15 - 3
include/configs/coreboot.h

@@ -38,7 +38,6 @@
 #define CONFIG_SHOW_BOOT_PROGRESS
 #define CONFIG_LAST_STAGE_INIT
 #define CONFIG_SYS_VSNPRINTF
-#define CONFIG_INTEL_CORE_ARCH	/* Sandy bridge and ivy bridge chipsets. */
 #define CONFIG_ZBOOT_32
 #define CONFIG_PHYSMEM
 #define CONFIG_SYS_EARLY_PCI_INIT
@@ -49,6 +48,19 @@
 #define CONFIG_OF_SEPARATE
 #define CONFIG_DEFAULT_DEVICE_TREE	link
 
+#define CONFIG_BOOTSTAGE
+#define CONFIG_BOOTSTAGE_REPORT
+#define CONFIG_BOOTSTAGE_FDT
+#define CONFIG_CMD_BOOTSTAGE
+/* Place to stash bootstage data from first-stage U-Boot */
+#define CONFIG_BOOTSTAGE_STASH		0x0110f000
+#define CONFIG_BOOTSTAGE_STASH_SIZE	0x7fc
+#define CONFIG_BOOTSTAGE_USER_COUNT	60
+
+#define CONFIG_LZO
+#undef CONFIG_ZLIB
+#undef CONFIG_GZIP
+
 /*-----------------------------------------------------------------------
  * Watchdog Configuration
  */
@@ -218,7 +230,6 @@
 #define CONFIG_SYS_MEMTEST_END			0x01000000
 #define CONFIG_SYS_LOAD_ADDR			0x100000
 #define CONFIG_SYS_HZ				1000
-#define CONFIG_SYS_X86_ISR_TIMER
 
 /*-----------------------------------------------------------------------
  * SDRAM Configuration
@@ -235,8 +246,9 @@
  * CPU Features
  */
 
-#define CONFIG_SYS_GENERIC_TIMER
+#define CONFIG_SYS_X86_TSC_TIMER
 #define CONFIG_SYS_PCAT_INTERRUPTS
+#define CONFIG_SYS_PCAT_TIMER
 #define CONFIG_SYS_NUM_IRQS			16
 
 /*-----------------------------------------------------------------------