[U-Boot] add nand spl boot for qi_lb60 board
Hi Scott Wood this is the patch I try to add nand spl boot for qi_lb60 board this patch works fine under qi_lb60(ben nanonote) but there are three 'extern' lines under: nand_spl/board/qi/qi_lb60/nand_spl.c those 'extern' lines already in jz4740.h, my question is when I remove those three lines under nand_spl/board/qi/qi_lb60/nand_spl.c, it will make u-boot-nand.bin break. can't boot the device anymore. Please give me some advice how to debug the error. thanks xiangfu Signed-off-by: Xiangfu Liu xian...@openmobilefree.net --- arch/mips/cpu/xburst/cpu.c |4 + arch/mips/cpu/xburst/start_spl.S | 65 drivers/mtd/nand/jz4740_nand.c | 40 +++- include/configs/qi_lb60.h|1 + nand_spl/board/qi/qi_lb60/Makefile | 112 ++ nand_spl/board/qi/qi_lb60/nand_spl.c | 41 nand_spl/board/qi/qi_lb60/u-boot.lds | 63 +++ 7 files changed, 323 insertions(+), 3 deletions(-) create mode 100644 arch/mips/cpu/xburst/start_spl.S create mode 100644 nand_spl/board/qi/qi_lb60/Makefile create mode 100644 nand_spl/board/qi/qi_lb60/nand_spl.c create mode 100644 nand_spl/board/qi/qi_lb60/u-boot.lds diff --git a/arch/mips/cpu/xburst/cpu.c b/arch/mips/cpu/xburst/cpu.c index e976341..afd166c 100644 --- a/arch/mips/cpu/xburst/cpu.c +++ b/arch/mips/cpu/xburst/cpu.c @@ -42,6 +42,8 @@ : \ : i (op), R (*(unsigned char *)(addr))) +#ifndef CONFIG_NAND_SPL + void __attribute__((weak)) _machine_restart(void) { struct jz4740_wdt *wdt = (struct jz4740_wdt *)JZ4740_WDT_BASE; @@ -109,6 +111,8 @@ void invalidate_dcache_range(ulong start_addr, ulong stop) cache_op(Hit_Invalidate_D, addr); } +#endif + void flush_icache_all(void) { u32 addr, t = 0; diff --git a/arch/mips/cpu/xburst/start_spl.S b/arch/mips/cpu/xburst/start_spl.S new file mode 100644 index 000..f137ccd --- /dev/null +++ b/arch/mips/cpu/xburst/start_spl.S @@ -0,0 +1,65 @@ +/* + * Startup Code for MIPS32 XBURST CPU-core + * + * Copyright (c) 2010 Xiangfu Liu xian...@sharism.cc + * + * 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 3 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 config.h +#include version.h +#include asm/regdef.h +#include asm/mipsregs.h +#include asm/addrspace.h +#include asm/cacheops.h + +#include asm/jz4740.h + + .set noreorder + + .globl _start + .text +_start: + .word JZ4740_NANDBOOT_CFG /* fetched during NAND Boot */ +reset: + /* +* STATUS register +* CU0=UM=EXL=IE=0, BEV=ERL=1, IP2~7=1 +*/ + li t0, 0x0040FC04 + mtc0t0, CP0_STATUS + /* +* CAUSE register +* IV=1, use the specical interrupt vector (0x200) +*/ + li t1, 0x0080 + mtc0t1, CP0_CAUSE + + bal 1f +nop + .word _GLOBAL_OFFSET_TABLE_ +1: + movegp, ra + lw t1, 0(ra) + movegp, t1 + + la sp, 0x80004000 + la t9, nand_spl_boot + j t9 +nop diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c index 3ec34f3..7ef07a5 100644 --- a/drivers/mtd/nand/jz4740_nand.c +++ b/drivers/mtd/nand/jz4740_nand.c @@ -15,6 +15,10 @@ #include asm/io.h #include asm/jz4740.h +#ifdef CONFIG_NAND_SPL + #define printf(arg...) do {} while (0) +#endif + #define JZ_NAND_DATA_ADDR ((void __iomem *)0xB800) #define JZ_NAND_CMD_ADDR (JZ_NAND_DATA_ADDR + 0x8000) #define JZ_NAND_ADDR_ADDR (JZ_NAND_DATA_ADDR + 0x1) @@ -176,7 +180,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat, for (k = 0; k 9; k++) writeb(read_ecc[k], emc-nfpar[k]); } - /* Set PRDY */ + writel(readl(emc-nfecr) | EMC_NFECR_PRDY, emc-nfecr); /* Wait for completion */ @@ -184,7 +188,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat, status = readl(emc-nfints); } while (!(status EMC_NFINTS_DECF)); - /* disable ecc */ + /* Disable ECC */ writel(readl(emc-nfecr) ~EMC_NFECR_ECCE, emc-nfecr); /*
Re: [U-Boot] [RFC PATCH 0/19] Create generic board init and move ARM and x86 to it
Hi Wolfgang, On Sat, Dec 31, 2011 at 5:54 PM, Wolfgang Denk w...@denx.de wrote: Dear Simon Glass, In message CAPnjgZ1Zim6=u3rlcnake-0bw3so_hry+u67jkpknoni8g7...@mail.gmail.com you wrote: Also it does depend on expectations. I would hope that moving an architecture over would be a fairly small task: - getting generic relocation working I don;t see why this would be a direct prerequisite here. We want to have that, no boubt about that. But it appears to be an unrelated change to me. I don't think it's essential, but it is desirable, which I why it is on the list. - adding functions for anything that is missing from board init code anything that is missing from board init code ? By that I mean that if the architecture has its own little things which aren't supported by generic board init, then these would need to be worked into the generic board init somehow, perhaps initially with a new function in the initcall list. - removing things which don't work on the architecture? That would probably reander systems broken that need these things? Sorry for being so vague. What I mean is that if an arch does not support a feature, then we don't want to call the init functions for it on that architecture. Sometimes this is handled automatically - e.g. if an arch does not support CONFIG_POST then the generic board init code will skip this anyway. But there may be other cases where features available in the generic board init cannot be supported in all archs. - worrying about differences in ordering between functions This is indeed the biggest issue. Keep in mind that my original ida of providing a function call table was to allow to define this table in a board specific way (i. e. in the board config file). [Not that this idea found many friends...] With this series I have moved over to purely having a function call table, with no actual init code in board_init_f() and board_init_r(). Having done this, I have found that the list of functions is very long, So we probably don't want boards to duplicate this list and #ifdefs may be the lesser of two evils. If we can move to Graham' initcall idea (basically using the linker to create the list of initcalls for pre- and post-reloc) then it becomes possible to boards to insert things in the init sequence without #ifdefs in commong/board.f/r.c. For now I have tried to simply move the code into separate functions, since this makes it easier to compare against the original code in the arch/xxx/lib/board.c files, to make sure nothing is left out and the ordering is OK. pull out common init code like init_baudrate() and hang() and change the function signatures of the functions that require wrappers and move some #ifdef's into more appropriate locations - One example in board.c: Well it seems like a lot of work to refactor each arch/xxx/board.c file into functions with a function pointer list, then later remove this code function by function. Would that really be a clever approach? I'm not convinced it is the best idea. A trivial change of just removing duplicated code from all the archs and inserting it into generic board should be safe enough. But is that really a common case? I have found lots of subtle differences that need to be worked out, and there is the ordering to worry about. Every time there is a patch we need to re-test all boards. It might be easier to just create a generic board implementation one, and then test it once on each board, rather than testing on each board with every patch. Of course every time you patch generic board you might introduce a breakage in an existing (previously working) board, but that is the normal situation with development so I don't see a problem there. Perhaps the biggest problem is the difficulty of testing, and if we can avoid months of little patches (each one potentially breaking lots of boards at run-time) then I would prefer that. My feeling is that with a generic board, it should hopefully be a fairly small amount of work for someone familiar with an architecture to find the bugs and patch the generic code to suit their architecture. It is something that needs to be done once, not every time there is a new patch removing (almost) common code. It is definitely not that easy. You fix one thing here, and break another board there. Ideally you would have to re-test any change on _all_ boards. Well I suppose that's what I'm saying. Doing this once, accepting that some boards will thereby be broken, and then accepting patches to fix them feels easier than trying to keep everything working through a long series of little changes. From previous discussions, if something is optional then the switch will never happen. The code you are talking about is sometimes identical, sometimes slightly different. In some cases the order is different. I see many ways of introducing breakages. I do agree that And I bet most of them _will_ introduce breakages. doing
Re: [U-Boot] [RFC PATCH 0/19] Create generic board init and move ARM and x86 to it
Hi Graeme, On Sat, Dec 31, 2011 at 3:52 AM, Graeme Russ graeme.r...@gmail.com wrote: Hi Simon, On 31/12/11 13:02, Simon Glass wrote: Hi Graeme, On Fri, Dec 30, 2011 at 7:49 AM, Graeme Russ graeme.r...@gmail.com wrote: Hi Simon, [snip] However, I think this approach is not the right one - and I think the CFI driver backs me up. Your plan is to create generic code which you want ALL arches to cross over to, but you only look to migrate two initially and migrate the rest 'later'. This is similar to what happened with the CFI driver, and there are still boards with custom flash.c files which are completely redundant. But, creating a single patch-set to migrate everyone in one go is going to be too massive a job to do in one go, and too prone to introducing breakage. Yes to some extent. However, my patch basically splits the two board_init_x() functions into parts, and puts them in a function table. Ah yes, looking a bit closer I see this now in patches 5 6. However, I think if you look at my patches 9, 10, 12 and 13 I'm doing essentially the same thing for x86. The difference is, I'm moving live code, rather than creating dead code then switching over. I personally do not think your approach is very safe - If there is a breakage, it is spread over multiple patches - With the 'move code around' approach, all breakages are confined to a single patch See my other email on this topic though - I feel that one test/fix cycle is better than testing every board for every little patch over an extended period. I don't think it is a huge job to do this for PowerPC also, and that seems to be the most feature-full architecture. I agree - The init architecture is the same, but the sequence is bigger (and not in the same order) Yes that's what I'm finding. Also it does depend on expectations. I would hope that moving an architecture over would be a fairly small task: - getting generic relocation working - adding functions for anything that is missing from board init code - removing things which don't work on the architecture? - worrying about differences in ordering between functions I see it as: 1) Rework the arch init sequence to be a pure list of 'int foo(void)' functions, adding helpers and wrappers where necessary 2) Switch over to use the generic init processing loop 3) Factor out common helpers and wrappers across all arches 4) Factor out common functionality (e.g. relocation) 5) After all arches are switched, remove wrappers by changing the function signature of the wrapped function 6) Move helpers into relevant driver/common source file I think 1 2 need to be done for at least ARM, x86 and PPC before starting 3 4 and 1-4 needs to be done for all arches before doing 5 6 OK yes we could do this. But I think the end result is different. I am keen to create a single common/board_f.c implementation for pre-reloc init and common/board_r.c for post-reloc init. I believe where your approach ends up with with separate arch/xxx/board.c files still, with their own initcall list, and a number of private functions. Now this is better than where we are now, but my original complaint was that I want to be able to add features to a single place and have them work across all architectures. With your end-result I still need to figure out where to put the new feature in each initcall list and create 10 patches, one for each arch, to plumb it in. IMO the ordering differences between architectures are mostly unnecessary - an artifact of forking the code - and we should aim to minimise these differences. Putting everything in one file helps to clarify exactly what the differences are between archs, and discussions can take place as to why and whether this differences can be removed. If we accept that PPC is the one true way (in terms of U-Boot code base), then the job is to make other arch's code more like PPC. This is best done in one place I think. After a bit of thought, I worry also that your approach will create an extended period of time where U-Boot is unstable, as patch are patch is added to refactor the code. Granted, many of these patches are small and the risk is small. But why bother? At the end we still have 10 different board files, lots of differences and no one willing to change anything because it requires an entire test cycle again. Maybe I am being too ambitious here, but since everything started with PPC's board.c, I don't see why we shouldn't head back in that direction and just create a single file again. It does create a big test problem, but only once :-) Anyway if we do go with what you propose I still think it is better than what we have. [snip] If we work each individual arch to use a generic init sequence (like the proposed x86 code) then the init processing naturally falls out as common code and the patch to realise this is trivial. From there, we can start to pull out common init code like init_baudrate() and
[U-Boot] [PATCH 00/17] x86: Rework of board init code (plus support patches)
Happy New Year! I was thinking I would do another RFC, but instead I pulled an all-nighter to get this series cleaned up ready for mainline There a two major architectural changes introduced by this series: - The global data pointer is converted to a psuedo register implementation which allows global data to be access pre and post relocations like all other aches - The init sequences in board.c are reduced to be purely to loops which execute arrays of init functions All patches are checkpatch clean Series is rebased to commit bfcc40bb09b05c90cc3b1496abb270eb8aa72134 (Merge branch 'next' of ../next) Regards, Graeme Graeme Russ (17): x86: Import glibc memcpy implementation x86: Speed up copy-to-RAM and clear BSS operations x86: Remove GDR related magic numbers x86: Rework Global Descriptor Table loading x86: Simplify Flash-to-RAM code execution transition x86: Rework relocation calcuations x86: Use fs for global data x86: Set GD_FLG_RELOC after entering in-RAM copy of U-Boot x86: Create weak init_cache() function x86: Allow cache before copy to RAM CHECKPATCH: arch/x86/cpu/* CHECKPATCH: arch/x86/lib/* x86: Move do_go_exec() out of board.c x86: Move setup_pcat_compatibility() out of board.c x86: Move relocation code out of board.c x86: Simplify board.c x86: Tweak initialisation procedure arch/x86/cpu/cpu.c | 107 ++--- arch/x86/cpu/interrupts.c|2 +- arch/x86/cpu/start.S | 31 +-- arch/x86/cpu/start16.S | 57 - arch/x86/include/asm/global_data.h | 21 +- arch/x86/include/asm/init_helpers.h | 43 +++ arch/x86/include/asm/init_wrappers.h | 42 +++ arch/x86/include/asm/processor.h | 12 +- arch/x86/include/asm/relocate.h | 33 +++ arch/x86/include/asm/string.h|2 +- arch/x86/include/asm/u-boot-x86.h|5 + arch/x86/lib/Makefile|4 + arch/x86/lib/bios.S | 134 ++ arch/x86/lib/board.c | 474 +- arch/x86/lib/cmd_boot.c | 64 + arch/x86/lib/init_helpers.c | 210 +++ arch/x86/lib/init_wrappers.c | 137 ++ arch/x86/lib/realmode_switch.S | 61 +++-- arch/x86/lib/relocate.c | 91 +++ arch/x86/lib/string.c| 61 + arch/x86/lib/zimage.c|7 + 21 files changed, 1099 insertions(+), 499 deletions(-) create mode 100644 arch/x86/include/asm/init_helpers.h create mode 100644 arch/x86/include/asm/init_wrappers.h create mode 100644 arch/x86/include/asm/relocate.h create mode 100644 arch/x86/lib/cmd_boot.c create mode 100644 arch/x86/lib/init_helpers.c create mode 100644 arch/x86/lib/init_wrappers.c create mode 100644 arch/x86/lib/relocate.c -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 01/17] x86: Import glibc memcpy implementation
Taken from glibc version 2.14.90 Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/include/asm/string.h |2 +- arch/x86/lib/string.c | 61 + 2 files changed, 62 insertions(+), 1 deletions(-) diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h index 3aa6c11..0ad612f 100644 --- a/arch/x86/include/asm/string.h +++ b/arch/x86/include/asm/string.h @@ -14,7 +14,7 @@ extern char * strrchr(const char * s, int c); #undef __HAVE_ARCH_STRCHR extern char * strchr(const char * s, int c); -#undef __HAVE_ARCH_MEMCPY +#define __HAVE_ARCH_MEMCPY extern void * memcpy(void *, const void *, __kernel_size_t); #undef __HAVE_ARCH_MEMMOVE diff --git a/arch/x86/lib/string.c b/arch/x86/lib/string.c index f2ea7e4..1fde81b 100644 --- a/arch/x86/lib/string.c +++ b/arch/x86/lib/string.c @@ -85,3 +85,64 @@ void *memset(void *dstpp, int c, size_t len) return dstpp; } + +#defineOP_T_THRES 8 +#define OPSIZ (sizeof(op_t)) + +#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes)\ +do { \ + int __d0; \ + asm volatile( \ + /* Clear the direction flag, so copying goes forward. */ \ + cld\n \ + /* Copy bytes. */\ + rep\n \ + movsb : \ + =D (dst_bp), =S (src_bp), =c (__d0) : \ + 0 (dst_bp), 1 (src_bp), 2 (nbytes) :\ + memory);\ +} while (0) + +#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \ +do { \ + int __d0; \ + asm volatile( \ + /* Clear the direction flag, so copying goes forward. */ \ + cld\n \ + /* Copy longwords. */\ + rep\n \ + movsl : \ + =D (dst_bp), =S (src_bp), =c (__d0) : \ + 0 (dst_bp), 1 (src_bp), 2 ((nbytes) / 4) : \ + memory);\ + (nbytes_left) = (nbytes) % 4; \ +} while (0) + +void *memcpy(void *dstpp, const void *srcpp, size_t len) +{ + unsigned long int dstp = (long int)dstpp; + unsigned long int srcp = (long int)srcpp; + + /* Copy from the beginning to the end. */ + + /* If there not too few bytes to copy, use word copy. */ + if (len = OP_T_THRES) { + /* Copy just a few bytes to make DSTP aligned. */ + len -= (-dstp) % OPSIZ; + BYTE_COPY_FWD(dstp, srcp, (-dstp) % OPSIZ); + + /* Copy from SRCP to DSTP taking advantage of the known +* alignment of DSTP. Number of bytes remaining is put +* in the third argument, i.e. in LEN. This number may +* vary from machine to machine. +*/ + WORD_COPY_FWD(dstp, srcp, len, len); + + /* Fall out and copy the tail. */ + } + + /* There are just a few bytes to copy. Use byte memory operations. */ + BYTE_COPY_FWD(dstp, srcp, len); + + return dstpp; +} -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 02/17] x86: Speed up copy-to-RAM and clear BSS operations
The implementations of memcpy and memset are now the optimised versions from glibc, so use them instead of simple copy loops Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/lib/board.c | 17 + 1 files changed, 5 insertions(+), 12 deletions(-) diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index d742fec..ba6b59f 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -188,26 +188,19 @@ static int calculate_relocation_address(void) static int copy_uboot_to_ram(void) { - ulong *dst_addr = (ulong *)gd-relocaddr; - ulong *src_addr = (ulong *)__text_start; - ulong *end_addr = (ulong *)__data_end; + size_t len = (size_t)(__data_end) - (size_t)(__text_start); - while (src_addr end_addr) - *dst_addr++ = *src_addr++; + memcpy((void *)gd-relocaddr, (void *)__text_start, len); return 0; } static int clear_bss(void) { - void *bss_start = __bss_start; - void *bss_end = __bss_end; + ulong dst_addr = (ulong)(__bss_start) + gd-reloc_off; + size_t len = (size_t)(__bss_end) - (size_t)(__bss_start); - ulong *dst_addr = (ulong *)(bss_start + gd-reloc_off); - ulong *end_addr = (ulong *)(bss_end + gd-reloc_off); - - while (dst_addr end_addr) - *dst_addr++ = 0x; + memset((void *)dst_addr, 0x00, len); return 0; } -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 03/17] x86: Remove GDR related magic numbers
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/cpu/start.S |3 ++- arch/x86/include/asm/processor.h |6 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S index f87633b..7f9b6a7 100644 --- a/arch/x86/cpu/start.S +++ b/arch/x86/cpu/start.S @@ -29,6 +29,7 @@ #include config.h #include version.h #include asm/global_data.h +#include asm/processor.h #include asm/processor-flags.h #include generated/asm-offsets.h @@ -58,7 +59,7 @@ _start: /* This is the 32-bit cold-reset entry point */ /* Load the segement registes to match the gdt loaded in start16.S */ - movl$0x18, %eax + movl$(GDT_ENTRY_32BIT_DS * 8), %eax movw%ax, %fs movw%ax, %ds movw%ax, %gs diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 1e5dccd..203c63a 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -24,9 +24,13 @@ #ifndef __ASM_PROCESSOR_H_ #define __ASM_PROCESSOR_H_ 1 -#define GDT_ENTRY_32BIT_CS 2 +#define GDT_ENTRY_NULL 0 +#define GDT_ENTRY_UNUSED (GDT_ENTRY_NULL + 1) +#define GDT_ENTRY_32BIT_CS (GDT_ENTRY_UNUSED + 1) #define GDT_ENTRY_32BIT_DS (GDT_ENTRY_32BIT_CS + 1) #define GDT_ENTRY_16BIT_CS (GDT_ENTRY_32BIT_DS + 1) #define GDT_ENTRY_16BIT_DS (GDT_ENTRY_16BIT_CS + 1) +#define GDT_NUM_ENTRIES(GDT_ENTRY_16BIT_DS + 1) + #endif -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 04/17] x86: Rework Global Descriptor Table loading
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/cpu/cpu.c | 82 +-- 1 files changed, 53 insertions(+), 29 deletions(-) diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index 61d0b69..bf55c26 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -55,35 +55,39 @@ struct gdt_ptr { u32 ptr; } __packed; -static void reload_gdt(void) +static void load_ds(u32 segment) { - /* -* There are machines which are known to not boot with the GDT -* being 8-byte unaligned. Intel recommends 16 byte alignment -*/ - static const u64 boot_gdt[] __attribute__((aligned(16))) = { - /* CS: code, read/execute, 4 GB, base 0 */ - [GDT_ENTRY_32BIT_CS] = GDT_ENTRY(0xc09b, 0, 0xf), - /* DS: data, read/write, 4 GB, base 0 */ - [GDT_ENTRY_32BIT_DS] = GDT_ENTRY(0xc093, 0, 0xf), - /* 16-bit CS: code, read/execute, 64 kB, base 0 */ - [GDT_ENTRY_16BIT_CS] = GDT_ENTRY(0x109b, 0, 0x0), - /* 16-bit DS: data, read/write, 64 kB, base 0 */ - [GDT_ENTRY_16BIT_DS] = GDT_ENTRY(0x1093, 0, 0x0), - }; - static struct gdt_ptr gdt; - - gdt.len = sizeof(boot_gdt)-1; - gdt.ptr = (u32)boot_gdt; - - asm volatile(lgdtl %0\n \ -movl $((2+1)*8), %%ecx\n \ -movl %%ecx, %%ds\n \ -movl %%ecx, %%es\n \ -movl %%ecx, %%fs\n \ -movl %%ecx, %%gs\n \ -movl %%ecx, %%ss \ -: : m (gdt) : ecx); + asm volatile(movl %0, %%ds : : r (segment * 8)); +} + +static void load_es(u32 segment) +{ + asm volatile(movl %0, %%es : : r (segment * 8)); +} + +static void load_fs(u32 segment) +{ + asm volatile(movl %0, %%fs : : r (segment * 8)); +} + +static void load_gs(u32 segment) +{ + asm volatile(movl %0, %%gs : : r (segment * 8)); +} + +static void load_ss(u32 segment) +{ + asm volatile(movl %0, %%ss : : r (segment * 8)); +} + +static void load_gdt(const u64 *boot_gdt, u16 num_entries) +{ + struct gdt_ptr gdt; + + gdt.len = (num_entries * 8) - 1; + gdt.ptr = (u32)boot_gdt; + + asm volatile(lgdtl %0\n : : m (gdt)); } int x86_cpu_init_f(void) @@ -113,7 +117,27 @@ int x86_cpu_init_r(void) movl %%eax, %%cr0\n wbinvd\n : : i (nw_cd_rst) : eax); - reload_gdt(); + /* +* There are machines which are known to not boot with the GDT +* being 8-byte unaligned. Intel recommends 16 byte alignment +*/ + static const u64 boot_gdt[] __aligned(16) = { + /* CS: code, read/execute, 4 GB, base 0 */ + [GDT_ENTRY_32BIT_CS] = GDT_ENTRY(0xc09b, 0, 0xf), + /* DS: data, read/write, 4 GB, base 0 */ + [GDT_ENTRY_32BIT_DS] = GDT_ENTRY(0xc093, 0, 0xf), + /* 16-bit CS: code, read/execute, 64 kB, base 0 */ + [GDT_ENTRY_16BIT_CS] = GDT_ENTRY(0x109b, 0, 0x0), + /* 16-bit DS: data, read/write, 64 kB, base 0 */ + [GDT_ENTRY_16BIT_DS] = GDT_ENTRY(0x1093, 0, 0x0), + }; + + load_gdt(boot_gdt, GDT_NUM_ENTRIES); + load_ds(GDT_ENTRY_32BIT_DS); + load_es(GDT_ENTRY_32BIT_DS); + load_fs(GDT_ENTRY_32BIT_DS); + load_gs(GDT_ENTRY_32BIT_DS); + load_ss(GDT_ENTRY_32BIT_DS); /* Initialize core interrupt and exception functionality of CPU */ cpu_init_interrupts(); -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 05/17] x86: Simplify Flash-to-RAM code execution transition
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/cpu/start.S | 20 +--- arch/x86/include/asm/u-boot-x86.h |2 ++ arch/x86/lib/board.c | 25 ++--- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S index 7f9b6a7..9592158 100644 --- a/arch/x86/cpu/start.S +++ b/arch/x86/cpu/start.S @@ -96,32 +96,22 @@ car_init_ret: movw$0x85, %ax jmp die -.globl relocate_code -.type relocate_code, @function -relocate_code: +.globl board_init_f_r_trampoline +.type board_init_f_r_trampoline, @function +board_init_f_r_trampoline: /* * SDRAM has been initialised, U-Boot code has been copied into * RAM, BSS has been cleared and relocation adjustments have been * made. It is now time to jump into the in-RAM copy of U-Boot * * %eax = Address of top of stack -* %edx = Address of Global Data -* %ecx = Base address of in-RAM copy of U-Boot */ /* Setup stack in RAM */ movl%eax, %esp - /* Setup call address of in-RAM copy of board_init_r() */ - movl$board_init_r, %ebp - addl(GENERATED_GD_RELOC_OFF)(%edx), %ebp - - /* Setup parameters to board_init_r() */ - movl%edx, %eax - movl%ecx, %edx - - /* Jump to in-RAM copy of board_init_r() */ - call*%ebp + /* Re-enter U-Boot by calling board_init_f_r */ + callboard_init_f_r die: hlt diff --git a/arch/x86/include/asm/u-boot-x86.h b/arch/x86/include/asm/u-boot-x86.h index 755f88a..c3d2277 100644 --- a/arch/x86/include/asm/u-boot-x86.h +++ b/arch/x86/include/asm/u-boot-x86.h @@ -61,5 +61,7 @@ u32 isa_map_rom(u32 bus_addr, int size); int video_bios_init(void); int video_init(void); +void board_init_f_r_trampoline(ulong) __attribute__ ((noreturn)); +void board_init_f_r(void) __attribute__ ((noreturn)); #endif /* _U_BOOT_I386_H_ */ diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index ba6b59f..978beaa 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -253,10 +253,29 @@ void board_init_f(ulong boot_flags) gd-flags |= GD_FLG_RELOC; - /* Enter the relocated U-Boot! */ - relocate_code(gd-start_addr_sp, gd, gd-relocaddr); + /* +* SDRAM is now initialised, U-Boot has been copied into SDRAM, +* the BSS has been cleared etc. The final stack can now be setup +* in SDRAM. Code execution will continue (momentarily) 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) +{ + /* +* 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 - relocate_code() does not return */ + /* NOTREACHED - board_init_r() does not return */ while (1) ; } -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 06/17] x86: Rework relocation calcuations
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/lib/board.c | 23 +++ 1 files changed, 11 insertions(+), 12 deletions(-) diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 978beaa..bc5027b 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -164,24 +164,23 @@ static int calculate_relocation_address(void) ulong text_start = (ulong)__text_start; ulong bss_end = (ulong)__bss_end; ulong dest_addr; - ulong rel_offset; - - /* Calculate destination RAM Address and relocation offset */ - dest_addr = gd-ram_size; - dest_addr -= CONFIG_SYS_STACK_SIZE; - dest_addr -= (bss_end - text_start); /* -* Round destination address down to 16-byte boundary to keep -* IDT and GDT 16-byte aligned +* NOTE: All destination address are rounded down to 16-byte +* boundary to satisfy various worst-case alignment +* requirements */ - dest_addr = ~15; - rel_offset = dest_addr - text_start; + /* Stack is at top of available memory */ + dest_addr = gd-ram_size; + gd-start_addr_sp = dest_addr; - gd-start_addr_sp = gd-ram_size; + /* U-Boot is below the stack */ + dest_addr -= CONFIG_SYS_STACK_SIZE; + dest_addr -= (bss_end - text_start); + dest_addr = ~15; gd-relocaddr = dest_addr; - gd-reloc_off = rel_offset; + gd-reloc_off = (dest_addr - text_start); return 0; } -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 07/17] x86: Use fs for global data
Use the base address of the 'F' segment as a pointer to the global data structure. By adding the linear address (i.e. the 'D' segment address) as the first word of the global data structure, the address of the global data relative to the 'D' segment can be found simply, for example, by: fs movl 0, %eax This makes the gd 'pointer' writable prior to relocation (by reloading the GDT) which brings x86 into line with all other arches NOTE: Writing to the gd 'pointer' is expensive (but we only do it twice) but using it to access global data members (read and write) is still fairly cheap Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/cpu/cpu.c | 53 -- arch/x86/cpu/start.S |8 - arch/x86/include/asm/global_data.h | 21 + arch/x86/include/asm/processor.h |6 +++- arch/x86/include/asm/u-boot-x86.h |2 + arch/x86/lib/board.c | 56 +--- 6 files changed, 98 insertions(+), 48 deletions(-) diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index bf55c26..e7a5fc0 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -90,6 +90,37 @@ static void load_gdt(const u64 *boot_gdt, u16 num_entries) asm volatile(lgdtl %0\n : : m (gdt)); } +void init_gd(gd_t *id, u64 *gdt_addr) +{ + id-gd_addr = (ulong)id; + setup_gdt(id, gdt_addr); +} + +void setup_gdt(gd_t *id, u64 *gdt_addr) +{ + /* CS: code, read/execute, 4 GB, base 0 */ + gdt_addr[GDT_ENTRY_32BIT_CS] = GDT_ENTRY(0xc09b, 0, 0xf); + + /* DS: data, read/write, 4 GB, base 0 */ + gdt_addr[GDT_ENTRY_32BIT_DS] = GDT_ENTRY(0xc093, 0, 0xf); + + /* FS: data, read/write, 4 GB, base (Global Data Pointer) */ + gdt_addr[GDT_ENTRY_32BIT_FS] = GDT_ENTRY(0xc093, (ulong)id, 0xf); + + /* 16-bit CS: code, read/execute, 64 kB, base 0 */ + gdt_addr[GDT_ENTRY_16BIT_CS] = GDT_ENTRY(0x109b, 0, 0x0); + + /* 16-bit DS: data, read/write, 64 kB, base 0 */ + gdt_addr[GDT_ENTRY_16BIT_DS] = GDT_ENTRY(0x1093, 0, 0x0); + + load_gdt(gdt_addr, GDT_NUM_ENTRIES); + load_ds(GDT_ENTRY_32BIT_DS); + load_es(GDT_ENTRY_32BIT_DS); + load_gs(GDT_ENTRY_32BIT_DS); + load_ss(GDT_ENTRY_32BIT_DS); + load_fs(GDT_ENTRY_32BIT_FS); +} + int x86_cpu_init_f(void) { const u32 em_rst = ~X86_CR0_EM; @@ -117,28 +148,6 @@ int x86_cpu_init_r(void) movl %%eax, %%cr0\n wbinvd\n : : i (nw_cd_rst) : eax); - /* -* There are machines which are known to not boot with the GDT -* being 8-byte unaligned. Intel recommends 16 byte alignment -*/ - static const u64 boot_gdt[] __aligned(16) = { - /* CS: code, read/execute, 4 GB, base 0 */ - [GDT_ENTRY_32BIT_CS] = GDT_ENTRY(0xc09b, 0, 0xf), - /* DS: data, read/write, 4 GB, base 0 */ - [GDT_ENTRY_32BIT_DS] = GDT_ENTRY(0xc093, 0, 0xf), - /* 16-bit CS: code, read/execute, 64 kB, base 0 */ - [GDT_ENTRY_16BIT_CS] = GDT_ENTRY(0x109b, 0, 0x0), - /* 16-bit DS: data, read/write, 64 kB, base 0 */ - [GDT_ENTRY_16BIT_DS] = GDT_ENTRY(0x1093, 0, 0x0), - }; - - load_gdt(boot_gdt, GDT_NUM_ENTRIES); - load_ds(GDT_ENTRY_32BIT_DS); - load_es(GDT_ENTRY_32BIT_DS); - load_fs(GDT_ENTRY_32BIT_DS); - load_gs(GDT_ENTRY_32BIT_DS); - load_ss(GDT_ENTRY_32BIT_DS); - /* Initialize core interrupt and exception functionality of CPU */ cpu_init_interrupts(); return 0; diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S index 9592158..4fb9e6b 100644 --- a/arch/x86/cpu/start.S +++ b/arch/x86/cpu/start.S @@ -31,7 +31,7 @@ #include asm/global_data.h #include asm/processor.h #include asm/processor-flags.h -#include generated/asm-offsets.h +#include generated/generic-asm-offsets.h .section .text .code32 @@ -85,6 +85,12 @@ car_init_ret: */ movl$CONFIG_SYS_INIT_SP_ADDR, %esp + /* Initialise the Global Data Pointer */ + movl$CONFIG_SYS_INIT_GD_ADDR, %eax + movl%eax, %edx + addl$GENERATED_GBL_DATA_SIZE, %edx + callinit_gd; + /* Set parameter to board_init_f() to boot flags */ xorl%eax, %eax movw%bx, %ax diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h index 05a2139..908a02c 100644 --- a/arch/x86/include/asm/global_data.h +++ b/arch/x86/include/asm/global_data.h @@ -36,6 +36,8 @@ #ifndef __ASSEMBLY__ typedefstruct global_data { + /* NOTE: gd_addr MUST be first member of struct global_data! */ + unsigned long gd_addr;/* Location of Global Data */ bd_t*bd; unsigned long flags; unsigned long baudrate; @@ -51,13 +53,24 @@ typedef struct
[U-Boot] [PATCH 08/17] x86: Set GD_FLG_RELOC after entering in-RAM copy of U-Boot
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/lib/board.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 9c4ecda..4e54dba 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -252,8 +252,6 @@ void board_init_f(ulong boot_flags) hang(); } - gd-flags |= GD_FLG_RELOC; - /* * SDRAM is now initialised, U-Boot has been copied into SDRAM, * the BSS has been cleared etc. The final stack can now be setup @@ -322,6 +320,8 @@ void board_init_r(gd_t *id, ulong dest_addr) /* compiler optimization barrier needed for GCC = 3.4 */ __asm__ __volatile__( : : : memory); + gd-flags |= GD_FLG_RELOC; + gd-bd = bd_data; memset(gd-bd, 0, sizeof(bd_t)); show_boot_progress(0x22); -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 09/17] x86: Create weak init_cache() function
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/cpu/cpu.c| 18 +++--- arch/x86/include/asm/u-boot-x86.h |1 + arch/x86/lib/board.c |1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index e7a5fc0..4351f20 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -140,6 +140,14 @@ int cpu_init_f(void) __attribute__((weak, alias(x86_cpu_init_f))); int x86_cpu_init_r(void) { + /* Initialize core interrupt and exception functionality of CPU */ + cpu_init_interrupts(); + return 0; +} +int cpu_init_r(void) __attribute__((weak, alias(x86_cpu_init_r))); + +void x86_enable_caches(void) +{ const u32 nw_cd_rst = ~(X86_CR0_NW | X86_CR0_CD); /* turn on the cache and disable write through */ @@ -147,12 +155,16 @@ int x86_cpu_init_r(void) andl %0, %%eax\n movl %%eax, %%cr0\n wbinvd\n : : i (nw_cd_rst) : eax); +} +void enable_caches(void) __attribute__((weak, alias(x86_enable_caches))); + +int x86_init_cache(void) +{ + enable_caches(); - /* Initialize core interrupt and exception functionality of CPU */ - cpu_init_interrupts(); return 0; } -int cpu_init_r(void) __attribute__((weak, alias(x86_cpu_init_r))); +int init_cache(void) __attribute__((weak, alias(x86_init_cache))); int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { diff --git a/arch/x86/include/asm/u-boot-x86.h b/arch/x86/include/asm/u-boot-x86.h index 5540d51..878a1ee 100644 --- a/arch/x86/include/asm/u-boot-x86.h +++ b/arch/x86/include/asm/u-boot-x86.h @@ -39,6 +39,7 @@ int x86_cpu_init_f(void); int cpu_init_f(void); void init_gd(gd_t *id, u64 *gdt_addr); void setup_gdt(gd_t *id, u64 *gdt_addr); +int init_cache(void); /* cpu/.../timer.c */ void timer_isr(void *); diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 4e54dba..ffddfbe 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -140,6 +140,7 @@ init_fnc_t *init_sequence_f[] = { init_fnc_t *init_sequence_r[] = { copy_gd_to_ram, + init_cache, cpu_init_r, /* basic cpu dependent setup */ board_early_init_r, /* basic board dependent setup */ dram_init, /* configure available RAM banks */ -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 10/17] x86: Allow cache before copy to RAM
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/lib/board.c | 15 ++- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index ffddfbe..52e27e1 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -131,16 +131,11 @@ init_fnc_t *init_sequence_f[] = { console_init_f, dram_init_f, calculate_relocation_address, - copy_uboot_to_ram, - clear_bss, - do_elf_reloc_fixups, NULL, }; init_fnc_t *init_sequence_r[] = { - copy_gd_to_ram, - init_cache, cpu_init_r, /* basic cpu dependent setup */ board_early_init_r, /* basic board dependent setup */ dram_init, /* configure available RAM banks */ @@ -269,6 +264,16 @@ void board_init_f(ulong boot_flags) void board_init_f_r(void) { + if (copy_gd_to_ram() != 0) + hang(); + + if (init_cache() != 0) + hang(); + + copy_uboot_to_ram(); + clear_bss(); + do_elf_reloc_fixups(); + /* * Transfer execution from Flash to RAM by calculating the address * of the in-RAM copy of board_init_r() and calling it -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 11/17] CHECKPATCH: arch/x86/cpu/*
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/cpu/interrupts.c |2 +- arch/x86/cpu/start16.S| 57 +++- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/arch/x86/cpu/interrupts.c b/arch/x86/cpu/interrupts.c index e0958eb..43ec3f8 100644 --- a/arch/x86/cpu/interrupts.c +++ b/arch/x86/cpu/interrupts.c @@ -174,7 +174,7 @@ struct desc_ptr { unsigned short segment; } __packed; -struct idt_entry idt[256] __attribute__((aligned(16))); +struct idt_entry idt[256] __aligned(16); struct desc_ptr idt_ptr; diff --git a/arch/x86/cpu/start16.S b/arch/x86/cpu/start16.S index 33e53cd..cc393ff 100644 --- a/arch/x86/cpu/start16.S +++ b/arch/x86/cpu/start16.S @@ -86,7 +86,11 @@ gdt_ptr: .word 0x20/* limit (32 bytes = 4 GDT entries) */ .long BOOT_SEG + gdt /* base */ - /* The GDT table ... +/* Some CPUs are picky about GDT alignment... */ +.align 16 +gdt: + /* +* The GDT table ... * * Selector Type * 0x00 NULL @@ -94,17 +98,46 @@ gdt_ptr: * 0x10 32bit code * 0x18 32bit data/stack */ + /* The NULL Desciptor - Mandatory */ + .word 0x /* limit_low */ + .word 0x /* base_low */ + .byte 0x00/* base_middle */ + .byte 0x00/* access */ + .byte 0x00/* flags + limit_high */ + .byte 0x00/* base_high */ -gdt: - .word 0, 0, 0, 0 /* NULL */ - .word 0, 0, 0, 0 /* unused */ + /* Unused Desciptor - (matches Linux) */ + .word 0x /* limit_low */ + .word 0x /* base_low */ + .byte 0x00/* base_middle */ + .byte 0x00/* access */ + .byte 0x00/* flags + limit_high */ + .byte 0x00/* base_high */ - .word 0x /* 4Gb - (0x10*0x1000 = 4Gb) */ - .word 0 /* base address = 0 */ - .word 0x9B00 /* code read/exec */ - .word 0x00CF /* granularity = 4096, 386 (+5th nibble of limit) */ + /* +* The Code Segment Descriptor: +* - Base = 0x +* - Size = 4GB +* - Access = Present, Ring 0, Exec (Code), Readable +* - Flags = 4kB Granularity, 32-bit +*/ + .word 0x /* limit_low */ + .word 0x /* base_low */ + .byte 0x00/* base_middle */ + .byte 0x9b/* access */ + .byte 0xcf/* flags + limit_high */ + .byte 0x00/* base_high */ - .word 0x /* 4Gb - (0x10*0x1000 = 4Gb) */ - .word 0x0 /* base address = 0 */ - .word 0x9300 /* data read/write */ - .word 0x00CF /* granularity = 4096, 386 (+5th nibble of limit) */ + /* +* The Data Segment Descriptor: +* - Base = 0x +* - Size = 4GB +* - Access = Present, Ring 0, Non-Exec (Data), Writable +* - Flags = 4kB Granularity, 32-bit +*/ + .word 0x /* limit_low */ + .word 0x /* base_low */ + .byte 0x00/* base_middle */ + .byte 0x93/* access */ + .byte 0xcf/* flags + limit_high */ + .byte 0x00/* base_high */ -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 12/17] CHECKPATCH: arch/x86/lib/*
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/lib/bios.S| 134 +-- arch/x86/lib/realmode_switch.S | 61 +++ 2 files changed, 122 insertions(+), 73 deletions(-) diff --git a/arch/x86/lib/bios.S b/arch/x86/lib/bios.S index ce8deb5..239aaa9 100644 --- a/arch/x86/lib/bios.S +++ b/arch/x86/lib/bios.S @@ -246,11 +246,9 @@ rm_int1f: rm_def_int: iret - /* -* All interrupt jumptable entries jump to here -* after pushing the interrupt vector number onto the -* stack. +* All interrupt jumptable entries jump to here after pushing the +* interrupt vector number onto the stack. */ any_interrupt16: MAKE_BIOS_STACK @@ -272,7 +270,8 @@ gs movwOFFS_VECTOR(%bp), %ax je Lint_1ah movw$0x, %ax jmp Lout -Lint_10h: /* VGA BIOS services */ +Lint_10h: + /* VGA BIOS services */ callbios_10h jmp Lout Lint_11h: @@ -281,35 +280,42 @@ Lint_11h: Lint_12h: callbios_12h jmp Lout -Lint_13h: /* BIOS disk services */ +Lint_13h: + /* BIOS disk services */ callbios_13h jmp Lout -Lint_15h: /* Misc. BIOS services */ +Lint_15h: + /* Misc. BIOS services */ callbios_15h jmp Lout -Lint_16h: /* keyboard services */ +Lint_16h: + /* keyboard services */ callbios_16h jmp Lout -Lint_1ah: /* PCI bios */ +Lint_1ah: + /* PCI bios */ callbios_1ah jmp Lout Lout: cmpw$0, %ax je Lhandeled - /* Insert code for unhandeled INTs here. + /* +* Insert code for unhandeled INTs here. * -* ROLO prints a message to the console -* (we could do that but then we're in 16bit mode -* so we'll have to get back into 32bit mode -* to use the console I/O routines (if we do this -* we shuls make int 0x10 and int 0x16 work as well)) +* ROLO prints a message to the console we could do that but then +* we're in 16bit mode so we'll have to get back into 32bit mode +* to use the console I/O routines (if we do this we should make +* int 0x10 and int 0x16 work as well) */ Lhandeled: RESTORE_CALLERS_STACK - addw$2,%sp /* dump vector number */ - iret/* return from interrupt */ + /* dump vector number */ + addw$2,%sp + + /* return from interrupt */ + iret /* @@ -327,22 +333,24 @@ gsmovwOFFS_AX(%bp), %ax je Lvid_cfg movw$0x, %ax ret -Lcur_pos: /* Read Cursor Position and Size */ +Lcur_pos: + /* Read Cursor Position and Size */ gs movw$0, OFFS_CX(%bp) gs movw$0, OFFS_DX(%bp) xorw%ax, %ax ret -Lvid_state:/* Get Video State */ -gs movw$(80 8|0x03), OFFS_AX(%bp) /* 80 columns, 80x25, 16 colors */ +Lvid_state: + /* Get Video State - 80 columns, 80x25, 16 colors */ +gs movw$(80 8|0x03), OFFS_AX(%bp) gs movw$0, OFFS_BX(%bp) xorw%ax, %ax ret -Lvid_cfg: /* Video Subsystem Configuration (EGA/VGA) */ -gs movw$0x10, OFFS_BX(%bp) /* indicate CGA/MDA/HGA */ +Lvid_cfg: + /* Video Subsystem Configuration (EGA/VGA) - indicate CGA/MDA/HGA */ +gs movw$0x10, OFFS_BX(%bp) xorw%ax, %ax ret - /* * BIOS interrupt 11h -- Equipment determination @@ -355,7 +363,6 @@ gs movw%ax, OFFS_AX(%bp) xorw%ax, %ax ret - /* * BIOSinterrupt 12h -- Get Memory Size @@ -370,16 +377,18 @@ csmovwram_in_64kb_chunks, %ax b12_more_than_640k: movw$0x280, %ax b12_return: -gs movw%ax, OFFS_AX(%bp) /* return number of kilobytes in ax */ + /* return number of kilobytes in ax */ +gs movw%ax, OFFS_AX(%bp) gs movwOFFS_FLAGS(%bp), %ax - andw$0xfffe, %ax/* clear carry -- function succeeded */ + + /* clear carry -- function succeeded */ + andw$0xfffe, %ax gs movw%ax, OFFS_FLAGS(%bp) xorw%ax, %ax ret - /* * BIOS interrupt 13h -- Disk services @@ -394,12 +403,13 @@ gsmovwOFFS_AX(%bp), %ax ret
[U-Boot] [PATCH 13/17] x86: Move do_go_exec() out of board.c
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/lib/Makefile |1 + arch/x86/lib/board.c| 27 --- arch/x86/lib/cmd_boot.c | 64 +++ 3 files changed, 65 insertions(+), 27 deletions(-) create mode 100644 arch/x86/lib/cmd_boot.c diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index d584aa4..7820895 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -32,6 +32,7 @@ SOBJS-$(CONFIG_SYS_X86_REALMODE) += realmode_switch.o COBJS-$(CONFIG_SYS_PC_BIOS)+= bios_setup.o COBJS-y+= board.o COBJS-y+= bootm.o +COBJS-y+= cmd_boot.o COBJS-y+= gcc.o COBJS-y+= interrupts.o COBJS-$(CONFIG_SYS_PCAT_INTERRUPTS) += pcat_interrupts.o diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 52e27e1..533adf1 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -487,33 +487,6 @@ void hang(void) ; } -unsigned long do_go_exec(ulong (*entry)(int, char * const []), -int argc, char * const argv[]) -{ - unsigned long ret = 0; - char **argv_tmp; - - /* -* x86 does not use a dedicated register to pass the pointer to -* the global_data, so it is instead passed as argv[-1]. By using -* argv[-1], the called 'Application' can use the contents of -* argv natively. However, to safely use argv[-1] a new copy of -* argv is needed with the extra element -*/ - argv_tmp = malloc(sizeof(char *) * (argc + 1)); - - if (argv_tmp) { - argv_tmp[0] = (char *)gd; - - memcpy(argv_tmp[1], argv, (size_t)(sizeof(char *) * argc)); - - ret = (entry) (argc, argv_tmp[1]); - free(argv_tmp); - } - - return ret; -} - void setup_pcat_compatibility(void) __attribute__((weak, alias(__setup_pcat_compatibility))); diff --git a/arch/x86/lib/cmd_boot.c b/arch/x86/lib/cmd_boot.c new file mode 100644 index 000..a81a9a3 --- /dev/null +++ b/arch/x86/lib/cmd_boot.c @@ -0,0 +1,64 @@ +/* + * (C) Copyright 2008-2011 + * Graeme Russ, graeme.r...@gmail.com + * + * (C) Copyright 2002 + * Daniel Engström, Omicron Ceti AB, dan...@omicron.se + * + * (C) Copyright 2002 + * Wolfgang Denk, DENX Software Engineering, w...@denx.de + * + * (C) Copyright 2002 + * Sysgo Real-Time Solutions, GmbH www.elinos.com + * Marius Groeger mgroe...@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 command.h +#include malloc.h +#include asm/u-boot-x86.h + +unsigned long do_go_exec(ulong (*entry)(int, char * const []), +int argc, char * const argv[]) +{ + unsigned long ret = 0; + char **argv_tmp; + + /* +* x86 does not use a dedicated register to pass the pointer to +* the global_data, so it is instead passed as argv[-1]. By using +* argv[-1], the called 'Application' can use the contents of +* argv natively. However, to safely use argv[-1] a new copy of +* argv is needed with the extra element +*/ + argv_tmp = malloc(sizeof(char *) * (argc + 1)); + + if (argv_tmp) { + argv_tmp[0] = (char *)gd; + + memcpy(argv_tmp[1], argv, (size_t)(sizeof(char *) * argc)); + + ret = (entry) (argc, argv_tmp[1]); + free(argv_tmp); + } + + return ret; +} -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 14/17] x86: Move setup_pcat_compatibility() out of board.c
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/lib/board.c |7 --- arch/x86/lib/zimage.c |7 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 533adf1..993e7df 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -486,10 +486,3 @@ void hang(void) for (;;) ; } - -void setup_pcat_compatibility(void) - __attribute__((weak, alias(__setup_pcat_compatibility))); - -void __setup_pcat_compatibility(void) -{ -} diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index bb40517..2214286 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -314,6 +314,13 @@ void boot_zimage(void *setup_base, void *load_address) #endif } +void setup_pcat_compatibility(void) + __attribute__((weak, alias(__setup_pcat_compatibility))); + +void __setup_pcat_compatibility(void) +{ +} + int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { struct boot_params *base_ptr; -- 1.7.5.2.317.g391b14 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 15/17] x86: Move relocation code out of board.c
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/lib/Makefile |1 + arch/x86/lib/board.c| 69 +--- arch/x86/lib/relocate.c | 115 +++ 3 files changed, 118 insertions(+), 67 deletions(-) create mode 100644 arch/x86/lib/relocate.c diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 7820895..57b6896 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -40,6 +40,7 @@ COBJS-$(CONFIG_SYS_GENERIC_TIMER) += pcat_timer.o COBJS-$(CONFIG_PCI) += pci.o COBJS-$(CONFIG_PCI) += pci_type1.o COBJS-$(CONFIG_SYS_X86_REALMODE) += realmode.o +COBJS-y+= relocate.o COBJS-y+= string.o COBJS-$(CONFIG_SYS_X86_ISR_TIMER) += timer.o COBJS-$(CONFIG_VIDEO) += video_bios.o diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 993e7df..fc7d0b7 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -41,7 +41,6 @@ #include ide.h #include serial.h #include asm/u-boot-x86.h -#include elf.h #include asm/processor.h #ifdef CONFIG_BITBANGMII @@ -117,9 +116,6 @@ static void display_flash_config(ulong size) typedef int (init_fnc_t) (void); static int calculate_relocation_address(void); -static int copy_uboot_to_ram(void); -static int clear_bss(void); -static int do_elf_reloc_fixups(void); static int copy_gd_to_ram(void); init_fnc_t *init_sequence_f[] = { @@ -183,59 +179,6 @@ static int calculate_relocation_address(void) return 0; } -static int copy_uboot_to_ram(void) -{ - size_t len = (size_t)(__data_end) - (size_t)(__text_start); - - memcpy((void *)gd-relocaddr, (void *)__text_start, len); - - return 0; -} - -static int clear_bss(void) -{ - ulong dst_addr = (ulong)(__bss_start) + gd-reloc_off; - size_t len = (size_t)(__bss_end) - (size_t)(__bss_start); - - memset((void *)dst_addr, 0x00, len); - - return 0; -} - -static int do_elf_reloc_fixups(void) -{ - Elf32_Rel *re_src = (Elf32_Rel *)(__rel_dyn_start); - Elf32_Rel *re_end = (Elf32_Rel *)(__rel_dyn_end); - - Elf32_Addr *offset_ptr_rom; - Elf32_Addr *offset_ptr_ram; - - /* The size of the region of u-boot that runs out of RAM. */ - uintptr_t size = (uintptr_t)__bss_end - (uintptr_t)__text_start; - - do { - /* Get the location from the relocation entry */ - offset_ptr_rom = (Elf32_Addr *)re_src-r_offset; - - /* Check that the location of the relocation is in .text */ - if (offset_ptr_rom = (Elf32_Addr *)CONFIG_SYS_TEXT_BASE) { - - /* Switch to the in-RAM version */ - offset_ptr_ram = (Elf32_Addr *)((ulong)offset_ptr_rom + - gd-reloc_off); - - /* Check that the target points into .text */ - if (*offset_ptr_ram = CONFIG_SYS_TEXT_BASE - *offset_ptr_ram - (CONFIG_SYS_TEXT_BASE + size)) { - *offset_ptr_ram += gd-reloc_off; - } - } - } while (re_src++ re_end); - - return 0; -} - /* Load U-Boot into RAM, initialize BSS, perform relocation adjustments */ void board_init_f(ulong boot_flags) { @@ -270,17 +213,9 @@ void board_init_f_r(void) if (init_cache() != 0) hang(); - copy_uboot_to_ram(); - clear_bss(); - do_elf_reloc_fixups(); - - /* -* 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); + relocate_code(0, gd, 0); - /* NOTREACHED - board_init_r() does not return */ + /* NOTREACHED - relocate_code() does not return */ while (1) ; } diff --git a/arch/x86/lib/relocate.c b/arch/x86/lib/relocate.c new file mode 100644 index 000..badb5f8 --- /dev/null +++ b/arch/x86/lib/relocate.c @@ -0,0 +1,115 @@ +/* + * (C) Copyright 2008-2011 + * Graeme Russ, graeme.r...@gmail.com + * + * (C) Copyright 2002 + * Daniel Engström, Omicron Ceti AB, dan...@omicron.se + * + * (C) Copyright 2002 + * Wolfgang Denk, DENX Software Engineering, w...@denx.de + * + * (C) Copyright 2002 + * Sysgo Real-Time Solutions, GmbH www.elinos.com + * Marius Groeger mgroe...@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 + *
[U-Boot] [PATCH 17/17] x86: Tweak initialisation procedure
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/include/asm/init_helpers.h |5 + arch/x86/include/asm/relocate.h | 33 ++ arch/x86/lib/board.c| 188 +-- arch/x86/lib/init_helpers.c | 75 ++ arch/x86/lib/relocate.c | 32 +- 5 files changed, 206 insertions(+), 127 deletions(-) create mode 100644 arch/x86/include/asm/relocate.h diff --git a/arch/x86/include/asm/init_helpers.h b/arch/x86/include/asm/init_helpers.h index 14ef11a..192f18e 100644 --- a/arch/x86/include/asm/init_helpers.h +++ b/arch/x86/include/asm/init_helpers.h @@ -27,7 +27,12 @@ int display_banner(void); int display_dram_config(void); int init_baudrate_f(void); +int calculate_relocation_address(void); +int copy_gd_to_ram_f_r(void); +int init_cache_f_r(void); + +int set_reloc_flag_r(void); int mem_malloc_init_r(void); int init_bd_struct_r(void); int flash_init_r(void); diff --git a/arch/x86/include/asm/relocate.h b/arch/x86/include/asm/relocate.h new file mode 100644 index 000..33129ef --- /dev/null +++ b/arch/x86/include/asm/relocate.h @@ -0,0 +1,33 @@ +/* + * (C) Copyright 2011 + * Graeme Russ, graeme.r...@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 _RELOCATE_H_ +#define _RELOCATE_H_ + +#include common.h + +int copy_uboot_to_ram(void); +int clear_bss(void); +int do_elf_reloc_fixups(void); + +#endif /* !_RELOCATE_H_ */ diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index f0a8e9c..d45b8fd 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -35,7 +35,7 @@ #include watchdog.h #include stdio_dev.h #include asm/u-boot-x86.h -#include asm/processor.h +#include asm/relocate.h #include asm/init_helpers.h #include asm/init_wrappers.h @@ -43,31 +43,58 @@ /* * Breath some life into the board... * - * Initialize an SMC for serial comms, and carry out some hardware - * tests. + * 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 first part of initialization is running from Flash memory; - * its main purpose is to initialize the RAM so that we - * can relocate the monitor code to RAM. + * 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 */ /* - * All attempts to come up with a common initialization sequence - * that works for all boards and architectures failed: some of the - * requirements are just _too_ different. To get rid of the resulting - * mess of board dependend #ifdef'ed code we now make the whole - * initialization sequence configurable to the user. - * - * The requirements for any new initalization function is simple: it - * receives a pointer to the global data structure as it's only - * argument, and returns an integer return code, where 0 means - * continue and != 0 means fatal error, hang the system. + * The requirements for any new initalization function is simple: it is + *
[U-Boot] [PATCH 16/17] x86: Simplify board.c
Signed-off-by: Graeme Russ graeme.r...@gmail.com --- arch/x86/include/asm/init_helpers.h | 39 + arch/x86/include/asm/init_wrappers.h | 42 + arch/x86/lib/Makefile|2 + arch/x86/lib/board.c | 297 +- arch/x86/lib/init_helpers.c | 142 arch/x86/lib/init_wrappers.c | 137 6 files changed, 438 insertions(+), 221 deletions(-) create mode 100644 arch/x86/include/asm/init_helpers.h create mode 100644 arch/x86/include/asm/init_wrappers.h create mode 100644 arch/x86/lib/init_helpers.c create mode 100644 arch/x86/lib/init_wrappers.c diff --git a/arch/x86/include/asm/init_helpers.h b/arch/x86/include/asm/init_helpers.h new file mode 100644 index 000..14ef11a --- /dev/null +++ b/arch/x86/include/asm/init_helpers.h @@ -0,0 +1,39 @@ +/* + * (C) Copyright 2011 + * Graeme Russ, graeme.r...@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_HELPERS_H_ +#define _INIT_HELPERS_H_ + +int display_banner(void); +int display_dram_config(void); +int init_baudrate_f(void); + +int mem_malloc_init_r(void); +int init_bd_struct_r(void); +int flash_init_r(void); +int init_ip_address_r(void); +int status_led_set_r(void); +int set_bootfile_r(void); +int set_load_addr_r(void); + +#endif /* !_INIT_HELPERS_H_ */ diff --git a/arch/x86/include/asm/init_wrappers.h b/arch/x86/include/asm/init_wrappers.h new file mode 100644 index 000..899ffb1 --- /dev/null +++ b/arch/x86/include/asm/init_wrappers.h @@ -0,0 +1,42 @@ +/* + * (C) Copyright 2011 + * Graeme Russ, graeme.r...@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_ */ diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 57b6896..51836da 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -34,6 +34,8 @@ COBJS-y += board.o 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 diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index fc7d0b7..f0a8e9c 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -33,62 +33,12 @@ #include common.h #include watchdog.h -#include command.h #include stdio_dev.h -#include version.h -#include malloc.h -#include net.h -#include ide.h -#include serial.h #include asm/u-boot-x86.h #include asm/processor.h -#ifdef CONFIG_BITBANGMII -#include miiphy.h -#endif - -/ - * Init Utilities * - - * Some of this code should be moved into the core functions, - * or dropped completely, - * but let's get it working (again) first... - */ -static int
[U-Boot] [PATCH] Change kernel address in dataflash to match u-boot's size
On at91sam platforms, u-boot grew larger than the allocated size in dataflash, the layout was: bootstrap 0x ubootenv 0x4200 uboot 0x8400 kernel 0x00042000 u-boot with the defconfig doesn't seem to fit in 0x42000 - 0x8400 = 0x39C00 bytes anymore. Loading the kernel from 0x44000 will make the process easier for users using the default configuration but they'll have to remember to flash the kernel at 0x44000. Signed-off-by: Alexandre Belloni alexandre.bell...@piout.net --- include/configs/at91sam9260ek.h |4 ++-- include/configs/at91sam9261ek.h |4 ++-- include/configs/at91sam9263ek.h |2 +- include/configs/at91sam9rlek.h |2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/configs/at91sam9260ek.h b/include/configs/at91sam9260ek.h index db52ee6..7f99975 100644 --- a/include/configs/at91sam9260ek.h +++ b/include/configs/at91sam9260ek.h @@ -188,7 +188,7 @@ #define CONFIG_ENV_OFFSET 0x4200 #define CONFIG_ENV_ADDR(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xC0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xC0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGSconsole=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ @@ -202,7 +202,7 @@ #define CONFIG_ENV_OFFSET 0x4200 #define CONFIG_ENV_ADDR(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xD0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xD0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGSconsole=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h index 5140b26..1aa6373 100644 --- a/include/configs/at91sam9261ek.h +++ b/include/configs/at91sam9261ek.h @@ -190,7 +190,7 @@ #define CONFIG_ENV_OFFSET 0x4200 #define CONFIG_ENV_ADDR(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xC0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xC0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGSconsole=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ @@ -204,7 +204,7 @@ #define CONFIG_ENV_OFFSET 0x4200 #define CONFIG_ENV_ADDR(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS3 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xD0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xD0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGSconsole=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ diff --git a/include/configs/at91sam9263ek.h b/include/configs/at91sam9263ek.h index 8399246..658ae73 100644 --- a/include/configs/at91sam9263ek.h +++ b/include/configs/at91sam9263ek.h @@ -317,7 +317,7 @@ #define CONFIG_ENV_OFFSET 0x4200 #define CONFIG_ENV_ADDR(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xC0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xC0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGSconsole=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ diff --git a/include/configs/at91sam9rlek.h b/include/configs/at91sam9rlek.h index 79ea1f2..dc6e007 100644 --- a/include/configs/at91sam9rlek.h +++ b/include/configs/at91sam9rlek.h @@ -156,7 +156,7 @@ #define CONFIG_ENV_OFFSET 0x4200 #define CONFIG_ENV_ADDR(CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xC0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xC0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGSconsole=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ -- 1.7.5.4 ___ U-Boot mailing list U-Boot@lists.denx.de
Re: [U-Boot] [PATCH] Change kernel address in dataflash to match u-boot's size
On at91sam platforms, u-boot grew larger than the allocated size in dataflash, the layout was: bootstrap 0x ubootenv 0x4200 uboot 0x8400 kernel 0x00042000 u-boot with the defconfig doesn't seem to fit in 0x42000 - 0x8400 = 0x39C00 bytes anymore. Loading the kernel from 0x44000 will make the process easier for users using the default configuration but they'll have to remember to flash the kernel at 0x44000. You're just pushing it slowly further. That's bogus: 1) ubootenv is at weird offset ... why such a weird number? Also, what about redund. env? 2) u-boot itself is at weird offset ... just set it to some normal location and let it be eg. up to 512kb big, to make sure you don't need to change it in the future. 3) Why is env at offset 0x4200 ... is the bootstrap exactly so big ? what about erasing nor, you can't make sure you won't overwrite those 0x200 bytes safely too, right ? = I'd do the layout like this: 0x0 - bootstrap 0x05000 - u-boot (align to block size) 0x85000 - env (~16kb) 0x89000 - env redund note, here's some space, so align as necessary 0x9 - kernel It wastes a bit, but it's ready for future growth M Signed-off-by: Alexandre Belloni alexandre.bell...@piout.net --- include/configs/at91sam9260ek.h |4 ++-- include/configs/at91sam9261ek.h |4 ++-- include/configs/at91sam9263ek.h |2 +- include/configs/at91sam9rlek.h |2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/configs/at91sam9260ek.h b/include/configs/at91sam9260ek.h index db52ee6..7f99975 100644 --- a/include/configs/at91sam9260ek.h +++ b/include/configs/at91sam9260ek.h @@ -188,7 +188,7 @@ #define CONFIG_ENV_OFFSET0x4200 #define CONFIG_ENV_ADDR (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xC0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xC0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGS console=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ @@ -202,7 +202,7 @@ #define CONFIG_ENV_OFFSET0x4200 #define CONFIG_ENV_ADDR (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xD0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xD0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGS console=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h index 5140b26..1aa6373 100644 --- a/include/configs/at91sam9261ek.h +++ b/include/configs/at91sam9261ek.h @@ -190,7 +190,7 @@ #define CONFIG_ENV_OFFSET0x4200 #define CONFIG_ENV_ADDR (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xC0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xC0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGS console=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ @@ -204,7 +204,7 @@ #define CONFIG_ENV_OFFSET0x4200 #define CONFIG_ENV_ADDR (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS3 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xD0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xD0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGS console=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ diff --git a/include/configs/at91sam9263ek.h b/include/configs/at91sam9263ek.h index 8399246..658ae73 100644 --- a/include/configs/at91sam9263ek.h +++ b/include/configs/at91sam9263ek.h @@ -317,7 +317,7 @@ #define CONFIG_ENV_OFFSET0x4200 #define CONFIG_ENV_ADDR (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + CONFIG_ENV_OFFSET) #define CONFIG_ENV_SIZE0x4200 -#define CONFIG_BOOTCOMMAND cp.b 0xC0042000 0x2200 0x21; bootm +#define CONFIG_BOOTCOMMAND cp.b 0xC0044000 0x2200 0x21; bootm #define CONFIG_BOOTARGS console=ttyS0,115200 \ root=/dev/mtdblock0 \ mtdparts=atmel_nand:-(root) \ diff --git a/include/configs/at91sam9rlek.h b/include/configs/at91sam9rlek.h index 79ea1f2..dc6e007 100644 ---
[U-Boot] NAND boot looks broken on P1020RDB
Hi, NAND boot implementation for P2020RDB/P1020RDB first copies u-boot to L2 SRAM, and then to DDR. This works for P2020, where L2 size is 512K, but breaks on P1020, where L2 size is 256K. Looks like NAND SPL for these platforms should not rely on L2 cache, and copy u-boot directly into DDR. Felix. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] NAND boot looks broken on P1020RDB
Hello Felix NAND boot must use DDR for P1020RDB. Infact it is DDR for P2020RDB also as per implementation. We need to change the CONFIG_SYS_TEXT_BASE to 0x11001000 as shown below for NAND boot in include/configs/P1_P2_RDB.h #ifdef CONFIG_NAND_SPL #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE_SPL #else #define CONFIG_SYS_TEXT_BASE0x11001000 #endif /* CONFIG_NAND_SPL */ #endif Looks like we missed to push this change, I will send a patch for this. Regards Poonam -Original Message- From: u-boot-boun...@lists.denx.de [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Felix Radensky Sent: Monday, January 02, 2012 11:28 AM To: U-Boot-Denx; Aggrwal Poonam-B10812; Kumar Gala Subject: [U-Boot] NAND boot looks broken on P1020RDB Hi, NAND boot implementation for P2020RDB/P1020RDB first copies u-boot to L2 SRAM, and then to DDR. This works for P2020, where L2 size is 512K, but breaks on P1020, where L2 size is 256K. Looks like NAND SPL for these platforms should not rely on L2 cache, and copy u-boot directly into DDR. Felix. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RFC PATCH 0/19] Create generic board init and move ARM and x86 to it
Dear Simon Glass, In message CAPnjgZ1eutEboyvEtYcxcZcv=1z_3tkq_45wbrgndpsnxrt...@mail.gmail.com you wrote: - getting generic relocation working I don;t see why this would be a direct prerequisite here. =A0We want to have that, no boubt about that. =A0But it appears to be an unrelated change to me. I don't think it's essential, but it is desirable, which I why it is on the list. I recommend to put this on a different list. Please keep changes orthogonal and restict this discussion and patch series to things dealing with the normalization of the board init code. This is complicated enough, and it does not good to include additional, unrelated tasks. - adding functions for anything that is missing from board init code anything that is missing from board init code ? By that I mean that if the architecture has its own little things which aren't supported by generic board init, then these would need to be worked into the generic board init somehow, perhaps initially with a new function in the initcall list. Such an approach will most probable result in a mess of code that is even more dificult to maintain than the current split we have now. - removing things which don't work on the architecture? That would probably reander systems broken that need these things? Sorry for being so vague. What I mean is that if an arch does not support a feature, then we don't want to call the init functions for it on that architecture. Sometimes this is handled automatically - e.g. if an arch does not support CONFIG_POST then the generic board init code will skip this anyway. But there may be other cases where features available in the generic board init cannot be supported in all archs. This is the same problem as above, right? Each architecture, and actually each board may or may not require certain initializations, and actually may require them to happen in a certain order (which may be different from other boards). Keep in mind that my original ida of providing a function call table was to allow to define this table in a board specific way (i. e. in the board config file). [Not that this idea found many friends...] With this series I have moved over to purely having a function call table, with no actual init code in board_init_f() and board_init_r(). This was the original plan. Having done this, I have found that the list of functions is very long, So we probably don't want boards to duplicate this list and #ifdefs may be the lesser of two evils. If we can move to Graham' I don't really see this as an practical approach. Did you look at the PPC code? init_sequence[] has a total of 29 entries, decorated with 21 conditionals. If we merge in ARM and x86, we will have a mess nobody is able to understand. For now I have tried to simply move the code into separate functions, since this makes it easier to compare against the original code in the arch/xxx/lib/board.c files, to make sure nothing is left out and the ordering is OK. Agreed. I'm not convinced it is the best idea. A trivial change of just removing duplicated code from all the archs and inserting it into generic board should be safe enough. But is that really a common case? I have found lots of subtle differences that need to be worked out, and there is the ordering to worry about. Every time there is a patch we need to re-test all boards. It might be easier to just create a generic board implementation one, and then test it once on each board, rather than testing on each board with every patch. Of course every time you patch generic board you might introduce a breakage in an existing (previously working) board, but that is the normal situation with development so I don't see a problem there. Perhaps the biggest problem is the difficulty of testing, and if we can avoid months of little patches (each one potentially breaking lots of boards at run-time) then I would prefer that. I am not sure that the whole approach makes sense. The resulkting mess of #ifdef's is not there because people didn't care, but because of very specific requirements of specific hardware, that - at least given the tools of the respective point of time - could not be solved more efficiently. I see two options here: - We can take the existing code and try to unify it, and make all boards (including a large number of EOLed and unmaintained ones) to that new code base. This will be a lot of work, and the resulting code will probably messy again. - We could as well try to come up with a new, cleaned up implementa- tion that maybe doesn't fit all, but only 80 or 90% of the existing boards. We could then (1) convert existing code step by step to the new implementation and (2) accept new submissions only when using the new code. There may be a number of boards where conversion is non trivial, or where nobody is willing or able to perform the changes and / or the testing. My gut