diff options
45 files changed, 1295 insertions, 484 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..90f0fd7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,150 @@ +# Copyright Roger Meier <r.meier@siemens.com> +# SPDX-License-Identifier: GPL-2.0+ + +# build U-Boot on Travis CI - https://travis-ci.org/ + +language: c + +cache: + - apt + +install: + # install U-Boot build dependencies + - sudo apt-get install -qq cppcheck sloccount sparse bc libsdl-dev gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf + # install latest device tree compiler + - git clone --depth=1 https://git.kernel.org/pub/scm/utils/dtc/dtc.git /tmp/dtc + - make -j4 -C /tmp/dtc + # prepare buildman environment + - export BUILDMAN_ROOT="root:" + - export BUILDMAN_MIPS="mips:" + - export BUILDMAN_PPC="ppc:" + - echo -e "[toolchain]\\n${BUILDMAN_ROOT} /\n" > ~/.buildman + - echo -e "${BUILDMAN_MIPS} /opt/eldk-5.4/mips/sysroots/i686-eldk-linux/usr/bin/mips32-linux/" >> ~/.buildman + - echo -e "${BUILDMAN_PPC} /opt/eldk-5.4/powerpc/sysroots/i686-eldk-linux/usr/bin/powerpc-linux/" >> ~/.buildman + - export BUILDMAN_ALIAS="x86:" + - echo -e "[toolchain-alias]\\n${BUILDMAN_ALIAS} i386" >> ~/.buildman + - cat ~/.buildman + +env: + global: + - PATH=/tmp/dtc:$PATH + - BUILD_DIR=build + - CROSS_COMPILE="" + - HOSTCC="cc" + - HOSTCXX="c++" + - TEST_CONFIG_CMD="" + +before_script: + # install toolchains based on INSTALL_TOOLCHAIN} variable + - if [[ "${INSTALL_TOOLCHAIN}" == *ppc* ]]; then wget ftp://ftp.denx.de/pub/eldk/5.4/targets/powerpc/eldk-eglibc-i686-powerpc-toolchain-gmae-5.4.sh ; fi + - if [[ "${INSTALL_TOOLCHAIN}" == *ppc* ]]; then sh eldk-eglibc-i686-powerpc-toolchain-gmae-5.4.sh -y ; fi + - if [[ "${INSTALL_TOOLCHAIN}" == *mips* ]]; then wget ftp://ftp.denx.de/pub/eldk/5.4/targets/mips/eldk-eglibc-i686-mips-toolchain-gmae-5.4.sh ; fi + - if [[ "${INSTALL_TOOLCHAIN}" == *mips* ]]; then sh eldk-eglibc-i686-mips-toolchain-gmae-5.4.sh -y ; fi + +script: + # the execution sequence for each test + - echo ${TEST_CONFIG_CMD} + - ${TEST_CONFIG_CMD} + - echo ${TEST_CMD} + - ${TEST_CMD} + +matrix: + include: + # we need to build by vendor due to 50min time limit for builds + # each env setting here is a dedicated build + - env: + - TEST_CMD="./MAKEALL -a arm -v atmel" + CROSS_COMPILE="arm-linux-gnueabi-" + - env: + - TEST_CMD="./MAKEALL -a arm -v denx" + CROSS_COMPILE="arm-linux-gnueabi-" + - env: + - TEST_CMD="./MAKEALL -a arm -v freescale" + CROSS_COMPILE="arm-linux-gnueabi-" + - env: + - TEST_CMD="./MAKEALL -a arm -v siemens" + CROSS_COMPILE="arm-linux-gnueabi-" + - env: + - TEST_CMD="./MAKEALL -a arm -v ti" + CROSS_COMPILE="arm-linux-gnueabi-" + - env: + - TEST_CONFIG_CMD="make sandbox_defconfig" + TEST_CMD="make -j4" + HOSTCC = "gcc" + HOSTCXX = "g++" + - env: + - TEST_CONFIG_CMD="make sandbox_defconfig" + TEST_CMD="make -j4" + HOSTCC = "clang" + HOSTCXX = "clang++" + - env: + - TEST_CMD="./MAKEALL -a mips" + INSTALL_TOOLCHAIN="mips" + CROSS_COMPILE="/opt/eldk-5.4/mips/sysroots/i686-eldk-linux/usr/bin/mips32-linux/mips-linux-" + - env: + - TEST_CMD="tools/buildman/buildman --list-error-boards atmel" + - env: + - TEST_CMD="tools/buildman/buildman --list-error-boards denx" + - env: + - TEST_CMD="tools/buildman/buildman --list-error-boards freescale arm" + - env: + - TEST_CMD="tools/buildman/buildman --list-error-boards siemens" + - env: + - TEST_CMD="tools/buildman/buildman --list-error-boards ti" + - env: + - TEST_CMD="tools/buildman/buildman mips" + INSTALL_TOOLCHAIN="mips" + - env: + - TEST_CMD="tools/buildman/buildman mpc5xx" + INSTALL_TOOLCHAIN="ppc" + - env: + - TEST_CMD="tools/buildman/buildman mpc8xx" + INSTALL_TOOLCHAIN="ppc" + - env: + - TEST_CMD="tools/buildman/buildman mpc5xxx" + INSTALL_TOOLCHAIN="ppc" + - env: + - TEST_CMD="tools/buildman/buildman mpc512x" + INSTALL_TOOLCHAIN="ppc" + - env: + - TEST_CMD="tools/buildman/buildman mpc824x" + INSTALL_TOOLCHAIN="ppc" + - env: + - TEST_CMD="tools/buildman/buildman mpc8260" + INSTALL_TOOLCHAIN="ppc" + - env: + - TEST_CMD="tools/buildman/buildman mpc83xx" + INSTALL_TOOLCHAIN="ppc" + - env: + - TEST_CMD="tools/buildman/buildman mpc85xx" + INSTALL_TOOLCHAIN="ppc" + - env: + - TEST_CMD="tools/buildman/buildman mpc86xx" + INSTALL_TOOLCHAIN="ppc" + + - env: + - TEST_CMD="tools/buildman/buildman --list-error-boards sandbox x86" + + # QA jobs for code analytics + # static code analysis with cppcheck (we can add --enable=all later) + - env: + - TEST_CMD="cppcheck --force --quiet --inline-suppr ." + # search for TODO within source tree + - env: + - TEST_CMD="grep -r TODO ." + # search for FIXME within source tree + - env: + - TEST_CMD="grep -r FIXME ." + # search for HACK within source tree and ignore HACKKIT board + - env: + - TEST_CMD="grep -r HACK . | grep -v HACKKIT" + script: + - grep -r HACK . | grep -v HACKKIT + # some statistics about the code base + - env: + - TEST_CMD="sloccount ." + +notifications: + email: false + +# TODO make it perfect ;-r @@ -143,6 +143,12 @@ config SYS_TEXT_BASE help TODO: Move CONFIG_SYS_TEXT_BASE for all the architecture +config SYS_CLK_FREQ + depends on ARC + int "CPU clock frequency" + help + TODO: Move CONFIG_SYS_CLK_FREQ for all the architecture + endmenu # Boot images source "arch/Kconfig" diff --git a/arch/arm/cpu/arm926ejs/kirkwood/Kconfig b/arch/arm/cpu/arm926ejs/kirkwood/Kconfig index 6c037a1..45c6687 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/Kconfig +++ b/arch/arm/cpu/arm926ejs/kirkwood/Kconfig @@ -57,6 +57,9 @@ config TARGET_DOCKSTAR config TARGET_GOFLEXHOME bool "GoFlex Home Board" +config TARGET_NAS220 + bool "BlackArmor NAS220" + endchoice config SYS_SOC @@ -80,5 +83,6 @@ source "board/LaCie/wireless_space/Kconfig" source "board/raidsonic/ib62x0/Kconfig" source "board/Seagate/dockstar/Kconfig" source "board/Seagate/goflexhome/Kconfig" +source "board/Seagate/nas220/Kconfig" endif diff --git a/arch/arm/cpu/armv8/cache.S b/arch/arm/cpu/armv8/cache.S index 4b3ee6e..9c6e824 100644 --- a/arch/arm/cpu/armv8/cache.S +++ b/arch/arm/cpu/armv8/cache.S @@ -94,7 +94,7 @@ skip: b.gt loop_level mov x0, #0 - msr csselr_el1, x0 /* resotre csselr_el1 */ + msr csselr_el1, x0 /* restore csselr_el1 */ dsb sy isb mov lr, x15 diff --git a/board/Seagate/nas220/Kconfig b/board/Seagate/nas220/Kconfig new file mode 100644 index 0000000..0fa529c --- /dev/null +++ b/board/Seagate/nas220/Kconfig @@ -0,0 +1,12 @@ +if TARGET_NAS220 + +config SYS_BOARD + default "nas220" + +config SYS_VENDOR + default "Seagate" + +config SYS_CONFIG_NAME + default "nas220" + +endif diff --git a/board/Seagate/nas220/MAINTAINERS b/board/Seagate/nas220/MAINTAINERS new file mode 100644 index 0000000..f2df7ea --- /dev/null +++ b/board/Seagate/nas220/MAINTAINERS @@ -0,0 +1,6 @@ +NAS220 BOARD +M: Evgeni Dobrev <evgeni@studio-punkt.com> +S: Maintained +F: board/Seagate/nas220/ +F: include/configs/nas220.h +F: configs/nas220_defconfig diff --git a/board/Seagate/nas220/Makefile b/board/Seagate/nas220/Makefile new file mode 100644 index 0000000..9de73e6 --- /dev/null +++ b/board/Seagate/nas220/Makefile @@ -0,0 +1,7 @@ +# +# Copyright (C) 2014 Evgeni Dobrev <evgeni@studio-punkt.com> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y := nas220.o diff --git a/board/Seagate/nas220/kwbimage.cfg b/board/Seagate/nas220/kwbimage.cfg new file mode 100644 index 0000000..dbbfb9c --- /dev/null +++ b/board/Seagate/nas220/kwbimage.cfg @@ -0,0 +1,151 @@ +# +# Copyright (C) 2014 Evgeni Dobrev <evgeni@studio-punkt.com> +# +# Based on sheevaplug/kwbimage.cfg originally written by +# Prafulla Wadaskar <prafulla@marvell.com> +# (C) Copyright 2009 +# Marvell Semiconductor <www.marvell.com> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Refer doc/README.kwbimage for more details about how-to configure +# and create kirkwood boot image +# + +# Boot Media configurations +BOOT_FROM nand +NAND_ECC_MODE default +NAND_PAGE_SIZE 0x0200 + +# SOC registers configuration using bootrom header extension +# Maximum KWBIMAGE_MAX_CONFIG configurations allowed + +# Configure RGMII-0 interface pad voltage to 1.8V +DATA 0xFFD100e0 0x1b1b1b9b + +#Dram initalization for SINGLE x16 CL=5 @ 400MHz +DATA 0xFFD01400 0x43000618 # DDR Configuration register +# bit13-0: 0xa00 (2560 DDR2 clks refresh rate) +# bit23-14: zero +# bit24: 1= enable exit self refresh mode on DDR access +# bit25: 1 required +# bit29-26: zero +# bit31-30: 01 + +DATA 0xFFD01404 0x35143000 # DDR Controller Control Low +# bit 4: 0=addr/cmd in smame cycle +# bit 5: 0=clk is driven during self refresh, we don't care for APX +# bit 6: 0=use recommended falling edge of clk for addr/cmd +# bit14: 0=input buffer always powered up +# bit18: 1=cpu lock transaction enabled +# bit23-20: 5=recommended value for CL=5 and STARTBURST_DEL disabled bit31=0 +# bit27-24: 8= CL+3, STARTBURST sample stages, for freqs 400MHz, unbuffered DIMM +# bit30-28: 3 required +# bit31: 0=no additional STARTBURST delay + +DATA 0xFFD01408 0x11012227 # DDR Timing (Low) (active cycles value +1) +# bit7-4: TRCD +# bit11- 8: TRP +# bit15-12: TWR +# bit19-16: TWTR +# bit20: TRAS msb +# bit23-21: 0x0 +# bit27-24: TRRD +# bit31-28: TRTP + +DATA 0xFFD0140C 0x00000819 # DDR Timing (High) +# bit6-0: TRFC +# bit8-7: TR2R +# bit10-9: TR2W +# bit12-11: TW2W +# bit31-13: zero required + + +DATA 0xFFD01410 0x0000000d # DDR Address Control +# bit1-0: 00, Cs0width=x8 +# bit3-2: 11, Cs0size=1Gb +# bit5-4: 00, Cs1width=nonexistent +# bit7-6: 00, Cs1size =nonexistent +# bit9-8: 00, Cs2width=nonexistent +# bit11-10: 00, Cs2size =nonexistent +# bit13-12: 00, Cs3width=nonexistent +# bit15-14: 00, Cs3size =nonexistent +# bit16: 0, Cs0AddrSel +# bit17: 0, Cs1AddrSel +# bit18: 0, Cs2AddrSel +# bit19: 0, Cs3AddrSel +# bit31-20: 0 required + +DATA 0xFFD01414 0x00000000 # DDR Open Pages Control +# bit0: 0, OpenPage enabled +# bit31-1: 0 required + +DATA 0xFFD01418 0x00000000 # DDR Operation +# bit3-0: 0x0, DDR cmd +# bit31-4: 0 required + +DATA 0xFFD0141C 0x00000632 # DDR Mode +# bit2-0: 2, BurstLen=2 required +# bit3: 0, BurstType=0 required +# bit6-4: 4, CL=5 +# bit7: 0, TestMode=0 normal +# bit8: 0, DLL reset=0 normal +# bit11-9: 6, auto-precharge write recovery ???????????? +# bit12: 0, PD must be zero +# bit31-13: 0 required + + +DATA 0xFFD01420 0x00000040 # DDR Extended Mode +# bit0: 0, DDR DLL enabled +# bit1: 0, DDR drive strenght normal +# bit2: 0, DDR ODT control lsd (disabled) +# bit5-3: 000, required +# bit6: 1, DDR ODT control msb, (disabled) +# bit9-7: 000, required +# bit10: 0, differential DQS enabled +# bit11: 0, required +# bit12: 0, DDR output buffer enabled +# bit31-13: 0 required + +DATA 0xFFD01424 0x0000F07F # DDR Controller Control High +# bit2-0: 111, required +# bit3 : 1 , MBUS Burst Chop disabled +# bit6-4: 111, required +# bit7 : 0 +# bit8 : 0 +# bit9 : 0 , no half clock cycle addition to dataout +# bit10 : 0 , 1/4 clock cycle skew enabled for addr/ctl signals +# bit11 : 0 , 1/4 clock cycle skew disabled for write mesh +# bit15-12: 1111 required +# bit31-16: 0 required + +DATA 0xFFD01504 0x07FFFFF1 # CS[0]n Size +# bit0: 1, Window enabled +# bit1: 0, Write Protect disabled +# bit3-2: 00, CS0 hit selected +# bit23-4: ones, required +# bit31-24: 0x07, Size (i.e. 128MB) + +DATA 0xFFD01508 0x00000000 # CS[1]n Base address to 0x0 + +DATA 0xFFD0150C 0x00000000 # CS[1]n Size, window disabled + +DATA 0xFFD01514 0x00000000 # CS[2]n Size, window disabled +DATA 0xFFD0151C 0x00000000 # CS[3]n Size, window disabled + +DATA 0xFFD01494 0x00030000 # DDR ODT Control (Low) +DATA 0xFFD01498 0x00000000 # DDR ODT Control (High) +# bit1-0: 00, ODT0 controlled by ODT Control (low) register above +# bit3-2: 01, ODT1 active NEVER! +# bit31-4: zero, required + +DATA 0xFFD0149C 0x0000E803 # CPU ODT Control + +DATA 0xFFD01480 0x00000001 # DDR Initialization Control +#bit0=1, enable DDR init upon this register write + +DATA 0xffd01620 0x00465000 + +# End of Header extension +DATA 0x0 0x0 + diff --git a/board/Seagate/nas220/nas220.c b/board/Seagate/nas220/nas220.c new file mode 100644 index 0000000..d9a0627 --- /dev/null +++ b/board/Seagate/nas220/nas220.c @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2014 Evgeni Dobrev <evgeni@studio-punkt.com> + * + * Based on sheevaplug.c originally written by + * Prafulla Wadaskar <prafulla@marvell.com> + * (C) Copyright 2009 + * Marvell Semiconductor <www.marvell.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <miiphy.h> +#include <asm/arch/soc.h> +#include <asm/arch/mpp.h> +#include <asm/arch/cpu.h> +#include <asm/io.h> + +DECLARE_GLOBAL_DATA_PTR; + +int board_early_init_f(void) +{ + /* + * default gpio configuration + */ + mvebu_config_gpio(NAS220_GE_OE_VAL_LOW, NAS220_GE_OE_VAL_HIGH, + NAS220_GE_OE_LOW, NAS220_GE_OE_HIGH); + + /* Multi-Purpose Pins Functionality configuration */ + static const u32 kwmpp_config[] = { + MPP0_NF_IO2, + MPP1_NF_IO3, + MPP2_NF_IO4, + MPP3_NF_IO5, + MPP4_NF_IO6, + MPP5_NF_IO7, + MPP6_SYSRST_OUTn, + MPP7_SPI_SCn, + MPP8_TW_SDA, + MPP9_TW_SCK, + MPP10_UART0_TXD, + MPP11_UART0_RXD, + MPP12_GPO, + MPP13_GPIO, + MPP14_GPIO, + MPP15_SATA0_ACTn, + MPP16_SATA1_ACTn, + MPP17_SATA0_PRESENTn, + MPP18_NF_IO0, + MPP19_NF_IO1, + MPP20_GPIO, + MPP21_GPIO, + MPP22_GPIO, + MPP23_GPIO, + MPP24_GPIO, + MPP25_GPIO, + MPP26_GPIO, + MPP27_GPIO, + MPP28_GPIO, + MPP29_GPIO, + MPP30_GPIO, + MPP31_GPIO, + MPP32_GPIO, + MPP33_GPIO, + MPP34_GPIO, + MPP35_GPIO, + 0 + }; + kirkwood_mpp_conf(kwmpp_config, NULL); + return 0; +} + +int board_init(void) +{ + /* + * arch number of board + */ + gd->bd->bi_arch_number = MACH_TYPE_NAS220; + + /* adress of boot parameters */ + gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; + + return 0; +} + +#ifdef CONFIG_RESET_PHY_R +/* Configure and enable MV88E1116 PHY */ +void reset_phy(void) +{ + u16 reg; + u16 devadr; + char *name = "egiga0"; + + if (miiphy_set_current_dev(name)) + return; + + /* command to read PHY dev address */ + if (miiphy_read(name, 0xEE, 0xEE, (u16 *)&devadr)) { + printf("Err..%s could not read PHY dev address\n", __func__); + return; + } + + /* + * Enable RGMII delay on Tx and Rx for CPU port + * Ref: sec 4.7.2 of chip datasheet + */ + miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2); + miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®); + reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL); + miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg); + miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0); + + /* reset the phy */ + miiphy_reset(name, devadr); + + printf("88E1116 Initialized on %s\n", name); +} +#endif /* CONFIG_RESET_PHY_R */ diff --git a/common/Makefile b/common/Makefile index c668a2f..94554f2 100644 --- a/common/Makefile +++ b/common/Makefile @@ -196,7 +196,7 @@ obj-$(CONFIG_CMD_KGDB) += kgdb.o kgdb_stubs.o obj-$(CONFIG_I2C_EDID) += edid.o obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-y += splash.o -obj-$(CONFIG_LCD) += lcd.o +obj-$(CONFIG_LCD) += lcd.o lcd_console.o obj-$(CONFIG_LYNXKDI) += lynxkdi.o obj-$(CONFIG_MENU) += menu.o obj-$(CONFIG_MODEM_SUPPORT) += modem.o diff --git a/common/bootm.c b/common/bootm.c index 6b3ea8c..e2dc164 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -264,103 +264,122 @@ static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } -#endif /* USE_HOSTCC */ +#endif /* USE_HOSTC */ /** - * decomp_image() - decompress the operating system + * print_decomp_msg() - Print a suitable decompression/loading message * - * @comp: Compression algorithm that is used (IH_COMP_...) - * @load: Destination load address in U-Boot memory - * @image_start Image start address (where we are decompressing from) * @type: OS type (IH_OS_...) - * @load_bug: Place to decompress to - * @image_buf: Address to decompress from - * @return 0 if OK, -ve on error (BOOTM_ERR_...) + * @comp_type: Compression type being used (IH_COMP_...) + * @is_xip: true if the load address matches the image start */ -static int decomp_image(int comp, ulong load, ulong image_start, int type, - void *load_buf, void *image_buf, ulong image_len, - ulong *load_end) +static void print_decomp_msg(int comp_type, int type, bool is_xip) { - const char *type_name = genimg_get_type_name(type); - __attribute__((unused)) uint unc_len = CONFIG_SYS_BOOTM_LEN; + const char *name = genimg_get_type_name(type); + + if (comp_type == IH_COMP_NONE) + printf(" %s %s ... ", is_xip ? "XIP" : "Loading", name); + else + printf(" Uncompressing %s ... ", name); +} + +/** + * handle_decomp_error() - display a decompression error + * + * This function tries to produce a useful message. In the case where the + * uncompressed size is the same as the available space, we can assume that + * the image is too large for the buffer. + * + * @comp_type: Compression type being used (IH_COMP_...) + * @uncomp_size: Number of bytes uncompressed + * @unc_len: Amount of space available for decompression + * @ret: Error code to report + * @return BOOTM_ERR_RESET, indicating that the board must be reset + */ +static int handle_decomp_error(int comp_type, size_t uncomp_size, + size_t unc_len, int ret) +{ + const char *name = genimg_get_comp_name(comp_type); + + if (uncomp_size >= unc_len) + printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n"); + else + printf("%s: uncompress error %d\n", name, ret); + + /* + * The decompression routines are now safe, so will not write beyond + * their bounds. Probably it is not necessary to reset, but maintain + * the current behaviour for now. + */ + printf("Must RESET board to recover\n"); +#ifndef USE_HOSTCC + bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE); +#endif + + return BOOTM_ERR_RESET; +} + +int bootm_decomp_image(int comp, ulong load, ulong image_start, int type, + void *load_buf, void *image_buf, ulong image_len, + uint unc_len, ulong *load_end) +{ + int ret = 0; *load_end = load; + print_decomp_msg(comp, type, load == image_start); + + /* + * Load the image to the right place, decompressing if needed. After + * this, image_len will be set to the number of uncompressed bytes + * loaded, ret will be non-zero on error. + */ switch (comp) { case IH_COMP_NONE: - if (load == image_start) { - printf(" XIP %s ... ", type_name); - } else { - printf(" Loading %s ... ", type_name); + if (load == image_start) + break; + if (image_len <= unc_len) memmove_wd(load_buf, image_buf, image_len, CHUNKSZ); - } - *load_end = load + image_len; + else + ret = 1; break; #ifdef CONFIG_GZIP - case IH_COMP_GZIP: - printf(" Uncompressing %s ... ", type_name); - if (gunzip(load_buf, unc_len, image_buf, &image_len) != 0) { - puts("GUNZIP: uncompress, out-of-mem or overwrite error - must RESET board to recover\n"); - return BOOTM_ERR_RESET; - } - - *load_end = load + image_len; + case IH_COMP_GZIP: { + ret = gunzip(load_buf, unc_len, image_buf, &image_len); break; + } #endif /* CONFIG_GZIP */ #ifdef CONFIG_BZIP2 - case IH_COMP_BZIP2: - printf(" Uncompressing %s ... ", type_name); + case IH_COMP_BZIP2: { + uint size = unc_len; + /* * If we've got less than 4 MB of malloc() space, * use slower decompression algorithm which requires * at most 2300 KB of memory. */ - int i = BZ2_bzBuffToBuffDecompress(load_buf, &unc_len, + ret = BZ2_bzBuffToBuffDecompress(load_buf, &size, image_buf, image_len, CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0); - if (i != BZ_OK) { - printf("BUNZIP2: uncompress or overwrite error %d - must RESET board to recover\n", - i); - return BOOTM_ERR_RESET; - } - - *load_end = load + unc_len; + image_len = size; break; + } #endif /* CONFIG_BZIP2 */ #ifdef CONFIG_LZMA case IH_COMP_LZMA: { SizeT lzma_len = unc_len; - int ret; - - printf(" Uncompressing %s ... ", type_name); ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len, image_buf, image_len); - unc_len = lzma_len; - if (ret != SZ_OK) { - printf("LZMA: uncompress or overwrite error %d - must RESET board to recover\n", - ret); - bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE); - return BOOTM_ERR_RESET; - } - *load_end = load + unc_len; + image_len = lzma_len; break; } #endif /* CONFIG_LZMA */ #ifdef CONFIG_LZO case IH_COMP_LZO: { size_t size = unc_len; - int ret; - - printf(" Uncompressing %s ... ", type_name); ret = lzop_decompress(image_buf, image_len, load_buf, &size); - if (ret != LZO_E_OK) { - printf("LZO: uncompress or overwrite error %d - must RESET board to recover\n", - ret); - return BOOTM_ERR_RESET; - } - - *load_end = load + size; + image_len = size; break; } #endif /* CONFIG_LZO */ @@ -369,6 +388,10 @@ static int decomp_image(int comp, ulong load, ulong image_start, int type, return BOOTM_ERR_UNIMPLEMENTED; } + if (ret) + return handle_decomp_error(comp, image_len, unc_len, ret); + *load_end = load + image_len; + puts("OK\n"); return 0; @@ -390,8 +413,9 @@ static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end, load_buf = map_sysmem(load, 0); image_buf = map_sysmem(os.image_start, image_len); - err = decomp_image(os.comp, load, os.image_start, os.type, load_buf, - image_buf, image_len, load_end); + err = bootm_decomp_image(os.comp, load, os.image_start, os.type, + load_buf, image_buf, image_len, + CONFIG_SYS_BOOTM_LEN, load_end); if (err) { bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE); return err; @@ -882,9 +906,11 @@ static int bootm_host_load_image(const void *fit, int req_image_type) /* Allow the image to expand by a factor of 4, should be safe */ load_buf = malloc((1 << 20) + len * 4); - ret = decomp_image(imape_comp, 0, data, image_type, load_buf, - (void *)data, len, &load_end); + ret = bootm_decomp_image(imape_comp, 0, data, image_type, load_buf, + (void *)data, len, CONFIG_SYS_BOOTM_LEN, + &load_end); free(load_buf); + if (ret && ret != BOOTM_ERR_UNIMPLEMENTED) return ret; diff --git a/common/bootm_os.c b/common/bootm_os.c index 5be4467..72477f0 100644 --- a/common/bootm_os.c +++ b/common/bootm_os.c @@ -404,6 +404,32 @@ static int do_bootm_integrity(int flag, int argc, char * const argv[], } #endif +#ifdef CONFIG_BOOTM_OPENRTOS +static int do_bootm_openrtos(int flag, int argc, char * const argv[], + bootm_headers_t *images) +{ + void (*entry_point)(void); + + if (flag != BOOTM_STATE_OS_GO) + return 0; + + entry_point = (void (*)(void))images->ep; + + printf("## Transferring control to OpenRTOS (at address %08lx) ...\n", + (ulong)entry_point); + + bootstage_mark(BOOTSTAGE_ID_RUN_OS); + + /* + * OpenRTOS Parameters: + * None + */ + (*entry_point)(); + + return 1; +} +#endif + static boot_os_fn *boot_os[] = { [IH_OS_U_BOOT] = do_bootm_standalone, #ifdef CONFIG_BOOTM_LINUX @@ -434,6 +460,9 @@ static boot_os_fn *boot_os[] = { #ifdef CONFIG_INTEGRITY [IH_OS_INTEGRITY] = do_bootm_integrity, #endif +#ifdef CONFIG_BOOTM_OPENRTOS + [IH_OS_OPENRTOS] = do_bootm_openrtos, +#endif }; /* Allow for arch specific config before we boot */ diff --git a/common/cmd_sandbox.c b/common/cmd_sandbox.c index 3d9fce7..4286969 100644 --- a/common/cmd_sandbox.c +++ b/common/cmd_sandbox.c @@ -117,7 +117,7 @@ U_BOOT_CMD( "load hostfs - <addr> <filename> [<bytes> <offset>] - " "load a file from host\n" "sb ls hostfs - <filename> - list files on host\n" - "sb save hostfs - <filename> <addr> <bytes> [<offset>] - " + "sb save hostfs - <addr> <filename> <bytes> [<offset>] - " "save a file to host\n" "sb bind <dev> [<filename>] - bind \"host\" device to file\n" "sb info [<dev>] - show device binding & info\n" diff --git a/common/image-fit.c b/common/image-fit.c index 4ffc5aa..1589ee3 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1518,6 +1518,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr, size_t size; int type_ok, os_ok; ulong load, data, len; + uint8_t os; const char *prop_name; int ret; @@ -1612,10 +1613,15 @@ int fit_image_load(bootm_headers_t *images, ulong addr, (image_type == IH_TYPE_KERNEL && fit_image_check_type(fit, noffset, IH_TYPE_KERNEL_NOLOAD)); + os_ok = image_type == IH_TYPE_FLATDT || - fit_image_check_os(fit, noffset, IH_OS_LINUX); + fit_image_check_os(fit, noffset, IH_OS_LINUX) || + fit_image_check_os(fit, noffset, IH_OS_OPENRTOS); if (!type_ok || !os_ok) { - printf("No Linux %s %s Image\n", genimg_get_arch_name(arch), + fit_image_get_os(fit, noffset, &os); + printf("No %s %s %s Image\n", + genimg_get_os_name(os), + genimg_get_arch_name(arch), genimg_get_type_name(image_type)); bootstage_error(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL); return -EIO; diff --git a/common/image.c b/common/image.c index e691a51..ad7a46d 100644 --- a/common/image.c +++ b/common/image.c @@ -120,6 +120,10 @@ static const table_entry_t uimage_os[] = { { IH_OS_SOLARIS, "solaris", "Solaris", }, { IH_OS_SVR4, "svr4", "SVR4", }, #endif +#if defined(CONFIG_BOOTM_OPENRTOS) || defined(USE_HOSTCC) + { IH_OS_OPENRTOS, "openrtos", "OpenRTOS", }, +#endif + { -1, "", "", }, }; diff --git a/common/lcd.c b/common/lcd.c index 3ed504d..cc34b8a 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -73,45 +73,13 @@ #define CONFIG_LCD_ALIGNMENT PAGE_SIZE #endif -/* By default we scroll by a single line */ -#ifndef CONFIG_CONSOLE_SCROLL_LINES -#define CONFIG_CONSOLE_SCROLL_LINES 1 -#endif - -/************************************************************************/ -/* ** CONSOLE DEFINITIONS & FUNCTIONS */ -/************************************************************************/ -#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) -# define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \ - / VIDEO_FONT_HEIGHT) -#else -# define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT) -#endif - -#define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH) -#define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) -#define CONSOLE_ROW_FIRST lcd_console_address -#define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) -#define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ - - CONSOLE_ROW_SIZE) -#define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) -#define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) - -#if LCD_BPP == LCD_MONOCHROME -# define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \ - (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7) -#elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16) || \ - (LCD_BPP == LCD_COLOR32) -# define COLOR_MASK(c) (c) -#else +#if (LCD_BPP != LCD_COLOR8) && (LCD_BPP != LCD_COLOR16) && \ + (LCD_BPP != LCD_COLOR32) # error Unsupported LCD BPP. #endif DECLARE_GLOBAL_DATA_PTR; -static void lcd_drawchars(ushort x, ushort y, uchar *str, int count); -static inline void lcd_putc_xy(ushort x, ushort y, uchar c); - static int lcd_init(void *lcdbase); static void *lcd_logo(void); @@ -125,10 +93,6 @@ int lcd_line_length; char lcd_is_enabled = 0; -static short console_col; -static short console_row; - -static void *lcd_console_address; static void *lcd_base; /* Start of framebuffer memory */ static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */ @@ -166,217 +130,16 @@ void lcd_set_flush_dcache(int flush) /*----------------------------------------------------------------------*/ -static void console_scrollup(void) -{ - const int rows = CONFIG_CONSOLE_SCROLL_LINES; - - /* Copy up rows ignoring those that will be overwritten */ - memcpy(CONSOLE_ROW_FIRST, - lcd_console_address + CONSOLE_ROW_SIZE * rows, - CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows); - - /* Clear the last rows */ -#if (LCD_BPP != LCD_COLOR32) - memset(lcd_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows, - COLOR_MASK(lcd_color_bg), - CONSOLE_ROW_SIZE * rows); -#else - u32 *ppix = lcd_console_address + - CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows; - u32 i; - for (i = 0; - i < (CONSOLE_ROW_SIZE * rows) / NBYTES(panel_info.vl_bpix); - i++) { - *ppix++ = COLOR_MASK(lcd_color_bg); - } -#endif - lcd_sync(); - console_row -= rows; -} - -/*----------------------------------------------------------------------*/ - -static inline void console_back(void) -{ - if (--console_col < 0) { - console_col = CONSOLE_COLS-1 ; - if (--console_row < 0) - console_row = 0; - } - - lcd_putc_xy(console_col * VIDEO_FONT_WIDTH, - console_row * VIDEO_FONT_HEIGHT, ' '); -} - -/*----------------------------------------------------------------------*/ - -static inline void console_newline(void) -{ - console_col = 0; - - /* Check if we need to scroll the terminal */ - if (++console_row >= CONSOLE_ROWS) - console_scrollup(); - else - lcd_sync(); -} - -/*----------------------------------------------------------------------*/ - static void lcd_stub_putc(struct stdio_dev *dev, const char c) { lcd_putc(c); } -void lcd_putc(const char c) -{ - if (!lcd_is_enabled) { - serial_putc(c); - - return; - } - - switch (c) { - case '\r': - console_col = 0; - - return; - case '\n': - console_newline(); - - return; - case '\t': /* Tab (8 chars alignment) */ - console_col += 8; - console_col &= ~7; - - if (console_col >= CONSOLE_COLS) - console_newline(); - - return; - case '\b': - console_back(); - - return; - default: - lcd_putc_xy(console_col * VIDEO_FONT_WIDTH, - console_row * VIDEO_FONT_HEIGHT, c); - if (++console_col >= CONSOLE_COLS) - console_newline(); - } -} - -/*----------------------------------------------------------------------*/ - static void lcd_stub_puts(struct stdio_dev *dev, const char *s) { lcd_puts(s); } -void lcd_puts(const char *s) -{ - if (!lcd_is_enabled) { - serial_puts(s); - - return; - } - - while (*s) - lcd_putc(*s++); - - lcd_sync(); -} - -/*----------------------------------------------------------------------*/ - -void lcd_printf(const char *fmt, ...) -{ - va_list args; - char buf[CONFIG_SYS_PBSIZE]; - - va_start(args, fmt); - vsprintf(buf, fmt, args); - va_end(args); - - lcd_puts(buf); -} - -/************************************************************************/ -/* ** Low-Level Graphics Routines */ -/************************************************************************/ - -static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) -{ - uchar *dest; - ushort row; - -#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) - y += BMP_LOGO_HEIGHT; -#endif - -#if LCD_BPP == LCD_MONOCHROME - ushort off = x * (1 << LCD_BPP) % 8; -#endif - - dest = (uchar *)(lcd_base + y * lcd_line_length + x * NBITS(LCD_BPP)/8); - - for (row = 0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) { - uchar *s = str; - int i; -#if LCD_BPP == LCD_COLOR16 - ushort *d = (ushort *)dest; -#elif LCD_BPP == LCD_COLOR32 - u32 *d = (u32 *)dest; -#else - uchar *d = dest; -#endif - -#if LCD_BPP == LCD_MONOCHROME - uchar rest = *d & -(1 << (8 - off)); - uchar sym; -#endif - for (i = 0; i < count; ++i) { - uchar c, bits; - - c = *s++; - bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row]; - -#if LCD_BPP == LCD_MONOCHROME - sym = (COLOR_MASK(lcd_color_fg) & bits) | - (COLOR_MASK(lcd_color_bg) & ~bits); - - *d++ = rest | (sym >> off); - rest = sym << (8-off); -#elif LCD_BPP == LCD_COLOR8 - for (c = 0; c < 8; ++c) { - *d++ = (bits & 0x80) ? - lcd_color_fg : lcd_color_bg; - bits <<= 1; - } -#elif LCD_BPP == LCD_COLOR16 - for (c = 0; c < 8; ++c) { - *d++ = (bits & 0x80) ? - lcd_color_fg : lcd_color_bg; - bits <<= 1; - } -#elif LCD_BPP == LCD_COLOR32 - for (c = 0; c < 8; ++c) { - *d++ = (bits & 0x80) ? - lcd_color_fg : lcd_color_bg; - bits <<= 1; - } -#endif - } -#if LCD_BPP == LCD_MONOCHROME - *d = rest | (*d & ((1 << (8 - off)) - 1)); -#endif - } -} - -static inline void lcd_putc_xy(ushort x, ushort y, uchar c) -{ - lcd_drawchars(x, y, &c, 1); -} - /************************************************************************/ /** Small utility to check that you got the colours right */ /************************************************************************/ @@ -455,11 +218,9 @@ int drv_lcd_init(void) /*----------------------------------------------------------------------*/ void lcd_clear(void) { -#if LCD_BPP == LCD_MONOCHROME - /* Setting the palette */ - lcd_initcolregs(); - -#elif LCD_BPP == LCD_COLOR8 + short console_rows, console_cols; + int bg_color; +#if LCD_BPP == LCD_COLOR8 /* Setting the palette */ lcd_setcolreg(CONSOLE_COLOR_BLACK, 0, 0, 0); lcd_setcolreg(CONSOLE_COLOR_RED, 0xFF, 0, 0); @@ -475,9 +236,11 @@ void lcd_clear(void) #ifndef CONFIG_SYS_WHITE_ON_BLACK lcd_setfgcolor(CONSOLE_COLOR_BLACK); lcd_setbgcolor(CONSOLE_COLOR_WHITE); + bg_color = CONSOLE_COLOR_WHITE; #else lcd_setfgcolor(CONSOLE_COLOR_WHITE); lcd_setbgcolor(CONSOLE_COLOR_BLACK); + bg_color = CONSOLE_COLOR_BLACK; #endif /* CONFIG_SYS_WHITE_ON_BLACK */ #ifdef LCD_TEST_PATTERN @@ -485,25 +248,27 @@ void lcd_clear(void) #else /* set framebuffer to background color */ #if (LCD_BPP != LCD_COLOR32) - memset((char *)lcd_base, - COLOR_MASK(lcd_color_bg), - lcd_line_length * panel_info.vl_row); + memset((char *)lcd_base, bg_color, lcd_line_length * panel_info.vl_row); #else u32 *ppix = lcd_base; u32 i; for (i = 0; i < (lcd_line_length * panel_info.vl_row)/NBYTES(panel_info.vl_bpix); i++) { - *ppix++ = COLOR_MASK(lcd_color_bg); + *ppix++ = bg_color; } #endif #endif /* Paint the logo and retrieve LCD base address */ debug("[LCD] Drawing the logo...\n"); - lcd_console_address = lcd_logo(); - - console_col = 0; - console_row = 0; +#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) + console_rows = (panel_info.vl_row - BMP_LOGO_HEIGHT); + console_rows /= VIDEO_FONT_HEIGHT; +#else + console_rows = panel_info.vl_row / VIDEO_FONT_HEIGHT; +#endif + console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH; + lcd_init_console(lcd_logo(), console_rows, console_cols); lcd_sync(); } @@ -546,11 +311,11 @@ static int lcd_init(void *lcdbase) lcd_enable(); /* Initialize the console */ - console_col = 0; + lcd_set_col(0); #ifdef CONFIG_LCD_INFO_BELOW_LOGO - console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT; + lcd_set_row(7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT); #else - console_row = 1; /* leave 1 blank line below logo */ + lcd_set_row(1); /* leave 1 blank line below logo */ #endif return 0; @@ -597,6 +362,11 @@ static void lcd_setfgcolor(int color) lcd_color_fg = color; } +int lcd_getfgcolor(void) +{ + return lcd_color_fg; +} + /*----------------------------------------------------------------------*/ static void lcd_setbgcolor(int color) @@ -604,6 +374,11 @@ static void lcd_setbgcolor(int color) lcd_color_bg = color; } +int lcd_getbgcolor(void) +{ + return lcd_color_bg; +} + /************************************************************************/ /* ** Chipset depending Bitmap / Logo stuff... */ /************************************************************************/ @@ -685,11 +460,7 @@ void bitmap_plot(int x, int y) *(cmap + BMP_LOGO_OFFSET) = lut_entry; cmap++; #else /* !CONFIG_ATMEL_LCD */ -#ifdef CONFIG_SYS_INVERT_COLORS - *cmap++ = 0xffff - colreg; -#else *cmap++ = colreg; -#endif #endif /* CONFIG_ATMEL_LCD */ } @@ -967,11 +738,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) ( ((cte.red) << 8) & 0xf800) | ( ((cte.green) << 3) & 0x07e0) | ( ((cte.blue) >> 3) & 0x001f) ; -#ifdef CONFIG_SYS_INVERT_COLORS - *cmap = 0xffff - colreg; -#else *cmap = colreg; -#endif #if defined(CONFIG_MPC823) cmap--; #else @@ -1108,8 +875,8 @@ static void *lcd_logo(void) bitmap_plot(0, 0); #ifdef CONFIG_LCD_INFO - console_col = LCD_INFO_X / VIDEO_FONT_WIDTH; - console_row = LCD_INFO_Y / VIDEO_FONT_HEIGHT; + lcd_set_col(LCD_INFO_X / VIDEO_FONT_WIDTH); + lcd_set_row(LCD_INFO_Y / VIDEO_FONT_HEIGHT); lcd_show_board_info(); #endif /* CONFIG_LCD_INFO */ @@ -1144,12 +911,6 @@ static int on_splashimage(const char *name, const char *value, enum env_op op, U_BOOT_ENV_CALLBACK(splashimage, on_splashimage); #endif -void lcd_position_cursor(unsigned col, unsigned row) -{ - console_col = min_t(short, col, CONSOLE_COLS - 1); - console_row = min_t(short, row, CONSOLE_ROWS - 1); -} - int lcd_get_pixel_width(void) { return panel_info.vl_col; @@ -1160,16 +921,6 @@ int lcd_get_pixel_height(void) return panel_info.vl_row; } -int lcd_get_screen_rows(void) -{ - return CONSOLE_ROWS; -} - -int lcd_get_screen_columns(void) -{ - return CONSOLE_COLS; -} - #if defined(CONFIG_LCD_DT_SIMPLEFB) static int lcd_dt_simplefb_configure_node(void *blob, int off) { diff --git a/common/lcd_console.c b/common/lcd_console.c new file mode 100644 index 0000000..74c388a --- /dev/null +++ b/common/lcd_console.c @@ -0,0 +1,211 @@ +/* + * (C) Copyright 2001-2014 + * DENX Software Engineering -- wd@denx.de + * Compulab Ltd - http://compulab.co.il/ + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <lcd.h> +#include <video_font.h> /* Get font data, width and height */ + +#define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) +#define CONSOLE_ROW_FIRST lcd_console_address +#define CONSOLE_SIZE (CONSOLE_ROW_SIZE * console_rows) + +static short console_curr_col; +static short console_curr_row; +static short console_cols; +static short console_rows; +static void *lcd_console_address; + +void lcd_init_console(void *address, int rows, int cols) +{ + console_curr_col = 0; + console_curr_row = 0; + console_cols = cols; + console_rows = rows; + lcd_console_address = address; +} + +void lcd_set_col(short col) +{ + console_curr_col = col; +} + +void lcd_set_row(short row) +{ + console_curr_row = row; +} + +void lcd_position_cursor(unsigned col, unsigned row) +{ + console_curr_col = min_t(short, col, console_cols - 1); + console_curr_row = min_t(short, row, console_rows - 1); +} + +int lcd_get_screen_rows(void) +{ + return console_rows; +} + +int lcd_get_screen_columns(void) +{ + return console_cols; +} + +static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) +{ + uchar *dest; + ushort row; + int fg_color, bg_color; + + dest = (uchar *)(lcd_console_address + + y * lcd_line_length + x * NBITS(LCD_BPP) / 8); + + for (row = 0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) { + uchar *s = str; + int i; +#if LCD_BPP == LCD_COLOR16 + ushort *d = (ushort *)dest; +#elif LCD_BPP == LCD_COLOR32 + u32 *d = (u32 *)dest; +#else + uchar *d = dest; +#endif + + fg_color = lcd_getfgcolor(); + bg_color = lcd_getbgcolor(); + for (i = 0; i < count; ++i) { + uchar c, bits; + + c = *s++; + bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row]; + + for (c = 0; c < 8; ++c) { + *d++ = (bits & 0x80) ? fg_color : bg_color; + bits <<= 1; + } + } + } +} + +static inline void lcd_putc_xy(ushort x, ushort y, uchar c) +{ + lcd_drawchars(x, y, &c, 1); +} + +static void console_scrollup(void) +{ + const int rows = CONFIG_CONSOLE_SCROLL_LINES; + int bg_color = lcd_getbgcolor(); + + /* Copy up rows ignoring those that will be overwritten */ + memcpy(CONSOLE_ROW_FIRST, + lcd_console_address + CONSOLE_ROW_SIZE * rows, + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows); + + /* Clear the last rows */ +#if (LCD_BPP != LCD_COLOR32) + memset(lcd_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows, + bg_color, CONSOLE_ROW_SIZE * rows); +#else + u32 *ppix = lcd_console_address + + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows; + u32 i; + for (i = 0; + i < (CONSOLE_ROW_SIZE * rows) / NBYTES(panel_info.vl_bpix); + i++) { + *ppix++ = bg_color; + } +#endif + lcd_sync(); + console_curr_row -= rows; +} + +static inline void console_back(void) +{ + if (--console_curr_col < 0) { + console_curr_col = console_cols - 1; + if (--console_curr_row < 0) + console_curr_row = 0; + } + + lcd_putc_xy(console_curr_col * VIDEO_FONT_WIDTH, + console_curr_row * VIDEO_FONT_HEIGHT, ' '); +} + +static inline void console_newline(void) +{ + console_curr_col = 0; + + /* Check if we need to scroll the terminal */ + if (++console_curr_row >= console_rows) + console_scrollup(); + else + lcd_sync(); +} + +void lcd_putc(const char c) +{ + if (!lcd_is_enabled) { + serial_putc(c); + + return; + } + + switch (c) { + case '\r': + console_curr_col = 0; + + return; + case '\n': + console_newline(); + + return; + case '\t': /* Tab (8 chars alignment) */ + console_curr_col += 8; + console_curr_col &= ~7; + + if (console_curr_col >= console_cols) + console_newline(); + + return; + case '\b': + console_back(); + + return; + default: + lcd_putc_xy(console_curr_col * VIDEO_FONT_WIDTH, + console_curr_row * VIDEO_FONT_HEIGHT, c); + if (++console_curr_col >= console_cols) + console_newline(); + } +} + +void lcd_puts(const char *s) +{ + if (!lcd_is_enabled) { + serial_puts(s); + + return; + } + + while (*s) + lcd_putc(*s++); + + lcd_sync(); +} + +void lcd_printf(const char *fmt, ...) +{ + va_list args; + char buf[CONFIG_SYS_PBSIZE]; + + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); + + lcd_puts(buf); +} diff --git a/common/memsize.c b/common/memsize.c index 589400d..0fb9ba5 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -33,43 +33,46 @@ long get_ram_size(long *base, long maxsize) long size; int i = 0; - for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) { + for (cnt = (maxsize / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) { addr = base + cnt; /* pointer arith! */ - sync (); + sync(); save[i++] = *addr; - sync (); + sync(); *addr = ~cnt; } addr = base; - sync (); + sync(); save[i] = *addr; - sync (); + sync(); *addr = 0; - sync (); + sync(); if ((val = *addr) != 0) { - /* Restore the original data before leaving the function. - */ - sync (); + /* 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 (); + sync(); *addr = save[--i]; } return (0); } - for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) { + for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) { addr = base + cnt; /* pointer arith! */ val = *addr; *addr = save[--i]; if (val != ~cnt) { - size = cnt * sizeof (long); - /* Restore the original data before leaving the function. + size = cnt * sizeof(long); + /* + * Restore the original data + * before leaving the function. */ - for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) { + for (cnt <<= 1; + cnt < maxsize / sizeof(long); + cnt <<= 1) { addr = base + cnt; *addr = save[--i]; } diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c index b444a3e..2c0e8e0 100644 --- a/common/spl/spl_nor.c +++ b/common/spl/spl_nor.c @@ -15,37 +15,51 @@ void spl_nor_load_image(void) */ spl_image.flags |= SPL_COPY_PAYLOAD_ONLY; - if (spl_start_uboot()) { - /* - * Load real U-Boot from its location in NOR flash to its - * defined location in SDRAM - */ - spl_parse_image_header( - (const struct image_header *)CONFIG_SYS_UBOOT_BASE); +#ifdef CONFIG_SPL_OS_BOOT + if (!spl_start_uboot()) { + struct image_header *header; - memcpy((void *)spl_image.load_addr, - (void *)(CONFIG_SYS_UBOOT_BASE + - sizeof(struct image_header)), - spl_image.size); - } else { /* * Load Linux from its location in NOR flash to its defined * location in SDRAM */ - spl_parse_image_header( - (const struct image_header *)CONFIG_SYS_OS_BASE); + header = (const struct image_header *)CONFIG_SYS_OS_BASE; - memcpy((void *)spl_image.load_addr, - (void *)(CONFIG_SYS_OS_BASE + - sizeof(struct image_header)), - spl_image.size); + if (image_get_os(header) == IH_OS_LINUX) { + /* happy - was a Linux */ - /* - * Copy DT blob (fdt) to SDRAM. Passing pointer to flash - * doesn't work (16 KiB should be enough for DT) - */ - memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR, - (void *)(CONFIG_SYS_FDT_BASE), - (16 << 10)); + spl_parse_image_header(header); + + memcpy((void *)spl_image.load_addr, + (void *)(CONFIG_SYS_OS_BASE + + sizeof(struct image_header)), + spl_image.size); + + /* + * Copy DT blob (fdt) to SDRAM. Passing pointer to + * flash doesn't work (16 KiB should be enough for DT) + */ + memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR, + (void *)(CONFIG_SYS_FDT_BASE), + (16 << 10)); + + return; + } else { + puts("The Expected Linux image was not found.\n" + "Please check your NOR configuration.\n" + "Trying to start u-boot now...\n"); + } } +#endif + + /* + * Load real U-Boot from its location in NOR flash to its + * defined location in SDRAM + */ + spl_parse_image_header( + (const struct image_header *)CONFIG_SYS_UBOOT_BASE); + + memcpy((void *)spl_image.load_addr, + (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)), + spl_image.size); } diff --git a/configs/arcangel4-be_defconfig b/configs/arcangel4-be_defconfig index 867fb1f..0c3ab4e 100644 --- a/configs/arcangel4-be_defconfig +++ b/configs/arcangel4-be_defconfig @@ -1,2 +1,3 @@ CONFIG_ARC=y CONFIG_TARGET_ARCANGEL4_BE=y +CONFIG_SYS_CLK_FREQ=70000000 diff --git a/configs/arcangel4_defconfig b/configs/arcangel4_defconfig index 82b583e..a63ef21 100644 --- a/configs/arcangel4_defconfig +++ b/configs/arcangel4_defconfig @@ -1,2 +1,3 @@ CONFIG_ARC=y CONFIG_TARGET_ARCANGEL4=y +CONFIG_SYS_CLK_FREQ=70000000 diff --git a/configs/axs101_defconfig b/configs/axs101_defconfig index bfa314e..5c0ca11 100644 --- a/configs/axs101_defconfig +++ b/configs/axs101_defconfig @@ -1,2 +1,3 @@ CONFIG_ARC=y CONFIG_TARGET_AXS101=y +CONFIG_SYS_CLK_FREQ=750000000
\ No newline at end of file diff --git a/configs/nas220_defconfig b/configs/nas220_defconfig new file mode 100644 index 0000000..5a79c51 --- /dev/null +++ b/configs/nas220_defconfig @@ -0,0 +1,3 @@ +CONFIG_ARM=y +CONFIG_KIRKWOOD=y +CONFIG_TARGET_NAS220=y diff --git a/configs/tb100_defconfig b/configs/tb100_defconfig index 9669dc0..d2de03b 100644 --- a/configs/tb100_defconfig +++ b/configs/tb100_defconfig @@ -1,2 +1,3 @@ CONFIG_ARC=y CONFIG_TARGET_TB100=y +CONFIG_SYS_CLK_FREQ=500000000
\ No newline at end of file diff --git a/doc/README.arm-caches b/doc/README.arm-caches index f6a52e3..dbb6190 100644 --- a/doc/README.arm-caches +++ b/doc/README.arm-caches @@ -47,7 +47,7 @@ Cleanup Before Linux: - cleanup_before_linux() should flush the D-cache, invalidate I-cache, and disable MMU and caches. - The following sequence is advisable while disabling d-cache: - 1. disable_dcache() - flushes and disables d-cache + 1. dcache_disable() - flushes and disables d-cache 2. invalidate_dcache_all() - invalid any entry that came to the cache in the short period after the cache was flushed but before the cache got disabled. diff --git a/drivers/video/mpc8xx_lcd.c b/drivers/video/mpc8xx_lcd.c index 50eed89..add7215 100644 --- a/drivers/video/mpc8xx_lcd.c +++ b/drivers/video/mpc8xx_lcd.c @@ -34,11 +34,6 @@ #define CONFIG_LCD_INFO /* Display Logo, (C) and system info */ #endif -#if defined(CONFIG_EDT32F10) -#undef CONFIG_LCD_LOGO -#undef CONFIG_LCD_INFO -#endif - /*----------------------------------------------------------------------*/ #ifdef CONFIG_KYOCERA_KCS057QV1AJ /* @@ -224,20 +219,6 @@ vidinfo_t panel_info = { }; #endif /* CONFIG_OPTREX_BW */ -/*-----------------------------------------------------------------*/ -#ifdef CONFIG_EDT32F10 -/* - * Emerging Display Technologies 320x240. Passive, monochrome, single scan. - */ -#define LCD_BPP LCD_MONOCHROME -#define LCD_DF 10 - -vidinfo_t panel_info = { - 320, 240, 0, 0, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, - LCD_BPP, 0, 0, 0, 0, 33, 0, 0, 0 -}; -#endif - /************************************************************************/ /* ----------------- chipset specific functions ----------------------- */ /************************************************************************/ @@ -305,7 +286,6 @@ void lcd_ctrl_init (void *lcdbase) immr->im_clkrst.car_sccr &= ~0x1F; immr->im_clkrst.car_sccr |= LCD_DF; /* was 8 */ -#if !defined(CONFIG_EDT32F10) /* Enable LCD on port D. */ immr->im_ioport.iop_pdpar |= 0x1FFF; @@ -315,14 +295,6 @@ void lcd_ctrl_init (void *lcdbase) */ immr->im_cpm.cp_pbpar |= 0x00005001; immr->im_cpm.cp_pbdir |= 0x00005001; -#else - /* Enable LCD on port D. - */ - immr->im_ioport.iop_pdpar |= 0x1DFF; - immr->im_ioport.iop_pdpar &= ~0x0200; - immr->im_ioport.iop_pddir |= 0x1FFF; - immr->im_ioport.iop_pddat |= 0x0200; -#endif /* Load the physical address of the linear frame buffer * into the LCD controller. @@ -373,9 +345,7 @@ lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue) colreg = ((red & 0x0F) << 8) | ((green & 0x0F) << 4) | (blue & 0x0F) ; -#ifdef CONFIG_SYS_INVERT_COLORS - colreg ^= 0x0FFF; -#endif + *cmap_ptr = colreg; debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %02X%02X\n", @@ -387,23 +357,6 @@ lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue) /*----------------------------------------------------------------------*/ -#if LCD_BPP == LCD_MONOCHROME -static -void lcd_initcolregs (void) -{ - volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; - volatile cpm8xx_t *cp = &(immr->im_cpm); - ushort regno; - - for (regno = 0; regno < 16; regno++) { - cp->lcd_cmap[regno * 2] = 0; - cp->lcd_cmap[(regno * 2) + 1] = regno & 0x0f; - } -} -#endif - -/*----------------------------------------------------------------------*/ - void lcd_enable (void) { volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; diff --git a/drivers/video/pxa_lcd.c b/drivers/video/pxa_lcd.c index e19f6ac..f66f615 100644 --- a/drivers/video/pxa_lcd.c +++ b/drivers/video/pxa_lcd.c @@ -379,21 +379,6 @@ lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue) #endif /* LCD_COLOR8 */ /*----------------------------------------------------------------------*/ -#if LCD_BPP == LCD_MONOCHROME -void lcd_initcolregs (void) -{ - struct pxafb_info *fbi = &panel_info.pxa; - cmap = (ushort *)fbi->palette; - ushort regno; - - for (regno = 0; regno < 16; regno++) { - cmap[regno * 2] = 0; - cmap[(regno * 2) + 1] = regno & 0x0f; - } -} -#endif /* LCD_MONOCHROME */ - -/*----------------------------------------------------------------------*/ __weak void lcd_enable(void) { } diff --git a/include/bootm.h b/include/bootm.h index b3d1a62..6181488 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -56,4 +56,21 @@ int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], void arch_preboot_os(void); +/** + * bootm_decomp_image() - decompress the operating system + * + * @comp: Compression algorithm that is used (IH_COMP_...) + * @load: Destination load address in U-Boot memory + * @image_start Image start address (where we are decompressing from) + * @type: OS type (IH_OS_...) + * @load_bug: Place to decompress to + * @image_buf: Address to decompress from + * @image_len: Number of bytes in @image_buf to decompress + * @unc_len: Available space for decompression + * @return 0 if OK, -ve on error (BOOTM_ERR_...) + */ +int bootm_decomp_image(int comp, ulong load, ulong image_start, int type, + void *load_buf, void *image_buf, ulong image_len, + uint unc_len, ulong *load_end); + #endif diff --git a/include/configs/arcangel4-be.h b/include/configs/arcangel4-be.h index 88d27db..76163ab 100644 --- a/include/configs/arcangel4-be.h +++ b/include/configs/arcangel4-be.h @@ -14,7 +14,6 @@ #define CONFIG_ARC700 #define CONFIG_ARC_MMU_VER 3 #define CONFIG_SYS_CACHELINE_SIZE 64 -#define CONFIG_SYS_CLK_FREQ 70000000 #define CONFIG_SYS_TIMER_RATE CONFIG_SYS_CLK_FREQ /* diff --git a/include/configs/arcangel4.h b/include/configs/arcangel4.h index 4579eb9..81934a4 100644 --- a/include/configs/arcangel4.h +++ b/include/configs/arcangel4.h @@ -13,7 +13,6 @@ #define CONFIG_ARC700 #define CONFIG_ARC_MMU_VER 3 #define CONFIG_SYS_CACHELINE_SIZE 64 -#define CONFIG_SYS_CLK_FREQ 70000000 #define CONFIG_SYS_TIMER_RATE CONFIG_SYS_CLK_FREQ /* diff --git a/include/configs/axs101.h b/include/configs/axs101.h index 6e8c56c..c61ddd6 100644 --- a/include/configs/axs101.h +++ b/include/configs/axs101.h @@ -13,7 +13,6 @@ #define CONFIG_ARC700 #define CONFIG_ARC_MMU_VER 3 #define CONFIG_SYS_CACHELINE_SIZE 32 -#define CONFIG_SYS_CLK_FREQ 750000000 #define CONFIG_SYS_TIMER_RATE CONFIG_SYS_CLK_FREQ /* NAND controller DMA doesn't work correctly with D$ enabled */ diff --git a/include/configs/nas220.h b/include/configs/nas220.h new file mode 100644 index 0000000..cfb85bf --- /dev/null +++ b/include/configs/nas220.h @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2014 Evgeni Dobrev <evgeni@studio-punkt.com> + * + * based on work from: + * (C) Copyright 2009 + * Marvell Semiconductor <www.marvell.com> + * Written-by: Prafulla Wadaskar <prafulla@marvell.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _CONFIG_NAS220_H +#define _CONFIG_NAS220_H + +/* + * Machine type definition and ID + */ +#define MACH_TYPE_NAS220 MACH_TYPE_RD88F6192_NAS +#define CONFIG_MACH_TYPE MACH_TYPE_NAS220 +#define CONFIG_IDENT_STRING "\nNAS 220" + +/* + * High Level Configuration Options (easy to change) + */ +#define CONFIG_FEROCEON_88FR131 /* #define CPU Core subversion */ +#define CONFIG_KW88F6192 /* SOC Name */ +#define CONFIG_SYS_GENERIC_BOARD +#define CONFIG_SKIP_LOWLEVEL_INIT /* disable board lowlevel_init */ + +/* power-on led, regulator, sata0, sata1 */ +#define NAS220_GE_OE_VAL_LOW ((1 << 12)|(1 << 14)|(1 << 24)|(1 << 28)) +#define NAS220_GE_OE_VAL_HIGH (0) +#define NAS220_GE_OE_LOW (~((1 << 12)|(1 << 14)|(1 << 24)|(1 << 28))) +#define NAS220_GE_OE_HIGH (~(0)) + +/* PHY related */ +#define MV88E1116_LED_FCTRL_REG 10 +#define MV88E1116_CPRSP_CR3_REG 21 +#define MV88E1116_MAC_CTRL_REG 21 +#define MV88E1116_PGADR_REG 22 +#define MV88E1116_RGMII_TXTM_CTRL (1 << 4) +#define MV88E1116_RGMII_RXTM_CTRL (1 << 5) + +/* + * Commands configuration + */ +#define CONFIG_SYS_NO_FLASH /* Declare no flash (NOR/SPI) */ +#include <config_cmd_default.h> +#define CONFIG_CMD_DHCP +#define CONFIG_CMD_MII +#define CONFIG_CMD_NAND +#define CONFIG_CMD_SAVEENV +#define CONFIG_CMD_PING +#define CONFIG_CMD_USB +#define CONFIG_CMD_DATE +#define CONFIG_CMD_IDE +#define CONFIG_SYS_LONGHELP +#define CONFIG_AUTO_COMPLETE +#define CONFIG_CMDLINE_EDITING +#define CONFIG_SYS_HUSH_PARSER +#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " + +/* + * mv-common.h should be defined after CMD configs since it used them + * to enable certain macros + */ +#include "mv-common.h" + +/* Remove or override few declarations from mv-common.h */ +#undef CONFIG_SYS_PROMPT /* previously defined in mv-common.h */ +#define CONFIG_SYS_PROMPT "nas220> " + +/* + * Environment variables configurations + */ +#ifdef CONFIG_CMD_NAND +#define CONFIG_ENV_IS_IN_NAND +#define CONFIG_ENV_SECT_SIZE 0x10000 +#else +#define CONFIG_ENV_IS_NOWHERE +#endif + +#define CONFIG_ENV_SIZE 0x10000 +#define CONFIG_ENV_OFFSET 0xa0000 + +/* + * Default environment variables + */ +#define CONFIG_BOOTCOMMAND "" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "bootargs=console=ttyS0,115200\0" \ + "mtdparts=mtdparts=orion_nand:0xa0000@0x0(uboot),"\ + "0x010000@0xa0000(env),"\ + "0x500000@0xc0000(uimage),"\ + "0x1a40000@0x5c0000(rootfs)\0" \ + "mtdids=nand0=orion_nand\0"\ + "bootdelay=-1\0"\ + "autostart=no\0"\ + "autoload=no\0" + +/* + * Ethernet Driver configuration + */ +#ifdef CONFIG_CMD_NET +#define CONFIG_MVGBE_PORTS {1, 0} /* enable port 0 only */ +#define CONFIG_PHY_BASE_ADR 8 +#endif /* CONFIG_CMD_NET */ + +/* + * USB/EHCI + */ +#ifdef CONFIG_CMD_USB +#define CONFIG_USB_EHCI /* Enable EHCI USB support */ +#define CONFIG_USB_EHCI_KIRKWOOD /* on Kirkwood platform */ +#define CONFIG_EHCI_IS_TDI +#define CONFIG_USB_STORAGE +#define CONFIG_DOS_PARTITION +#define CONFIG_SUPPORT_VFAT +#endif /* CONFIG_CMD_USB */ + +/* + * File system + */ +#define CONFIG_CMD_EXT2 +#define CONFIG_CMD_EXT4 +#define CONFIG_CMD_FAT +#define CONFIG_CMD_JFFS2 +#define CONFIG_JFFS2_NAND +#define CONFIG_JFFS2_LZO +#define CONFIG_CMD_UBI +#define CONFIG_CMD_UBIFS +#define CONFIG_RBTREE +#define CONFIG_MTD_DEVICE /* needed for mtdparts commands */ +#define CONFIG_MTD_PARTITIONS +#define CONFIG_CMD_MTDPARTS +#define CONFIG_LZO + +/* + * SATA + */ +#ifdef CONFIG_MVSATA_IDE +#define CONFIG_SYS_ATA_IDE0_OFFSET MV_SATA_PORT0_OFFSET +#define CONFIG_SYS_ATA_IDE1_OFFSET MV_SATA_PORT1_OFFSET +#endif + + +/* + * Device Tree + */ +#define CONFIG_OF_LIBFDT + +/* + * EFI partition + */ +#define CONFIG_EFI_PARTITION + +/* + * Date Time + */ +#ifdef CONFIG_CMD_DATE +#define CONFIG_RTC_MV +#endif /* CONFIG_CMD_DATE */ + +#define CONFIG_KIRKWOOD_GPIO + +#endif /* _CONFIG_NAS220_H */ + diff --git a/include/configs/tb100.h b/include/configs/tb100.h index 8a861a8..e9218f7 100644 --- a/include/configs/tb100.h +++ b/include/configs/tb100.h @@ -15,7 +15,6 @@ #define CONFIG_ARC700 #define CONFIG_ARC_MMU_VER 3 #define CONFIG_SYS_CACHELINE_SIZE 32 -#define CONFIG_SYS_CLK_FREQ 500000000 #define CONFIG_SYS_TIMER_RATE CONFIG_SYS_CLK_FREQ /* diff --git a/include/configs/vf610twr.h b/include/configs/vf610twr.h index bd79e81..05bc7d0 100644 --- a/include/configs/vf610twr.h +++ b/include/configs/vf610twr.h @@ -60,11 +60,8 @@ /* UBI */ #define CONFIG_CMD_UBI #define CONFIG_CMD_UBIFS -#define CONFIG_CMD_MTDPARTS #define CONFIG_RBTREE #define CONFIG_LZO -#define CONFIG_MTD_DEVICE -#define CONFIG_MTD_PARTITIONS /* Dynamic MTD partition support */ #define CONFIG_CMD_MTDPARTS diff --git a/include/image.h b/include/image.h index af30d60..ee3afe3 100644 --- a/include/image.h +++ b/include/image.h @@ -152,6 +152,7 @@ struct lmb; #define IH_OS_INTEGRITY 21 /* INTEGRITY */ #define IH_OS_OSE 22 /* OSE */ #define IH_OS_PLAN9 23 /* Plan 9 */ +#define IH_OS_OPENRTOS 24 /* OpenRTOS */ /* * CPU Architecture Codes (supported by Linux) diff --git a/include/lcd.h b/include/lcd.h index 020d880..160f940 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -12,6 +12,7 @@ #ifndef _LCD_H_ #define _LCD_H_ +#include <lcd_console.h> extern char lcd_is_enabled; @@ -291,6 +292,20 @@ int lcd_get_screen_rows(void); int lcd_get_screen_columns(void); /** + * Get the background color of the LCD + * + * @return background color value + */ +int lcd_getbgcolor(void); + +/** + * Get the foreground color of the LCD + * + * @return foreground color value + */ +int lcd_getfgcolor(void); + +/** * Set the position of the text cursor * * @param col Column to place cursor (0 = left side) @@ -359,15 +374,7 @@ void lcd_sync(void); /************************************************************************/ /* ** CONSOLE CONSTANTS */ /************************************************************************/ -#if LCD_BPP == LCD_MONOCHROME - -/* - * Simple black/white definitions - */ -# define CONSOLE_COLOR_BLACK 0 -# define CONSOLE_COLOR_WHITE 1 /* Must remain last / highest */ - -#elif LCD_BPP == LCD_COLOR8 +#if LCD_BPP == LCD_COLOR8 /* * 8bpp color definitions diff --git a/include/lcd_console.h b/include/lcd_console.h new file mode 100644 index 0000000..429214d --- /dev/null +++ b/include/lcd_console.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2014, Compulab Ltd - http://compulab.co.il/ + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +/* By default we scroll by a single line */ +#ifndef CONFIG_CONSOLE_SCROLL_LINES +#define CONFIG_CONSOLE_SCROLL_LINES 1 +#endif + +/** + * lcd_init_console() - Initialize lcd console parameters + * + * Setup the address of console base, and the number of rows and columns the + * console has. + * + * @address: Console base address + * @rows: Number of rows in the console + * @cols: Number of columns in the console + */ +void lcd_init_console(void *address, int rows, int cols); + +/** + * lcd_set_col() - Set the number of the current lcd console column + * + * Set the number of the console column where the cursor is. + * + * @col: Column number + */ +void lcd_set_col(short col); + +/** + * lcd_set_row() - Set the number of the current lcd console row + * + * Set the number of the console row where the cursor is. + * + * @row: Row number + */ +void lcd_set_row(short row); + +/** + * lcd_position_cursor() - Position the cursor on the screen + * + * Position the cursor at the given coordinates on the screen. + * + * @col: Column number + * @row: Row number + */ +void lcd_position_cursor(unsigned col, unsigned row); + +/** + * lcd_get_screen_rows() - Get the total number of screen rows + * + * @return: Number of screen rows + */ +int lcd_get_screen_rows(void); + +/** + * lcd_get_screen_columns() - Get the total number of screen columns + * + * @return: Number of screen columns + */ +int lcd_get_screen_columns(void); + +/** + * lcd_putc() - Print to screen a single character at the location of the cursor + * + * @c: The character to print + */ +void lcd_putc(const char c); + +/** + * lcd_puts() - Print to screen a string at the location of the cursor + * + * @s: The string to print + */ +void lcd_puts(const char *s); + +/** + * lcd_printf() - Print to screen a formatted string at location of the cursor + * + * @fmt: The formatted string to print + * @...: The arguments for the formatted string + */ +void lcd_printf(const char *fmt, ...); diff --git a/include/net.h b/include/net.h index 18d279e..3da35fe 100644 --- a/include/net.h +++ b/include/net.h @@ -81,7 +81,7 @@ enum eth_state_t { struct eth_device { char name[16]; unsigned char enetaddr[6]; - int iobase; + phys_addr_t iobase; int state; int (*init) (struct eth_device *, bd_t *); diff --git a/lib/bzip2/bzlib.c b/lib/bzip2/bzlib.c index 5844e18..9262e40 100644 --- a/lib/bzip2/bzlib.c +++ b/lib/bzip2/bzlib.c @@ -1350,11 +1350,11 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) strm.avail_out = *destLen; ret = BZ2_bzDecompress ( &strm ); + *destLen -= strm.avail_out; if (ret == BZ_OK) goto output_overflow_or_eof; if (ret != BZ_STREAM_END) goto errhandler; /* normal termination */ - *destLen -= strm.avail_out; BZ2_bzDecompressEnd ( &strm ); return BZ_OK; diff --git a/lib/gunzip.c b/lib/gunzip.c index 35abfb3..f469fcb 100644 --- a/lib/gunzip.c +++ b/lib/gunzip.c @@ -73,6 +73,7 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, int stoponerr, int offset) { z_stream s; + int err = 0; int r; s.zalloc = gzalloc; @@ -92,13 +93,13 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, if (stoponerr == 1 && r != Z_STREAM_END && (s.avail_out == 0 || r != Z_BUF_ERROR)) { printf("Error: inflate() returned %d\n", r); - inflateEnd(&s); - return -1; + err = -1; + break; } s.avail_in = *lenp - offset - (int)(s.next_out - (unsigned char*)dst); } while (r == Z_BUF_ERROR); *lenp = s.next_out - (unsigned char *) dst; inflateEnd(&s); - return 0; + return err; } diff --git a/lib/lzma/LzmaTools.c b/lib/lzma/LzmaTools.c index cfc7cb0..f88629b 100644 --- a/lib/lzma/LzmaTools.c +++ b/lib/lzma/LzmaTools.c @@ -102,7 +102,7 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize, return SZ_ERROR_OUTPUT_EOF; /* Decompress */ - outProcessed = outSizeFull; + outProcessed = min(outSizeFull, *uncompressedSize); WATCHDOG_RESET(); @@ -112,7 +112,7 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize, inStream, LZMA_PROPS_SIZE, LZMA_FINISH_END, &state, &g_Alloc); *uncompressedSize = outProcessed; - debug("LZMA: Uncompresed ................ 0x%zx\n", outProcessed); + debug("LZMA: Uncompressed ............... 0x%zx\n", outProcessed); if (res != SZ_OK) { return res; diff --git a/lib/lzo/lzo1x_decompress.c b/lib/lzo/lzo1x_decompress.c index 35f3793..ebdf10b 100644 --- a/lib/lzo/lzo1x_decompress.c +++ b/lib/lzo/lzo1x_decompress.c @@ -102,8 +102,10 @@ int lzop_decompress(const unsigned char *src, size_t src_len, tmp = dlen; r = lzo1x_decompress_safe((u8 *) src, slen, dst, &tmp); - if (r != LZO_E_OK) + if (r != LZO_E_OK) { + *dst_len = dst - start; return r; + } if (dlen != tmp) return LZO_E_ERROR; diff --git a/test/compression.c b/test/compression.c index 139ea01..ea2e4ad 100644 --- a/test/compression.c +++ b/test/compression.c @@ -7,8 +7,10 @@ #define DEBUG #include <common.h> +#include <bootm.h> #include <command.h> #include <malloc.h> +#include <asm/io.h> #include <u-boot/zlib.h> #include <bzlib.h> @@ -313,9 +315,8 @@ out: return ret; } - -static int do_test_compression(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) +static int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) { int err = 0; @@ -324,12 +325,94 @@ static int do_test_compression(cmd_tbl_t *cmdtp, int flag, int argc, err += run_test("lzma", compress_using_lzma, uncompress_using_lzma); err += run_test("lzo", compress_using_lzo, uncompress_using_lzo); - printf("test_compression %s\n", err == 0 ? "ok" : "FAILED"); + printf("ut_compression %s\n", err == 0 ? "ok" : "FAILED"); return err; } +static int compress_using_none(void *in, unsigned long in_size, + void *out, unsigned long out_max, + unsigned long *out_size) +{ + /* Here we just copy */ + memcpy(out, in, in_size); + *out_size = in_size; + + return 0; +} + +/** + * run_bootm_test() - Run tests on the bootm decopmression function + * + * @comp_type: Compression type to test + * @compress: Our function to compress data + * @return 0 if OK, non-zero on failure + */ +static int run_bootm_test(int comp_type, mutate_func compress) +{ + ulong compress_size = 1024; + void *compress_buff; + int unc_len; + int err = 0; + const ulong image_start = 0; + const ulong load_addr = 0x1000; + ulong load_end; + + printf("Testing: %s\n", genimg_get_comp_name(comp_type)); + compress_buff = map_sysmem(image_start, 0); + unc_len = strlen(plain); + compress((void *)plain, unc_len, compress_buff, compress_size, + &compress_size); + err = bootm_decomp_image(comp_type, load_addr, image_start, + IH_TYPE_KERNEL, map_sysmem(load_addr, 0), + compress_buff, compress_size, unc_len, + &load_end); + if (err) + return err; + err = bootm_decomp_image(comp_type, load_addr, image_start, + IH_TYPE_KERNEL, map_sysmem(load_addr, 0), + compress_buff, compress_size, unc_len - 1, + &load_end); + if (!err) + return -EINVAL; + + /* We can't detect corruption when not decompressing */ + if (comp_type == IH_COMP_NONE) + return 0; + memset(compress_buff + compress_size / 2, '\x49', + compress_size / 2); + err = bootm_decomp_image(comp_type, load_addr, image_start, + IH_TYPE_KERNEL, map_sysmem(load_addr, 0), + compress_buff, compress_size, 0x10000, + &load_end); + if (!err) + return -EINVAL; + + return 0; +} + +static int do_ut_image_decomp(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ + int err = 0; + + err = run_bootm_test(IH_COMP_GZIP, compress_using_gzip); + err |= run_bootm_test(IH_COMP_BZIP2, compress_using_bzip2); + err |= run_bootm_test(IH_COMP_LZMA, compress_using_lzma); + err |= run_bootm_test(IH_COMP_LZO, compress_using_lzo); + err |= run_bootm_test(IH_COMP_NONE, compress_using_none); + + printf("ut_image_decomp %s\n", err == 0 ? "ok" : "FAILED"); + + return 0; +} + U_BOOT_CMD( - test_compression, 5, 1, do_test_compression, + ut_compression, 5, 1, do_ut_compression, "Basic test of compressors: gzip bzip2 lzma lzo", "" ); + +U_BOOT_CMD( + ut_image_decomp, 5, 1, do_ut_image_decomp, + "Basic test of bootm decompression", "" +); diff --git a/test/dm/sf.c b/test/dm/sf.c index 57dd134..08098a1 100644 --- a/test/dm/sf.c +++ b/test/dm/sf.c @@ -29,7 +29,7 @@ static int dm_test_spi_flash(struct dm_test_state *dms) * benefit is worth the extra complexity. */ ut_asserteq(0, run_command_list( - "sb save hostfs - spi.bin 0 200000;" + "sb save hostfs - 0 spi.bin 200000;" "sf probe;" "sf test 0 10000", -1, 0)); /* diff --git a/test/image/test-fit.py b/test/image/test-fit.py index b065fcb..e9e756a 100755 --- a/test/image/test-fit.py +++ b/test/image/test-fit.py @@ -20,6 +20,9 @@ import struct import sys import tempfile +# Enable printing of all U-Boot output +DEBUG = True + # The 'command' library in patman is convenient for running commands base_path = os.path.dirname(sys.argv[0]) patman = os.path.join(base_path, '../../tools/patman') @@ -97,12 +100,16 @@ sb load hostfs 0 %(fit_addr)x %(fit)s fdt addr %(fit_addr)x bootm start %(fit_addr)x bootm loados -sb save hostfs 0 %(kernel_out)s %(kernel_addr)x %(kernel_size)x -sb save hostfs 0 %(fdt_out)s %(fdt_addr)x %(fdt_size)x -sb save hostfs 0 %(ramdisk_out)s %(ramdisk_addr)x %(ramdisk_size)x +sb save hostfs 0 %(kernel_addr)x %(kernel_out)s %(kernel_size)x +sb save hostfs 0 %(fdt_addr)x %(fdt_out)s %(fdt_size)x +sb save hostfs 0 %(ramdisk_addr)x %(ramdisk_out)s %(ramdisk_size)x reset ''' +def debug_stdout(stdout): + if DEBUG: + print stdout + def make_fname(leaf): """Make a temporary filename @@ -328,6 +335,7 @@ def run_fit_test(mkimage, u_boot): # We could perhaps reduce duplication with some loss of readability set_test('Kernel load') stdout = command.Output(u_boot, '-d', control_dtb, '-c', cmd) + debug_stdout(stdout) if read_file(kernel) != read_file(kernel_out): fail('Kernel not loaded', stdout) if read_file(control_dtb) == read_file(fdt_out): @@ -352,6 +360,7 @@ def run_fit_test(mkimage, u_boot): params['fdt_load'] = 'load = <%#x>;' % params['fdt_addr'] fit = make_fit(mkimage, params) stdout = command.Output(u_boot, '-d', control_dtb, '-c', cmd) + debug_stdout(stdout) if read_file(kernel) != read_file(kernel_out): fail('Kernel not loaded', stdout) if read_file(control_dtb) != read_file(fdt_out): @@ -365,6 +374,7 @@ def run_fit_test(mkimage, u_boot): params['ramdisk_load'] = 'load = <%#x>;' % params['ramdisk_addr'] fit = make_fit(mkimage, params) stdout = command.Output(u_boot, '-d', control_dtb, '-c', cmd) + debug_stdout(stdout) if read_file(ramdisk) != read_file(ramdisk_out): fail('Ramdisk not loaded', stdout) |