summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2006-11-10 07:48:47 +0100
committerStefan Roese <sr@denx.de>2006-11-10 07:48:47 +0100
commitdfc8a9ee0040e53ada125a3c52f241e37f09cf28 (patch)
tree60fd3973150a4e6b3d9d129d117ecab71b5edabe /common
parent5c912cb1c31266c66ca59b36f9b6f87296421d75 (diff)
parent91650b3e4de688038d4f71279c44858e3e2c6870 (diff)
downloadu-boot-imx-dfc8a9ee0040e53ada125a3c52f241e37f09cf28.zip
u-boot-imx-dfc8a9ee0040e53ada125a3c52f241e37f09cf28.tar.gz
u-boot-imx-dfc8a9ee0040e53ada125a3c52f241e37f09cf28.tar.bz2
Merge with /home/stefan/git/u-boot/denx
Diffstat (limited to 'common')
-rw-r--r--common/Makefile4
-rw-r--r--common/cmd_boot.c2
-rw-r--r--common/cmd_bootm.c171
-rw-r--r--common/cmd_dcr.c131
-rw-r--r--common/cmd_jffs2.c14
-rw-r--r--common/cmd_mac.c66
-rw-r--r--common/cmd_nand.c465
-rw-r--r--common/cmd_nvedit.c5
-rw-r--r--common/cmd_scsi.c7
-rw-r--r--common/ft_build.c349
-rw-r--r--common/lcd.c11
-rw-r--r--common/main.c174
-rw-r--r--common/memsize.c17
-rw-r--r--common/miiphybb.c6
-rw-r--r--common/usb_storage.c4
15 files changed, 935 insertions, 491 deletions
diff --git a/common/Makefile b/common/Makefile
index 2eac66b..0106088 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
SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
@@ -61,7 +61,7 @@ CPPFLAGS += -I..
all: $(LIB) $(AOBJS)
$(LIB): $(obj).depend $(OBJS)
- $(AR) crv $@ $(OBJS)
+ $(AR) $(ARFLAGS) $@ $(OBJS)
$(obj)environment.o: $(src)environment.c $(obj)../tools/envcrc
$(CC) $(AFLAGS) -Wa,--no-warn \
diff --git a/common/cmd_boot.c b/common/cmd_boot.c
index e68f16f..182e2ab 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
);
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index fdf7180..3091a58 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -260,6 +260,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (hdr->ih_arch != IH_CPU_NIOS2)
#elif defined(__blackfin__)
if (hdr->ih_arch != IH_CPU_BLACKFIN)
+#elif defined(__avr32__)
+ if (hdr->ih_arch != IH_CPU_AVR32)
#else
# error Unknown CPU type
#endif
@@ -465,6 +467,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,13 +509,8 @@ 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
+static void __attribute__((noinline))
do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
int argc, char *argv[],
ulong addr,
@@ -526,7 +530,8 @@ 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;
+ ulong of_data = 0;
#endif
if ((s = getenv ("initrd_high")) != NULL) {
@@ -616,7 +621,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");
+ len = 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 +739,106 @@ 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);
+ 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)
+ of_data = (ulong)of_flat_tree;
+#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);
+ } else if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1]) && (len_ptr[2])) {
+ u_long tail = ntohl(len_ptr[0]) % 4;
+ int i;
+
+ /* skip kernel length, initrd length, and terminator */
+ of_data = (ulong)(&len_ptr[3]);
+ /* skip any additional image length fields */
+ for (i=2; len_ptr[i]; ++i)
+ of_data += 4;
+ /* add kernel length, and align */
+ of_data += ntohl(len_ptr[0]);
+ if (tail) {
+ of_data += 4 - tail;
+ }
+
+ /* add initrd length, and align */
+ tail = ntohl(len_ptr[1]) % 4;
+ of_data += ntohl(len_ptr[1]);
+ if (tail) {
+ of_data += 4 - tail;
+ }
+
+ if (((struct boot_param_header *)of_data)->magic != OF_DT_HEADER) {
+ printf ("ERROR: image is not a flat device tree\n");
+ return;
+ }
+
+ if (((struct boot_param_header *)of_data)->totalsize != ntohl(len_ptr[2])) {
+ printf ("ERROR: flat device tree size does not agree with image\n");
+ return;
+ }
+
+ } else if (getenv("disable_of") == NULL) {
+ printf ("ERROR: bootm needs flat device tree as third argument\n");
+ return;
+ }
+#endif
if (!data) {
debug ("No initrd\n");
}
@@ -793,15 +908,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);
@@ -823,8 +929,27 @@ 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);
+#else /* CONFIG_OF_FLAT_TREE */
+ /* move of_flat_tree if needed */
+ if (of_data) {
+ ulong of_start, of_len;
+ of_len = ((struct boot_param_header *)of_data)->totalsize;
+ /* provide extra 8k pad */
+ if (initrd_start)
+ of_start = initrd_start - of_len - 8192;
+ else
+ of_start = (ulong)kbd - of_len - 8192;
+ of_start &= ~(4096 - 1); /* align on page */
+ debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n",
+ of_data, of_data + of_len - 1, of_len, of_len);
+
+ of_flat_tree = (char *)of_start;
+ printf (" Loading Device Tree to %08lx, end %08lx ... ",
+ of_start, of_start + of_len - 1);
+ memmove ((void *)of_start, (void *)of_data, of_len);
+ }
+
+ 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)
@@ -841,10 +966,12 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
if (getenv("disable_of") != NULL)
(*kernel) ((bd_t *)of_flat_tree, initrd_start, initrd_end,
cmd_start, cmd_end);
- else
+ else {
+ ft_setup(of_flat_tree, kbd, initrd_start, initrd_end);
+ /* ft_dump_blob(of_flat_tree); */
(*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0);
-
-#endif
+ }
+#endif /* CONFIG_OF_FLAT_TREE */
}
#endif /* CONFIG_PPC */
@@ -1236,6 +1363,7 @@ print_type (image_header_t *hdr)
case IH_CPU_INVALID: arch = "Invalid CPU"; break;
case IH_CPU_ALPHA: arch = "Alpha"; break;
case IH_CPU_ARM: arch = "ARM"; break;
+ case IH_CPU_AVR32: arch = "AVR32"; break;
case IH_CPU_I386: arch = "Intel x86"; break;
case IH_CPU_IA64: arch = "IA64"; break;
case IH_CPU_MIPS: arch = "MIPS"; break;
@@ -1260,6 +1388,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;
}
diff --git a/common/cmd_dcr.c b/common/cmd_dcr.c
index 5842471..7221a86 100644
--- a/common/cmd_dcr.c
+++ b/common/cmd_dcr.c
@@ -31,6 +31,9 @@
#if defined(CONFIG_4xx) && (CONFIG_COMMANDS & CFG_CMD_SETGETDCR)
+unsigned long get_dcr (unsigned short);
+unsigned long set_dcr (unsigned short, unsigned long);
+
/* =======================================================================
* Interpreter command to retrieve an AMCC PPC 4xx Device Control Register
* =======================================================================
@@ -64,8 +67,6 @@ int do_getdcr ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] )
*/
int do_setdcr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
- unsigned long get_dcr (unsigned short);
- unsigned long set_dcr (unsigned short, unsigned long);
unsigned short dcrn; /* Device Control Register Num */
unsigned long value;
@@ -106,6 +107,120 @@ int do_setdcr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
return 0;
}
+/* =======================================================================
+ * Interpreter command to retrieve an register value through AMCC PPC 4xx
+ * Device Control Register inderect addressing.
+ * =======================================================================
+ */
+int do_getidcr (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ unsigned short adr_dcrn; /* Device Control Register Num for Address */
+ unsigned short dat_dcrn; /* Device Control Register Num for Data */
+ unsigned short offset; /* Register's offset */
+ unsigned long value; /* Register's value */
+ char *ptr = NULL;
+ char buf[80];
+
+ /* Validate arguments */
+ if (argc < 3) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return 1;
+ }
+
+ /* Find out whether ther is '.' (dot) symbol in the first parameter. */
+ strncpy (buf, argv[1], sizeof(buf)-1);
+ buf[sizeof(buf)-1] = 0; /* will guarantee zero-end string */
+ ptr = strchr (buf, '.');
+
+ if (ptr != NULL) {
+ /* First parameter has format adr_dcrn.dat_dcrn */
+ *ptr++ = 0; /* erase '.', create zero-end string */
+ adr_dcrn = (unsigned short) simple_strtoul (buf, NULL, 16);
+ dat_dcrn = (unsigned short) simple_strtoul (ptr, NULL, 16);
+ } else {
+ /*
+ * First parameter has format adr_dcrn; dat_dcrn will be
+ * calculated as adr_dcrn+1.
+ */
+ adr_dcrn = (unsigned short) simple_strtoul (buf, NULL, 16);
+ dat_dcrn = adr_dcrn+1;
+ }
+
+ /* Register's offset */
+ offset = (unsigned short) simple_strtoul (argv[2], NULL, 16);
+
+ /* Disable interrupts */
+ disable_interrupts ();
+ /* Set offset */
+ set_dcr (adr_dcrn, offset);
+ /* get data */
+ value = get_dcr (dat_dcrn);
+ /* Enable interrupts */
+ enable_interrupts ();
+
+ printf ("%04x.%04x-%04x Read %08lx\n", adr_dcrn, dat_dcrn, offset, value);
+
+ return 0;
+}
+
+/* =======================================================================
+ * Interpreter command to update an register value through AMCC PPC 4xx
+ * Device Control Register inderect addressing.
+ * =======================================================================
+ */
+int do_setidcr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+ unsigned short adr_dcrn; /* Device Control Register Num for Address */
+ unsigned short dat_dcrn; /* Device Control Register Num for Data */
+ unsigned short offset; /* Register's offset */
+ unsigned long value; /* Register's value */
+ char *ptr = NULL;
+ char buf[80];
+
+ /* Validate arguments */
+ if (argc < 4) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return 1;
+ }
+
+ /* Find out whether ther is '.' (dot) symbol in the first parameter. */
+ strncpy (buf, argv[1], sizeof(buf)-1);
+ buf[sizeof(buf)-1] = 0; /* will guarantee zero-end string */
+ ptr = strchr (buf, '.');
+
+ if (ptr != NULL) {
+ /* First parameter has format adr_dcrn.dat_dcrn */
+ *ptr++ = 0; /* erase '.', create zero-end string */
+ adr_dcrn = (unsigned short) simple_strtoul (buf, NULL, 16);
+ dat_dcrn = (unsigned short) simple_strtoul (ptr, NULL, 16);
+ } else {
+ /*
+ * First parameter has format adr_dcrn; dat_dcrn will be
+ * calculated as adr_dcrn+1.
+ */
+ adr_dcrn = (unsigned short) simple_strtoul (buf, NULL, 16);
+ dat_dcrn = adr_dcrn+1;
+ }
+
+ /* Register's offset */
+ offset = (unsigned short) simple_strtoul (argv[2], NULL, 16);
+ /* New value */
+ value = (unsigned long) simple_strtoul (argv[3], NULL, 16);
+
+ /* Disable interrupts */
+ disable_interrupts ();
+ /* Set offset */
+ set_dcr (adr_dcrn, offset);
+ /* set data */
+ set_dcr (dat_dcrn, value);
+ /* Enable interrupts */
+ enable_interrupts ();
+
+ printf ("%04x.%04x-%04x Write %08lx\n", adr_dcrn, dat_dcrn, offset, value);
+
+ return 0;
+}
+
/***************************************************/
U_BOOT_CMD(
@@ -119,4 +234,16 @@ U_BOOT_CMD(
"dcrn - set a DCR's value.\n"
);
+U_BOOT_CMD(
+ getidcr, 3, 1, do_getidcr,
+ "getidcr - Get a register value via indirect DCR addressing\n",
+ "adr_dcrn[.dat_dcrn] offset - write offset to adr_dcrn, read value from dat_dcrn.\n"
+);
+
+U_BOOT_CMD(
+ setidcr, 4, 1, do_setidcr,
+ "setidcr - Set a register value via indirect DCR addressing\n",
+ "adr_dcrn[.dat_dcrn] offset value - write offset to adr_dcrn, write value to dat_dcrn.\n"
+);
+
#endif /* CONFIG_4xx & CFG_CMD_SETGETDCR */
diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index b5fd417..7fd1fa3 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -1300,7 +1300,7 @@ static void list_partitions(void)
* Given partition identifier in form of <dev_type><dev_num>,<part_num> find
* corresponding device and verify partition number.
*
- * @param id string describing device and partition
+ * @param id string describing device and partition or partition name
* @param dev pointer to the requested device (output)
* @param part_num verified partition number (output)
* @param part pointer to requested partition (output)
@@ -1309,11 +1309,23 @@ static void list_partitions(void)
int find_dev_and_part(const char *id, struct mtd_device **dev,
u8 *part_num, struct part_info **part)
{
+ struct list_head *dentry, *pentry;
u8 type, dnum, pnum;
const char *p;
DEBUGF("--- find_dev_and_part ---\nid = %s\n", id);
+ list_for_each(dentry, &devices) {
+ *part_num = 0;
+ *dev = list_entry(dentry, struct mtd_device, link);
+ list_for_each(pentry, &(*dev)->parts) {
+ *part = list_entry(pentry, struct part_info, link);
+ if (strcmp((*part)->name, id) == 0)
+ return 0;
+ (*part_num)++;
+ }
+ }
+
p = id;
*dev = NULL;
*part = NULL;
diff --git a/common/cmd_mac.c b/common/cmd_mac.c
new file mode 100644
index 0000000..0add432
--- /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 <common.h>
+#include <command.h>
+
+#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 */
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 21adb1b..7286726 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -36,6 +36,15 @@
#include <jffs2/jffs2.h>
#include <nand.h>
+#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+
+/* parition handling routines */
+int mtdparts_init(void);
+int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num);
+int find_dev_and_part(const char *id, struct mtd_device **dev,
+ u8 *part_num, struct part_info **part);
+#endif
+
extern nand_info_t nand_info[]; /* info for NAND chips */
static int nand_dump_oob(nand_info_t *nand, ulong off)
@@ -83,50 +92,75 @@ static int nand_dump(nand_info_t *nand, ulong off)
/* ------------------------------------------------------------------------- */
-static void
-arg_off_size(int argc, char *argv[], ulong *off, ulong *size, ulong totsize)
+static inline int str2long(char *p, ulong *num)
{
- *off = 0;
- *size = 0;
-
-#if defined(CONFIG_JFFS2_NAND) && defined(CFG_JFFS_CUSTOM_PART)
- if (argc >= 1 && strcmp(argv[0], "partition") == 0) {
- int part_num;
- struct part_info *part;
- const char *partstr;
-
- if (argc >= 2)
- partstr = argv[1];
- else
- partstr = getenv("partition");
+ char *endptr;
- if (partstr)
- part_num = (int)simple_strtoul(partstr, NULL, 10);
- else
- part_num = 0;
+ *num = simple_strtoul(p, &endptr, 16);
+ return (*p != '\0' && *endptr == '\0') ? 1 : 0;
+}
- part = jffs2_part_info(part_num);
- if (part == NULL) {
- printf("\nInvalid partition %d\n", part_num);
- return;
+static int
+arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, ulong *size)
+{
+ int idx = nand_curr_device;
+#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+ struct mtd_device *dev;
+ struct part_info *part;
+ u8 pnum;
+
+ if (argc >= 1 && !(str2long(argv[0], off))) {
+ if ((mtdparts_init() == 0) &&
+ (find_dev_and_part(argv[0], &dev, &pnum, &part) == 0)) {
+ if (dev->id->type != MTD_DEV_TYPE_NAND) {
+ puts("not a NAND device\n");
+ return -1;
+ }
+ *off = part->offset;
+ if (argc >= 2) {
+ if (!(str2long(argv[1], size))) {
+ printf("'%s' is not a number\n", argv[1]);
+ return -1;
+ }
+ if (*size > part->size)
+ *size = part->size;
+ } else {
+ *size = part->size;
+ }
+ idx = dev->id->num;
+ *nand = nand_info[idx];
+ goto out;
}
- *size = part->size;
- *off = (ulong)part->offset;
- } else
+ }
#endif
- {
- if (argc >= 1)
- *off = (ulong)simple_strtoul(argv[0], NULL, 16);
- else
- *off = 0;
- if (argc >= 2)
- *size = (ulong)simple_strtoul(argv[1], NULL, 16);
- else
- *size = totsize - *off;
+ if (argc >= 1) {
+ if (!(str2long(argv[0], off))) {
+ printf("'%s' is not a number\n", argv[0]);
+ return -1;
+ }
+ } else {
+ *off = 0;
+ }
+ if (argc >= 2) {
+ if (!(str2long(argv[1], size))) {
+ printf("'%s' is not a number\n", argv[1]);
+ return -1;
+ }
+ } else {
+ *size = nand->size - *off;
}
+#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+out:
+#endif
+ printf("device %d ", idx);
+ if (*size == nand->size)
+ puts("whole chip\n");
+ else
+ printf("offset 0x%x, size 0x%x\n", *off, *size);
+ return 0;
}
int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
@@ -135,11 +169,16 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
ulong addr, off, size;
char *cmd, *s;
nand_info_t *nand;
+ int quiet = 0;
+ const char *quiet_str = getenv("quiet");
/* at least two arguments please */
if (argc < 2)
goto usage;
+ if (quiet_str)
+ quiet = simple_strtoul(quiet_str, NULL, 0) != 0;
+
cmd = argv[1];
if (strcmp(cmd, "info") == 0) {
@@ -173,12 +212,23 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
printf("Device %d: %s", dev, nand_info[dev].name);
puts("... is now current device\n");
nand_curr_device = dev;
+
+#ifdef CFG_NAND_SELECT_DEVICE
+ /*
+ * Select the chip in the board/cpu specific driver
+ */
+ board_nand_select_device(nand_info[dev].priv, dev);
+#endif
+
return 0;
}
if (strcmp(cmd, "bad") != 0 && strcmp(cmd, "erase") != 0 &&
strncmp(cmd, "dump", 4) != 0 &&
- strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0)
+ strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
+ strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
+ strcmp(cmd, "biterr") != 0 &&
+ strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
goto usage;
/* the following commands operate on the current device */
@@ -197,14 +247,50 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
return 0;
}
- if (strcmp(cmd, "erase") == 0) {
- arg_off_size(argc - 2, argv + 2, &off, &size, nand->size);
- if (off == 0 && size == 0)
+ /*
+ * Syntax is:
+ * 0 1 2 3 4
+ * nand erase [clean] [off size]
+ */
+ if (strcmp(cmd, "erase") == 0 || strcmp(cmd, "scrub") == 0) {
+ nand_erase_options_t opts;
+ /* "clean" at index 2 means request to write cleanmarker */
+ int clean = argc > 2 && !strcmp("clean", argv[2]);
+ int o = clean ? 3 : 2;
+ int scrub = !strcmp(cmd, "scrub");
+
+ printf("\nNAND %s: ", scrub ? "scrub" : "erase");
+ /* skip first two or three arguments, look for offset and size */
+ if (arg_off_size(argc - o, argv + o, nand, &off, &size) != 0)
return 1;
- printf("\nNAND erase: device %d offset 0x%x, size 0x%x ",
- nand_curr_device, off, size);
- ret = nand_erase(nand, off, size);
+ memset(&opts, 0, sizeof(opts));
+ opts.offset = off;
+ opts.length = size;
+ opts.jffs2 = clean;
+ opts.quiet = quiet;
+
+ if (scrub) {
+ puts("Warning: "
+ "scrub option will erase all factory set "
+ "bad blocks!\n"
+ " "
+ "There is no reliable way to recover them.\n"
+ " "
+ "Use this command only for testing purposes "
+ "if you\n"
+ " "
+ "are sure of what you are doing!\n"
+ "\nReally scrub this NAND flash? <y/N>\n");
+
+ if (getc() == 'y' && getc() == '\r') {
+ opts.scrub = 1;
+ } else {
+ puts("scrub aborted\n");
+ return -1;
+ }
+ }
+ ret = nand_erase_opts(nand, &opts);
printf("%s\n", ret ? "ERROR" : "OK");
return ret == 0 ? 0 : 1;
@@ -228,37 +314,142 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
/* read write */
if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) {
+ int read;
+
if (argc < 4)
goto usage;
-/*
- s = strchr(cmd, '.');
- clean = CLEAN_NONE;
- if (s != NULL) {
- if (strcmp(s, ".jffs2") == 0 || strcmp(s, ".e") == 0
- || strcmp(s, ".i"))
- clean = CLEAN_JFFS2;
- }
-*/
+
addr = (ulong)simple_strtoul(argv[2], NULL, 16);
- arg_off_size(argc - 3, argv + 3, &off, &size, nand->size);
- if (off == 0 && size == 0)
+ read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */
+ printf("\nNAND %s: ", read ? "read" : "write");
+ if (arg_off_size(argc - 3, argv + 3, nand, &off, &size) != 0)
return 1;
- i = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */
- printf("\nNAND %s: device %d offset %u, size %u ... ",
- i ? "read" : "write", nand_curr_device, off, size);
-
- if (i)
- ret = nand_read(nand, off, &size, (u_char *)addr);
- else
- ret = nand_write(nand, off, &size, (u_char *)addr);
+ s = strchr(cmd, '.');
+ if (s != NULL &&
+ (!strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i"))) {
+ if (read) {
+ /* read */
+ nand_read_options_t opts;
+ memset(&opts, 0, sizeof(opts));
+ opts.buffer = (u_char*) addr;
+ opts.length = size;
+ opts.offset = off;
+ opts.quiet = quiet;
+ ret = nand_read_opts(nand, &opts);
+ } else {
+ /* write */
+ nand_write_options_t opts;
+ memset(&opts, 0, sizeof(opts));
+ opts.buffer = (u_char*) addr;
+ opts.length = size;
+ opts.offset = off;
+ /* opts.forcejffs2 = 1; */
+ opts.pad = 1;
+ opts.blockalign = 1;
+ opts.quiet = quiet;
+ ret = nand_write_opts(nand, &opts);
+ }
+ } else {
+ if (read)
+ ret = nand_read(nand, off, &size, (u_char *)addr);
+ else
+ ret = nand_write(nand, off, &size, (u_char *)addr);
+ }
printf(" %d bytes %s: %s\n", size,
- i ? "read" : "written", ret ? "ERROR" : "OK");
+ read ? "read" : "written", ret ? "ERROR" : "OK");
return ret == 0 ? 0 : 1;
}
+
+ if (strcmp(cmd, "markbad") == 0) {
+ addr = (ulong)simple_strtoul(argv[2], NULL, 16);
+
+ int ret = nand->block_markbad(nand, addr);
+ if (ret == 0) {
+ printf("block 0x%08lx successfully marked as bad\n",
+ (ulong) addr);
+ return 0;
+ } else {
+ printf("block 0x%08lx NOT marked as bad! ERROR %d\n",
+ (ulong) addr, ret);
+ }
+ return 1;
+ }
+ if (strcmp(cmd, "biterr") == 0) {
+ /* todo */
+ return 1;
+ }
+
+ if (strcmp(cmd, "lock") == 0) {
+ int tight = 0;
+ int status = 0;
+ if (argc == 3) {
+ if (!strcmp("tight", argv[2]))
+ tight = 1;
+ if (!strcmp("status", argv[2]))
+ status = 1;
+ }
+
+ if (status) {
+ ulong block_start = 0;
+ ulong off;
+ int last_status = -1;
+
+ struct nand_chip *nand_chip = nand->priv;
+ /* check the WP bit */
+ nand_chip->cmdfunc (nand, NAND_CMD_STATUS, -1, -1);
+ printf("device is %swrite protected\n",
+ (nand_chip->read_byte(nand) & 0x80 ?
+ "NOT " : "" ) );
+
+ for (off = 0; off < nand->size; off += nand->oobblock) {
+ int s = nand_get_lock_status(nand, off);
+
+ /* print message only if status has changed
+ * or at end of chip
+ */
+ if (off == nand->size - nand->oobblock
+ || (s != last_status && off != 0)) {
+
+ printf("%08x - %08x: %8d pages %s%s%s\n",
+ block_start,
+ off-1,
+ (off-block_start)/nand->oobblock,
+ ((last_status & NAND_LOCK_STATUS_TIGHT) ? "TIGHT " : ""),
+ ((last_status & NAND_LOCK_STATUS_LOCK) ? "LOCK " : ""),
+ ((last_status & NAND_LOCK_STATUS_UNLOCK) ? "UNLOCK " : ""));
+ }
+
+ last_status = s;
+ }
+ } else {
+ if (!nand_lock(nand, tight)) {
+ puts("NAND flash successfully locked\n");
+ } else {
+ puts("Error locking NAND flash\n");
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+ if (strcmp(cmd, "unlock") == 0) {
+ if (arg_off_size(argc - 2, argv + 2, nand, &off, &size) < 0)
+ return 1;
+
+ if (!nand_unlock(nand, off, size)) {
+ puts("NAND flash successfully unlocked\n");
+ } else {
+ puts("Error unlocking NAND flash, "
+ "write and erase will probably fail\n");
+ return 1;
+ }
+ return 0;
+ }
+
usage:
printf("Usage:\n%s\n", cmdtp->usage);
return 1;
@@ -268,8 +459,8 @@ U_BOOT_CMD(nand, 5, 1, do_nand,
"nand - NAND sub-system\n",
"info - show available NAND devices\n"
"nand device [dev] - show or set current device\n"
- "nand read[.jffs2] - addr off size\n"
- "nand write[.jffs2] - addr off size - read/write `size' bytes starting\n"
+ "nand read[.jffs2] - addr off|partition size\n"
+ "nand write[.jffs2] - addr off|partiton size - read/write `size' bytes starting\n"
" at offset `off' to/from memory address `addr'\n"
"nand erase [clean] [off size] - erase `size' bytes from\n"
" offset `off' (entire device if not specified)\n"
@@ -277,64 +468,24 @@ U_BOOT_CMD(nand, 5, 1, do_nand,
"nand dump[.oob] off - dump page\n"
"nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n"
"nand markbad off - mark bad block at offset (UNSAFE)\n"
- "nand biterr off - make a bit error at offset (UNSAFE)\n");
+ "nand biterr off - make a bit error at offset (UNSAFE)\n"
+ "nand lock [tight] [status] - bring nand to lock state or display locked pages\n"
+ "nand unlock [offset] [size] - unlock section\n");
-int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
+ ulong offset, ulong addr, char *cmd)
{
- char *boot_device = NULL;
- char *ep;
- int dev;
int r;
- ulong addr, cnt, offset = 0;
+ char *ep;
+ ulong cnt;
image_header_t *hdr;
- nand_info_t *nand;
-
- switch (argc) {
- case 1:
- addr = CFG_LOAD_ADDR;
- boot_device = getenv("bootdevice");
- break;
- case 2:
- addr = simple_strtoul(argv[1], NULL, 16);
- boot_device = getenv("bootdevice");
- break;
- case 3:
- addr = simple_strtoul(argv[1], NULL, 16);
- boot_device = argv[2];
- break;
- case 4:
- addr = simple_strtoul(argv[1], NULL, 16);
- boot_device = argv[2];
- offset = simple_strtoul(argv[3], NULL, 16);
- break;
- default:
- printf("Usage:\n%s\n", cmdtp->usage);
- SHOW_BOOT_PROGRESS(-1);
- return 1;
- }
-
- if (!boot_device) {
- puts("\n** No boot device **\n");
- SHOW_BOOT_PROGRESS(-1);
- return 1;
- }
- dev = simple_strtoul(boot_device, &ep, 16);
-
- if (dev < 0 || dev >= CFG_MAX_NAND_DEVICE || !nand_info[dev].name) {
- printf("\n** Device %d not available\n", dev);
- SHOW_BOOT_PROGRESS(-1);
- return 1;
- }
-
- nand = &nand_info[dev];
- printf("\nLoading from device %d: %s (offset 0x%lx)\n",
- dev, nand->name, offset);
+ printf("\nLoading from %s, offset 0x%lx\n", nand->name, offset);
cnt = nand->oobblock;
r = nand_read(nand, offset, &cnt, (u_char *) addr);
if (r) {
- printf("** Read error on %d\n", dev);
+ puts("** Read error\n");
SHOW_BOOT_PROGRESS(-1);
return 1;
}
@@ -353,7 +504,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
r = nand_read(nand, offset, &cnt, (u_char *) addr);
if (r) {
- printf("** Read error on %d\n", dev);
+ puts("** Read error\n");
SHOW_BOOT_PROGRESS(-1);
return 1;
}
@@ -367,7 +518,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
char *local_args[2];
extern int do_bootm(cmd_tbl_t *, int, int, char *[]);
- local_args[0] = argv[0];
+ local_args[0] = cmd;
local_args[1] = NULL;
printf("Automatic boot of image at addr 0x%08lx ...\n", addr);
@@ -378,9 +529,83 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
return 0;
}
-U_BOOT_CMD(nboot, 4, 1, do_nandboot,
- "nboot - boot from NAND device\n", "loadAddr dev\n");
+int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+ char *boot_device = NULL;
+ int idx;
+ ulong addr, offset = 0;
+#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+ struct mtd_device *dev;
+ struct part_info *part;
+ u8 pnum;
+
+ if (argc >= 2) {
+ char *p = (argc == 2) ? argv[1] : argv[2];
+ if (!(str2long(p, &addr)) && (mtdparts_init() == 0) &&
+ (find_dev_and_part(p, &dev, &pnum, &part) == 0)) {
+ if (dev->id->type != MTD_DEV_TYPE_NAND) {
+ puts("Not a NAND device\n");
+ return 1;
+ }
+ if (argc > 3)
+ goto usage;
+ if (argc == 3)
+ addr = simple_strtoul(argv[2], NULL, 16);
+ else
+ addr = CFG_LOAD_ADDR;
+ return nand_load_image(cmdtp, &nand_info[dev->id->num],
+ part->offset, addr, argv[0]);
+ }
+ }
+#endif
+ switch (argc) {
+ case 1:
+ addr = CFG_LOAD_ADDR;
+ boot_device = getenv("bootdevice");
+ break;
+ case 2:
+ addr = simple_strtoul(argv[1], NULL, 16);
+ boot_device = getenv("bootdevice");
+ break;
+ case 3:
+ addr = simple_strtoul(argv[1], NULL, 16);
+ boot_device = argv[2];
+ break;
+ case 4:
+ addr = simple_strtoul(argv[1], NULL, 16);
+ boot_device = argv[2];
+ offset = simple_strtoul(argv[3], NULL, 16);
+ break;
+ default:
+#if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+usage:
+#endif
+ printf("Usage:\n%s\n", cmdtp->usage);
+ SHOW_BOOT_PROGRESS(-1);
+ return 1;
+ }
+
+ if (!boot_device) {
+ puts("\n** No boot device **\n");
+ SHOW_BOOT_PROGRESS(-1);
+ return 1;
+ }
+
+ idx = simple_strtoul(boot_device, NULL, 16);
+
+ if (idx < 0 || idx >= CFG_MAX_NAND_DEVICE || !nand_info[idx].name) {
+ printf("\n** Device %d not available\n", idx);
+ SHOW_BOOT_PROGRESS(-1);
+ return 1;
+ }
+
+ return nand_load_image(cmdtp, &nand_info[idx], offset, addr, argv[0]);
+}
+
+U_BOOT_CMD(nboot, 4, 1, do_nandboot,
+ "nboot - boot from NAND device\n",
+ "[partition] | [[[loadAddr] dev] offset]\n");
#endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */
@@ -596,7 +821,7 @@ int do_nand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1;
}
- printf ("\nNAND %s: device %d offset %ld, size %ld ... ",
+ printf ("\nNAND %s: device %d offset %ld, size %ld ...\n",
(cmd & NANDRW_READ) ? "read" : "write",
curr_device, off, size);
@@ -615,7 +840,7 @@ int do_nand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong size = simple_strtoul(argv[3 + clean], NULL, 16);
int ret;
- printf ("\nNAND erase: device %d offset %ld, size %ld ... ",
+ printf ("\nNAND erase: device %d offset %ld, size %ld ...\n",
curr_device, off, size);
ret = nand_legacy_erase (nand_dev_desc + curr_device,
@@ -635,7 +860,7 @@ int do_nand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
U_BOOT_CMD(
nand, 5, 1, do_nand,
- "nand - NAND sub-system\n",
+ "nand - legacy NAND sub-system\n",
"info - show available NAND devices\n"
"nand device [dev] - show or set current device\n"
"nand read[.jffs2[s]] addr off size\n"
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 6257fbd..d3f50f8 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -167,6 +167,11 @@ int _do_setenv (int flag, int argc, char *argv[])
name = argv[1];
+ if (strchr(name, '=')) {
+ printf ("## Error: illegal character '=' in variable name \"%s\"\n", name);
+ return 1;
+ }
+
/*
* search if variable with this name already exists
*/
diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c
index e804861..cc08743 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
diff --git a/common/ft_build.c b/common/ft_build.c
index 9e9c906..980e40f 100644
--- a/common/ft_build.c
+++ b/common/ft_build.c
@@ -1,5 +1,22 @@
/*
* OF flat tree builder
+ * Written by: Pantelis Antoniou <pantelis.antoniou@gmail.com>
+ * Updated by: Matthew McClintock <msm@freescale.com>
+ *
+ * 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>
@@ -13,44 +30,39 @@
#include <ft_build.h>
+#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,11 +85,11 @@ static int lookup_string(struct ft_cxt *cxt, const char *name)
{
u8 *p;
- p = cxt->pstr;
- while (p < cxt->pstr_begin) {
- if (strcmp(p, name) == 0)
- return p - cxt->p_begin;
- p += strlen(p) + 1;
+ p = cxt->p;
+ while (p < cxt->p_end) {
+ if (strcmp((char *)p, name) == 0)
+ return p - cxt->p;
+ p += strlen((char *)p) + 1;
}
return -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) + 1;
}
/* 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 = (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 */
-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;
@@ -293,22 +219,24 @@ static void print_data(const void *data, int len)
return;
if (is_printable_string(data, len)) {
- printf(" = \"%s\"", (char *)data);
+ puts(" = \"");
+ puts(data);
+ puts("\"");
return;
}
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 +278,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 +309,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 +325,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 +400,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 +453,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 +476,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 +514,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 +531,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 +580,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
diff --git a/common/lcd.c b/common/lcd.c
index d79350f..eaed2ab 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -578,7 +578,9 @@ void bitmap_plot (int x, int y)
*/
int lcd_display_bitmap(ulong bmp_image, int x, int y)
{
+#if !defined(CONFIG_MCC200)
ushort *cmap;
+#endif
ushort i, j;
uchar *fb;
bmp_image_t *bmp=(bmp_image_t *)bmp_image;
@@ -624,13 +626,13 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
debug ("Display-bmp: %d x %d with %d colors\n",
(int)width, (int)height, (int)colors);
+#if !defined(CONFIG_MCC200)
+ /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
if (bpix==8) {
#if defined(CONFIG_PXA250)
cmap = (ushort *)fbi->palette;
#elif defined(CONFIG_MPC823)
cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]);
-#elif defined(CONFIG_MCC200)
- /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
#else
# error "Don't know location of color map"
#endif
@@ -654,6 +656,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
#endif
}
}
+#endif
/*
* BMP format for Monochrome assumes that the state of a
@@ -661,8 +664,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
* So, in case of Monochrome BMP we should align widths
* on a byte boundary and convert them from Bit to Byte
* units.
- * Probably, PXA250 and MPC823 process 1bpp BMP images in
- * their own ways, so make the converting to be MCC200
+ * Probably, PXA250 and MPC823 process 1bpp BMP images in
+ * their own ways, so make the converting to be MCC200
* specific.
*/
#if defined(CONFIG_MCC200)
diff --git a/common/main.c b/common/main.c
index 13d12a4..cc4b50f 100644
--- a/common/main.c
+++ b/common/main.c
@@ -95,14 +95,12 @@ static __inline__ int abortboot(int bootdelay)
{
int abort = 0;
uint64_t etime = endtick(bootdelay);
- struct
- {
+ struct {
char* str;
u_int len;
int retry;
}
- delaykey [] =
- {
+ delaykey [] = {
{ str: getenv ("bootdelaykey"), retry: 1 },
{ str: getenv ("bootdelaykey2"), retry: 1 },
{ str: getenv ("bootstopkey"), retry: 0 },
@@ -498,7 +496,7 @@ void main_loop (void)
#ifdef CONFIG_BOOT_RETRY_TIME
/***************************************************************************
- * initialise command line timeout
+ * initialize command line timeout
*/
void init_cmd_timeout(void)
{
@@ -529,23 +527,9 @@ void reset_cmd_timeout(void)
* Author: Janghoon Lyu <nandy@mizi.com>
*/
-#if 1 /* avoid redundand code -- wd */
#define putnstr(str,n) do { \
printf ("%.*s", n, str); \
} while (0)
-#else
-void putnstr(const char *str, size_t n)
-{
- if (str == NULL)
- return;
-
- while (n && *str != '\0') {
- putc(*str);
- str++;
- n--;
- }
-}
-#endif
#define CTL_CH(c) ((c) - 'a' + 1)
@@ -1138,97 +1122,99 @@ static void process_macros (const char *input, char *output)
{
char c, prev;
const char *varname_start = NULL;
- int inputcnt = strlen (input);
+ int inputcnt = strlen (input);
int outputcnt = CFG_CBSIZE;
- int state = 0; /* 0 = waiting for '$' */
- /* 1 = waiting for '(' or '{' */
- /* 2 = waiting for ')' or '}' */
- /* 3 = waiting for ''' */
+ int state = 0; /* 0 = waiting for '$' */
+
+ /* 1 = waiting for '(' or '{' */
+ /* 2 = waiting for ')' or '}' */
+ /* 3 = waiting for ''' */
#ifdef DEBUG_PARSER
char *output_start = output;
- printf ("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen(input), input);
+ printf ("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen (input),
+ input);
#endif
- prev = '\0'; /* previous character */
+ prev = '\0'; /* previous character */
while (inputcnt && outputcnt) {
- c = *input++;
- inputcnt--;
-
- if (state!=3) {
- /* remove one level of escape characters */
- if ((c == '\\') && (prev != '\\')) {
- if (inputcnt-- == 0)
- break;
- prev = c;
c = *input++;
- }
- }
-
- switch (state) {
- case 0: /* Waiting for (unescaped) $ */
- if ((c == '\'') && (prev != '\\')) {
- state = 3;
- break;
- }
- if ((c == '$') && (prev != '\\')) {
- state++;
- } else {
- *(output++) = c;
- outputcnt--;
+ inputcnt--;
+
+ if (state != 3) {
+ /* remove one level of escape characters */
+ if ((c == '\\') && (prev != '\\')) {
+ if (inputcnt-- == 0)
+ break;
+ prev = c;
+ c = *input++;
+ }
}
- break;
- case 1: /* Waiting for ( */
- if (c == '(' || c == '{') {
- state++;
- varname_start = input;
- } else {
- state = 0;
- *(output++) = '$';
- outputcnt--;
-
- if (outputcnt) {
+
+ switch (state) {
+ case 0: /* Waiting for (unescaped) $ */
+ if ((c == '\'') && (prev != '\\')) {
+ state = 3;
+ break;
+ }
+ if ((c == '$') && (prev != '\\')) {
+ state++;
+ } else {
*(output++) = c;
outputcnt--;
}
- }
- break;
- case 2: /* Waiting for ) */
- if (c == ')' || c == '}') {
- int i;
- char envname[CFG_CBSIZE], *envval;
- int envcnt = input-varname_start-1; /* Varname # of chars */
-
- /* Get the varname */
- for (i = 0; i < envcnt; i++) {
- envname[i] = varname_start[i];
- }
- envname[i] = 0;
-
- /* Get its value */
- envval = getenv (envname);
+ break;
+ case 1: /* Waiting for ( */
+ if (c == '(' || c == '{') {
+ state++;
+ varname_start = input;
+ } else {
+ state = 0;
+ *(output++) = '$';
+ outputcnt--;
- /* Copy into the line if it exists */
- if (envval != NULL)
- while ((*envval) && outputcnt) {
- *(output++) = *(envval++);
+ if (outputcnt) {
+ *(output++) = c;
outputcnt--;
}
- /* Look for another '$' */
- state = 0;
- }
- break;
- case 3: /* Waiting for ' */
- if ((c == '\'') && (prev != '\\')) {
- state = 0;
- } else {
- *(output++) = c;
- outputcnt--;
+ }
+ break;
+ case 2: /* Waiting for ) */
+ if (c == ')' || c == '}') {
+ int i;
+ char envname[CFG_CBSIZE], *envval;
+ int envcnt = input - varname_start - 1; /* Varname # of chars */
+
+ /* Get the varname */
+ for (i = 0; i < envcnt; i++) {
+ envname[i] = varname_start[i];
+ }
+ envname[i] = 0;
+
+ /* Get its value */
+ envval = getenv (envname);
+
+ /* Copy into the line if it exists */
+ if (envval != NULL)
+ while ((*envval) && outputcnt) {
+ *(output++) = *(envval++);
+ outputcnt--;
+ }
+ /* Look for another '$' */
+ state = 0;
+ }
+ break;
+ case 3: /* Waiting for ' */
+ if ((c == '\'') && (prev != '\\')) {
+ state = 0;
+ } else {
+ *(output++) = c;
+ outputcnt--;
+ }
+ break;
}
- break;
- }
- prev = c;
+ prev = c;
}
if (outputcnt)
@@ -1236,7 +1222,7 @@ static void process_macros (const char *input, char *output)
#ifdef DEBUG_PARSER
printf ("[PROCESS_MACROS] OUTPUT len %d: \"%s\"\n",
- strlen(output_start), output_start);
+ strlen (output_start), output_start);
#endif
}
diff --git a/common/memsize.c b/common/memsize.c
index dbc812d..6c275c9 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -21,6 +21,16 @@
* MA 02111-1307 USA
*/
+#include <config.h>
+#ifdef __PPC__
+/*
+ * At least on G2 PowerPC cores, sequential accesses to non-existent
+ * memory must be synchronized.
+ */
+# include <asm/io.h> /* for sync() */
+#else
+# define sync() /* nothing */
+#endif
/*
* Check memory range for valid RAM. A simple memory test determines
@@ -38,20 +48,27 @@ long get_ram_size(volatile long *base, long maxsize)
for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
addr = base + cnt; /* pointer arith! */
+ sync ();
save[i++] = *addr;
+ sync ();
*addr = ~cnt;
}
addr = base;
+ sync ();
save[i] = *addr;
+ sync ();
*addr = 0;
+ sync ();
if ((val = *addr) != 0) {
/* Restore the original data before leaving the function.
*/
+ sync ();
*addr = save[i];
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
addr = base + cnt;
+ sync ();
*addr = save[--i];
}
return (0);
diff --git a/common/miiphybb.c b/common/miiphybb.c
index adb697c..537c15d 100644
--- a/common/miiphybb.c
+++ b/common/miiphybb.c
@@ -41,7 +41,7 @@
static void miiphy_pre (char read, unsigned char addr, unsigned char reg)
{
int j; /* counter */
-#ifndef CONFIG_EP8248
+#if !(defined(CONFIG_EP8248) || defined(CONFIG_EP82XXM))
volatile ioport_t *iop = ioport_addr ((immap_t *) CFG_IMMR, MDIO_PORT);
#endif
@@ -126,7 +126,7 @@ int bb_miiphy_read (char *devname, unsigned char addr,
{
short rdreg; /* register working value */
int j; /* counter */
-#ifndef CONFIG_EP8248
+#if !(defined(CONFIG_EP8248) || defined(CONFIG_EP82XXM))
volatile ioport_t *iop = ioport_addr ((immap_t *) CFG_IMMR, MDIO_PORT);
#endif
@@ -193,7 +193,7 @@ int bb_miiphy_write (char *devname, unsigned char addr,
unsigned char reg, unsigned short value)
{
int j; /* counter */
-#ifndef CONFIG_EP8248
+#if !(defined(CONFIG_EP8248) || defined(CONFIG_EP82XXM))
volatile ioport_t *iop = ioport_addr ((immap_t *) CFG_IMMR, MDIO_PORT);
#endif
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 69ecf18..06ea99b 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -932,8 +932,8 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor,
const unsigned char max_vendor_len = 40;
const unsigned char max_product_len = 20;
if (descriptor.idVendor == 0x0424 && descriptor.idProduct == 0x223a) {
- strncpy(vendor, "SMSC", max_vendor_len);
- strncpy(product, "Flash Media Cntrller", max_product_len);
+ strncpy ((char *)vendor, "SMSC", max_vendor_len);
+ strncpy ((char *)product, "Flash Media Cntrller", max_product_len);
}
}
#endif /* CONFIG_USB_BIN_FIXUP */