From debb7354d1ea4f694154818df5e5b523f5c1cc1d Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Wed, 26 Apr 2006 17:58:56 -0500 Subject: Initial support for MPC8641 HPCN board. --- common/ft_build.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/ft_build.c b/common/ft_build.c index 9e9c906fc1..782046ddae 100644 --- a/common/ft_build.c +++ b/common/ft_build.c @@ -299,16 +299,16 @@ static void print_data(const void *data, int len) switch (len) { case 1: /* byte */ - printf(" = <0x%02x>", (*(u8 *) data) & 0xff); + printf(" = <%02x>", (*(u8 *) data) & 0xff); break; case 2: /* half-word */ - printf(" = <0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff); + printf(" = <%04x>", be16_to_cpu(*(u16 *) data) & 0xffff); break; case 4: /* word */ - printf(" = <0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); + printf(" = <%x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); break; case 8: /* double-word */ - printf(" = <0x%16llx>", be64_to_cpu(*(uint64_t *) data)); + printf(" = <%qx>", be64_to_cpu(*(uint64_t *) data)); break; default: /* anything else... hexdump */ printf(" = ["); @@ -350,7 +350,7 @@ void ft_dump_blob(const void *bphp) if (addr == 0 && size == 0) break; - printf("/memreserve/ 0x%llx 0x%llx;\n", addr, size); + printf("/memreserve/ %qx %qx;\n", addr, size); } p = p_struct; -- cgit v1.2.1 From 6cfea33477b04b63ed47386ed1629529484c33ba Mon Sep 17 00:00:00 2001 From: Haiying Wang Date: Wed, 10 May 2006 09:38:06 -0500 Subject: Remove unneeded INIT_RAM_LOCK cache twiddling. Correctly tracks r29 as global data pointer now. Signed-off-by: Haiying Wang --- common/cmd_bootm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index fdf7180a19..e5d70fa202 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -809,7 +809,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, #ifndef CONFIG_OF_FLAT_TREE -#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) +#if defined(CFG_INIT_RAM_LOCK) && (!defined(CONFIG_E500) || !defined(CONFIG_MPC86xx)) unlock_ram_in_cache(); #endif @@ -827,7 +827,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, ft_setup(of_flat_tree, OF_FLAT_TREE_MAX_SIZE, kbd, initrd_start, initrd_end); /* ft_dump_blob(of_flat_tree); */ -#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) +#if defined(CFG_INIT_RAM_LOCK) && (!defined(CONFIG_E500)||!defined(CONFIG_MPC86xx)) unlock_ram_in_cache(); #endif /* -- cgit v1.2.1 From 3033ebb20fd7c372c7bca3c9955a4692bb2240b7 Mon Sep 17 00:00:00 2001 From: Haiying Wang Date: Fri, 26 May 2006 10:01:16 -0500 Subject: Allow args on reset command. Signed-off-by: Jon Loeliger --- common/cmd_boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_boot.c b/common/cmd_boot.c index e68f16f9da..182e2ab980 100644 --- a/common/cmd_boot.c +++ b/common/cmd_boot.c @@ -83,7 +83,7 @@ U_BOOT_CMD( extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); U_BOOT_CMD( - reset, 1, 0, do_reset, + reset, CFG_MAXARGS, 1, do_reset, "reset - Perform RESET of the CPU\n", NULL ); -- cgit v1.2.1 From e6cd2a1785d74ec3d30a86f1cb360be8de478151 Mon Sep 17 00:00:00 2001 From: Jason Jin Date: Fri, 7 Jul 2006 10:01:45 -0500 Subject: We made a u-boot patch to fix the hang up issue when booting filesystem from ramdisk. Signed-off-by:Jason Jin --- common/cmd_bootm.c | 1 + 1 file changed, 1 insertion(+) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index e5d70fa202..a78a16df9c 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -538,6 +538,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, initrd_copy_to_ram = 0; } else { /* not set, no restrictions to load high */ initrd_high = ~0; + initrd_copy_to_ram = 0; } #ifdef CONFIG_LOGBUFFER -- cgit v1.2.1 From fcb28e763415e0e4e66b0f45842d1557ae198e5e Mon Sep 17 00:00:00 2001 From: Jin Zhengxiong Date: Thu, 13 Jul 2006 10:35:10 -0500 Subject: Fixed initrd issue by define big RAM Signed-off-by:Jason Jin --- common/cmd_bootm.c | 1 - 1 file changed, 1 deletion(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index a78a16df9c..e5d70fa202 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -538,7 +538,6 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, initrd_copy_to_ram = 0; } else { /* not set, no restrictions to load high */ initrd_high = ~0; - initrd_copy_to_ram = 0; } #ifdef CONFIG_LOGBUFFER -- cgit v1.2.1 From bea3f28d285942bf3f7ab339ce85178ded544225 Mon Sep 17 00:00:00 2001 From: Haiying Wang Date: Wed, 12 Jul 2006 10:48:05 -0400 Subject: Add support for reading and writing mac addresses to or from ID EEPROM. Added code for reading and writing Mac addresses to/from ID EEPROM(0x57). With attached patch, we can use command "mac/mac read/mac save/" to read and write EEPROM under u-boot prompt. U-boot will calculate the checksum of EEPROM while bootup, if it is right, then u-boot will check whether the mac address of eTSEC0/1/2/3 is availalbe (non-zero). If there is mac address availabe in EEPROM, u-boot will use it, otherewise, u-boot will use the mac address defined in MPC8641HPCN.h. This matches the requirement to set unique mac address for each TSEC port. Signed-off-by: Haiying Wang Signed-off-by: York Sun --- common/Makefile | 2 +- common/cmd_mac.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 common/cmd_mac.c (limited to 'common') diff --git a/common/Makefile b/common/Makefile index eb0b5dadfe..a62bc16e85 100644 --- a/common/Makefile +++ b/common/Makefile @@ -51,7 +51,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o \ memsize.o miiphybb.o miiphyutil.o \ s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o spartan3.o \ usb.o usb_kbd.o usb_storage.o \ - virtex2.o xilinx.o crc16.o xyzModem.o + virtex2.o xilinx.o crc16.o xyzModem.o cmd_mac.o OBJS = $(AOBJS) $(COBJS) diff --git a/common/cmd_mac.c b/common/cmd_mac.c new file mode 100644 index 0000000000..0add43285f --- /dev/null +++ b/common/cmd_mac.c @@ -0,0 +1,66 @@ +/* + * Copyright 2006 Freescale Semiconductor + * York Sun (yorksun@freescale.com) + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include + +#ifdef CFG_ID_EEPROM + +extern int do_mac(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + +U_BOOT_CMD( + mac, 3, 1, do_mac, + "mac - display and program the system ID and MAC addresses in EEPROM\n", + "[read|save|id|num|errata|date|ports|0|1|2|3|4|5|6|7]\n" + "read\n" + " - show content of mac\n" + "mac save\n" + " - save to the EEPROM\n" + "mac id\n" + " - program system id\n" + "mac num\n" + " - program system serial number\n" + "mac errata\n" + " - program errata data\n" + "mac date\n" + " - program data date\n" + "mac ports\n" + " - program the number of ports\n" + "mac 0\n" + " - program the MAC address for port 0\n" + "mac 1\n" + " - program the MAC address for port 1\n" + "mac 2\n" + " - program the MAC address for port 2\n" + "mac 3\n" + " - program the MAC address for port 3\n" + "mac 4\n" + " - program the MAC address for port 4\n" + "mac 5\n" + " - program the MAC address for port 5\n" + "mac 6\n" + " - program the MAC address for port 6\n" + "mac 7\n" + " - program the MAC address for port 7\n" +); +#endif /* CFG_ID_EEPROM */ -- cgit v1.2.1 From 0267768eddc5ca7bc1865bc40c866829ac5efbfe Mon Sep 17 00:00:00 2001 From: Matthew McClintock Date: Wed, 28 Jun 2006 10:41:37 -0500 Subject: * Modify bootm command to support booting with flat device trees Patch by Matthew McClintock 26-June-2006 --- common/cmd_bootm.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index fdf7180a19..a472a1d7b2 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -465,6 +465,13 @@ U_BOOT_CMD( "[addr [arg ...]]\n - boot application image stored in memory\n" "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n" "\t'arg' can be the address of an initrd image\n" +#ifdef CONFIG_OF_FLAT_TREE + "\tWhen booting a Linux kernel which requires a flat device-tree\n" + "\ta third argument is required which is the address of the of the\n" + "\tdevice-tree blob. To boot that kernel without an initrd image,\n" + "\tuse a '-' for the second argument. If you do not pass a third\n" + "\ta bd_info struct will be passed instead\n" +#endif ); #ifdef CONFIG_SILENT_CONSOLE @@ -500,11 +507,6 @@ fixup_silent_linux () } #endif /* CONFIG_SILENT_CONSOLE */ -#ifdef CONFIG_OF_FLAT_TREE -extern const unsigned char oftree_dtb[]; -extern const unsigned int oftree_dtb_len; -#endif - #ifdef CONFIG_PPC static void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, @@ -616,7 +618,17 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, /* * Check if there is an initrd image */ + +#ifdef CONFIG_OF_FLAT_TREE + /* Look for a '-' which indicates to ignore the ramdisk argument */ + if (argc >= 3 && strcmp(argv[2], "-") == 0) { + debug ("Skipping initrd\n"); + data = 0; + } + else +#endif if (argc >= 3) { + debug ("Not skipping initrd\n"); SHOW_BOOT_PROGRESS (9); addr = simple_strtoul(argv[2], NULL, 16); @@ -724,6 +736,15 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, len = data = 0; } +#ifdef CONFIG_OF_FLAT_TREE + if (argc >= 3) + { + of_flat_tree = (char *) simple_strtoul(argv[3], NULL, 16); + printf ("Booting using flat device tree at 0x%x\n", + of_flat_tree); + } +#endif + if (!data) { debug ("No initrd\n"); } @@ -793,15 +814,6 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, initrd_end = 0; } -#ifdef CONFIG_OF_FLAT_TREE - if (initrd_start == 0) - of_flat_tree = (char *)(((ulong)kbd - OF_FLAT_TREE_MAX_SIZE - - sizeof(bd_t)) & ~0xF); - else - of_flat_tree = (char *)((initrd_start - OF_FLAT_TREE_MAX_SIZE - - sizeof(bd_t)) & ~0xF); -#endif - debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong)kernel); -- cgit v1.2.1 From 5498d90312aad9f6bdbf047986027c35b03cd163 Mon Sep 17 00:00:00 2001 From: Matthew McClintock Date: Wed, 28 Jun 2006 10:42:24 -0500 Subject: * Patch to modify ft_build.c to update flat device trees in place Patch by Matthew McClintock 26-June-2006 --- common/cmd_bootm.c | 2 +- common/ft_build.c | 341 ++++++++++++++++------------------------------------- 2 files changed, 105 insertions(+), 238 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index a472a1d7b2..f1c0eb4d18 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -836,7 +836,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); #else - ft_setup(of_flat_tree, OF_FLAT_TREE_MAX_SIZE, kbd, initrd_start, initrd_end); + ft_setup(of_flat_tree, kbd, initrd_start, initrd_end); /* ft_dump_blob(of_flat_tree); */ #if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) diff --git a/common/ft_build.c b/common/ft_build.c index 9e9c906fc1..b5a997c1ba 100644 --- a/common/ft_build.c +++ b/common/ft_build.c @@ -1,5 +1,22 @@ /* * OF flat tree builder + * Written by: Pantelis Antoniou + * Updated by: Matthew McClintock + * + * 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 @@ -13,44 +30,39 @@ #include +#undef DEBUG + /* align addr on a size boundary - adjust address up if needed -- Cort */ #define _ALIGN(addr,size) (((addr)+(size)-1)&(~((size)-1))) +#ifndef CONFIG_OF_BOOT_CPU +#define CONFIG_OF_BOOT_CPU 0 +#endif +#define SIZE_OF_RSVMAP_ENTRY (2*sizeof(u64)) static void ft_put_word(struct ft_cxt *cxt, u32 v) { - if (cxt->overflow) /* do nothing */ - return; - - /* check for overflow */ - if (cxt->p + 4 > cxt->pstr) { - cxt->overflow = 1; - return; - } + memmove(cxt->p + sizeof(u32), cxt->p, cxt->p_end - cxt->p); *(u32 *) cxt->p = cpu_to_be32(v); - cxt->p += 4; + cxt->p += sizeof(u32); + cxt->p_end += sizeof(u32); } static inline void ft_put_bin(struct ft_cxt *cxt, const void *data, int sz) { - u8 *p; + int aligned_size = ((u8 *)_ALIGN((unsigned long)cxt->p + sz, + sizeof(u32))) - cxt->p; - if (cxt->overflow) /* do nothing */ - return; - - /* next pointer pos */ - p = (u8 *) _ALIGN((unsigned long)cxt->p + sz, 4); + memmove(cxt->p + aligned_size, cxt->p, cxt->p_end - cxt->p); - /* check for overflow */ - if (p > cxt->pstr) { - cxt->overflow = 1; - return; - } + /* make sure the last bytes are zeroed */ + memset(cxt->p + aligned_size - (aligned_size % sizeof(u32)), 0, + (aligned_size % sizeof(u32))); memcpy(cxt->p, data, sz); - if ((sz & 3) != 0) - memset(cxt->p + sz, 0, 4 - (sz & 3)); - cxt->p = p; + + cxt->p += aligned_size; + cxt->p_end += aligned_size; } void ft_begin_node(struct ft_cxt *cxt, const char *name) @@ -73,10 +85,10 @@ static int lookup_string(struct ft_cxt *cxt, const char *name) { u8 *p; - p = cxt->pstr; - while (p < cxt->pstr_begin) { + p = cxt->p; + while (p < cxt->p_end) { if (strcmp(p, name) == 0) - return p - cxt->p_begin; + return p - cxt->p; p += strlen(p) + 1; } @@ -85,24 +97,13 @@ static int lookup_string(struct ft_cxt *cxt, const char *name) void ft_prop(struct ft_cxt *cxt, const char *name, const void *data, int sz) { - int len, off; - - if (cxt->overflow) - return; - - len = strlen(name) + 1; + int off = 0; off = lookup_string(cxt, name); if (off == -1) { - /* check if we have space */ - if (cxt->p + 12 + sz + len > cxt->pstr) { - cxt->overflow = 1; - return; - } - - cxt->pstr -= len; - memcpy(cxt->pstr, name, len); - off = cxt->pstr - cxt->p_begin; + memcpy(cxt->p_end, name, strlen(name) + 1); + off = cxt->p_end - cxt->p; + cxt->p_end += strlen(name) + 2; } /* now put offset from beginning of *STRUCTURE* */ @@ -122,138 +123,63 @@ void ft_prop_int(struct ft_cxt *cxt, const char *name, int val) { u32 v = cpu_to_be32((u32) val); - ft_prop(cxt, name, &v, 4); + ft_prop(cxt, name, &v, sizeof(u32)); } -/* start construction of the flat OF tree */ -void ft_begin(struct ft_cxt *cxt, void *blob, int max_size) +/* pick up and start working on a tree in place */ +void ft_init_cxt(struct ft_cxt *cxt, void *blob) { struct boot_param_header *bph = blob; - u32 off; - /* clear the cxt */ memset(cxt, 0, sizeof(*cxt)); cxt->bph = bph; - cxt->max_size = max_size; - - /* zero everything in the header area */ - memset(bph, 0, sizeof(*bph)); - - bph->magic = cpu_to_be32(OF_DT_HEADER); - bph->version = cpu_to_be32(0x10); - bph->last_comp_version = cpu_to_be32(0x10); + bph->boot_cpuid_phys = CONFIG_OF_BOOT_CPU; - /* start pointers */ - cxt->pres_begin = (u8 *) _ALIGN((unsigned long)(bph + 1), 8); - cxt->pres = cxt->pres_begin; - - off = (unsigned long)cxt->pres_begin - (unsigned long)bph; - bph->off_mem_rsvmap = cpu_to_be32(off); - - ((u64 *) cxt->pres)[0] = 0; /* phys = 0, size = 0, terminate */ - ((u64 *) cxt->pres)[1] = 0; + /* find beginning and end of reserve map table (zeros in last entry) */ + cxt->p_rsvmap = (u8 *)bph + bph->off_mem_rsvmap; + while ( ((uint64_t *)cxt->p_rsvmap)[0] != 0 && + ((uint64_t *)cxt->p_rsvmap)[1] != 0 ) { + cxt->p_rsvmap += SIZE_OF_RSVMAP_ENTRY; + } - cxt->p_anchor = cxt->pres + 16; /* over the terminator */ + cxt->p_start = (char*)bph + bph->off_dt_struct; + cxt->p_end = (char *)bph + bph->totalsize; + cxt->p = (char *)bph + bph->off_dt_strings; } /* add a reserver physical area to the rsvmap */ -void ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size) +void ft_add_rsvmap(struct ft_cxt *cxt, u64 physstart, u64 physend) { - ((u64 *) cxt->pres)[0] = cpu_to_be64(physaddr); /* phys = 0, size = 0, terminate */ - ((u64 *) cxt->pres)[1] = cpu_to_be64(size); - - cxt->pres += 16; /* advance */ - - ((u64 *) cxt->pres)[0] = 0; /* phys = 0, size = 0, terminate */ - ((u64 *) cxt->pres)[1] = 0; - - /* keep track of size */ - cxt->res_size = cxt->pres + 16 - cxt->pres_begin; - - cxt->p_anchor = cxt->pres + 16; /* over the terminator */ + memmove(cxt->p_rsvmap + SIZE_OF_RSVMAP_ENTRY, cxt->p_rsvmap, + cxt->p_end - cxt->p_rsvmap); + + ((u64 *)cxt->p_rsvmap)[0] = cpu_to_be64(physstart); + ((u64 *)cxt->p_rsvmap)[1] = cpu_to_be64(physend); + ((u64 *)cxt->p_rsvmap)[2] = 0; + ((u64 *)cxt->p_rsvmap)[3] = 0; + + cxt->p_rsvmap += SIZE_OF_RSVMAP_ENTRY; + cxt->p_start += SIZE_OF_RSVMAP_ENTRY; + cxt->p += SIZE_OF_RSVMAP_ENTRY; + cxt->p_end += SIZE_OF_RSVMAP_ENTRY; } -void ft_begin_tree(struct ft_cxt *cxt) +void ft_end_tree(struct ft_cxt *cxt) { - cxt->p_begin = cxt->p_anchor; - cxt->pstr_begin = (char *)cxt->bph + cxt->max_size; /* point at the end */ - - cxt->p = cxt->p_begin; - cxt->pstr = cxt->pstr_begin; + ft_put_word(cxt, OF_DT_END); } -int ft_end_tree(struct ft_cxt *cxt) -{ +/* update the boot param header with correct values */ +void ft_finalize_tree(struct ft_cxt *cxt) { struct boot_param_header *bph = cxt->bph; - int off, sz, sz1; - u32 tag, v; - u8 *p; - - ft_put_word(cxt, OF_DT_END); - - if (cxt->overflow) - return -ENOMEM; - - /* size of the areas */ - cxt->struct_size = cxt->p - cxt->p_begin; - cxt->strings_size = cxt->pstr_begin - cxt->pstr; - - /* the offset we must move */ - off = (cxt->pstr_begin - cxt->p_begin) - cxt->strings_size; - - /* the new strings start */ - cxt->pstr_begin = cxt->p_begin + cxt->struct_size; - - /* move the whole string area */ - memmove(cxt->pstr_begin, cxt->pstr, cxt->strings_size); - /* now perform the fixup of the strings */ - p = cxt->p_begin; - while ((tag = be32_to_cpu(*(u32 *) p)) != OF_DT_END) { - p += 4; - - if (tag == OF_DT_BEGIN_NODE) { - p = (u8 *) _ALIGN((unsigned long)p + strlen(p) + 1, 4); - continue; - } - - if (tag == OF_DT_END_NODE || tag == OF_DT_NOP) - continue; - - if (tag != OF_DT_PROP) - return -EINVAL; - - sz = be32_to_cpu(*(u32 *) p); - p += 4; - - v = be32_to_cpu(*(u32 *) p); - v -= off; - *(u32 *) p = cpu_to_be32(v); /* move down */ - p += 4; - - p = (u8 *) _ALIGN((unsigned long)p + sz, 4); - } - - /* fix sizes */ - p = (char *)cxt->bph; - sz = (cxt->pstr_begin + cxt->strings_size) - p; - sz1 = _ALIGN(sz, 16); /* align at 16 bytes */ - if (sz != sz1) - memset(p + sz, 0, sz1 - sz); - bph->totalsize = cpu_to_be32(sz1); - bph->off_dt_struct = cpu_to_be32(cxt->p_begin - p); - bph->off_dt_strings = cpu_to_be32(cxt->pstr_begin - p); - - /* the new strings start */ - cxt->pstr_begin = cxt->p_begin + cxt->struct_size; - cxt->pstr = cxt->pstr_begin + cxt->strings_size; - - return 0; + bph->totalsize = cxt->p_end - (u8 *)bph; + bph->off_dt_struct = cxt->p_start - (u8 *)bph; + bph->off_dt_strings = cxt->p - (u8 *)bph; + bph->dt_strings_size = cxt->p_end - cxt->p; } -/**********************************************************************/ - static inline int isprint(int c) { return c >= 0x20 && c <= 0x7e; @@ -299,16 +225,16 @@ static void print_data(const void *data, int len) switch (len) { case 1: /* byte */ - printf(" = <0x%02x>", (*(u8 *) data) & 0xff); + printf(" = <%02x>", (*(u8 *) data) & 0xff); break; case 2: /* half-word */ - printf(" = <0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff); + printf(" = <%04x>", be16_to_cpu(*(u16 *) data) & 0xffff); break; case 4: /* word */ - printf(" = <0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); + printf(" = <%x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); break; case 8: /* double-word */ - printf(" = <0x%16llx>", be64_to_cpu(*(uint64_t *) data)); + printf(" = <%qx>", be64_to_cpu(*(uint64_t *) data)); break; default: /* anything else... hexdump */ printf(" = ["); @@ -350,7 +276,7 @@ void ft_dump_blob(const void *bphp) if (addr == 0 && size == 0) break; - printf("/memreserve/ 0x%llx 0x%llx;\n", addr, size); + printf("/memreserve/ %qx %qx;\n", addr, size); } p = p_struct; @@ -381,8 +307,8 @@ void ft_dump_blob(const void *bphp) } if (tag != OF_DT_PROP) { - fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", - depth * shift, "", tag); + fprintf(stderr, "%*s ** Unknown tag 0x%08x at 0x%x\n", + depth * shift, "", tag, --p); break; } sz = be32_to_cpu(*p++); @@ -397,64 +323,15 @@ void ft_dump_blob(const void *bphp) void ft_backtrack_node(struct ft_cxt *cxt) { - if (be32_to_cpu(*(u32 *) (cxt->p - 4)) != OF_DT_END_NODE) - return; /* XXX only for node */ - - cxt->p -= 4; -} - -/* note that the root node of the blob is "peeled" off */ -void ft_merge_blob(struct ft_cxt *cxt, void *blob) -{ - struct boot_param_header *bph = (struct boot_param_header *)blob; - u32 *p_struct = (u32 *) ((char *)bph + be32_to_cpu(bph->off_dt_struct)); - u32 *p_strings = - (u32 *) ((char *)bph + be32_to_cpu(bph->off_dt_strings)); - u32 tag, *p; - char *s, *t; - int depth, sz; - - if (be32_to_cpu(*(u32 *) (cxt->p - 4)) != OF_DT_END_NODE) - return; /* XXX only for node */ - - cxt->p -= 4; - - depth = 0; - p = p_struct; - while ((tag = be32_to_cpu(*p++)) != OF_DT_END) { - - /* printf("tag: 0x%08x (%d) - %d\n", tag, p - p_struct, depth); */ - - if (tag == OF_DT_BEGIN_NODE) { - s = (char *)p; - p = (u32 *) _ALIGN((unsigned long)p + strlen(s) + 1, 4); - - if (depth++ > 0) - ft_begin_node(cxt, s); - - continue; - } - - if (tag == OF_DT_END_NODE) { - ft_end_node(cxt); - if (--depth == 0) - break; - continue; - } - - if (tag == OF_DT_NOP) - continue; + int i = 4; - if (tag != OF_DT_PROP) - break; + while (be32_to_cpu(*(u32 *) (cxt->p - i)) != OF_DT_END_NODE) + i += 4; - sz = be32_to_cpu(*p++); - s = (char *)p_strings + be32_to_cpu(*p++); - t = (char *)p; - p = (u32 *) _ALIGN((unsigned long)p + sz, 4); + memmove (cxt->p - i, cxt->p, cxt->p_end - cxt->p); - ft_prop(cxt, s, t, sz); - } + cxt->p_end -= i; + cxt->p -= i; } void *ft_get_prop(void *bphp, const char *propname, int *szp) @@ -521,9 +398,6 @@ void *ft_get_prop(void *bphp, const char *propname, int *szp) /********************************************************************/ -extern unsigned char oftree_dtb[]; -extern unsigned int oftree_dtb_len; - /* Function that returns a character from the environment */ extern uchar(*env_get_char) (int); @@ -577,7 +451,7 @@ static const struct { }; #endif -void ft_setup(void *blob, int size, bd_t * bd, ulong initrd_start, ulong initrd_end) +void ft_setup(void *blob, bd_t * bd, ulong initrd_start, ulong initrd_end) { u32 *p; int len; @@ -600,20 +474,16 @@ void ft_setup(void *blob, int size, bd_t * bd, ulong initrd_start, ulong initrd_ return; } - ft_begin(&cxt, blob, size); +#ifdef DEBUG + printf ("recieved oftree\n"); + ft_dump_blob(blob); +#endif + + ft_init_cxt(&cxt, blob); if (initrd_start && initrd_end) ft_add_rsvmap(&cxt, initrd_start, initrd_end - initrd_start + 1); - ft_begin_tree(&cxt); - - ft_begin_node(&cxt, ""); - - ft_end_node(&cxt); - - /* copy RO tree */ - ft_merge_blob(&cxt, oftree_dtb); - /* back into root */ ft_backtrack_node(&cxt); @@ -642,8 +512,8 @@ void ft_setup(void *blob, int size, bd_t * bd, ulong initrd_start, ulong initrd_ #endif ft_begin_node(&cxt, "chosen"); - ft_prop_str(&cxt, "name", "chosen"); + ft_prop_str(&cxt, "bootargs", getenv("bootargs")); ft_prop_int(&cxt, "linux,platform", 0x600); /* what is this? */ if (initrd_start && initrd_end) { @@ -659,11 +529,7 @@ void ft_setup(void *blob, int size, bd_t * bd, ulong initrd_start, ulong initrd_ ft_end_node(&cxt); /* end root */ ft_end_tree(&cxt); - - /* - printf("merged OF-tree\n"); - ft_dump_blob(blob); - */ + ft_finalize_tree(&cxt); #ifdef CONFIG_OF_HAS_BD_T /* paste the bd_t at the end of the flat tree */ @@ -712,11 +578,12 @@ void ft_setup(void *blob, int size, bd_t * bd, ulong initrd_start, ulong initrd_ ft_board_setup(blob, bd); #endif - /* - printf("final OF-tree\n"); - ft_dump_blob(blob); - */ + /* in case the size changed in the platform code */ + ft_finalize_tree(&cxt); +#ifdef DEBUG + printf("final OF-tree\n"); + ft_dump_blob(blob); +#endif } - #endif -- cgit v1.2.1 From 1c8f6d8fb028f156094d05f2d14298e6479364ac Mon Sep 17 00:00:00 2001 From: Haiying Wang Date: Tue, 15 Aug 2006 15:12:55 -0400 Subject: Unlock cache before kernel starts up for MPC86xx --- common/cmd_bootm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 0225cb7f27..f1c0eb4d18 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -821,7 +821,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, #ifndef CONFIG_OF_FLAT_TREE -#if defined(CFG_INIT_RAM_LOCK) && (!defined(CONFIG_E500) || !defined(CONFIG_MPC86xx)) +#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) unlock_ram_in_cache(); #endif @@ -839,7 +839,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, ft_setup(of_flat_tree, kbd, initrd_start, initrd_end); /* ft_dump_blob(of_flat_tree); */ -#if defined(CFG_INIT_RAM_LOCK) && (!defined(CONFIG_E500)||!defined(CONFIG_MPC86xx)) +#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) unlock_ram_in_cache(); #endif /* -- cgit v1.2.1 From 75c299c38369d01addd5e054b8a16217b70f4a86 Mon Sep 17 00:00:00 2001 From: Haiying Wang Date: Tue, 15 Aug 2006 15:12:55 -0400 Subject: Unlock cache before kernel starts up for MPC86xx --- common/cmd_bootm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index e5d70fa202..fdf7180a19 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -809,7 +809,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, #ifndef CONFIG_OF_FLAT_TREE -#if defined(CFG_INIT_RAM_LOCK) && (!defined(CONFIG_E500) || !defined(CONFIG_MPC86xx)) +#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) unlock_ram_in_cache(); #endif @@ -827,7 +827,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, ft_setup(of_flat_tree, OF_FLAT_TREE_MAX_SIZE, kbd, initrd_start, initrd_end); /* ft_dump_blob(of_flat_tree); */ -#if defined(CFG_INIT_RAM_LOCK) && (!defined(CONFIG_E500)||!defined(CONFIG_MPC86xx)) +#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) unlock_ram_in_cache(); #endif /* -- cgit v1.2.1 From 87a449c8ac396420cb24260f717ea9e6faa82047 Mon Sep 17 00:00:00 2001 From: Matthew McClintock Date: Tue, 22 Aug 2006 09:23:55 -0500 Subject: Support for FDT in uImage format, error when using FDT from flash Signed-off-by: Matthew McClintock --- common/cmd_bootm.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index f1c0eb4d18..f980659f7b 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -528,7 +528,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, void (*kernel)(bd_t *, ulong, ulong, ulong, ulong); image_header_t *hdr = &header; #ifdef CONFIG_OF_FLAT_TREE - char *of_flat_tree; + char *of_flat_tree = NULL; #endif if ((s = getenv ("initrd_high")) != NULL) { @@ -737,14 +737,73 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, } #ifdef CONFIG_OF_FLAT_TREE - if (argc >= 3) - { + if(argc >= 3) { of_flat_tree = (char *) simple_strtoul(argv[3], NULL, 16); - printf ("Booting using flat device tree at 0x%x\n", + hdr = (image_header_t *)of_flat_tree; + + if (*(ulong *)of_flat_tree == OF_DT_HEADER) { +#ifndef CFG_NO_FLASH + if (addr2info((ulong)of_flat_tree) != NULL) { + printf ("Cannot modify flat device tree stored in flash\n" \ + "Copy to memory before using the bootm command\n"); + return; + } +#endif + } else if (ntohl(hdr->ih_magic) == IH_MAGIC) { + printf("## Flat Device Tree Image at %08lX\n", hdr); + print_image_hdr(hdr); + + if ((ntohl(hdr->ih_load) < ((unsigned long)hdr + ntohl(hdr->ih_size) + sizeof(hdr))) && + ((ntohl(hdr->ih_load) + ntohl(hdr->ih_size)) > (unsigned long)hdr)) { + printf ("ERROR: Load address overwrites Flat Device Tree uImage\n"); + return; + } + + printf(" Verifying Checksum ... "); + memmove (&header, (char *)hdr, sizeof(image_header_t)); + checksum = ntohl(header.ih_hcrc); + header.ih_hcrc = 0; + + if(checksum != crc32(0, (uchar *)&header, sizeof(image_header_t))) { + printf("ERROR: Flat Device Tree header checksum is invalid\n"); + return; + } + + checksum = ntohl(hdr->ih_dcrc); + addr = (ulong)((uchar *)(hdr) + sizeof(image_header_t)); + len = ntohl(hdr->ih_size); + + if(checksum != crc32(0, (uchar *)addr, len)) { + printf("ERROR: Flat Device Tree checksum is invalid\n"); + return; + } + printf("OK\n"); + + if (ntohl(hdr->ih_type) != IH_TYPE_FLATDT) { + printf ("ERROR: uImage not Flat Device Tree type\n"); + return; + } + if (ntohl(hdr->ih_comp) != IH_COMP_NONE) { + printf("ERROR: uImage is not uncompressed\n"); + return; + } + if (*((ulong *)(of_flat_tree + sizeof(image_header_t))) != OF_DT_HEADER) { + printf ("ERROR: uImage data is not a flat device tree\n"); + return; + } + + memmove((void *)ntohl(hdr->ih_load), + (void *)(of_flat_tree + sizeof(image_header_t)), + ntohl(hdr->ih_size)); + of_flat_tree = (char *)ntohl(hdr->ih_load); + } else { + printf ("Did not find a flat flat device tree at address %08lX\n", of_flat_tree); + return; + } + printf (" Booting using flat device tree at 0x%x\n", of_flat_tree); } #endif - if (!data) { debug ("No initrd\n"); } @@ -1272,6 +1331,7 @@ print_type (image_header_t *hdr) case IH_TYPE_MULTI: type = "Multi-File Image"; break; case IH_TYPE_FIRMWARE: type = "Firmware"; break; case IH_TYPE_SCRIPT: type = "Script"; break; + case IH_TYPE_FLATDT: type = "Flat Device Tree"; break; default: type = "Unknown Image"; break; } -- cgit v1.2.1 From 5de62c47a8628b3da4d73f7c07027f32a3342d40 Mon Sep 17 00:00:00 2001 From: Matthew McClintock Date: Tue, 22 Aug 2006 09:31:59 -0500 Subject: Fix disable_of booting Signed-off-by: Matthew McClintock --- common/cmd_bootm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index f980659f7b..652d8431da 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -737,7 +737,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, } #ifdef CONFIG_OF_FLAT_TREE - if(argc >= 3) { + if(argc > 3) { of_flat_tree = (char *) simple_strtoul(argv[3], NULL, 16); hdr = (image_header_t *)of_flat_tree; @@ -802,6 +802,9 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, } printf (" Booting using flat device tree at 0x%x\n", of_flat_tree); + } else if(getenv("disable_of") == NULL) { + printf ("ERROR: bootm needs flat device tree as third argument\n"); + return; } #endif if (!data) { -- cgit v1.2.1 From 4782ac80b02f0d01afd309e2200dd3c7037f2ba4 Mon Sep 17 00:00:00 2001 From: Jin Zhengxiong Date: Wed, 23 Aug 2006 19:10:44 +0800 Subject: Add AHCI support to u-boot Add AHCI support in u-boot, enable the sata disk controllers which following the AHCI protocol. Signed-off-by:Jason Jin --- common/cmd_scsi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c index e8048611f9..cc08743d5d 100644 --- a/common/cmd_scsi.c +++ b/common/cmd_scsi.c @@ -43,8 +43,13 @@ #else #define SCSI_DEV_ID CONFIG_SCSI_DEV_ID #endif +#elif defined CONFIG_SATA_ULI5288 + +#define SCSI_VEND_ID 0x10b9 +#define SCSI_DEV_ID 0x5288 + #else -#error CONFIG_SCSI_SYM53C8XX must be defined +#error no scsi device defined #endif -- cgit v1.2.1 From 2f15776ccc6dc32377d8ba9652b8f58059c27c6d Mon Sep 17 00:00:00 2001 From: Zhang Wei Date: Mon, 28 Aug 2006 14:25:31 +0800 Subject: Fixed an OF-tree off-by-one bug when adding a new property name. This bug will cause the kernel booting to pause a long time. Signed-off-by: Zhang Wei --- common/ft_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/ft_build.c b/common/ft_build.c index b5a997c1ba..b5937e35f7 100644 --- a/common/ft_build.c +++ b/common/ft_build.c @@ -103,7 +103,7 @@ void ft_prop(struct ft_cxt *cxt, const char *name, const void *data, int sz) if (off == -1) { memcpy(cxt->p_end, name, strlen(name) + 1); off = cxt->p_end - cxt->p; - cxt->p_end += strlen(name) + 2; + cxt->p_end += strlen(name) + 1; } /* now put offset from beginning of *STRUCTURE* */ -- cgit v1.2.1 From 1eaf3a5ff4960a46f3a9063568ba2af7883f07c5 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Tue, 10 Oct 2006 00:23:32 -0600 Subject: Fix possible uninitialized variable compiler warning. When CONFIG_OF_FLAG_TREE is set, the compiler complains that 'len' in do_bootm_linux() may be uninitialized. There is no possibility in the current code that len will get used uninitialized, but this fix follows the existing convention of setting both len and data to zero at the same time. Signed-off-by: Grant Likely --- common/cmd_bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index e2cb6b93cd..c533c00d66 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -625,7 +625,7 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag, /* Look for a '-' which indicates to ignore the ramdisk argument */ if (argc >= 3 && strcmp(argv[2], "-") == 0) { debug ("Skipping initrd\n"); - data = 0; + len = data = 0; } else #endif -- cgit v1.2.1 From 13a7fcdf37f6ea9429ae04c9df67f893364cfe4b Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Thu, 19 Oct 2006 11:33:52 -0500 Subject: * Fix a bunch of compiler warnings for gcc 4.0 Signed-off-by: Matthew McClintock --- common/ft_build.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/ft_build.c b/common/ft_build.c index 87883cc7d2..980e40f55d 100644 --- a/common/ft_build.c +++ b/common/ft_build.c @@ -87,9 +87,9 @@ static int lookup_string(struct ft_cxt *cxt, const char *name) p = cxt->p; while (p < cxt->p_end) { - if (strcmp(p, name) == 0) + if (strcmp((char *)p, name) == 0) return p - cxt->p; - p += strlen(p) + 1; + p += strlen((char *)p) + 1; } return -1; @@ -143,9 +143,9 @@ void ft_init_cxt(struct ft_cxt *cxt, void *blob) cxt->p_rsvmap += SIZE_OF_RSVMAP_ENTRY; } - cxt->p_start = (char*)bph + bph->off_dt_struct; - cxt->p_end = (char *)bph + bph->totalsize; - cxt->p = (char *)bph + bph->off_dt_strings; + cxt->p_start = (u8 *)bph + bph->off_dt_struct; + cxt->p_end = (u8 *)bph + bph->totalsize; + cxt->p = (u8 *)bph + bph->off_dt_strings; } /* add a reserver physical area to the rsvmap */ -- cgit v1.2.1