diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/ACEX1K.c | 4 | ||||
-rw-r--r-- | common/Makefile | 1 | ||||
-rw-r--r-- | common/altera.c | 18 | ||||
-rw-r--r-- | common/cmd_bmp.c | 134 | ||||
-rw-r--r-- | common/cmd_fdt.c | 26 | ||||
-rw-r--r-- | common/cmd_fpga.c | 39 | ||||
-rw-r--r-- | common/cmd_jffs2.c | 9 | ||||
-rw-r--r-- | common/cmd_nand.c | 8 | ||||
-rw-r--r-- | common/cmd_terminal.c | 102 | ||||
-rw-r--r-- | common/cyclon2.c | 4 | ||||
-rw-r--r-- | common/env_onenand.c | 4 | ||||
-rw-r--r-- | common/fdt_support.c | 73 | ||||
-rw-r--r-- | common/fpga.c | 30 | ||||
-rw-r--r-- | common/main.c | 26 | ||||
-rw-r--r-- | common/serial.c | 4 | ||||
-rw-r--r-- | common/spartan2.c | 22 | ||||
-rw-r--r-- | common/spartan3.c | 22 | ||||
-rw-r--r-- | common/virtex2.c | 2 | ||||
-rw-r--r-- | common/xilinx.c | 28 |
19 files changed, 363 insertions, 193 deletions
diff --git a/common/ACEX1K.c b/common/ACEX1K.c index 2a421e2..76dc166 100644 --- a/common/ACEX1K.c +++ b/common/ACEX1K.c @@ -28,7 +28,7 @@ #include <common.h> /* core U-Boot definitions */ #include <ACEX1K.h> /* ACEX device family */ -#if (CONFIG_FPGA & (CFG_ALTERA | CFG_ACEX1K)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA) && defined(CONFIG_FPGA_ACEX1K) /* Define FPGA_DEBUG to get debug printf's */ #ifdef FPGA_DEBUG @@ -363,4 +363,4 @@ static int ACEX1K_ps_reloc (Altera_desc * desc, ulong reloc_offset) } -#endif /* (CONFIG_FPGA & (CFG_ALTERA | CFG_ACEX1K)) */ +#endif /* CONFIG_FPGA && CONFIG_FPGA_ALTERA && CONFIG_FPGA_ACEX1K */ diff --git a/common/Makefile b/common/Makefile index 7be89a4..fbfa536 100644 --- a/common/Makefile +++ b/common/Makefile @@ -86,6 +86,7 @@ COBJS-$(CONFIG_CMD_REISER) += cmd_reiser.o COBJS-y += cmd_sata.o COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o +COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o COBJS-$(CONFIG_CMD_USB) += cmd_usb.o COBJS-y += cmd_vfd.o diff --git a/common/altera.c b/common/altera.c index 06e8a95..0df7bae 100644 --- a/common/altera.c +++ b/common/altera.c @@ -40,7 +40,7 @@ #define PRINTF(fmt,args...) #endif -#if (CONFIG_FPGA & CFG_FPGA_ALTERA) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA) /* Local Static Functions */ static int altera_validate (Altera_desc * desc, char *fn); @@ -56,11 +56,11 @@ int altera_load( Altera_desc *desc, void *buf, size_t bsize ) switch (desc->family) { case Altera_ACEX1K: case Altera_CYC2: -#if (CONFIG_FPGA & CFG_ACEX1K) +#if defined(CONFIG_FPGA_ACEX1K) PRINTF ("%s: Launching the ACEX1K Loader...\n", __FUNCTION__); ret_val = ACEX1K_load (desc, buf, bsize); -#elif (CONFIG_FPGA & CFG_CYCLON2) +#elif defined CONFIG_FPGA_CYCLON2 PRINTF ("%s: Launching the CYCLON II Loader...\n", __FUNCTION__); ret_val = CYC2_load (desc, buf, bsize); @@ -88,7 +88,7 @@ int altera_dump( Altera_desc *desc, void *buf, size_t bsize ) } else { switch (desc->family) { case Altera_ACEX1K: -#if (CONFIG_FPGA & CFG_ACEX) +#if defined(CONFIG_FPGA_ACEX) PRINTF ("%s: Launching the ACEX1K Reader...\n", __FUNCTION__); ret_val = ACEX1K_dump (desc, buf, bsize); @@ -156,9 +156,9 @@ int altera_info( Altera_desc *desc ) switch (desc->family) { case Altera_ACEX1K: case Altera_CYC2: -#if (CONFIG_FPGA & CFG_ACEX1K) +#if defined(CONFIG_FPGA_ACEX1K) ACEX1K_info (desc); -#elif (CONFIG_FPGA & CFG_CYCLON2) +#elif defined(CONFIG_FPGA_CYCLON2) CYC2_info (desc); #else /* just in case */ @@ -192,7 +192,7 @@ int altera_reloc( Altera_desc *desc, ulong reloc_offset) } else { switch (desc->family) { case Altera_ACEX1K: -#if (CONFIG_FPGA & CFG_ACEX1K) +#if defined(CONFIG_FPGA_ACEX1K) ret_val = ACEX1K_reloc (desc, reloc_offset); #else printf ("%s: No support for ACEX devices.\n", @@ -200,7 +200,7 @@ int altera_reloc( Altera_desc *desc, ulong reloc_offset) #endif break; case Altera_CYC2: -#if (CONFIG_FPGA & CFG_CYCLON2) +#if defined(CONFIG_FPGA_CYCLON2) ret_val = CYC2_reloc (desc, reloc_offset); #else printf ("%s: No support for CYCLON II devices.\n", @@ -249,4 +249,4 @@ static int altera_validate (Altera_desc * desc, char *fn) /* ------------------------------------------------------------------------- */ -#endif /* CONFIG_FPGA & CFG_FPGA_ALTERA */ +#endif /* CONFIG_FPGA & CONFIG_FPGA_ALTERA */ diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 907f9a2..2437e22 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -37,6 +37,62 @@ static int bmp_display (ulong addr, int x, int y); int gunzip(void *, int, unsigned char *, unsigned long *); /* + * Allocate and decompress a BMP image using gunzip(). + * + * Returns a pointer to the decompressed image data. Must be freed by + * the caller after use. + * + * Returns NULL if decompression failed, or if the decompressed data + * didn't contain a valid BMP signature. + */ +#ifdef CONFIG_VIDEO_BMP_GZIP +static bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp) +{ + void *dst; + unsigned long len; + bmp_image_t *bmp; + + /* + * Decompress bmp image + */ + len = CFG_VIDEO_LOGO_MAX_SIZE; + dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE); + if (dst == NULL) { + puts("Error: malloc in gunzip failed!\n"); + return NULL; + } + if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) { + free(dst); + return NULL; + } + if (len == CFG_VIDEO_LOGO_MAX_SIZE) + puts("Image could be truncated" + " (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n"); + + bmp = dst; + + /* + * Check for bmp mark 'BM' + */ + if (!((bmp->header.signature[0] == 'B') && + (bmp->header.signature[1] == 'M'))) { + free(dst); + return NULL; + } + + puts("Gzipped BMP image detected!\n"); + + return bmp; +} +#else +static bmp_image_t *gunzip_bmp(unsigned long addr) +{ + return NULL; +} +#endif + + +/* * Subroutine: do_bmp * * Description: Handler for 'bmp' command.. @@ -101,63 +157,24 @@ U_BOOT_CMD( static int bmp_info(ulong addr) { bmp_image_t *bmp=(bmp_image_t *)addr; -#ifdef CONFIG_VIDEO_BMP_GZIP - unsigned char *dst = NULL; - ulong len; -#endif /* CONFIG_VIDEO_BMP_GZIP */ + unsigned long len; if (!((bmp->header.signature[0]=='B') && - (bmp->header.signature[1]=='M'))) { + (bmp->header.signature[1]=='M'))) + bmp = gunzip_bmp(addr, &len); -#ifdef CONFIG_VIDEO_BMP_GZIP - /* - * Decompress bmp image - */ - len = CFG_VIDEO_LOGO_MAX_SIZE; - dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE); - if (dst == NULL) { - printf("Error: malloc in gunzip failed!\n"); - return(1); - } - if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) { - printf("There is no valid bmp file at the given address\n"); - return(1); - } - if (len == CFG_VIDEO_LOGO_MAX_SIZE) { - printf("Image could be truncated (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n"); - } - - /* - * Set addr to decompressed image - */ - bmp = (bmp_image_t *)dst; - - /* - * Check for bmp mark 'BM' - */ - if (!((bmp->header.signature[0] == 'B') && - (bmp->header.signature[1] == 'M'))) { - printf("There is no valid bmp file at the given address\n"); - free(dst); - return(1); - } - - printf("Gzipped BMP image detected!\n"); -#else /* CONFIG_VIDEO_BMP_GZIP */ + if (bmp == NULL) { printf("There is no valid bmp file at the given address\n"); - return(1); -#endif /* CONFIG_VIDEO_BMP_GZIP */ + return 1; } + printf("Image size : %d x %d\n", le32_to_cpu(bmp->header.width), le32_to_cpu(bmp->header.height)); printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count)); printf("Compression : %d\n", le32_to_cpu(bmp->header.compression)); -#ifdef CONFIG_VIDEO_BMP_GZIP - if (dst) { - free(dst); - } -#endif /* CONFIG_VIDEO_BMP_GZIP */ + if ((unsigned long)bmp != addr) + free(bmp); return(0); } @@ -174,14 +191,33 @@ static int bmp_info(ulong addr) */ static int bmp_display(ulong addr, int x, int y) { + int ret; + bmp_image_t *bmp = (bmp_image_t *)addr; + unsigned long len; + + if (!((bmp->header.signature[0]=='B') && + (bmp->header.signature[1]=='M'))) + bmp = gunzip_bmp(addr, &len); + + if (!bmp) { + printf("There is no valid bmp file at the given address\n"); + return 1; + } + #if defined(CONFIG_LCD) extern int lcd_display_bitmap (ulong, int, int); - return (lcd_display_bitmap (addr, x, y)); + ret = lcd_display_bitmap ((unsigned long)bmp, x, y); #elif defined(CONFIG_VIDEO) extern int video_display_bitmap (ulong, int, int); - return (video_display_bitmap (addr, x, y)); + + ret = video_display_bitmap ((unsigned long)bmp, x, y); #else # error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO #endif + + if ((unsigned long)bmp != addr) + free(bmp); + + return ret; } diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 4639126..9cd22ee 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -184,23 +184,28 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) } else if (argv[1][0] == 's') { char *pathp; /* path */ char *prop; /* property */ - char *newval; /* value from the user (as a string) */ int nodeoffset; /* node offset from libfdt */ static char data[SCRATCHPAD]; /* storage for the property */ int len; /* new length of the property */ int ret; /* return value */ /* - * Parameters: Node path, property, value. + * Parameters: Node path, property, optional value. */ - if (argc < 5) { + if (argc < 4) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } pathp = argv[2]; prop = argv[3]; - newval = argv[4]; + if (argc == 4) { + len = 0; + } else { + ret = fdt_parse_prop(pathp, prop, argv[4], data, &len); + if (ret != 0) + return ret; + } nodeoffset = fdt_path_offset (fdt, pathp); if (nodeoffset < 0) { @@ -211,9 +216,6 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) fdt_strerror(nodeoffset)); return 1; } - ret = fdt_parse_prop(pathp, prop, newval, data, &len); - if (ret != 0) - return ret; ret = fdt_setprop(fdt, nodeoffset, prop, data, len); if (ret < 0) { @@ -681,7 +683,7 @@ U_BOOT_CMD( #ifdef CONFIG_OF_BOARD_SETUP "fdt boardsetup - Do board-specific set up\n" #endif - "fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr>\n" + "fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr> and make it active\n" "fdt print <path> [<prop>] - Recursive print starting at <path>\n" "fdt list <path> [<prop>] - Print one level starting at <path>\n" "fdt set <path> <prop> [<val>] - Set <property> [to <val>]\n" @@ -694,10 +696,6 @@ U_BOOT_CMD( #ifdef CONFIG_OF_HAS_BD_T "fdt bd_t - Add/replace the /bd_t branch in the tree\n" #endif - "Hints:\n" - " If the property you are setting/printing has a '#' character or spaces,\n" - " you MUST escape it with a \\ character or quote it with \".\n" - "Examples: fdt print / # print the whole tree\n" - " fdt print /cpus \"#address-cells\"\n" - " fdt set /cpus \"#address-cells\" \"[00 00 00 01]\"\n" + "NOTE: If the path or property you are setting/printing has a '#' character\n" + " or spaces, you MUST escape it with a \\ character or quote it with \".\n" ); diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c index 377a692..f55447a 100644 --- a/common/cmd_fpga.c +++ b/common/cmd_fpga.c @@ -58,14 +58,11 @@ static int fpga_get_op (char *opstr); /* Convert bitstream data and load into the fpga */ int fpga_loadbitstream(unsigned long dev, char* fpgadata, size_t size) { -#if (CONFIG_FPGA & CFG_FPGA_XILINX) +#if defined(CONFIG_FPGA_XILINX) unsigned int length; - unsigned char* swapdata; unsigned int swapsize; char buffer[80]; - unsigned char *ptr; unsigned char *dataptr; - unsigned char data; unsigned int i; int rc; @@ -143,39 +140,7 @@ int fpga_loadbitstream(unsigned long dev, char* fpgadata, size_t size) dataptr+=4; printf(" bytes in bitstream = %d\n", swapsize); - /* check consistency of length obtained */ - if (swapsize >= size) { - printf("%s: Could not find right length of data in bitstream\n", - __FUNCTION__); - return FPGA_FAIL; - } - - /* allocate memory */ - swapdata = (unsigned char *)malloc(swapsize); - if (swapdata == NULL) { - printf("%s: Could not allocate %d bytes memory !\n", - __FUNCTION__, swapsize); - return FPGA_FAIL; - } - - /* read data into memory and swap bits */ - ptr = swapdata; - for (i = 0; i < swapsize; i++) { - data = 0x00; - data |= (*dataptr & 0x01) << 7; - data |= (*dataptr & 0x02) << 5; - data |= (*dataptr & 0x04) << 3; - data |= (*dataptr & 0x08) << 1; - data |= (*dataptr & 0x10) >> 1; - data |= (*dataptr & 0x20) >> 3; - data |= (*dataptr & 0x40) >> 5; - data |= (*dataptr & 0x80) >> 7; - *ptr++ = data; - dataptr++; - } - - rc = fpga_load(dev, swapdata, swapsize); - free(swapdata); + rc = fpga_load(dev, dataptr, swapsize); return rc; #else printf("Bitstream support only for Xilinx devices\n"); diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index efe9eb7..1b67e73 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -167,10 +167,19 @@ struct list_head devices; static struct mtd_device *current_dev = NULL; static u8 current_partnum = 0; +#if defined(CONFIG_CMD_CRAMFS) extern int cramfs_check (struct part_info *info); extern int cramfs_load (char *loadoffset, struct part_info *info, char *filename); extern int cramfs_ls (struct part_info *info, char *filename); extern int cramfs_info (struct part_info *info); +#else +/* defining empty macros for function names is ugly but avoids ifdef clutter + * all over the code */ +#define cramfs_check(x) (0) +#define cramfs_load(x,y,z) (-1) +#define cramfs_ls(x,y) (0) +#define cramfs_info(x) (0) +#endif static struct part_info* jffs2_part_info(struct mtd_device *dev, unsigned int part_num); diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 1fdd7a6..b248a2c 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -347,6 +347,14 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) opts.quiet = quiet; ret = nand_write_opts(nand, &opts); } + } else if (s != NULL && !strcmp(s, ".oob")) { + /* read out-of-band data */ + if (read) + ret = nand->read_oob(nand, off, size, &size, + (u_char *) addr); + else + ret = nand->write_oob(nand, off, size, &size, + (u_char *) addr); } else { if (read) ret = nand_read(nand, off, &size, (u_char *)addr); diff --git a/common/cmd_terminal.c b/common/cmd_terminal.c new file mode 100644 index 0000000..8871607 --- /dev/null +++ b/common/cmd_terminal.c @@ -0,0 +1,102 @@ +/* + * (C) Copyright 2007 OpenMoko, Inc. + * Written by Harald Welte <laforge@openmoko.org> + * + * 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 + */ + +/* + * Boot support + */ +#include <common.h> +#include <command.h> +#include <devices.h> + +#if defined(CONFIG_CMD_TERMINAL) + +int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[]) +{ + int i, l; + int last_tilde = 0; + device_t *dev = NULL; + + if (argc < 1) + return -1; + + /* Scan for selected output/input device */ + for (i = 1; i <= ListNumItems (devlist); i++) { + device_t *tmp = ListGetPtrToItem (devlist, i); + if (!strcmp(tmp->name, argv[1])) { + dev = tmp; + break; + } + } + if (!dev) + return -1; + + serial_reinit_all(); + printf("Entering terminal mode for port %s\n", dev->name); + puts("Use '~.' to leave the terminal and get back to u-boot\n"); + + while (1) { + int c; + + /* read from console and display on serial port */ + if (stdio_devices[0]->tstc()) { + c = stdio_devices[0]->getc(); + if (last_tilde == 1) { + if (c == '.') { + putc(c); + putc('\n'); + break; + } else { + last_tilde = 0; + /* write the delayed tilde */ + dev->putc('~'); + /* fall-through to print current + * character */ + } + } + if (c == '~') { + last_tilde = 1; + puts("[u-boot]"); + putc(c); + } + dev->putc(c); + } + + /* read from serial port and display on console */ + if (dev->tstc()) { + c = dev->getc(); + putc(c); + } + } + return 0; +} + + +/***************************************************/ + +U_BOOT_CMD( + terminal, 3, 1, do_terminal, + "terminal - start terminal emulator\n", + "" +); + +#endif /* CONFIG_CMD_TERMINAL */ diff --git a/common/cyclon2.c b/common/cyclon2.c index dce13b5..06f5e8a 100644 --- a/common/cyclon2.c +++ b/common/cyclon2.c @@ -27,7 +27,7 @@ #include <altera.h> #include <ACEX1K.h> /* ACEX device family */ -#if (CONFIG_FPGA & (CFG_ALTERA | CFG_CYCLON2)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ALTERA) && defined(CONFIG_FPGA_CYCLON2) /* Define FPGA_DEBUG to get debug printf's */ #ifdef FPGA_DEBUG @@ -302,4 +302,4 @@ static int CYC2_ps_reloc (Altera_desc * desc, ulong reloc_offset) return ret_val; } -#endif /* (CONFIG_FPGA & (CFG_ALTERA | CFG_CYCLON2)) */ +#endif /* CONFIG_FPGA && CONFIG_FPGA_ALTERA && CONFIG_FPGA_CYCLON2 */ diff --git a/common/env_onenand.c b/common/env_onenand.c index 66107f9..5888f75 100644 --- a/common/env_onenand.c +++ b/common/env_onenand.c @@ -64,7 +64,7 @@ void env_relocate_spec(void) DECLARE_GLOBAL_DATA_PTR; unsigned long env_addr; int use_default = 0; - int retlen; + size_t retlen; env_addr = CFG_ENV_ADDR; env_addr -= (unsigned long)onenand_chip.base; @@ -96,7 +96,7 @@ int saveenv(void) { unsigned long env_addr = CFG_ENV_ADDR; struct erase_info instr; - int retlen; + size_t retlen; instr.len = CFG_ENV_SIZE; instr.addr = env_addr; diff --git a/common/fdt_support.c b/common/fdt_support.c index b5ee6e9..92f1c7f 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -111,6 +111,7 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force) int err; u32 tmp; /* used to set 32 bit integer properties */ char *str; /* used to set string properties */ + const char *path; err = fdt_check_header(fdt); if (err < 0) { @@ -148,14 +149,7 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force) nodeoffset = fdt_path_offset (fdt, "/chosen"); /* - * If we have a "chosen" node already the "force the writing" - * is not set, our job is done. - */ - if ((nodeoffset >= 0) && !force) - return 0; - - /* - * No "chosen" node in the blob: create it. + * If there is no "chosen" node in the blob, create it. */ if (nodeoffset < 0) { /* @@ -170,42 +164,55 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force) } /* - * Update pre-existing properties, create them if non-existant. + * Create /chosen properites that don't exist in the fdt. + * If the property exists, update it only if the "force" parameter + * is true. */ str = getenv("bootargs"); if (str != NULL) { - err = fdt_setprop(fdt, nodeoffset, - "bootargs", str, strlen(str)+1); - if (err < 0) - printf("WARNING: could not set bootargs %s.\n", - fdt_strerror(err)); + path = fdt_getprop(fdt, nodeoffset, "bootargs", NULL); + if ((path == NULL) || force) { + err = fdt_setprop(fdt, nodeoffset, + "bootargs", str, strlen(str)+1); + if (err < 0) + printf("WARNING: could not set bootargs %s.\n", + fdt_strerror(err)); + } } if (initrd_start && initrd_end) { - tmp = __cpu_to_be32(initrd_start); - err = fdt_setprop(fdt, nodeoffset, - "linux,initrd-start", &tmp, sizeof(tmp)); - if (err < 0) - printf("WARNING: " - "could not set linux,initrd-start %s.\n", - fdt_strerror(err)); - tmp = __cpu_to_be32(initrd_end); - err = fdt_setprop(fdt, nodeoffset, - "linux,initrd-end", &tmp, sizeof(tmp)); - if (err < 0) - printf("WARNING: could not set linux,initrd-end %s.\n", - fdt_strerror(err)); + path = fdt_getprop(fdt, nodeoffset, "linux,initrd-start", NULL); + if ((path == NULL) || force) { + tmp = __cpu_to_be32(initrd_start); + err = fdt_setprop(fdt, nodeoffset, + "linux,initrd-start", &tmp, sizeof(tmp)); + if (err < 0) + printf("WARNING: " + "could not set linux,initrd-start %s.\n", + fdt_strerror(err)); + tmp = __cpu_to_be32(initrd_end); + err = fdt_setprop(fdt, nodeoffset, + "linux,initrd-end", &tmp, sizeof(tmp)); + if (err < 0) + printf("WARNING: could not set linux,initrd-end %s.\n", + fdt_strerror(err)); + } } #ifdef CONFIG_OF_STDOUT_VIA_ALIAS - err = fdt_fixup_stdout(fdt, nodeoffset); + path = fdt_getprop(fdt, nodeoffset, "linux,stdout-path", NULL); + if ((path == NULL) || force) + err = fdt_fixup_stdout(fdt, nodeoffset); #endif #ifdef OF_STDOUT_PATH - err = fdt_setprop(fdt, nodeoffset, - "linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1); - if (err < 0) - printf("WARNING: could not set linux,stdout-path %s.\n", - fdt_strerror(err)); + path = fdt_getprop(fdt, nodeoffset, "linux,stdout-path", NULL); + if ((path == NULL) || force) { + err = fdt_setprop(fdt, nodeoffset, + "linux,stdout-path", OF_STDOUT_PATH, strlen(OF_STDOUT_PATH)+1); + if (err < 0) + printf("WARNING: could not set linux,stdout-path %s.\n", + fdt_strerror(err)); + } #endif return err; diff --git a/common/fpga.c b/common/fpga.c index 2eff239..d8b6ae3 100644 --- a/common/fpga.c +++ b/common/fpga.c @@ -67,14 +67,11 @@ static int fpga_dev_info( int devnum ); static void fpga_no_sup( char *fn, char *msg ) { if ( fn && msg ) { - printf( "%s: No support for %s. CONFIG_FPGA defined as 0x%x.\n", - fn, msg, CONFIG_FPGA ); + printf( "%s: No support for %s.\n", fn, msg); } else if ( msg ) { - printf( "No support for %s. CONFIG_FPGA defined as 0x%x.\n", - msg, CONFIG_FPGA ); + printf( "No support for %s.\n", msg); } else { - printf( "No FPGA suport! CONFIG_FPGA defined as 0x%x.\n", - CONFIG_FPGA ); + printf( "No FPGA suport!\n"); } } @@ -112,11 +109,6 @@ static __attribute__((__const__)) fpga_desc * __attribute__((__const__)) fpga_va printf( "%s: Null buffer.\n", fn ); return (fpga_desc * const)NULL; } - if ( !bsize ) { - printf( "%s: Null buffer size.\n", fn ); - return (fpga_desc * const)NULL; - } - return desc; } @@ -135,7 +127,7 @@ static int fpga_dev_info( int devnum ) switch ( desc->devtype ) { case fpga_xilinx: -#if CONFIG_FPGA & CFG_FPGA_XILINX +#if defined(CONFIG_FPGA_XILINX) printf( "Xilinx Device\nDescriptor @ 0x%p\n", desc ); ret_val = xilinx_info( desc->devdesc ); #else @@ -143,7 +135,7 @@ static int fpga_dev_info( int devnum ) #endif break; case fpga_altera: -#if CONFIG_FPGA & CFG_FPGA_ALTERA +#if defined(CONFIG_FPGA_ALTERA) printf( "Altera Device\nDescriptor @ 0x%p\n", desc ); ret_val = altera_info( desc->devdesc ); #else @@ -175,14 +167,14 @@ int fpga_reloc( fpga_type devtype, void *desc, ulong reloc_off ) switch ( devtype ) { case fpga_xilinx: -#if CONFIG_FPGA & CFG_FPGA_XILINX +#if defined(CONFIG_FPGA_XILINX) ret_val = xilinx_reloc( desc, reloc_off ); #else fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" ); #endif break; case fpga_altera: -#if CONFIG_FPGA & CFG_FPGA_ALTERA +#if defined(CONFIG_FPGA_ALTERA) ret_val = altera_reloc( desc, reloc_off ); #else fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); @@ -268,14 +260,14 @@ int fpga_load( int devnum, void *buf, size_t bsize ) if ( desc ) { switch ( desc->devtype ) { case fpga_xilinx: -#if CONFIG_FPGA & CFG_FPGA_XILINX +#if defined(CONFIG_FPGA_XILINX) ret_val = xilinx_load( desc->devdesc, buf, bsize ); #else fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" ); #endif break; case fpga_altera: -#if CONFIG_FPGA & CFG_FPGA_ALTERA +#if defined(CONFIG_FPGA_ALTERA) ret_val = altera_load( desc->devdesc, buf, bsize ); #else fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); @@ -301,14 +293,14 @@ int fpga_dump( int devnum, void *buf, size_t bsize ) if ( desc ) { switch ( desc->devtype ) { case fpga_xilinx: -#if CONFIG_FPGA & CFG_FPGA_XILINX +#if defined(CONFIG_FPGA_XILINX) ret_val = xilinx_dump( desc->devdesc, buf, bsize ); #else fpga_no_sup( (char *)__FUNCTION__, "Xilinx devices" ); #endif break; case fpga_altera: -#if CONFIG_FPGA & CFG_FPGA_ALTERA +#if defined(CONFIG_FPGA_ALTERA) ret_val = altera_dump( desc->devdesc, buf, bsize ); #else fpga_no_sup( (char *)__FUNCTION__, "Altera devices" ); diff --git a/common/main.c b/common/main.c index 379695c..4253eac 100644 --- a/common/main.c +++ b/common/main.c @@ -696,7 +696,7 @@ static void cread_add_str(char *str, int strsize, int insert, unsigned long *num } } -static int cread_line(char *buf, unsigned int *len) +static int cread_line(const char *const prompt, char *buf, unsigned int *len) { unsigned long num = 0; unsigned long eol_num = 0; @@ -818,6 +818,7 @@ static int cread_line(char *buf, unsigned int *len) insert = !insert; break; case CTL_CH('x'): + case CTL_CH('u'): BEGINNING_OF_LINE(); ERASE_TO_EOL(); break; @@ -867,6 +868,27 @@ static int cread_line(char *buf, unsigned int *len) REFRESH_TO_EOL(); continue; } +#ifdef CONFIG_AUTO_COMPLETE + case '\t': { + int num2, col; + + /* do not autocomplete when in the middle */ + if (num < eol_num) { + getcmd_cbeep(); + break; + } + + buf[num] = '\0'; + col = strlen(prompt) + eol_num; + num2 = num; + if (cmd_auto_complete(prompt, buf, &num2, &col)) { + col = num2 - num; + num += col; + eol_num += col; + } + break; + } +#endif default: cread_add_char(ichar, insert, &num, &eol_num, buf, *len); break; @@ -909,7 +931,7 @@ int readline (const char *const prompt) puts (prompt); - rc = cread_line(p, &len); + rc = cread_line(prompt, p, &len); return rc < 0 ? rc : len; #else char *p = console_buffer; diff --git a/common/serial.c b/common/serial.c index b9916e2..5601080 100644 --- a/common/serial.c +++ b/common/serial.c @@ -33,7 +33,7 @@ static struct serial_device *serial_devices = NULL; static struct serial_device *serial_current = NULL; #if !defined(CONFIG_LWMON) && !defined(CONFIG_PXA27X) -struct serial_device *default_serial_console (void) +struct serial_device *__default_serial_console (void) { #if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2) return &serial_smc_device; @@ -64,6 +64,8 @@ struct serial_device *default_serial_console (void) #error No default console #endif } + +struct serial_device *default_serial_console(void) __attribute__((weak, alias("__default_serial_console"))); #endif int serial_register (struct serial_device *dev) diff --git a/common/spartan2.c b/common/spartan2.c index 06550b9..2f1ea2c 100644 --- a/common/spartan2.c +++ b/common/spartan2.c @@ -25,7 +25,7 @@ #include <common.h> /* core U-Boot definitions */ #include <spartan2.h> /* Spartan-II device family */ -#if (CONFIG_FPGA & (CFG_XILINX | CFG_SPARTAN2)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_SPARTAN2) /* Define FPGA_DEBUG to get debug printf's */ #ifdef FPGA_DEBUG @@ -441,7 +441,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) int ret_val = FPGA_FAIL; /* assume the worst */ Xilinx_Spartan2_Slave_Serial_fns *fn = desc->iface_fns; int i; - char val; + unsigned char val; PRINTF ("%s: start with interface functions @ 0x%p\n", __FUNCTION__, fn); @@ -561,6 +561,13 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) } putc ('\n'); /* terminate the dotted line */ + /* + * Run the post configuration function if there is one. + */ + if (*fn->post) { + (*fn->post) (cookie); + } + #ifdef CFG_FPGA_PROG_FEEDBACK if (ret_val == FPGA_SUCCESS) { puts ("Done.\n"); @@ -615,8 +622,10 @@ static int Spartan2_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, desc); - addr = (ulong) (fn->pre) + reloc_offset; - fn_r->pre = (Xilinx_pre_fn) addr; + if (fn->pre) { + addr = (ulong) (fn->pre) + reloc_offset; + fn_r->pre = (Xilinx_pre_fn) addr; + } addr = (ulong) (fn->pgm) + reloc_offset; fn_r->pgm = (Xilinx_pgm_fn) addr; @@ -633,6 +642,11 @@ static int Spartan2_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) addr = (ulong) (fn->wr) + reloc_offset; fn_r->wr = (Xilinx_wr_fn) addr; + if (fn->post) { + addr = (ulong) (fn->post) + reloc_offset; + fn_r->post = (Xilinx_post_fn) addr; + } + fn_r->relocated = TRUE; } else { diff --git a/common/spartan3.c b/common/spartan3.c index f7c4f8c..d329e70 100644 --- a/common/spartan3.c +++ b/common/spartan3.c @@ -30,7 +30,7 @@ #include <common.h> /* core U-Boot definitions */ #include <spartan3.h> /* Spartan-II device family */ -#if (CONFIG_FPGA & (CFG_XILINX | CFG_SPARTAN3)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_SPARTAN3) /* Define FPGA_DEBUG to get debug printf's */ #ifdef FPGA_DEBUG @@ -446,7 +446,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) int ret_val = FPGA_FAIL; /* assume the worst */ Xilinx_Spartan3_Slave_Serial_fns *fn = desc->iface_fns; int i; - char val; + unsigned char val; PRINTF ("%s: start with interface functions @ 0x%p\n", __FUNCTION__, fn); @@ -566,6 +566,13 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) } putc ('\n'); /* terminate the dotted line */ + /* + * Run the post configuration function if there is one. + */ + if (*fn->post) { + (*fn->post) (cookie); + } + #ifdef CFG_FPGA_PROG_FEEDBACK if (ret_val == FPGA_SUCCESS) { puts ("Done.\n"); @@ -620,8 +627,10 @@ static int Spartan3_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) PRINTF ("%s: Relocating descriptor at 0x%p\n", __FUNCTION__, desc); - addr = (ulong) (fn->pre) + reloc_offset; - fn_r->pre = (Xilinx_pre_fn) addr; + if (fn->pre) { + addr = (ulong) (fn->pre) + reloc_offset; + fn_r->pre = (Xilinx_pre_fn) addr; + } addr = (ulong) (fn->pgm) + reloc_offset; fn_r->pgm = (Xilinx_pgm_fn) addr; @@ -638,6 +647,11 @@ static int Spartan3_ss_reloc (Xilinx_desc * desc, ulong reloc_offset) addr = (ulong) (fn->wr) + reloc_offset; fn_r->wr = (Xilinx_wr_fn) addr; + if (fn->post) { + addr = (ulong) (fn->post) + reloc_offset; + fn_r->post = (Xilinx_post_fn) addr; + } + fn_r->relocated = TRUE; } else { diff --git a/common/virtex2.c b/common/virtex2.c index b5dc366..1283ff6 100644 --- a/common/virtex2.c +++ b/common/virtex2.c @@ -31,7 +31,7 @@ #include <common.h> #include <virtex2.h> -#if (CONFIG_FPGA & (CFG_XILINX | CFG_VIRTEX2)) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_VIRTEX2) #if 0 #define FPGA_DEBUG diff --git a/common/xilinx.c b/common/xilinx.c index e03e78c..c898238 100644 --- a/common/xilinx.c +++ b/common/xilinx.c @@ -32,7 +32,7 @@ #include <spartan2.h> #include <spartan3.h> -#if (CONFIG_FPGA & CFG_FPGA_XILINX) +#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX) #if 0 #define FPGA_DEBUG @@ -59,7 +59,7 @@ int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize) } else switch (desc->family) { case Xilinx_Spartan2: -#if (CONFIG_FPGA & CFG_SPARTAN2) +#if defined(CONFIG_FPGA_SPARTAN2) PRINTF ("%s: Launching the Spartan-II Loader...\n", __FUNCTION__); ret_val = Spartan2_load (desc, buf, bsize); @@ -69,7 +69,7 @@ int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif break; case Xilinx_Spartan3: -#if (CONFIG_FPGA & CFG_SPARTAN3) +#if defined(CONFIG_FPGA_SPARTAN3) PRINTF ("%s: Launching the Spartan-III Loader...\n", __FUNCTION__); ret_val = Spartan3_load (desc, buf, bsize); @@ -79,7 +79,7 @@ int xilinx_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif break; case Xilinx_Virtex2: -#if (CONFIG_FPGA & CFG_VIRTEX2) +#if defined(CONFIG_FPGA_VIRTEX2) PRINTF ("%s: Launching the Virtex-II Loader...\n", __FUNCTION__); ret_val = Virtex2_load (desc, buf, bsize); @@ -106,7 +106,7 @@ int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize) } else switch (desc->family) { case Xilinx_Spartan2: -#if (CONFIG_FPGA & CFG_SPARTAN2) +#if defined(CONFIG_FPGA_SPARTAN2) PRINTF ("%s: Launching the Spartan-II Reader...\n", __FUNCTION__); ret_val = Spartan2_dump (desc, buf, bsize); @@ -116,7 +116,7 @@ int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize) #endif break; case Xilinx_Spartan3: -#if (CONFIG_FPGA & CFG_SPARTAN3) +#if defined(CONFIG_FPGA_SPARTAN3) PRINTF ("%s: Launching the Spartan-III Reader...\n", __FUNCTION__); ret_val = Spartan3_dump (desc, buf, bsize); @@ -126,7 +126,7 @@ int xilinx_dump (Xilinx_desc * desc, void *buf, size_t bsize) #endif break; case Xilinx_Virtex2: -#if (CONFIG_FPGA & CFG_VIRTEX2) +#if defined( CONFIG_FPGA_VIRTEX2) PRINTF ("%s: Launching the Virtex-II Reader...\n", __FUNCTION__); ret_val = Virtex2_dump (desc, buf, bsize); @@ -198,7 +198,7 @@ int xilinx_info (Xilinx_desc * desc) printf ("Device Function Table @ 0x%p\n", desc->iface_fns); switch (desc->family) { case Xilinx_Spartan2: -#if (CONFIG_FPGA & CFG_SPARTAN2) +#if defined(CONFIG_FPGA_SPARTAN2) Spartan2_info (desc); #else /* just in case */ @@ -207,7 +207,7 @@ int xilinx_info (Xilinx_desc * desc) #endif break; case Xilinx_Spartan3: -#if (CONFIG_FPGA & CFG_SPARTAN3) +#if defined(CONFIG_FPGA_SPARTAN3) Spartan3_info (desc); #else /* just in case */ @@ -216,7 +216,7 @@ int xilinx_info (Xilinx_desc * desc) #endif break; case Xilinx_Virtex2: -#if (CONFIG_FPGA & CFG_VIRTEX2) +#if defined(CONFIG_FPGA_VIRTEX2) Virtex2_info (desc); #else /* just in case */ @@ -249,7 +249,7 @@ int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset) } else switch (desc->family) { case Xilinx_Spartan2: -#if (CONFIG_FPGA & CFG_SPARTAN2) +#if defined(CONFIG_FPGA_SPARTAN2) ret_val = Spartan2_reloc (desc, reloc_offset); #else printf ("%s: No support for Spartan-II devices.\n", @@ -257,7 +257,7 @@ int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset) #endif break; case Xilinx_Spartan3: -#if (CONFIG_FPGA & CFG_SPARTAN3) +#if defined(CONFIG_FPGA_SPARTAN3) ret_val = Spartan3_reloc (desc, reloc_offset); #else printf ("%s: No support for Spartan-III devices.\n", @@ -265,7 +265,7 @@ int xilinx_reloc (Xilinx_desc * desc, ulong reloc_offset) #endif break; case Xilinx_Virtex2: -#if (CONFIG_FPGA & CFG_VIRTEX2) +#if defined(CONFIG_FPGA_VIRTEX2) ret_val = Virtex2_reloc (desc, reloc_offset); #else printf ("%s: No support for Virtex-II devices.\n", @@ -308,4 +308,4 @@ static int xilinx_validate (Xilinx_desc * desc, char *fn) return ret_val; } -#endif /* CONFIG_FPGA & CFG_FPGA_XILINX */ +#endif /* CONFIG_FPGA && CONFIG_FPGA_XILINX */ |