Skip to contentSkip to conversation

Remove unused code, add accurate timier and bootstage

PATCH New Simon Glass 4 participants 35 messages Apr 18, 2013 – May 13, 2013 x86

lore
Share & tools
lore
#0 lore raw

cover Remove unused code, add accurate timier and bootstage

This series removes unused x86 code based on advice from Graeme Russ. THis code was used for real mode which is no longer needed in U-Boot.

A new more accurate timer is added, and this permits bootstage to be enabled and produce useful results on x86.

Doug Anderson (2):
bootstage: Copy bootstage strings post-relocation Call bootstage_relocate() after malloc is initted

Simon Glass (17):
x86: Remove unused bios/pci code
x86: Remove unused portion of link script
x86: Remove legacy board init code
x86: Declare global_data pointer when it is used
x86: Implement panic output for coreboot
x86: Rationalise kernel booting logic and bootstage
x86: Add TSC timer
x86: Remove old broken timer implementation
x86: Remove ISR timer
x86: Re-enable PCAT timer 2 for beeping
bootstage: Add stubs for new bootstage functions
x86: Enable bootstage for coreboot
bootstage: Allow marking a particular line of code
x86: Fix warning in cmd_ximg.c when CONFIG_GZIP is not defined
x86: config: Enable LZO for coreboot, remove zlib, gzip
x86: Support adding coreboot timestanps to bootstage
x86: Add coreboot timestamps

 arch/x86/cpu/Makefile                          |   2 +-
 arch/x86/cpu/coreboot/coreboot.c               |  13 ++
 arch/x86/cpu/coreboot/timestamp.c              |  42 +++-
 arch/x86/cpu/cpu.c                             |   5 +
 arch/x86/cpu/interrupts.c                      |   2 +
 arch/x86/cpu/timer.c                           |  17 --
 arch/x86/cpu/u-boot.lds                        |  12 --
 arch/x86/include/asm/arch-coreboot/timestamp.h |   7 +
 arch/x86/include/asm/init_helpers.h            |   9 -
 arch/x86/include/asm/init_wrappers.h           |  42 ----
 arch/x86/include/asm/pci.h                     |   4 -
 arch/x86/include/asm/u-boot-x86.h              |   4 +
 arch/x86/include/asm/u-boot.h                  |  32 ---
 arch/x86/lib/Makefile                          |  10 +-
 arch/x86/lib/bios.h                            | 170 ---------------
 arch/x86/lib/board.c                           | 273 -------------------------
 arch/x86/lib/bootm.c                           |   8 -
 arch/x86/lib/cmd_boot.c                        |   2 +
 arch/x86/lib/init_helpers.c                    |  98 ---------
 arch/x86/lib/init_wrappers.c                   | 164 ---------------
 arch/x86/lib/pcat_timer.c                      |  69 +------
 arch/x86/lib/pci.c                             | 188 -----------------
 arch/x86/lib/physmem.c                         |   2 +
 arch/x86/lib/relocate.c                        |   2 +
 arch/x86/lib/timer.c                           | 116 -----------
 arch/x86/lib/tsc_timer.c                       | 107 ++++++++++
 arch/x86/lib/zimage.c                          |  11 +-
 common/board_r.c                               |   1 +
 common/bootstage.c                             |  44 ++++
 common/cmd_ximg.c                              |   2 +
 include/bootstage.h                            |  54 +++++
 include/configs/coreboot.h                     |  18 +-
 32 files changed, 314 insertions(+), 1216 deletions(-)
 delete mode 100644 arch/x86/cpu/timer.c
 delete mode 100644 arch/x86/include/asm/init_wrappers.h
 delete mode 100644 arch/x86/lib/bios.h
 delete mode 100644 arch/x86/lib/board.c
 delete mode 100644 arch/x86/lib/init_wrappers.c
 delete mode 100644 arch/x86/lib/pci.c
 delete mode 100644 arch/x86/lib/timer.c
 create mode 100644 arch/x86/lib/tsc_timer.c
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH 1/19 x86: Remove unused bios/pci code

Graeme Russ pointed out that this code is no longer used. Remove it.

---
 arch/x86/include/asm/pci.h |   4 -
 arch/x86/lib/Makefile      |   1 -
 arch/x86/lib/bios.h        | 170 ----------------------------------------
 arch/x86/lib/pci.c         | 188 ---------------------------------------------
 4 files changed, 363 deletions(-)
 delete mode 100644 arch/x86/lib/bios.h
 delete mode 100644 arch/x86/lib/pci.c
arch/x86/include/asm/pci.h +0 -4
index 6d68ab6..9cc2034 100644
@@ -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
arch/x86/lib/Makefile +0 -1
index ee89354..9c6b621 100644
@@ -37,7 +37,6 @@ 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_PCI) += pci_type1.o
 COBJS-y	+= relocate.o
 COBJS-y += physmem.o
arch/x86/lib/bios.h deleted +0 -170

170 lines not on this page · raw message

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

188 lines not on this page · raw message

Signature · 1 line
1.8.2.1
#2 lore raw

PATCH 1/19 x86: Remove unused bios/pci code

Hi Simon,

Quoted 9 lines · Simon Glass

Graeme Russ pointed out that this code is no longer used. Remove it.

---
 arch/x86/include/asm/pci.h |   4 -
 arch/x86/lib/Makefile      |   1 -
 arch/x86/lib/bios.h        | 170 ----------------------------------------
 arch/x86/lib/pci.c         | 188

---------------------------------------------

Quoted 4 lines
 4 files changed, 363 deletions(-)
 delete mode 100644 arch/x86/lib/bios.h
 delete mode 100644 arch/x86/lib/pci.c

[snip]

#3 lore raw

PATCH 2/19 x86: Remove unused portion of link script

In reply to Simon Glass

Since we don't have real-mode code now, we can remove this chunk of the link script.

---
 arch/x86/cpu/u-boot.lds | 12 ------------
 1 file changed, 12 deletions(-)
arch/x86/cpu/u-boot.lds +0 -12
index 2d6911a..b4ecd4b 100644
@@ -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
 
 	/*
Signature · 1 line
1.8.2.1
#4 lore raw

PATCH 2/19 x86: Remove unused portion of link script

Hi Simon,

Quoted 2 lines · Simon Glass

Since we don't have real-mode code now, we can remove this chunk of the

link

Quoted 12 lines

script.

---
 arch/x86/cpu/u-boot.lds | 12 ------------
 1 file changed, 12 deletions(-)
arch/x86/cpu/u-boot.lds +0 -0
index 2d6911a..b4ecd4b 100644

arch/x86/cpu/u-boot.lds SECTIONS · line 83

Quoted 5 lines
arch/x86/cpu/u-boot.lds +0 -2
@@ -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)) }

arch/x86/cpu/u-boot.lds SECTIONS

Quoted 6 lines
arch/x86/cpu/u-boot.lds +0 -6
-
-       __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)) }

Quoted 10 lines
arch/x86/cpu/u-boot.lds +0 -5
-
-       __bios_start = LOADADDR(.bios);
-       __bios_size = SIZEOF(.bios);
-
 #ifdef CONFIG_X86_RESET_VECTOR
 
        /*
--

1.8.2.1

#5 lore raw

PATCH 3/19 x86: Remove legacy board init code

In reply to Simon Glass

Since we use CONFIG_SYS_GENERIC_BOARD on x86, we don't need this anymore.

---
 arch/x86/include/asm/init_helpers.h  |   9 --
 arch/x86/include/asm/init_wrappers.h |  42 ------
 arch/x86/include/asm/u-boot.h        |  32 ----
 arch/x86/lib/Makefile                |   5 -
 arch/x86/lib/board.c                 | 273 -----------------------------------
 arch/x86/lib/init_helpers.c          |  98 -------------
 arch/x86/lib/init_wrappers.c         | 164 ---------------------
 7 files changed, 623 deletions(-)
 delete mode 100644 arch/x86/include/asm/init_wrappers.h
 delete mode 100644 arch/x86/lib/board.c
 delete mode 100644 arch/x86/lib/init_wrappers.c
arch/x86/include/asm/init_helpers.h +0 -9
index d018b29..0a6a675 100644
@@ -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);
arch/x86/include/asm/init_wrappers.h deleted +0 -42

42 lines not on this page · raw message

arch/x86/include/asm/u-boot.h +0 -32
index df759fa..006232b 100644
@@ -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
arch/x86/lib/Makefile +0 -5
index 9c6b621..962593d 100644
@@ -25,15 +25,10 @@ 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
arch/x86/lib/board.c deleted +0 -273

273 lines not on this page · raw message

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

131 lines not on this page · raw message

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

164 lines not on this page · raw message

Signature · 1 line
1.8.2.1
#6 lore raw

PATCH 3/19 x86: Remove legacy board init code

Hi Simon

Quoted 10 lines · Simon Glass

Since we use CONFIG_SYS_GENERIC_BOARD on x86, we don't need this anymore.

---
 arch/x86/include/asm/init_helpers.h  |   9 --
 arch/x86/include/asm/init_wrappers.h |  42 ------
 arch/x86/include/asm/u-boot.h        |  32 ----
 arch/x86/lib/Makefile                |   5 -
 arch/x86/lib/board.c                 | 273

-----------------------------------

Quoted 6 lines
 arch/x86/lib/init_helpers.c          |  98 -------------
 arch/x86/lib/init_wrappers.c         | 164 ---------------------
 7 files changed, 623 deletions(-)
 delete mode 100644 arch/x86/include/asm/init_wrappers.h
 delete mode 100644 arch/x86/lib/board.c
 delete mode 100644 arch/x86/lib/init_wrappers.c
#7 lore raw

PATCH 4/19 x86: Declare global_data pointer when it is used

In reply to Simon Glass

Several files use the global_data pointer without declaring it. This works because the declaration is currently a NOP. But still it is better to fix this so that x86 lines up with other archs.

---
 arch/x86/cpu/interrupts.c | 2 ++
 arch/x86/lib/cmd_boot.c   | 2 ++
 arch/x86/lib/physmem.c    | 2 ++
 arch/x86/lib/relocate.c   | 2 ++
 arch/x86/lib/timer.c      | 2 ++
 5 files changed, 10 insertions(+)
arch/x86/cpu/interrupts.c +2 -0
index 6dc74e3..e733bcb 100644
@@ -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" \
arch/x86/lib/cmd_boot.c +2 -0
index a81a9a3..315be5a 100644
@@ -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[])
 {
arch/x86/lib/physmem.c +2 -0
index 18f0e62..59b3fe9 100644
@@ -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)
 
arch/x86/lib/relocate.c +2 -0
index f178db9..21982db 100644
@@ -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;
arch/x86/lib/timer.c +2 -0
index 1f8ce60..fb11bfe 100644
@@ -30,6 +30,8 @@
 #include <asm/i8254.h>
 #include <asm/ibmpc.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 struct timer_isr_function {
 	struct timer_isr_function *next;
 	timer_fnc_t *isr_func;
Signature · 1 line
1.8.2.1
#8 lore raw

PATCH 5/19 x86: Implement panic output for coreboot

In reply to Simon Glass

panic_puts() can be called in early boot to display a message. It might help with early debugging.

---
 arch/x86/cpu/coreboot/coreboot.c  | 10 ++++++++++
 arch/x86/include/asm/u-boot-x86.h |  1 +
 2 files changed, 11 insertions(+)
arch/x86/cpu/coreboot/coreboot.c +10 -0
index f8e28f0..4a7dae49 100644
@@ -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>
@@ -135,3 +136,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++);
+}
arch/x86/include/asm/u-boot-x86.h +1 -0
index ae0c388..5a59db6 100644
@@ -33,6 +33,7 @@ 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 *);
Signature · 1 line
1.8.2.1
#9 lore raw

PATCH 6/19 x86: Rationalise kernel booting logic and bootstage

In reply to Simon Glass

The 'Starting linux' message appears twice in the code, but both call through the same place. Unify these and add calls to bootstage to mark the occasion.

---
 arch/x86/cpu/cpu.c    |  5 +++++
 arch/x86/lib/bootm.c  |  8 --------
 arch/x86/lib/zimage.c | 11 +++++++----
 3 files changed, 12 insertions(+), 12 deletions(-)
arch/x86/cpu/cpu.c +5 -0
index 1a2f85c..7a914a5 100644
@@ -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;
 }
 
arch/x86/lib/bootm.c +0 -8
index 83caf6b..2520228 100644
@@ -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 */
 
arch/x86/lib/zimage.c +7 -4
index 4e9e1f7..b54cf12 100644
@@ -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 */
Signature · 1 line
1.8.2.1
#10 lore raw

PATCH 6/19 x86: Rationalise kernel booting logic and bootstage

Hi Simon,

arch/x86/lib/bootm.c int do_bootm_linux(int flag, int argc, char * const

Quoted 34 lines · Simon Glass

The 'Starting linux' message appears twice in the code, but both call through the same place. Unify these and add calls to bootstage to mark the occasion.

---
 arch/x86/cpu/cpu.c    |  5 +++++
 arch/x86/lib/bootm.c  |  8 --------
 arch/x86/lib/zimage.c | 11 +++++++----
 3 files changed, 12 insertions(+), 12 deletions(-)
arch/x86/cpu/cpu.c +5 -0
index 1a2f85c..7a914a5 100644
@@ -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;
 }
 
arch/x86/lib/bootm.c +0 -0
index 83caf6b..2520228 100644
@@ -93,14 +93,6 @@ int do_bootm_linux(int flag, int argc, char * const

argv[],

arch/x86/lib/zimage.c int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc,

Quoted 33 lines
arch/x86/lib/bootm.c +0 -8
                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 */
 
arch/x86/lib/zimage.c +7 -0
index 4e9e1f7..b54cf12 100644
@@ -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[])

Quoted 11 lines
arch/x86/lib/zimage.c +0 -5
                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 */
--
Quoted 2 lines

1.8.2.1

#11 lore raw

PATCH 7/19 x86: Add TSC timer

In reply to Simon Glass

This timer runs at a rate that can be calculated, well over 100MHz. It is ideal for accurate timing and does not need interrupt servicing.

Tidy up some old broken and unneeded implementations at the same time.

To provide a consistent view of boot time, we use the same time base as coreboot. Use the base timestamp supplied by coreboot as U-Boot's base time.

---
 arch/x86/cpu/coreboot/timestamp.c |   4 +-
 arch/x86/cpu/timer.c              |   3 ++
 arch/x86/include/asm/u-boot-x86.h |   2 +
 arch/x86/lib/Makefile             |   1 +
 arch/x86/lib/tsc_timer.c          | 103 ++++++++++++++++++++++++++++++++++++++
 include/configs/coreboot.h        |   4 +-
 6 files changed, 113 insertions(+), 4 deletions(-)
 create mode 100644 arch/x86/lib/tsc_timer.c
arch/x86/cpu/coreboot/timestamp.c +3 -1
index 2ca7a57..d26718e 100644
@@ -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);
 }
 
arch/x86/cpu/timer.c +3 -0
index 149109d..f95fce5 100644
@@ -10,8 +10,11 @@
 
 #include <common.h>
 
+/* Temporary patch to maintain bisectability, removed in next commit */
+#ifndef CONFIG_SYS_X86_TSC_TIMER
 unsigned long timer_get_us(void)
 {
 	printf("timer_get_us used but not implemented.\n");
 	return 0;
 }
+#endif
arch/x86/include/asm/u-boot-x86.h +2 -0
index 5a59db6..bec583f 100644
@@ -39,6 +39,8 @@ void panic_puts(const char *str);
 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);
 
 /* Architecture specific - can be in arch/x86/cpu/, arch/x86/lib/, or $(BOARD)/ */
 int dram_init_f(void);
arch/x86/lib/Makefile +1 -0
index 962593d..0bc8c2f 100644
@@ -37,6 +37,7 @@ 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
 
arch/x86/lib/tsc_timer.c new file +103 -0

103 lines not on this page · raw message

include/configs/coreboot.h +1 -3
index 5bacc77..99408dc 100644
@@ -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
@@ -218,7 +217,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,7 +233,7 @@
  * CPU Features
  */
 
-#define CONFIG_SYS_GENERIC_TIMER
+#define CONFIG_SYS_X86_TSC_TIMER
 #define CONFIG_SYS_PCAT_INTERRUPTS
 #define CONFIG_SYS_NUM_IRQS			16
 
Signature · 1 line
1.8.2.1
#12 lore raw

PATCH 7/19 x86: Add TSC timer

Hi Simon,

Quoted 10 lines · Simon Glass

This timer runs at a rate that can be calculated, well over 100MHz. It is ideal for accurate timing and does not need interrupt servicing.

Tidy up some old broken and unneeded implementations at the same time.

To provide a consistent view of boot time, we use the same time base as coreboot. Use the base timestamp supplied by coreboot as U-Boot's base time.

Quoted 8 lines
---
 arch/x86/cpu/coreboot/timestamp.c |   4 +-
 arch/x86/cpu/timer.c              |   3 ++
 arch/x86/include/asm/u-boot-x86.h |   2 +
 arch/x86/lib/Makefile             |   1 +
 arch/x86/lib/tsc_timer.c          | 103

++++++++++++++++++++++++++++++++++++++

Review

Quoted 5 lines
 include/configs/coreboot.h        |   4 +-
 6 files changed, 113 insertions(+), 4 deletions(-)
 create mode 100644 arch/x86/lib/tsc_timer.c
(quoted diff) +0 -0

b/arch/x86/cpu/coreboot/timestamp.c

arch/x86/cpu/coreboot/timestamp.c static struct timestamp_table *ts_table

Quoted 4 lines

index 2ca7a57..d26718e 100644

arch/x86/cpu/coreboot/timestamp.c +0 -0
@@ -39,7 +39,9 @@ static struct timestamp_table *ts_table

__attribute__((section(".data")));

Quoted 16 lines
arch/x86/cpu/coreboot/timestamp.c +3 -1
 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);
 }
 
arch/x86/cpu/timer.c +0 -0
index 149109d..f95fce5 100644
@@ -10,8 +10,11 @@
 

arch/x86/cpu/timer.c line 20

Quoted 10 lines
arch/x86/cpu/timer.c +3 -0
 #include <common.h>
 
+/* Temporary patch to maintain bisectability, removed in next commit */
+#ifndef CONFIG_SYS_X86_TSC_TIMER
 unsigned long timer_get_us(void)
 {
        printf("timer_get_us used but not implemented.\n");
        return 0;
 }
+#endif

Why bother? Why not just one commit 'Replace timer implementation with TSC Timer'?

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/x86/include/asm/u-boot-x86.h

arch/x86/include/asm/u-boot-x86.h void panic_puts(const char *str); · line 45

Quoted 11 lines

index 5a59db6..bec583f 100644

arch/x86/include/asm/u-boot-x86.h +2 -0
@@ -39,6 +39,8 @@ void panic_puts(const char *str);
 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);
 
 /* Architecture specific - can be in arch/x86/cpu/, arch/x86/lib/, or

$(BOARD)/ */

Quoted 45 lines
arch/x86/include/asm/u-boot-x86.h +0 -0
 int dram_init_f(void);
arch/x86/lib/Makefile +1 -0
index 962593d..0bc8c2f 100644
@@ -37,6 +37,7 @@ 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
 
arch/x86/lib/tsc_timer.c new file +26 -0
new file mode 100644
index 0000000..d931e5f
@@ -0,0 +1,103 @@
+/*
+ * 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>

arch/x86/lib/tsc_timer.c line 36

Quoted 10 lines
arch/x86/lib/tsc_timer.c new file +10 -0
+
+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

arch/x86/lib/tsc_timer.c line 37

Quoted 1 line
arch/x86/lib/tsc_timer.c new file +1 -0
+ * restart. This yields a free running counter guaranteed to take almost

6

Quoted 71 lines
arch/x86/lib/tsc_timer.c new file +66 -0
+ * 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)
+{
+       /* Nothing to do here - the timer needs no init */
+       return 0;
+}
include/configs/coreboot.h +0 -0
index 5bacc77..99408dc 100644

include/configs/coreboot.h line 41

Quoted 4 lines
include/configs/coreboot.h +0 -1
@@ -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.

*/

Why this?

Quoted 21 lines
include/configs/coreboot.h +1 -3
 #define CONFIG_ZBOOT_32
 #define CONFIG_PHYSMEM
 #define CONFIG_SYS_EARLY_PCI_INIT
@@ -218,7 +217,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,7 +233,7 @@
  * CPU Features
  */
 
-#define CONFIG_SYS_GENERIC_TIMER
+#define CONFIG_SYS_X86_TSC_TIMER
 #define CONFIG_SYS_PCAT_INTERRUPTS
 #define CONFIG_SYS_NUM_IRQS                    16
 
--
Quoted 2 lines

1.8.2.1

Regards,

Graeme

#13 lore raw

PATCH 7/19 x86: Add TSC timer

Hi Graeme,

Quoted 53 lines · Graeme Russ

Hi Simon,

Quoted 48 lines · Simon Glass

This timer runs at a rate that can be calculated, well over 100MHz. It is ideal for accurate timing and does not need interrupt servicing.

Tidy up some old broken and unneeded implementations at the same time.

To provide a consistent view of boot time, we use the same time base as coreboot. Use the base timestamp supplied by coreboot as U-Boot's base time.

---
 arch/x86/cpu/coreboot/timestamp.c |   4 +-
 arch/x86/cpu/timer.c              |   3 ++
 arch/x86/include/asm/u-boot-x86.h |   2 +
 arch/x86/lib/Makefile             |   1 +
 arch/x86/lib/tsc_timer.c          | 103
++++++++++++++++++++++++++++++++++++++
 include/configs/coreboot.h        |   4 +-
 6 files changed, 113 insertions(+), 4 deletions(-)
 create mode 100644 arch/x86/lib/tsc_timer.c
arch/x86/cpu/coreboot/timestamp.c +3 -1
index 2ca7a57..d26718e 100644
@@ -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);
 }
arch/x86/cpu/timer.c +0 -0
index 149109d..f95fce5 100644
@@ -10,8 +10,11 @@
 
 #include <common.h>
 
Quoted 11 lines

arch/x86/cpu/timer.c line 20

Quoted 8 lines
arch/x86/cpu/timer.c +3 -0
+/* Temporary patch to maintain bisectability, removed in next commit */
+#ifndef CONFIG_SYS_X86_TSC_TIMER
 unsigned long timer_get_us(void)
 {
        printf("timer_get_us used but not implemented.\n");
        return 0;
 }
+#endif

Why bother? Why not just one commit 'Replace timer implementation with TSC Timer'?

OK will do.

Quoted 143 lines
Quoted 143 lines
arch/x86/include/asm/u-boot-x86.h +2 -0
index 5a59db6..bec583f 100644
@@ -39,6 +39,8 @@ void panic_puts(const char *str);
 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);
 
 /* Architecture specific - can be in arch/x86/cpu/, arch/x86/lib/, or

$(BOARD)/ */
int dram_init_f(void);

arch/x86/lib/Makefile +1 -0
index 962593d..0bc8c2f 100644
@@ -37,6 +37,7 @@ 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
 
arch/x86/lib/tsc_timer.c new file +36 -0
new file mode 100644
index 0000000..d931e5f
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */

arch/x86/lib/tsc_timer.c new file +64 -0
+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)
+{
+       /* Nothing to do here - the timer needs no init */
+       return 0;
+}
include/configs/coreboot.h +0 -0
index 5bacc77..99408dc 100644
Quoted 8 lines

include/configs/coreboot.h line 41

Quoted 6 lines
include/configs/coreboot.h +0 -1
@@ -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.
 */

Why this?

We don't need the code that is enabled by this CONFIG, and we don't need the CONFIG. I will squash this in also.

Regards,
Simon

#14 lore raw

PATCH 8/19 x86: Remove old broken timer implementation

In reply to Simon Glass

Tidy up some old broken and unneeded implementations. These are not used by coreboot or anything else now.

---
 arch/x86/cpu/Makefile |  2 +-
 arch/x86/cpu/timer.c  | 20 --------------------
 2 files changed, 1 insertion(+), 21 deletions(-)
 delete mode 100644 arch/x86/cpu/timer.c
arch/x86/cpu/Makefile +1 -1
index 7b520f8..cddf0dd 100644
@@ -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))
arch/x86/cpu/timer.c deleted +0 -20
deleted file mode 100644
index f95fce5..0000000
@@ -1,20 +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>
-
-/* Temporary patch to maintain bisectability, removed in next commit */
-#ifndef CONFIG_SYS_X86_TSC_TIMER
-unsigned long timer_get_us(void)
-{
-	printf("timer_get_us used but not implemented.\n");
-	return 0;
-}
-#endif
Signature · 1 line
1.8.2.1
#15 lore raw

PATCH 8/19 x86: Remove old broken timer implementation

Hi Simon,

Quoted 54 lines · Simon Glass

Tidy up some old broken and unneeded implementations. These are not used by coreboot or anything else now.

---
 arch/x86/cpu/Makefile |  2 +-
 arch/x86/cpu/timer.c  | 20 --------------------
 2 files changed, 1 insertion(+), 21 deletions(-)
 delete mode 100644 arch/x86/cpu/timer.c
arch/x86/cpu/Makefile +1 -1
index 7b520f8..cddf0dd 100644
@@ -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))
arch/x86/cpu/timer.c deleted +0 -21
deleted file mode 100644
index f95fce5..0000000
@@ -1,20 +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>
-
-/* Temporary patch to maintain bisectability, removed in next commit */
-#ifndef CONFIG_SYS_X86_TSC_TIMER
-unsigned long timer_get_us(void)
-{
-       printf("timer_get_us used but not implemented.\n");
-       return 0;
-}
-#endif
--
Quoted 2 lines

1.8.2.1

#16 lore raw

PATCH 9/19 x86: Remove ISR timer

In reply to Simon Glass

This is no longer used since we prefer the more accurate TSC timer, so remove the dead code.

---
 arch/x86/lib/Makefile |   1 -
 arch/x86/lib/timer.c  | 118 --------------------------------------------------
 2 files changed, 119 deletions(-)
 delete mode 100644 arch/x86/lib/timer.c
arch/x86/lib/Makefile +0 -1
index 0bc8c2f..c614479 100644
@@ -36,7 +36,6 @@ 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
arch/x86/lib/timer.c deleted +0 -118

118 lines not on this page · raw message

Signature · 1 line
1.8.2.1
#17 lore raw

PATCH 9/19 x86: Remove ISR timer

Hi Simon,

Quoted 8 lines · Simon Glass

This is no longer used since we prefer the more accurate TSC timer, so remove the dead code.

---
 arch/x86/lib/Makefile |   1 -
 arch/x86/lib/timer.c  | 118

--------------------------------------------------

Quoted 140 lines
 2 files changed, 119 deletions(-)
 delete mode 100644 arch/x86/lib/timer.c
arch/x86/lib/Makefile +0 -1
index 0bc8c2f..c614479 100644
@@ -36,7 +36,6 @@ 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
arch/x86/lib/timer.c deleted +0 -119
deleted file mode 100644
index fb11bfe..0000000
@@ -1,118 +0,0 @@
-/*
- * (C) Copyright 2008,2009
- * Graeme Russ, <[email protected]>
- *
- * (C) Copyright 2002
- * Daniel Engstr?m, Omicron Ceti AB, <[email protected]>
- *
- * 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>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-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;
-}
--
Quoted 2 lines

1.8.2.1

#18 lore raw

PATCH 10/19 x86: Re-enable PCAT timer 2 for beeping

In reply to Simon Glass

While we don't want PCAT timers for timing, we want timer 2 so that we can still make a beep. Re-purpose the PCAT driver for this, and enable it in coreboot.

---
 arch/x86/include/asm/u-boot-x86.h |  1 +
 arch/x86/lib/Makefile             |  2 +-
 arch/x86/lib/pcat_timer.c         | 69 ++-------------------------------------
 arch/x86/lib/tsc_timer.c          |  6 +++-
 include/configs/coreboot.h        |  1 +
 5 files changed, 11 insertions(+), 68 deletions(-)
arch/x86/include/asm/u-boot-x86.h +1 -0
index bec583f..22e0934 100644
@@ -41,6 +41,7 @@ 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);
arch/x86/lib/Makefile +1 -1
index c614479..f66ad30 100644
@@ -31,7 +31,7 @@ COBJS-y	+= gcc.o
 COBJS-y	+= init_helpers.o
 COBJS-y	+= interrupts.o
 COBJS-$(CONFIG_SYS_PCAT_INTERRUPTS) += pcat_interrupts.o
-COBJS-$(CONFIG_SYS_GENERIC_TIMER) += pcat_timer.o
+COBJS-$(CONFIG_SYS_PCAT_TIMER) += pcat_timer.o
 COBJS-$(CONFIG_PCI) += pci_type1.o
 COBJS-y	+= relocate.o
 COBJS-y += physmem.o
arch/x86/lib/pcat_timer.c +3 -66

86 lines not on this page · raw message

arch/x86/lib/tsc_timer.c +5 -1
index d931e5f..c509801 100644
@@ -98,6 +98,10 @@ void __udelay(unsigned long usec)
 
 int timer_init(void)
 {
-	/* Nothing to do here - the timer needs no init */
+#ifdef CONFIG_SYS_PCAT_TIMER
+	/* Set up the PCAT timer if required */
+	pcat_timer_init();
+#endif
+
 	return 0;
 }
include/configs/coreboot.h +1 -0
index 99408dc..7953ec6 100644
@@ -235,6 +235,7 @@
 
 #define CONFIG_SYS_X86_TSC_TIMER
 #define CONFIG_SYS_PCAT_INTERRUPTS
+#define CONFIG_SYS_PCAT_TIMER
 #define CONFIG_SYS_NUM_IRQS			16
 
 /*-----------------------------------------------------------------------
Signature · 1 line
1.8.2.1
#19 lore raw

PATCH 10/19 x86: Re-enable PCAT timer 2 for beeping

Hi Simon,

Quoted 10 lines · Simon Glass

While we don't want PCAT timers for timing, we want timer 2 so that we can still make a beep. Re-purpose the PCAT driver for this, and enable it in coreboot.

---
 arch/x86/include/asm/u-boot-x86.h |  1 +
 arch/x86/lib/Makefile             |  2 +-
 arch/x86/lib/pcat_timer.c         | 69

++-------------------------------------

Quoted 3 lines
 arch/x86/lib/tsc_timer.c          |  6 +++-
 include/configs/coreboot.h        |  1 +
 5 files changed, 11 insertions(+), 68 deletions(-)

[snip]

Quoted 24 lines
arch/x86/lib/pcat_timer.c +0 -24
-/* 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)

arch/x86/lib/pcat_timer.c line 106

Quoted 10 lines
arch/x86/lib/pcat_timer.c +0 -10
-                               break;
-
-                       if (new_count > counter)
-                               wraps--;
-
-                       counter = new_count;
-               }
-       }
-
-}

This does not seem related...

Regards,

Graeme

#20 lore raw

PATCH 10/19 x86: Re-enable PCAT timer 2 for beeping

Hi Graeme,

Quoted 49 lines · Graeme Russ

Hi Simon,

Quoted 14 lines · Simon Glass

While we don't want PCAT timers for timing, we want timer 2 so that we can still make a beep. Re-purpose the PCAT driver for this, and enable it in coreboot.

---
 arch/x86/include/asm/u-boot-x86.h |  1 +
 arch/x86/lib/Makefile             |  2 +-
 arch/x86/lib/pcat_timer.c         | 69
++-------------------------------------
 arch/x86/lib/tsc_timer.c          |  6 +++-
 include/configs/coreboot.h        |  1 +
 5 files changed, 11 insertions(+), 68 deletions(-)

[snip]

Quoted 28 lines
arch/x86/lib/pcat_timer.c +0 -28
-/* 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--;
Quoted 8 lines

arch/x86/lib/pcat_timer.c line 106

Quoted 6 lines
arch/x86/lib/pcat_timer.c +0 -6
-
-                       counter = new_count;
-               }
-       }
-
-}

This does not seem related...

It really should be in a clean-up patch. But now that I am squashing them, I will just add it to the squashed patch.

Regards,
Simon

#21 lore raw

PATCH 11/19 bootstage: Add stubs for new bootstage functions

In reply to Simon Glass

Some functions don't have a stub for when CONFIG_BOOTSTAGE is not defined. Add one to avoid #ifdefs in the code when this is used in U-Boot.

---
 include/bootstage.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
include/bootstage.h +16 -0
index 3b2216b..bdda768 100644
@@ -315,6 +315,12 @@ 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
@@ -337,6 +343,16 @@ static inline ulong bootstage_mark_name(enum bootstage_id id, const char *name)
 	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 */
Signature · 1 line
1.8.2.1
#22 lore raw

PATCH 12/19 bootstage: Copy bootstage strings post-relocation

In reply to Simon Glass

From: Doug Anderson <[email protected]>

Any pointers to name strings that were passed to bootstage_mark_name() pre-relocation should be copied post-relocation so that they don't get trashed as the original location of U-Boot is re-used for other purposes.

This change introduces a new API call that should be called from board_init_r() after malloc has been initted on any board that uses bootstage.

---
 common/bootstage.c  | 15 +++++++++++++++
 include/bootstage.h | 15 +++++++++++++++
 2 files changed, 30 insertions(+)
common/bootstage.c +15 -0
index a1e0939..15afa24 100644
@@ -56,6 +56,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)
 {
include/bootstage.h +15 -0
index bdda768..c8235e8 100644
@@ -237,6 +237,16 @@ void show_boot_progress(int val);
 /* 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
  *
  * @param id	Bootstage ID to use (ignored if flags & BOOTSTAGEF_ALLOC)
@@ -326,6 +336,11 @@ static inline ulong bootstage_add_record(enum bootstage_id id,
  * 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);
Signature · 1 line
1.8.2.1
#23 lore raw

PATCH 13/19 Call bootstage_relocate() after malloc is initted

In reply to Simon Glass

From: Doug Anderson <[email protected]>

In a previous CL we added the bootstage_relocate(), which should be called after malloc is initted. Now we call it on generic board.

---
 common/board_r.c | 1 +
 1 file changed, 1 insertion(+)
common/board_r.c +1 -0
index 2b17fa6..a364ef24 100644
@@ -761,6 +761,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
Signature · 1 line
1.8.2.1
#24 lore raw

PATCH 14/19 x86: Enable bootstage for coreboot

In reply to Simon Glass

This is a convenient way of finding out where boottime is going. Enable it for coreboot.

---
 include/configs/coreboot.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/configs/coreboot.h +9 -0
index 7953ec6..743fb95 100644
@@ -48,6 +48,15 @@
 #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
+
 /*-----------------------------------------------------------------------
  * Watchdog Configuration
  */
Signature · 1 line
1.8.2.1
#25 lore raw

PATCH 15/19 bootstage: Allow marking a particular line of code

In reply to Simon Glass

Add a function which allows a (file, function, line number) to be marked in bootstage.

---
 common/bootstage.c  | 29 +++++++++++++++++++++++++++++
 include/bootstage.h | 23 +++++++++++++++++++++++
 2 files changed, 52 insertions(+)
common/bootstage.c +29 -0
index 15afa24..c5c6996 100644
@@ -30,6 +30,8 @@
 
 #include <common.h>
 #include <libfdt.h>
+#include <malloc.h>
+#include <linux/compiler.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -117,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];
include/bootstage.h +23 -0
index c8235e8..0f44e71 100644
@@ -267,6 +267,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
  * this function turns the given id into a accumulator rather than and
@@ -358,6 +371,12 @@ 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;
@@ -379,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
Signature · 1 line
1.8.2.1
#26 lore raw

PATCH 16/19 x86: Fix warning in cmd_ximg.c when CONFIG_GZIP is not defined

In reply to Simon Glass

This local variable is not used unless CONFIG_GZIP is defined. Fix it.

---
 common/cmd_ximg.c | 2 ++
 1 file changed, 2 insertions(+)
common/cmd_ximg.c +2 -0
index ea0a26e..02084b0 100644
@@ -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");
Signature · 1 line
1.8.2.1
#27 lore raw

PATCH 17/19 x86: config: Enable LZO for coreboot, remove zlib, gzip

In reply to Simon Glass

We don't use zlib and gzip but do use lzo, so enable this.

---
 include/configs/coreboot.h | 4 ++++
 1 file changed, 4 insertions(+)
include/configs/coreboot.h +4 -0
index 743fb95..be04a75 100644
@@ -57,6 +57,10 @@
 #define CONFIG_BOOTSTAGE_STASH_SIZE	0x7fc
 #define CONFIG_BOOTSTAGE_USER_COUNT	60
 
+#define CONFIG_LZO
+#undef CONFIG_ZLIB
+#undef CONFIG_GZIP
+
 /*-----------------------------------------------------------------------
  * Watchdog Configuration
  */
Signature · 1 line
1.8.2.1
#28 lore raw

PATCH 18/19 x86: Support adding coreboot timestanps to bootstage

In reply to Simon Glass

Coreboot provides a lot of useful timing information. Provide a facility to add this to bootstage on start-up.

---
 arch/x86/cpu/coreboot/timestamp.c              | 38 ++++++++++++++++++++++++++
 arch/x86/include/asm/arch-coreboot/timestamp.h |  7 +++++
 2 files changed, 45 insertions(+)
arch/x86/cpu/coreboot/timestamp.c +38 -0
index d26718e..bd3558a 100644
@@ -61,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;
+}
arch/x86/include/asm/arch-coreboot/timestamp.h +7 -0
index d104912..fcfc1d5 100644
@@ -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
Signature · 1 line
1.8.2.1
#29 lore raw

PATCH 19/19 x86: Add coreboot timestamps

In reply to Simon Glass

Add selected coreboot timestamps into bootstage to get a unified view of the boot timings.

---
 arch/x86/cpu/coreboot/coreboot.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/cpu/coreboot/coreboot.c +3 -0
index 4a7dae49..14cb699 100644
@@ -91,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;
 }
 
Signature · 1 line
1.8.2.1
#30 lore raw

cover Remove unused code, add accurate timier and bootstage

In reply to Simon Glass
Quoted 73 lines · Simon Glass

This series removes unused x86 code based on advice from Graeme Russ. THis code was used for real mode which is no longer needed in U-Boot.

A new more accurate timer is added, and this permits bootstage to be enabled and produce useful results on x86.

Doug Anderson (2):
bootstage: Copy bootstage strings post-relocation Call bootstage_relocate() after malloc is initted

Simon Glass (17):
x86: Remove unused bios/pci code
x86: Remove unused portion of link script
x86: Remove legacy board init code
x86: Declare global_data pointer when it is used
x86: Implement panic output for coreboot
x86: Rationalise kernel booting logic and bootstage
x86: Add TSC timer
x86: Remove old broken timer implementation
x86: Remove ISR timer
x86: Re-enable PCAT timer 2 for beeping
bootstage: Add stubs for new bootstage functions
x86: Enable bootstage for coreboot
bootstage: Allow marking a particular line of code
x86: Fix warning in cmd_ximg.c when CONFIG_GZIP is not defined
x86: config: Enable LZO for coreboot, remove zlib, gzip
x86: Support adding coreboot timestanps to bootstage
x86: Add coreboot timestamps

 arch/x86/cpu/Makefile                          |   2 +-
 arch/x86/cpu/coreboot/coreboot.c               |  13 ++
 arch/x86/cpu/coreboot/timestamp.c              |  42 +++-
 arch/x86/cpu/cpu.c                             |   5 +
 arch/x86/cpu/interrupts.c                      |   2 +
 arch/x86/cpu/timer.c                           |  17 --
 arch/x86/cpu/u-boot.lds                        |  12 --
 arch/x86/include/asm/arch-coreboot/timestamp.h |   7 +
 arch/x86/include/asm/init_helpers.h            |   9 -
 arch/x86/include/asm/init_wrappers.h           |  42 ----
 arch/x86/include/asm/pci.h                     |   4 -
 arch/x86/include/asm/u-boot-x86.h              |   4 +
 arch/x86/include/asm/u-boot.h                  |  32 ---
 arch/x86/lib/Makefile                          |  10 +-
 arch/x86/lib/bios.h                            | 170 ---------------
 arch/x86/lib/board.c                           | 273 -------------------------
 arch/x86/lib/bootm.c                           |   8 -
 arch/x86/lib/cmd_boot.c                        |   2 +
 arch/x86/lib/init_helpers.c                    |  98 ---------
 arch/x86/lib/init_wrappers.c                   | 164 ---------------
 arch/x86/lib/pcat_timer.c                      |  69 +------
 arch/x86/lib/pci.c                             | 188 -----------------
 arch/x86/lib/physmem.c                         |   2 +
 arch/x86/lib/relocate.c                        |   2 +
 arch/x86/lib/timer.c                           | 116 -----------
 arch/x86/lib/tsc_timer.c                       | 107 ++++++++++
 arch/x86/lib/zimage.c                          |  11 +-
 common/board_r.c                               |   1 +
 common/bootstage.c                             |  44 ++++
 common/cmd_ximg.c                              |   2 +
 include/bootstage.h                            |  54 +++++
 include/configs/coreboot.h                     |  18 +-
 32 files changed, 314 insertions(+), 1216 deletions(-)
 delete mode 100644 arch/x86/cpu/timer.c
 delete mode 100644 arch/x86/include/asm/init_wrappers.h
 delete mode 100644 arch/x86/lib/bios.h
 delete mode 100644 arch/x86/lib/board.c
 delete mode 100644 arch/x86/lib/init_wrappers.c
 delete mode 100644 arch/x86/lib/pci.c
 delete mode 100644 arch/x86/lib/timer.c
 create mode 100644 arch/x86/lib/tsc_timer.c
Quoted 3 lines

--
1.8.2.1

Simon, just out of curiosity: how was this tested, on what platforms, what procedure was followed, etc.

--vb

#31 lore raw

cover Remove unused code, add accurate timier and bootstage

Hi Vadim,

Quoted 74 lines · Vadim Bendebury (??)
Quoted 73 lines · Simon Glass

This series removes unused x86 code based on advice from Graeme Russ. THis code was used for real mode which is no longer needed in U-Boot.

A new more accurate timer is added, and this permits bootstage to be enabled and produce useful results on x86.

Doug Anderson (2):
bootstage: Copy bootstage strings post-relocation Call bootstage_relocate() after malloc is initted

Simon Glass (17):
x86: Remove unused bios/pci code
x86: Remove unused portion of link script
x86: Remove legacy board init code
x86: Declare global_data pointer when it is used
x86: Implement panic output for coreboot
x86: Rationalise kernel booting logic and bootstage
x86: Add TSC timer
x86: Remove old broken timer implementation
x86: Remove ISR timer
x86: Re-enable PCAT timer 2 for beeping
bootstage: Add stubs for new bootstage functions
x86: Enable bootstage for coreboot
bootstage: Allow marking a particular line of code
x86: Fix warning in cmd_ximg.c when CONFIG_GZIP is not defined
x86: config: Enable LZO for coreboot, remove zlib, gzip
x86: Support adding coreboot timestanps to bootstage
x86: Add coreboot timestamps

 arch/x86/cpu/Makefile                          |   2 +-
 arch/x86/cpu/coreboot/coreboot.c               |  13 ++
 arch/x86/cpu/coreboot/timestamp.c              |  42 +++-
 arch/x86/cpu/cpu.c                             |   5 +
 arch/x86/cpu/interrupts.c                      |   2 +
 arch/x86/cpu/timer.c                           |  17 --
 arch/x86/cpu/u-boot.lds                        |  12 --
 arch/x86/include/asm/arch-coreboot/timestamp.h |   7 +
 arch/x86/include/asm/init_helpers.h            |   9 -
 arch/x86/include/asm/init_wrappers.h           |  42 ----
 arch/x86/include/asm/pci.h                     |   4 -
 arch/x86/include/asm/u-boot-x86.h              |   4 +
 arch/x86/include/asm/u-boot.h                  |  32 ---
 arch/x86/lib/Makefile                          |  10 +-
 arch/x86/lib/bios.h                            | 170 ---------------
 arch/x86/lib/board.c                           | 273 -------------------------
 arch/x86/lib/bootm.c                           |   8 -
 arch/x86/lib/cmd_boot.c                        |   2 +
 arch/x86/lib/init_helpers.c                    |  98 ---------
 arch/x86/lib/init_wrappers.c                   | 164 ---------------
 arch/x86/lib/pcat_timer.c                      |  69 +------
 arch/x86/lib/pci.c                             | 188 -----------------
 arch/x86/lib/physmem.c                         |   2 +
 arch/x86/lib/relocate.c                        |   2 +
 arch/x86/lib/timer.c                           | 116 -----------
 arch/x86/lib/tsc_timer.c                       | 107 ++++++++++
 arch/x86/lib/zimage.c                          |  11 +-
 common/board_r.c                               |   1 +
 common/bootstage.c                             |  44 ++++
 common/cmd_ximg.c                              |   2 +
 include/bootstage.h                            |  54 +++++
 include/configs/coreboot.h                     |  18 +-
 32 files changed, 314 insertions(+), 1216 deletions(-)
 delete mode 100644 arch/x86/cpu/timer.c
 delete mode 100644 arch/x86/include/asm/init_wrappers.h
 delete mode 100644 arch/x86/lib/bios.h
 delete mode 100644 arch/x86/lib/board.c
 delete mode 100644 arch/x86/lib/init_wrappers.c
 delete mode 100644 arch/x86/lib/pci.c
 delete mode 100644 arch/x86/lib/timer.c
 create mode 100644 arch/x86/lib/tsc_timer.c
Quoted 6 lines
Quoted 3 lines

--
1.8.2.1

Simon, just out of curiosity: how was this tested, on what platforms, what procedure was followed, etc.

I used the time command to test that the time seems about right, by timing for 10 seconds and comparing against a stopwatch:

boot > time sleep 10

time: 10.000 seconds, 10000 ticks

Also I obtained a bootstage report which looked fairly sane:

boot > bootstage report
Timer summary in microseconds:

       Mark    Elapsed  Stage
          0          0  reset
  1,028,998  1,028,998  board_init_f
  1,035,680      6,682  board_init_r
  1,092,769     57,089  id=64
  1,094,506      1,737  main_loop

Accumulated time:

All testing was done on link only.

Regards,
Simon

#32 lore raw

cover Remove unused code, add accurate timier and bootstage

Hi Tom,

Quoted 77 lines · Simon Glass

Hi Vadim,

Quoted 73 lines · Vadim Bendebury (??)
Quoted 72 lines · Simon Glass

This series removes unused x86 code based on advice from Graeme Russ. THis code was used for real mode which is no longer needed in U-Boot.

A new more accurate timer is added, and this permits bootstage to be enabled and produce useful results on x86.

Doug Anderson (2):
bootstage: Copy bootstage strings post-relocation Call bootstage_relocate() after malloc is initted

Simon Glass (17):
x86: Remove unused bios/pci code
x86: Remove unused portion of link script
x86: Remove legacy board init code
x86: Declare global_data pointer when it is used
x86: Implement panic output for coreboot
x86: Rationalise kernel booting logic and bootstage
x86: Add TSC timer
x86: Remove old broken timer implementation
x86: Remove ISR timer
x86: Re-enable PCAT timer 2 for beeping
bootstage: Add stubs for new bootstage functions
x86: Enable bootstage for coreboot
bootstage: Allow marking a particular line of code
x86: Fix warning in cmd_ximg.c when CONFIG_GZIP is not defined
x86: config: Enable LZO for coreboot, remove zlib, gzip
x86: Support adding coreboot timestanps to bootstage
x86: Add coreboot timestamps

 arch/x86/cpu/Makefile                          |   2 +-
 arch/x86/cpu/coreboot/coreboot.c               |  13 ++
 arch/x86/cpu/coreboot/timestamp.c              |  42 +++-
 arch/x86/cpu/cpu.c                             |   5 +
 arch/x86/cpu/interrupts.c                      |   2 +
 arch/x86/cpu/timer.c                           |  17 --
 arch/x86/cpu/u-boot.lds                        |  12 --
 arch/x86/include/asm/arch-coreboot/timestamp.h |   7 +
 arch/x86/include/asm/init_helpers.h            |   9 -
 arch/x86/include/asm/init_wrappers.h           |  42 ----
 arch/x86/include/asm/pci.h                     |   4 -
 arch/x86/include/asm/u-boot-x86.h              |   4 +
 arch/x86/include/asm/u-boot.h                  |  32 ---
 arch/x86/lib/Makefile                          |  10 +-
 arch/x86/lib/bios.h                            | 170 ---------------
 arch/x86/lib/board.c                           | 273 -------------------------
 arch/x86/lib/bootm.c                           |   8 -
 arch/x86/lib/cmd_boot.c                        |   2 +
 arch/x86/lib/init_helpers.c                    |  98 ---------
 arch/x86/lib/init_wrappers.c                   | 164 ---------------
 arch/x86/lib/pcat_timer.c                      |  69 +------
 arch/x86/lib/pci.c                             | 188 -----------------
 arch/x86/lib/physmem.c                         |   2 +
 arch/x86/lib/relocate.c                        |   2 +
 arch/x86/lib/timer.c                           | 116 -----------
 arch/x86/lib/tsc_timer.c                       | 107 ++++++++++
 arch/x86/lib/zimage.c                          |  11 +-
 common/board_r.c                               |   1 +
 common/bootstage.c                             |  44 ++++
 common/cmd_ximg.c                              |   2 +
 include/bootstage.h                            |  54 +++++
 include/configs/coreboot.h                     |  18 +-
 32 files changed, 314 insertions(+), 1216 deletions(-)
 delete mode 100644 arch/x86/cpu/timer.c
 delete mode 100644 arch/x86/include/asm/init_wrappers.h
 delete mode 100644 arch/x86/lib/bios.h
 delete mode 100644 arch/x86/lib/board.c
 delete mode 100644 arch/x86/lib/init_wrappers.c
 delete mode 100644 arch/x86/lib/pci.c
 delete mode 100644 arch/x86/lib/timer.c
 create mode 100644 arch/x86/lib/tsc_timer.c

Some of these patches touch bootstage which is generic code. Are you OK with me doing an x86 pull request for this, or should we do something else?

Regards,
Simon

#33 lore raw

cover Remove unused code, add accurate timier and bootstage

Quoted 81 lines · Simon Glass

Hi Tom,

Quoted 77 lines · Simon Glass

Hi Vadim,

Quoted 73 lines · Vadim Bendebury (????)
Quoted 72 lines · Simon Glass

This series removes unused x86 code based on advice from Graeme Russ. THis code was used for real mode which is no longer needed in U-Boot.

A new more accurate timer is added, and this permits bootstage to be enabled and produce useful results on x86.

Doug Anderson (2):
bootstage: Copy bootstage strings post-relocation Call bootstage_relocate() after malloc is initted

Simon Glass (17):
x86: Remove unused bios/pci code
x86: Remove unused portion of link script
x86: Remove legacy board init code
x86: Declare global_data pointer when it is used
x86: Implement panic output for coreboot
x86: Rationalise kernel booting logic and bootstage
x86: Add TSC timer
x86: Remove old broken timer implementation
x86: Remove ISR timer
x86: Re-enable PCAT timer 2 for beeping
bootstage: Add stubs for new bootstage functions
x86: Enable bootstage for coreboot
bootstage: Allow marking a particular line of code
x86: Fix warning in cmd_ximg.c when CONFIG_GZIP is not defined
x86: config: Enable LZO for coreboot, remove zlib, gzip
x86: Support adding coreboot timestanps to bootstage
x86: Add coreboot timestamps

 arch/x86/cpu/Makefile                          |   2 +-
 arch/x86/cpu/coreboot/coreboot.c               |  13 ++
 arch/x86/cpu/coreboot/timestamp.c              |  42 +++-
 arch/x86/cpu/cpu.c                             |   5 +
 arch/x86/cpu/interrupts.c                      |   2 +
 arch/x86/cpu/timer.c                           |  17 --
 arch/x86/cpu/u-boot.lds                        |  12 --
 arch/x86/include/asm/arch-coreboot/timestamp.h |   7 +
 arch/x86/include/asm/init_helpers.h            |   9 -
 arch/x86/include/asm/init_wrappers.h           |  42 ----
 arch/x86/include/asm/pci.h                     |   4 -
 arch/x86/include/asm/u-boot-x86.h              |   4 +
 arch/x86/include/asm/u-boot.h                  |  32 ---
 arch/x86/lib/Makefile                          |  10 +-
 arch/x86/lib/bios.h                            | 170 ---------------
 arch/x86/lib/board.c                           | 273 -------------------------
 arch/x86/lib/bootm.c                           |   8 -
 arch/x86/lib/cmd_boot.c                        |   2 +
 arch/x86/lib/init_helpers.c                    |  98 ---------
 arch/x86/lib/init_wrappers.c                   | 164 ---------------
 arch/x86/lib/pcat_timer.c                      |  69 +------
 arch/x86/lib/pci.c                             | 188 -----------------
 arch/x86/lib/physmem.c                         |   2 +
 arch/x86/lib/relocate.c                        |   2 +
 arch/x86/lib/timer.c                           | 116 -----------
 arch/x86/lib/tsc_timer.c                       | 107 ++++++++++
 arch/x86/lib/zimage.c                          |  11 +-
 common/board_r.c                               |   1 +
 common/bootstage.c                             |  44 ++++
 common/cmd_ximg.c                              |   2 +
 include/bootstage.h                            |  54 +++++
 include/configs/coreboot.h                     |  18 +-
 32 files changed, 314 insertions(+), 1216 deletions(-)
 delete mode 100644 arch/x86/cpu/timer.c
 delete mode 100644 arch/x86/include/asm/init_wrappers.h
 delete mode 100644 arch/x86/lib/bios.h
 delete mode 100644 arch/x86/lib/board.c
 delete mode 100644 arch/x86/lib/init_wrappers.c
 delete mode 100644 arch/x86/lib/pci.c
 delete mode 100644 arch/x86/lib/timer.c
 create mode 100644 arch/x86/lib/tsc_timer.c
Quoted 3 lines

Some of these patches touch bootstage which is generic code. Are you OK with me doing an x86 pull request for this, or should we do something else?

I'm OK with the x86 tree.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130513/c257357a/attachment.pgp>
#34 lore raw

cover Remove unused code, add accurate timier and bootstage

Hi Tom,

Quoted 83 lines · Tom Rini
Quoted 81 lines · Simon Glass

Hi Tom,

Quoted 77 lines · Simon Glass

Hi Vadim,

Quoted 73 lines · Vadim Bendebury (????)
Quoted 72 lines · Simon Glass

This series removes unused x86 code based on advice from Graeme Russ. THis code was used for real mode which is no longer needed in U-Boot.

A new more accurate timer is added, and this permits bootstage to be enabled and produce useful results on x86.

Doug Anderson (2):
bootstage: Copy bootstage strings post-relocation Call bootstage_relocate() after malloc is initted

Simon Glass (17):
x86: Remove unused bios/pci code
x86: Remove unused portion of link script
x86: Remove legacy board init code
x86: Declare global_data pointer when it is used
x86: Implement panic output for coreboot
x86: Rationalise kernel booting logic and bootstage
x86: Add TSC timer
x86: Remove old broken timer implementation
x86: Remove ISR timer
x86: Re-enable PCAT timer 2 for beeping
bootstage: Add stubs for new bootstage functions
x86: Enable bootstage for coreboot
bootstage: Allow marking a particular line of code
x86: Fix warning in cmd_ximg.c when CONFIG_GZIP is not defined
x86: config: Enable LZO for coreboot, remove zlib, gzip
x86: Support adding coreboot timestanps to bootstage
x86: Add coreboot timestamps

 arch/x86/cpu/Makefile                          |   2 +-
 arch/x86/cpu/coreboot/coreboot.c               |  13 ++
 arch/x86/cpu/coreboot/timestamp.c              |  42 +++-
 arch/x86/cpu/cpu.c                             |   5 +
 arch/x86/cpu/interrupts.c                      |   2 +
 arch/x86/cpu/timer.c                           |  17 --
 arch/x86/cpu/u-boot.lds                        |  12 --
 arch/x86/include/asm/arch-coreboot/timestamp.h |   7 +
 arch/x86/include/asm/init_helpers.h            |   9 -
 arch/x86/include/asm/init_wrappers.h           |  42 ----
 arch/x86/include/asm/pci.h                     |   4 -
 arch/x86/include/asm/u-boot-x86.h              |   4 +
 arch/x86/include/asm/u-boot.h                  |  32 ---
 arch/x86/lib/Makefile                          |  10 +-
 arch/x86/lib/bios.h                            | 170 ---------------
 arch/x86/lib/board.c                           | 273 -------------------------
 arch/x86/lib/bootm.c                           |   8 -
 arch/x86/lib/cmd_boot.c                        |   2 +
 arch/x86/lib/init_helpers.c                    |  98 ---------
 arch/x86/lib/init_wrappers.c                   | 164 ---------------
 arch/x86/lib/pcat_timer.c                      |  69 +------
 arch/x86/lib/pci.c                             | 188 -----------------
 arch/x86/lib/physmem.c                         |   2 +
 arch/x86/lib/relocate.c                        |   2 +
 arch/x86/lib/timer.c                           | 116 -----------
 arch/x86/lib/tsc_timer.c                       | 107 ++++++++++
 arch/x86/lib/zimage.c                          |  11 +-
 common/board_r.c                               |   1 +
 common/bootstage.c                             |  44 ++++
 common/cmd_ximg.c                              |   2 +
 include/bootstage.h                            |  54 +++++
 include/configs/coreboot.h                     |  18 +-
 32 files changed, 314 insertions(+), 1216 deletions(-)
 delete mode 100644 arch/x86/cpu/timer.c
 delete mode 100644 arch/x86/include/asm/init_wrappers.h
 delete mode 100644 arch/x86/lib/bios.h
 delete mode 100644 arch/x86/lib/board.c
 delete mode 100644 arch/x86/lib/init_wrappers.c
 delete mode 100644 arch/x86/lib/pci.c
 delete mode 100644 arch/x86/lib/timer.c
 create mode 100644 arch/x86/lib/tsc_timer.c
Quoted 5 lines
Quoted 3 lines

Some of these patches touch bootstage which is generic code. Are you OK with me doing an x86 pull request for this, or should we do something else?

I'm OK with the x86 tree.

OK, I will do a pull from x86/master then.

Regards,
Simon