]> git.sur5r.net Git - u-boot/commitdiff
Merge branch 'master' of git://git.denx.de/u-boot-ti
authorTom Rini <trini@ti.com>
Mon, 8 Dec 2014 21:35:06 +0000 (16:35 -0500)
committerTom Rini <trini@ti.com>
Mon, 8 Dec 2014 21:35:06 +0000 (16:35 -0500)
149 files changed:
MAINTAINERS
Makefile
README
arch/arc/Makefile [new file with mode: 0644]
arch/arm/Kconfig
arch/arm/Makefile [new file with mode: 0644]
arch/arm/cpu/armv7/uniphier/Kconfig
arch/arm/cpu/armv7/uniphier/Makefile
arch/arm/cpu/armv7/uniphier/board_early_init_r.c [new file with mode: 0644]
arch/arm/cpu/armv7/uniphier/board_late_init.c
arch/arm/cpu/armv7/uniphier/init_page_table.c
arch/arm/cpu/armv7/uniphier/ph1-pro4/sbc_init.c
arch/arm/cpu/armv7/uniphier/support_card.c
arch/arm/dts/Makefile
arch/arm/dts/uniphier-ph1-ld4-ref.dts
arch/arm/dts/uniphier-ph1-ld4.dtsi
arch/arm/dts/uniphier-ph1-pro4-ref.dts
arch/arm/dts/uniphier-ph1-pro4.dtsi
arch/arm/dts/uniphier-ph1-sld3-ref.dts [new file with mode: 0644]
arch/arm/dts/uniphier-ph1-sld3.dtsi [new file with mode: 0644]
arch/arm/dts/uniphier-ph1-sld8-ref.dts
arch/arm/dts/uniphier-ph1-sld8.dtsi
arch/arm/include/asm/arch-bcm2835/mbox.h
arch/arm/include/asm/arch-uniphier/board.h
arch/avr32/Makefile [new file with mode: 0644]
arch/blackfin/Makefile [new file with mode: 0644]
arch/blackfin/include/asm/io.h
arch/m68k/Makefile [new file with mode: 0644]
arch/microblaze/Makefile [new file with mode: 0644]
arch/mips/Makefile [new file with mode: 0644]
arch/mips/include/asm/unaligned.h
arch/nds32/Makefile [new file with mode: 0644]
arch/nios2/Makefile [new file with mode: 0644]
arch/openrisc/Makefile [new file with mode: 0644]
arch/powerpc/Makefile [new file with mode: 0644]
arch/powerpc/cpu/mpc8xx/Kconfig
arch/powerpc/cpu/mpc8xx/cpu_init.c
arch/powerpc/lib/board.c
arch/sandbox/Makefile [new file with mode: 0644]
arch/sandbox/cpu/os.c
arch/sandbox/cpu/start.c
arch/sh/Makefile [new file with mode: 0644]
arch/sh/include/asm/unaligned.h
arch/sparc/Makefile [new file with mode: 0644]
arch/x86/Makefile [new file with mode: 0644]
arch/x86/cpu/coreboot/ipchecksum.c
arch/x86/include/asm/arch-coreboot/sysinfo.h
arch/x86/include/asm/arch-coreboot/tables.h
arch/x86/include/asm/io.h
arch/x86/lib/string.c
board/hermes/Kconfig [deleted file]
board/hermes/MAINTAINERS [deleted file]
board/hermes/Makefile [deleted file]
board/hermes/flash.c [deleted file]
board/hermes/hermes.c [deleted file]
board/hermes/u-boot.lds [deleted file]
board/hermes/u-boot.lds.debug [deleted file]
board/raspberrypi/rpi/Kconfig [new file with mode: 0644]
board/raspberrypi/rpi/MAINTAINERS [new file with mode: 0644]
board/raspberrypi/rpi/Makefile [new file with mode: 0644]
board/raspberrypi/rpi/rpi.c [new file with mode: 0644]
board/raspberrypi/rpi_b/Kconfig [deleted file]
board/raspberrypi/rpi_b/MAINTAINERS [deleted file]
board/raspberrypi/rpi_b/Makefile [deleted file]
board/raspberrypi/rpi_b/rpi_b.c [deleted file]
common/board_r.c
common/cmd_bdinfo.c
common/cmd_fuse.c
common/cmd_mem.c
common/console.c
common/fdt_support.c
common/image-fdt.c
common/lcd.c
common/spl/spl_mmc.c
common/usb.c
configs/hermes_defconfig [deleted file]
configs/ph1_ld4_defconfig
configs/ph1_pro4_defconfig
configs/ph1_sld8_defconfig
configs/rpi_b_defconfig [deleted file]
configs/rpi_defconfig [new file with mode: 0644]
disk/part_efi.c
doc/README.clang
doc/README.scrapyard
doc/git-mailrc
drivers/block/pata_bfin.h
drivers/i2c/i2c_core.c
drivers/mmc/sh_mmcif.c
drivers/mmc/sh_mmcif.h
drivers/power/power_i2c.c
drivers/rtc/mvrtc.h
drivers/serial/serial_pl01x.c
drivers/tpm/tpm.c
drivers/tpm/tpm_tis_i2c.c
include/common.h
include/commproc.h
include/configs/a3m071.h
include/configs/am3517_crane.h
include/configs/am3517_evm.h
include/configs/cm_t35.h
include/configs/devkit8000.h
include/configs/hermes.h [deleted file]
include/configs/imx6_spl.h
include/configs/lwmon5.h
include/configs/mcx.h
include/configs/omap3_evm.h
include/configs/omap3_evm_quick_mmc.h
include/configs/ph1_ld4.h [deleted file]
include/configs/ph1_pro4.h [deleted file]
include/configs/ph1_sld8.h [deleted file]
include/configs/rpi.h [new file with mode: 0644]
include/configs/rpi_b.h [deleted file]
include/configs/sama5d3_xplained.h
include/configs/sama5d3xek.h
include/configs/siemens-am33x-common.h
include/configs/tao3530.h
include/configs/ti814x_evm.h
include/configs/ti816x_evm.h
include/configs/ti_armv7_common.h
include/configs/tricorder.h
include/configs/uniphier-common.h [deleted file]
include/configs/uniphier.h [new file with mode: 0644]
include/configs/zynq-common.h
include/linux/compat.h
lib/Makefile
lib/bzip2/Makefile [new file with mode: 0644]
lib/bzip2/bzlib.c [new file with mode: 0644]
lib/bzip2/bzlib_crctable.c [new file with mode: 0644]
lib/bzip2/bzlib_decompress.c [new file with mode: 0644]
lib/bzip2/bzlib_huffman.c [new file with mode: 0644]
lib/bzip2/bzlib_private.h [new file with mode: 0644]
lib/bzip2/bzlib_randtable.c [new file with mode: 0644]
lib/bzlib.c [deleted file]
lib/bzlib_crctable.c [deleted file]
lib/bzlib_decompress.c [deleted file]
lib/bzlib_huffman.c [deleted file]
lib/bzlib_private.h [deleted file]
lib/bzlib_randtable.c [deleted file]
lib/libfdt/Makefile
lib/zlib/zlib.h
net/bootp.c
scripts/Makefile.spl
scripts/get_maintainer.pl
scripts/kconfig/menu.c
tools/buildman/README
tools/buildman/builder.py
tools/buildman/builderthread.py
tools/buildman/control.py
tools/patman/patchstream.py

index c8386ab61984aefa894bb0714cf590f99a860347..0cf26025359d93aa19401ad43688bdd49288880a 100644 (file)
@@ -196,7 +196,8 @@ F:  drivers/mtd/cfi_flash.c
 F:     drivers/mtd/jedec_flash.c
 
 COLDFIRE
-M:     Jason Jin <jason.jin@freescale.com>
+M:     Huan Wang <alison.wang@freescale.com>
+M:     Angelo Dureghello <angelo@sysam.it>
 S:     Maintained
 T:     git git://git.denx.de/u-boot-coldfire.git
 F:     arch/m68k/
@@ -390,6 +391,7 @@ T:  git git://git.denx.de/u-boot-tq-group.git
 
 UBI
 M:     Kyungmin Park <kmpark@infradead.org>
+M:     Heiko Schocher <hs@denx.de>
 S:     Maintained
 T:     git git://git.denx.de/u-boot-ubi.git
 F:     drivers/mtd/ubi/
index b4ed77595f0f59b4749df30850a90453a08d6629..8a0de5c67df48670ee27cbf99a2bbb70c6d09ff3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -503,6 +503,7 @@ autoconf_is_current := $(if $(wildcard $(KCONFIG_CONFIG)),$(shell find . \
                -path ./include/config/auto.conf -newer $(KCONFIG_CONFIG)))
 ifneq ($(autoconf_is_current),)
 include $(srctree)/config.mk
+include $(srctree)/arch/$(ARCH)/Makefile
 endif
 
 # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
@@ -601,17 +602,11 @@ c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
 #########################################################################
 # U-Boot objects....order is important (i.e. start must be first)
 
-head-y := $(CPUDIR)/start.o
-head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
-head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
-
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
 
 libs-y += lib/
 libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
-libs-y += $(CPUDIR)/
 libs-$(CONFIG_OF_EMBED) += dts/
-libs-y += arch/$(ARCH)/lib/
 libs-y += fs/
 libs-y += net/
 libs-y += disk/
@@ -645,23 +640,11 @@ libs-y += drivers/usb/musb-new/
 libs-y += drivers/usb/phy/
 libs-y += drivers/usb/ulpi/
 libs-y += common/
-libs-y += lib/libfdt/
 libs-$(CONFIG_API) += api/
 libs-$(CONFIG_HAS_POST) += post/
 libs-y += test/
 libs-y += test/dm/
 
-ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
-libs-y += arch/$(ARCH)/imx-common/
-endif
-
-ifneq (,$(filter $(SOC), armada-xp kirkwood))
-libs-y += arch/$(ARCH)/mvebu-common/
-endif
-
-libs-$(CONFIG_ARM) += arch/arm/cpu/
-libs-$(CONFIG_PPC) += arch/powerpc/cpu/
-
 libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
 
 libs-y := $(sort $(libs-y))
diff --git a/README b/README
index 66770b648539701fe0fdd8b36b1076359557ddd3..bfefa21b3bfd568bee43322e6210ff39dc151257 100644 (file)
--- a/README
+++ b/README
@@ -3657,10 +3657,13 @@ FIT uImage format:
 
                CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
                CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS,
-               CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION
-               Address, size and partition on the MMC to load U-Boot from
+               Address and partition on the MMC to load U-Boot from
                when the MMC is being used in raw mode.
 
+               CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
+               Partition on the MMC to load U-Boot from when the MMC is being
+               used in raw mode
+
                CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR
                Sector to load kernel uImage from when MMC is being
                used in raw mode (for Falcon mode)
@@ -3671,6 +3674,10 @@ FIT uImage format:
                parameters from when MMC is being used in raw mode
                (for falcon mode)
 
+               CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
+               Partition on the MMC to load U-Boot from when the MMC is being
+               used in fs mode
+
                CONFIG_SPL_FAT_SUPPORT
                Support for fs/fat/libfat.o in SPL binary
 
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
new file mode 100644 (file)
index 0000000..de25cc9
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/arc/cpu/$(CPU)/start.o
+
+libs-y += arch/arc/cpu/$(CPU)/
+libs-y += arch/arc/lib/
index 0982117fadac7ad8e57d32df37beb6f0ca352587..7a64b665c63c6aa2718d40a83cfdd93471989495 100644 (file)
@@ -396,8 +396,8 @@ config TARGET_MX35PDK
        bool "Support mx35pdk"
        select CPU_ARM1136
 
-config TARGET_RPI_B
-       bool "Support rpi_b"
+config TARGET_RPI
+       bool "Support rpi"
        select CPU_ARM1176
 
 config TARGET_TNETV107X_EVM
@@ -931,7 +931,7 @@ source "board/palmtreo680/Kconfig"
 source "board/phytec/pcm051/Kconfig"
 source "board/ppcag/bg0900/Kconfig"
 source "board/pxa255_idp/Kconfig"
-source "board/raspberrypi/rpi_b/Kconfig"
+source "board/raspberrypi/rpi/Kconfig"
 source "board/ronetix/pm9261/Kconfig"
 source "board/ronetix/pm9263/Kconfig"
 source "board/ronetix/pm9g45/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
new file mode 100644 (file)
index 0000000..ebb7dc3
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/arm/cpu/$(CPU)/start.o
+
+ifeq ($(CONFIG_SPL_BUILD),y)
+ifneq ($(CONFIG_SPL_START_S_PATH),)
+head-y := $(CONFIG_SPL_START_S_PATH:"%"=%)/start.o
+endif
+endif
+
+libs-y += arch/arm/cpu/$(CPU)/
+libs-y += arch/arm/cpu/
+libs-y += arch/arm/lib/
+
+ifeq ($(CONFIG_SPL_BUILD),y)
+ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
+libs-y += arch/arm/imx-common/
+endif
+else
+ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
+libs-y += arch/arm/imx-common/
+endif
+endif
+
+ifneq (,$(filter $(SOC), armada-xp kirkwood))
+libs-y += arch/arm/mvebu-common/
+endif
index 36b7f11fbeb7fb28db48ed8257d05b1294115843..97602990aa8b693bb29fd7ff459ccccc76177e63 100644 (file)
@@ -5,15 +5,17 @@ config SYS_SOC
        default "uniphier"
 
 config SYS_CONFIG_NAME
-       default "ph1_pro4" if MACH_PH1_PRO4
-       default "ph1_ld4" if MACH_PH1_LD4
-       default "ph1_sld8" if MACH_PH1_SLD8
+       default "uniphier"
+
+config UNIPHIER_SMP
+       bool
 
 choice
        prompt "UniPhier SoC select"
 
 config MACH_PH1_PRO4
        bool "PH1-Pro4"
+       select UNIPHIER_SMP
 
 config MACH_PH1_LD4
        bool "PH1-LD4"
@@ -23,6 +25,29 @@ config MACH_PH1_SLD8
 
 endchoice
 
+choice
+       prompt "UniPhier Support Card select"
+       optional
+
+config PFC_MICRO_SUPPORT_CARD
+       bool "Support card with PFC CPLD"
+       help
+         This option provides support for the expansion board with PFC
+         original address mapping.
+
+         Say Y to use the on-board UART, Ether, LED devices.
+
+config DCC_MICRO_SUPPORT_CARD
+       bool "Support card with DCC CPLD"
+       help
+         This option provides support for the expansion board with DCC-
+         arranged address mapping that is compatible with legacy UniPhier
+         reference boards.
+
+         Say Y to use the on-board UART, Ether, LED devices.
+
+endchoice
+
 config CMD_PINMON
        bool "Enable boot mode pins monitor command"
        depends on !SPL_BUILD
index 0f64d2591c0e9c0aef7303fb7ae6a9337db76df9..4a7b8a9d0815a7fd5d87cbfdc69f1238f6889f64 100644 (file)
@@ -11,6 +11,7 @@ obj-y += cache_uniphier.o
 obj-$(CONFIG_BOARD_POSTCLK_INIT) += board_postclk_init.o
 obj-y += dram_init.o
 obj-$(CONFIG_DISPLAY_CPUINFO) += cpu_info.o
+obj-$(CONFIG_BOARD_EARLY_INIT_R) += board_early_init_r.o
 obj-$(CONFIG_BOARD_LATE_INIT) += board_late_init.o
 obj-$(CONFIG_UNIPHIER_SMP) += smp.o
 obj-$(CONFIG_CMD_PINMON) += cmd_pinmon.o
diff --git a/arch/arm/cpu/armv7/uniphier/board_early_init_r.c b/arch/arm/cpu/armv7/uniphier/board_early_init_r.c
new file mode 100644 (file)
index 0000000..cb7e04f
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/arch/board.h>
+
+int board_early_init_r(void)
+{
+       uniphier_board_late_init();
+       return 0;
+}
index 37300206f60ab5b9ac0365c63e93d1876c8b0b1e..0622a1e16e0dfc3a63b04fa46f962538958eca66 100644 (file)
@@ -26,42 +26,6 @@ static void nand_denali_wp_disable(void)
 #endif
 }
 
-static void nand_denali_fixup(void)
-{
-#if defined(CONFIG_NAND_DENALI) && \
-       (defined(CONFIG_MACH_PH1_SLD8) || defined(CONFIG_MACH_PH1_PRO4))
-       /*
-        * The Denali NAND controller on some of UniPhier SoCs does not
-        * automatically query the device parameters.  For those SoCs,
-        * some registers must be set after the device is probed.
-        */
-       void __iomem *denali_reg = (void __iomem *)CONFIG_SYS_NAND_REGS_BASE;
-       struct mtd_info *mtd;
-       struct nand_chip *chip;
-
-       if (nand_curr_device < 0 ||
-           nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE) {
-               /* NAND was not detected. Just return. */
-               return;
-       }
-
-       mtd = &nand_info[nand_curr_device];
-       chip = mtd->priv;
-
-       writel(mtd->erasesize / mtd->writesize, denali_reg + PAGES_PER_BLOCK);
-       writel(0, denali_reg + DEVICE_WIDTH);
-       writel(mtd->writesize, denali_reg + DEVICE_MAIN_AREA_SIZE);
-       writel(mtd->oobsize, denali_reg + DEVICE_SPARE_AREA_SIZE);
-       writel(1, denali_reg + DEVICES_CONNECTED);
-
-       /*
-        * chip->scan_bbt in nand_scan_tail() has been skipped.
-        * It should be done in here.
-        */
-       chip->scan_bbt(mtd);
-#endif
-}
-
 int board_late_init(void)
 {
        puts("MODE:  ");
@@ -70,7 +34,6 @@ int board_late_init(void)
        case BOOT_DEVICE_MMC1:
                printf("eMMC Boot\n");
                setenv("bootmode", "emmcboot");
-               nand_denali_fixup();
                break;
        case BOOT_DEVICE_NAND:
                printf("NAND Boot\n");
@@ -80,7 +43,6 @@ int board_late_init(void)
        case BOOT_DEVICE_NOR:
                printf("NOR Boot\n");
                setenv("bootmode", "norboot");
-               nand_denali_fixup();
                break;
        default:
                printf("Unsupported Boot Mode\n");
index d2738350a352e5b75e7a6e5c965ec134f742fe1b..a0d10a995d2b3d3e05357a28978691badc8603d9 100644 (file)
 #define IS_SSC(x)              ((IS_SPL_TEXT_AREA(x)) || \
                                        (IS_INIT_STACK_AREA(x)))
 #define IS_EXT(x)              ((x) < 0x100)
-#define IS_REG(x)              (0x500 <= (x) && (x) < 0x700)
+
+/* 0x20000000-0x2fffffff, 0xf0000000-0xffffffff are only used by PH1-sLD3 */
+#define IS_REG(x)              (0x200 <= (x) && (x) < 0x300) || \
+                               (0x500 <= (x) && (x) < 0x700) || \
+                               (0xf00 <= (x))
+
 #define IS_DDR(x)              (0x800 <= (x) && (x) < 0xf00)
 
 #define MMU_FLAGS(x)           (IS_SSC(x)) ? SSC : \
index f113db54d1eaacd1f810feb76ca2152bb3ef5deb..3c82a1aca4c85369eb1f7712ca6b65337ecd82e0 100644 (file)
@@ -22,16 +22,7 @@ void sbc_init(void)
        writel(SBCTRL2_SAVEPIN_PERI_VALUE, SBCTRL12);
        writel(SBCTRL4_SAVEPIN_PERI_VALUE, SBCTRL14);
 
-       if (readl(SBBASE0) & 0x1) {
-               /*
-                * Boot Swap Off: boot from mask ROM
-                * 0x00000000-0x01ffffff: mask ROM
-                * 0x02000000-0x3effffff: memory bank (31MB)
-                * 0x03f00000-0x3fffffff: peripherals (1MB)
-                */
-               writel(0x0000be01, SBBASE0); /* dummy */
-               writel(0x0200be01, SBBASE1);
-       } else {
+       if (boot_is_swapped()) {
                /*
                 * Boot Swap On: boot from external NOR/SRAM
                 * 0x02000000-0x03ffffff is a mirror of 0x00000000-0x01ffffff.
@@ -40,6 +31,15 @@ void sbc_init(void)
                 * 0x01f00000-0x01ffffff, 0x03f00000-0x03ffffff: peripherals
                 */
                writel(0x0000bc01, SBBASE0);
+       } else {
+               /*
+                * Boot Swap Off: boot from mask ROM
+                * 0x00000000-0x01ffffff: mask ROM
+                * 0x02000000-0x3effffff: memory bank (31MB)
+                * 0x03f00000-0x3fffffff: peripherals (1MB)
+                */
+               writel(0x0000be01, SBBASE0); /* dummy */
+               writel(0x0200be01, SBBASE1);
        }
 #elif defined(CONFIG_DCC_MICRO_SUPPORT_CARD)
 #if !defined(CONFIG_SPL_BUILD)
index 40d49409c27814d7831456dffe4f7c640b9010a9..419012e1ab64367ae5dcbf8f24ef27124115a60b 100644 (file)
@@ -83,6 +83,12 @@ static int support_card_show_revision(void)
 }
 #endif
 
+int check_support_card(void)
+{
+       printf("SC:    Micro Support Card ");
+       return support_card_show_revision();
+}
+
 void support_card_init(void)
 {
        /*
@@ -94,12 +100,6 @@ void support_card_init(void)
        support_card_reset_deassert();
 }
 
-int check_support_card(void)
-{
-       printf("SC:    Micro Support Card ");
-       return support_card_show_revision();
-}
-
 #if defined(CONFIG_SMC911X)
 #include <netdev.h>
 
@@ -112,18 +112,14 @@ int board_eth_init(bd_t *bis)
 #if !defined(CONFIG_SYS_NO_FLASH)
 
 #include <mtd/cfi_flash.h>
+#include <asm/arch/sbc-regs.h>
 
-#if CONFIG_SYS_MAX_FLASH_BANKS > 1
-static phys_addr_t flash_banks_list[CONFIG_SYS_MAX_FLASH_BANKS] =
-                                       CONFIG_SYS_FLASH_BANKS_LIST;
+struct memory_bank {
+       phys_addr_t base;
+       unsigned long size;
+};
 
-phys_addr_t cfi_flash_bank_addr(int i)
-{
-       return flash_banks_list[i];
-}
-#endif
-
-int mem_is_flash(phys_addr_t base)
+static int mem_is_flash(const struct memory_bank *mem)
 {
        const int loop = 128;
        u32 *scratch_addr;
@@ -131,8 +127,9 @@ int mem_is_flash(phys_addr_t base)
        int ret = 1;
        int i;
 
-       scratch_addr = map_physmem(base + 0x01e00000,
-                                       sizeof(u32) * loop, MAP_NOCACHE);
+       /* just in case, use the tail of the memory bank */
+       scratch_addr = map_physmem(mem->base + mem->size - sizeof(u32) * loop,
+                                  sizeof(u32) * loop, MAP_NOCACHE);
 
        for (i = 0; i < loop; i++, scratch_addr++) {
                saved_value = readl(scratch_addr);
@@ -150,31 +147,79 @@ int mem_is_flash(phys_addr_t base)
        return ret;
 }
 
-int board_flash_wp_on(void)
+#if defined(CONFIG_PFC_MICRO_SUPPORT_CARD)
+       /* {address, size} */
+static const struct memory_bank memory_banks_boot_swap_off[] = {
+       {0x02000000, 0x01f00000},
+};
+
+static const struct memory_bank memory_banks_boot_swap_on[] = {
+       {0x00000000, 0x01f00000},
+};
+#endif
+
+#if defined(CONFIG_DCC_MICRO_SUPPORT_CARD)
+static const struct memory_bank memory_banks_boot_swap_off[] = {
+       {0x04000000, 0x04000000},
+};
+
+static const struct memory_bank memory_banks_boot_swap_on[] = {
+       {0x00000000, 0x04000000},
+       {0x04000000, 0x04000000},
+};
+#endif
+
+static const struct memory_bank
+*flash_banks_list[CONFIG_SYS_MAX_FLASH_BANKS_DETECT];
+
+phys_addr_t cfi_flash_bank_addr(int i)
 {
-       int i;
-       int ret = 1;
+       return flash_banks_list[i]->base;
+}
 
-       for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
-               if (mem_is_flash(cfi_flash_bank_addr(i))) {
-                       /*
-                        * We found at least one flash.
-                        * We need to return 0 and call flash_init().
-                        */
-                       ret = 0;
-               }
-#if CONFIG_SYS_MAX_FLASH_BANKS > 1
-               else {
-                       /*
-                        * We might have a SRAM here.
-                        * To prevent SRAM data from being destroyed,
-                        * we set dummy address (SDRAM).
-                        */
-                       flash_banks_list[i] = 0x80000000 + 0x10000 * i;
+unsigned long cfi_flash_bank_size(int i)
+{
+       return flash_banks_list[i]->size;
+}
+
+static void detect_num_flash_banks(void)
+{
+       const struct memory_bank *memory_bank, *end;
+
+       cfi_flash_num_flash_banks = 0;
+
+       if (boot_is_swapped()) {
+               memory_bank = memory_banks_boot_swap_on;
+               end = memory_bank + ARRAY_SIZE(memory_banks_boot_swap_on);
+       } else {
+               memory_bank = memory_banks_boot_swap_off;
+               end = memory_bank + ARRAY_SIZE(memory_banks_boot_swap_off);
+       }
+
+       for (; memory_bank < end; memory_bank++) {
+               if (cfi_flash_num_flash_banks >=
+                   CONFIG_SYS_MAX_FLASH_BANKS_DETECT)
+                       break;
+
+               if (mem_is_flash(memory_bank)) {
+                       flash_banks_list[cfi_flash_num_flash_banks] =
+                                                               memory_bank;
+
+                       debug("flash bank found: base = 0x%lx, size = 0x%lx\n",
+                             memory_bank->base, memory_bank->size);
+                       cfi_flash_num_flash_banks++;
                }
-#endif
        }
 
-       return ret;
+       debug("number of flash banks: %d\n", cfi_flash_num_flash_banks);
+}
+#else /* ONFIG_SYS_NO_FLASH */
+void detect_num_flash_banks(void)
+{
+};
+#endif /* ONFIG_SYS_NO_FLASH */
+
+void support_card_late_init(void)
+{
+       detect_num_flash_banks();
 }
-#endif
index 01df9a9f0e1f6a567b1410453abe85d3bb022d7b..187d58c498be88c27496b458d43bb50afa958f19 100644 (file)
@@ -33,6 +33,7 @@ dtb-$(CONFIG_TEGRA) += tegra20-harmony.dtb \
        tegra124-jetson-tk1.dtb \
        tegra124-venice2.dtb
 dtb-$(CONFIG_ARCH_UNIPHIER) += \
+       uniphier-ph1-sld3-ref.dtb \
        uniphier-ph1-pro4-ref.dtb \
        uniphier-ph1-ld4-ref.dtb \
        uniphier-ph1-sld8-ref.dtb
index f01189c99339bd699553837445d394859ba2df50..08bbd032c99056950fab8e6d3e7df4f2a1a2f06e 100644 (file)
                bootargs = "console=ttyPS0,115200 earlyprintk";
                stdout-path = &uart0;
        };
+
+       aliases {
+               uart0 = &uart0;
+               uart1 = &uart1;
+               uart2 = &uart2;
+               uart3 = &uart3;
+               i2c0 = &i2c0;
+               i2c1 = &i2c1;
+               i2c2 = &i2c2;
+               i2c3 = &i2c3;
+       };
 };
 
 &uart0 {
-       status = "okay";
+       status = "okay";
 };
 
 &uart1 {
-       status = "okay";
+       status = "okay";
+};
+
+&i2c0 {
+       status = "okay";
+       eeprom {
+               compatible = "i2c-eeprom";
+               reg = <0x50>;
+       };
 };
 
 &usb0 {
-      status = "okay";
+       status = "okay";
 };
 
 &usb1 {
-      status = "okay";
+       status = "okay";
 };
index 80074c50b5b9a51405e8dff805f61ba877362ea5..2a3dd73ead5c36319c9db18fe60cd000fa5743e1 100644 (file)
@@ -13,8 +13,8 @@
        compatible = "panasonic,ph1-ld4";
 
        cpus {
-               #size-cells = <0>;
                #address-cells = <1>;
+               #size-cells = <0>;
 
                cpu@0 {
                        device_type = "cpu";
                        clock-frequency = <36864000>;
                };
 
+               i2c0: i2c@58400000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58400000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c1: i2c@58480000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58480000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c2: i2c@58500000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58500000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c3: i2c@58580000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58580000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
                usb0: usb@5a800100 {
                        compatible = "panasonic,uniphier-ehci", "usb-ehci";
                        status = "disabled";
                        status = "disabled";
                        reg = <0x5a820100 0x100>;
                };
+
+               nand: nand@68000000 {
+                       compatible = "denali,denali-nand-dt";
+                       reg = <0x68000000 0x20>, <0x68100000 0x1000>;
+                       reg-names = "nand_data", "denali_reg";
+               };
        };
 };
index 52fa81fae15e6ce6eaa70e675d8091edce155428..23add7cfd0dd8771f839ed6bf2b21379696b638d 100644 (file)
                bootargs = "console=ttyPS0,115200 earlyprintk";
                stdout-path = &uart0;
        };
+
+       aliases {
+               uart0 = &uart0;
+               uart1 = &uart1;
+               uart2 = &uart2;
+               uart3 = &uart3;
+               i2c0 = &i2c0;
+               i2c1 = &i2c1;
+               i2c2 = &i2c2;
+               i2c3 = &i2c3;
+               i2c5 = &i2c5;
+               i2c6 = &i2c6;
+       };
 };
 
 &uart0 {
-       status = "okay";
+       status = "okay";
 };
 
 &uart1 {
-       status = "okay";
+       status = "okay";
+};
+
+&i2c0 {
+       status = "okay";
+       eeprom {
+               compatible = "i2c-eeprom";
+               reg = <0x50>;
+       };
 };
 
 &usb0 {
-      status = "okay";
+       status = "okay";
 };
 
 &usb1 {
-      status = "okay";
+       status = "okay";
 };
index dd84269d1ade467c95ba95c986cae194b40e52d5..49e375e8d24649acf99a97e0a9173cc47f4f0222 100644 (file)
@@ -13,8 +13,8 @@
        compatible = "panasonic,ph1-pro4";
 
        cpus {
-               #size-cells = <0>;
                #address-cells = <1>;
+               #size-cells = <0>;
 
                cpu@0 {
                        device_type = "cpu";
                        clock-frequency = <73728000>;
                };
 
+               i2c0: i2c@58780000 {
+                       compatible = "panasonic,uniphier-fi2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58780000 0x80>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c1: i2c@58781000 {
+                       compatible = "panasonic,uniphier-fi2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58781000 0x80>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c2: i2c@58782000 {
+                       compatible = "panasonic,uniphier-fi2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58782000 0x80>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c3: i2c@58783000 {
+                       compatible = "panasonic,uniphier-fi2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58783000 0x80>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               /* i2c4 does not exist */
+
+               i2c5: i2c@58785000 {
+                       compatible = "panasonic,uniphier-fi2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58785000 0x80>;
+                       clock-frequency = <400000>;
+                       status = "ok";
+               };
+
+               i2c6: i2c@58786000 {
+                       compatible = "panasonic,uniphier-fi2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58786000 0x80>;
+                       clock-frequency = <400000>;
+                       status = "ok";
+               };
+
                usb0: usb@5a800100 {
                        compatible = "panasonic,uniphier-ehci", "usb-ehci";
                        status = "disabled";
                        status = "disabled";
                        reg = <0x5a810100 0x100>;
                };
+
+               nand: nand@68000000 {
+                       compatible = "denali,denali-nand-dt";
+                       reg = <0x68000000 0x20>, <0x68100000 0x1000>;
+                       reg-names = "nand_data", "denali_reg";
+               };
        };
 };
diff --git a/arch/arm/dts/uniphier-ph1-sld3-ref.dts b/arch/arm/dts/uniphier-ph1-sld3-ref.dts
new file mode 100644 (file)
index 0000000..91b4dbe
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Device Tree Source for UniPhier PH1-sLD3 Reference Board
+ *
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/dts-v1/;
+/include/ "uniphier-ph1-sld3.dtsi"
+
+/ {
+       model = "Panasonic UniPhier PH1-sLD3 Reference Board";
+       compatible = "panasonic,ph1-sld3-ref", "panasonic,ph1-sld3";
+
+       memory {
+               device_type = "memory";
+               reg = <0x80000000 0x40000000>;
+       };
+
+       chosen {
+               bootargs = "console=ttyPS0,115200 earlyprintk";
+               stdout-path = &uart0;
+       };
+
+       aliases {
+               uart0 = &uart0;
+               uart1 = &uart1;
+               uart2 = &uart2;
+               i2c0 = &i2c0;
+               i2c1 = &i2c1;
+               i2c2 = &i2c2;
+               i2c3 = &i2c3;
+       };
+};
+
+&uart0 {
+       status = "okay";
+};
+
+&uart1 {
+       status = "okay";
+};
+
+&i2c0 {
+       status = "okay";
+       eeprom {
+               compatible = "i2c-eeprom";
+               reg = <0x50>;
+       };
+};
+
+&usb0 {
+       status = "okay";
+};
+
+&usb1 {
+       status = "okay";
+};
diff --git a/arch/arm/dts/uniphier-ph1-sld3.dtsi b/arch/arm/dts/uniphier-ph1-sld3.dtsi
new file mode 100644 (file)
index 0000000..f5529d2
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Device Tree Source for UniPhier PH1-sLD3 SoC
+ *
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/include/ "skeleton.dtsi"
+
+/ {
+       compatible = "panasonic,ph1-sld3";
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu@0 {
+                       device_type = "cpu";
+                       compatible = "arm,cortex-a9";
+                       reg = <0>;
+               };
+
+               cpu@1 {
+                       device_type = "cpu";
+                       compatible = "arm,cortex-a9";
+                       reg = <1>;
+               };
+       };
+
+       soc {
+               compatible = "simple-bus";
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges;
+
+               uart0: serial@54006800 {
+                       compatible = "panasonic,uniphier-uart";
+                       status = "disabled";
+                       reg = <0x54006800 0x20>;
+                       clock-frequency = <36864000>;
+               };
+
+               uart1: serial@54006900 {
+                       compatible = "panasonic,uniphier-uart";
+                       status = "disabled";
+                       reg = <0x54006900 0x20>;
+                       clock-frequency = <36864000>;
+               };
+
+               uart2: serial@54006a00 {
+                       compatible = "panasonic,uniphier-uart";
+                       status = "disabled";
+                       reg = <0x54006a00 0x20>;
+                       clock-frequency = <36864000>;
+               };
+
+               i2c0: i2c@58400000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58400000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c1: i2c@58480000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58480000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c2: i2c@58500000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58500000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c3: i2c@58580000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58580000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               usb0: usb@5a800100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a800100 0x100>;
+               };
+
+               usb1: usb@5a810100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a810100 0x100>;
+               };
+
+               usb2: usb@5a820100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a820100 0x100>;
+               };
+
+               usb3: usb@5a830100 {
+                       compatible = "panasonic,uniphier-ehci", "usb-ehci";
+                       status = "disabled";
+                       reg = <0x5a830100 0x100>;
+               };
+
+               nand: nand@f8000000 {
+                       compatible = "denali,denali-nand-dt";
+                       reg = <0xf8000000 0x20>, <0xf8100000 0x1000>;
+                       reg-names = "nand_data", "denali_reg";
+               };
+       };
+};
index ac73aad928e7c3ce5f7459262bb31c090c848991..a8ce049d6cdbd7f3266b4b33fc4c56d00ac6dfc6 100644 (file)
                bootargs = "console=ttyPS0,115200 earlyprintk";
                stdout-path = &uart0;
        };
+
+       aliases {
+               uart0 = &uart0;
+               uart1 = &uart1;
+               uart2 = &uart2;
+               uart3 = &uart3;
+               i2c0 = &i2c0;
+               i2c1 = &i2c1;
+               i2c2 = &i2c2;
+               i2c3 = &i2c3;
+       };
 };
 
 &uart0 {
-       status = "okay";
+       status = "okay";
 };
 
 &uart1 {
-       status = "okay";
+       status = "okay";
+};
+
+&i2c0 {
+       status = "okay";
+       eeprom {
+               compatible = "i2c-eeprom";
+               reg = <0x50>;
+       };
 };
 
 &usb0 {
-      status = "okay";
+       status = "okay";
 };
 
 &usb1 {
-      status = "okay";
+       status = "okay";
 };
index 43a39f5a4c546c917ded9b8f8b90772660eb570c..0ea76e59fcb27090aab6b4e9453c635984c7f532 100644 (file)
@@ -13,8 +13,8 @@
        compatible = "panasonic,ph1-sld8";
 
        cpus {
-               #size-cells = <0>;
                #address-cells = <1>;
+               #size-cells = <0>;
 
                cpu@0 {
                        device_type = "cpu";
                        clock-frequency = <80000000>;
                };
 
+               i2c0: i2c@58400000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58400000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c1: i2c@58480000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58480000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c2: i2c@58500000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58500000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
+               i2c3: i2c@58580000 {
+                       compatible = "panasonic,uniphier-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58580000 0x40>;
+                       clock-frequency = <100000>;
+                       status = "disabled";
+               };
+
                usb0: usb@5a800100 {
                        compatible = "panasonic,uniphier-ehci", "usb-ehci";
                        status = "disabled";
                        status = "disabled";
                        reg = <0x5a820100 0x100>;
                };
+
+               nand: nand@68000000 {
+                       compatible = "denali,denali-nand-dt";
+                       reg = <0x68000000 0x20>, <0x68100000 0x1000>;
+                       reg-names = "nand_data", "denali_reg";
+               };
        };
 };
index 61f427d914cd939386806a2c45f263d397a11058..0289ba6a917e25765aa84995007652612f8d3e5e 100644 (file)
@@ -119,6 +119,39 @@ struct bcm2835_mbox_tag_hdr {
  * };
  */
 
+#define BCM2835_MBOX_TAG_GET_BOARD_REV 0x00010002
+
+/*
+ * 0x2..0xf from:
+ * http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/
+ * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=32733
+ * 0x10, 0x11 from swarren's testing
+ */
+#define BCM2835_BOARD_REV_B_I2C0_2     0x2
+#define BCM2835_BOARD_REV_B_I2C0_3     0x3
+#define BCM2835_BOARD_REV_B_I2C1_4     0x4
+#define BCM2835_BOARD_REV_B_I2C1_5     0x5
+#define BCM2835_BOARD_REV_B_I2C1_6     0x6
+#define BCM2835_BOARD_REV_A_7          0x7
+#define BCM2835_BOARD_REV_A_8          0x8
+#define BCM2835_BOARD_REV_A_9          0x9
+#define BCM2835_BOARD_REV_B_REV2_d     0xd
+#define BCM2835_BOARD_REV_B_REV2_e     0xe
+#define BCM2835_BOARD_REV_B_REV2_f     0xf
+#define BCM2835_BOARD_REV_B_PLUS       0x10
+#define BCM2835_BOARD_REV_CM           0x11
+
+struct bcm2835_mbox_tag_get_board_rev {
+       struct bcm2835_mbox_tag_hdr tag_hdr;
+       union {
+               struct {
+               } req;
+               struct {
+                       u32 rev;
+               } resp;
+       } body;
+};
+
 #define BCM2835_MBOX_TAG_GET_MAC_ADDRESS       0x00010003
 
 struct bcm2835_mbox_tag_get_mac_address {
index e6ba4e4ee4d624abacc5457cadf1d43973d44cc2..e3cba5befe2a8cdd1518caef2d47fe8f6953619b 100644 (file)
        defined(CONFIG_DCC_MICRO_SUPPORT_CARD)
 void support_card_reset(void);
 void support_card_init(void);
+void support_card_late_init(void);
 int check_support_card(void);
 #else
 #define support_card_reset() do {} while (0)
 #define support_card_init()  do {} while (0)
+#define support_card_late_init()  do {} while (0)
 static inline int check_support_card(void)
 {
        return 0;
@@ -32,4 +34,9 @@ static inline void uniphier_board_init(void)
        support_card_init();
 }
 
+static inline void uniphier_board_late_init(void)
+{
+       support_card_late_init();
+}
+
 #endif /* ARCH_BOARD_H */
diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile
new file mode 100644 (file)
index 0000000..e9b3184
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/avr32/cpu/start.o
+
+libs-y += arch/avr32/cpu/
+libs-y += arch/avr32/lib/
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
new file mode 100644 (file)
index 0000000..787475e
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/blackfin/cpu/start.o
+
+libs-y += arch/blackfin/cpu/
+libs-y += arch/blackfin/lib/
index 69f08bc7efb526a85f3edeab3a184944d178cb72..aadb0d2d4ee42ac3a7e494e14670697c006854de 100644 (file)
 
 #ifdef __KERNEL__
 
+#include <linux/compiler.h>
 #include <asm/blackfin.h>
 
-#define __iomem
-
 static inline void sync(void)
 {
        SSYNC();
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
new file mode 100644 (file)
index 0000000..aa3d2fa
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/m68k/cpu/$(CPU)/start.o
+
+libs-y += arch/m68k/cpu/$(CPU)/
+libs-y += arch/m68k/lib/
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
new file mode 100644 (file)
index 0000000..ae4adc2
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/microblaze/cpu/start.o
+
+libs-y += arch/microblaze/cpu/
+libs-y += arch/microblaze/lib/
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
new file mode 100644 (file)
index 0000000..1907b57
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/mips/cpu/$(CPU)/start.o
+
+libs-y += arch/mips/cpu/$(CPU)/
+libs-y += arch/mips/lib/
index 1d5112ea69f8f10820ab9a2a41f7f8848c60abf1..c25a8462c72e104cb898af9b4f3258a414f0ce9b 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef _ASM_MIPS_UNALIGNED_H
 #define _ASM_MIPS_UNALIGNED_H
 
-#include <compiler.h>
+#include <linux/compiler.h>
 #if defined(__MIPSEB__)
 #define get_unaligned  __get_unaligned_be
 #define put_unaligned  __put_unaligned_be
diff --git a/arch/nds32/Makefile b/arch/nds32/Makefile
new file mode 100644 (file)
index 0000000..e1eccba
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/nds32/cpu/$(CPU)/start.o
+
+libs-y += arch/nds32/cpu/$(CPU)/
+libs-y += arch/nds32/lib/
diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile
new file mode 100644 (file)
index 0000000..18685a9
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/nios2/cpu/start.o
+
+libs-y += arch/nios2/cpu/
+libs-y += arch/nios2/lib/
diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
new file mode 100644 (file)
index 0000000..c4da3ce
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/openrisc/cpu/start.o
+
+libs-y += arch/openrisc/cpu/
+libs-y += arch/openrisc/lib/
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
new file mode 100644 (file)
index 0000000..8aa1d60
--- /dev/null
@@ -0,0 +1,11 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/powerpc/cpu/$(CPU)/start.o
+head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
+head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
+
+libs-y += arch/powerpc/cpu/$(CPU)/
+libs-y += arch/powerpc/cpu/
+libs-y += arch/powerpc/lib/
index e447748e120be3f6acfaa1bf91883ee95fd788df..99420abc897a046400a0e48e227fcd4f7af511ef 100644 (file)
@@ -13,9 +13,6 @@ config TARGET_COGENT_MPC8XX
 config TARGET_ESTEEM192E
        bool "Support ESTEEM192E"
 
-config TARGET_HERMES
-       bool "Support hermes"
-
 config TARGET_IP860
        bool "Support IP860"
 
@@ -112,7 +109,6 @@ source "board/LEOX/elpt860/Kconfig"
 source "board/RRvision/Kconfig"
 source "board/cogent/Kconfig"
 source "board/esteem192e/Kconfig"
-source "board/hermes/Kconfig"
 source "board/ip860/Kconfig"
 source "board/ivm/Kconfig"
 source "board/kup/kup4k/Kconfig"
index 60c401e311ecddb7fd7b52e76057ddcfb6135365..6a1cd4675ae005cc3d77d0f4d307b9ae645e478a 100644 (file)
@@ -125,8 +125,7 @@ void cpu_init_f (volatile immap_t * immr)
         *  I owe him a free beer. - wd]
         */
 
-#if defined(CONFIG_HERMES)     || \
-    defined(CONFIG_IP860)      || \
+#if defined(CONFIG_IP860)      || \
     defined(CONFIG_IVML24)     || \
     defined(CONFIG_IVMS8)      || \
     defined(CONFIG_LWMON)      || \
index 6eaab882437dda464db83c2943669203a26f2998..e6d5355f261fd9b6e4bd521fa141ccd61db22860 100644 (file)
@@ -820,13 +820,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
        mac_read_from_eeprom();
 #endif
 
-#ifdef CONFIG_HERMES
-       if ((gd->board_type >> 16) == 2)
-               bd->bi_ethspeed = gd->board_type & 0xFFFF;
-       else
-               bd->bi_ethspeed = 0xFFFF;
-#endif
-
 #ifdef CONFIG_CMD_NET
        /* kept around for legacy kernels only ... ignore the next section */
        eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
@@ -876,11 +869,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
        misc_init_r();
 #endif
 
-#ifdef CONFIG_HERMES
-       if (bd->bi_ethspeed != 0xFFFF)
-               hermes_start_lxt980((int) bd->bi_ethspeed);
-#endif
-
 #if defined(CONFIG_CMD_KGDB)
        WATCHDOG_RESET();
        puts("KGDB:  ");
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
new file mode 100644 (file)
index 0000000..23fdcdb
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/sandbox/cpu/start.o
+
+libs-y += arch/sandbox/cpu/
+libs-y += arch/sandbox/lib/
index 31c93443dba008036e49723fe284eab58a40bda1..4d5f8057533e89f2ed6edd0298ac4c69038360eb 100644 (file)
@@ -367,6 +367,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 
 done:
        closedir(dir);
+       free(fname);
        return ret;
 }
 
index 0df77704c6f769c7085940ca81592d064c7362af..42353d80a847bc51eade86f414e72238a8a4916f 100644 (file)
@@ -130,7 +130,8 @@ static int sandbox_cmdline_cb_memory(struct sandbox_state *state,
        state->write_ram_buf = true;
        state->ram_buf_fname = arg;
 
-       if (os_read_ram_buf(arg)) {
+       err = os_read_ram_buf(arg);
+       if (err) {
                printf("Failed to read RAM buffer\n");
                return err;
        }
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
new file mode 100644 (file)
index 0000000..ca55fac
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/sh/cpu/$(CPU)/start.o
+
+libs-y += arch/sh/cpu/$(CPU)/
+libs-y += arch/sh/lib/
index 2e0d16405024f59a5b62acd7cbf27ae4b0877dd1..06096eeac574bed06e93ea074ed03ca2c6350819 100644 (file)
@@ -8,7 +8,7 @@
 #include <asm/unaligned-sh4a.h>
 #else
 /* Otherwise, SH can't handle unaligned accesses. */
-#include <compiler.h>
+#include <linux/compiler.h>
 #if defined(__BIG_ENDIAN__)
 #define get_unaligned   __get_unaligned_be
 #define put_unaligned   __put_unaligned_be
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
new file mode 100644 (file)
index 0000000..2d4c971
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/sparc/cpu/$(CPU)/start.o
+
+libs-y += arch/sparc/cpu/$(CPU)/
+libs-y += arch/sparc/lib/
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
new file mode 100644 (file)
index 0000000..36a6018
--- /dev/null
@@ -0,0 +1,12 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+head-y := arch/x86/cpu/start.o
+ifeq ($(CONFIG_SPL_BUILD),y)
+head-y += arch/x86/cpu/start16.o
+head-y += arch/x86/cpu/resetvec.o
+endif
+
+libs-y += arch/x86/cpu/
+libs-y += arch/x86/lib/
index 5f6c00945bb292ec706b6afe1a152ab0618e090b..3340872a87cd89913707d20858f7ec9ab80a0ad4 100644 (file)
@@ -29,7 +29,8 @@
  * SUCH DAMAGE.
  */
 
-#include <compiler.h>
+#include <linux/types.h>
+#include <linux/compiler.h>
 #include <asm/arch/ipchecksum.h>
 
 unsigned short ipchksum(const void *vptr, unsigned long nbytes)
index 8e4a61de7d07cf73dba726f0de80794a2d9a0d89..832c50aa63886e5e96c3cb852cf0746e02271afa 100644 (file)
@@ -10,7 +10,7 @@
 #define _COREBOOT_SYSINFO_H
 
 #include <common.h>
-#include <compiler.h>
+#include <linux/compiler.h>
 #include <libfdt.h>
 #include <asm/arch/tables.h>
 
index 0d02fe0592eed1775e251ad23838ab92319a4aca..e254484e75ae958ddec32a541d3943ef22852ffc 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef _COREBOOT_TABLES_H
 #define _COREBOOT_TABLES_H
 
-#include <compiler.h>
+#include <linux/compiler.h>
 
 struct cbuint64 {
        u32 lo;
index fcd9aa98574cd15f0b87bed7eaef3ee59bf8c978..e0b25619cd50e8f2877e774dc5c1f2bf5be01b4d 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _ASM_IO_H
 #define _ASM_IO_H
 
-#include <compiler.h>
+#include <linux/compiler.h>
 
 /*
  * This file contains the definitions for the x86 IO instructions
index a1656ccfe7d82480031789ec987781a9a094d2b3..6c66431ed93b3d4943954f0e07a04a0acf665c77 100644 (file)
@@ -8,9 +8,9 @@
 
 /* From glibc-2.14, sysdeps/i386/memset.c */
 
-#include <compiler.h>
-#include <asm/string.h>
 #include <linux/types.h>
+#include <linux/compiler.h>
+#include <asm/string.h>
 
 typedef uint32_t op_t;
 
diff --git a/board/hermes/Kconfig b/board/hermes/Kconfig
deleted file mode 100644 (file)
index deb37fd..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-if TARGET_HERMES
-
-config SYS_BOARD
-       default "hermes"
-
-config SYS_CONFIG_NAME
-       default "hermes"
-
-endif
diff --git a/board/hermes/MAINTAINERS b/board/hermes/MAINTAINERS
deleted file mode 100644 (file)
index a596dad..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-HERMES BOARD
-M:     Wolfgang Denk <wd@denx.de>
-S:     Maintained
-F:     board/hermes/
-F:     include/configs/hermes.h
-F:     configs/hermes_defconfig
diff --git a/board/hermes/Makefile b/board/hermes/Makefile
deleted file mode 100644 (file)
index ccca520..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2000-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y  = hermes.o flash.o
diff --git a/board/hermes/flash.c b/board/hermes/flash.c
deleted file mode 100644 (file)
index 38d3cd3..0000000
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <mpc8xx.h>
-
-flash_info_t   flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
-
-/*-----------------------------------------------------------------------
- * Functions
- */
-static ulong flash_get_size (vu_long *addr, flash_info_t *info);
-static int write_byte (flash_info_t *info, ulong dest, uchar data);
-static void flash_get_offsets (ulong base, flash_info_t *info);
-
-/*-----------------------------------------------------------------------
- */
-
-unsigned long flash_init (void)
-{
-       volatile immap_t     *immap  = (immap_t *)CONFIG_SYS_IMMR;
-       volatile memctl8xx_t *memctl = &immap->im_memctl;
-       unsigned long size;
-       int i;
-
-       /* Init: no FLASHes known */
-       for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
-               flash_info[i].flash_id = FLASH_UNKNOWN;
-       }
-
-       /* Static FLASH Bank configuration here - FIXME XXX */
-
-       size = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
-
-       if (flash_info[0].flash_id == FLASH_UNKNOWN) {
-               printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
-                       size, size<<20);
-       }
-
-       /* Remap FLASH according to real size */
-       memctl->memc_or0 = CONFIG_SYS_OR_TIMING_FLASH | (-size & 0xFFFF8000);
-       memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) |
-                               (memctl->memc_br0 & ~(BR_BA_MSK));
-
-       /* Re-do sizing to get full correct info */
-       size = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE, &flash_info[0]);
-
-       flash_get_offsets (CONFIG_SYS_FLASH_BASE, &flash_info[0]);
-
-#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
-       /* monitor protection ON by default */
-       flash_protect(FLAG_PROTECT_SET,
-                     CONFIG_SYS_MONITOR_BASE,
-                     CONFIG_SYS_MONITOR_BASE+monitor_flash_len-1,
-                     &flash_info[0]);
-#endif
-
-       flash_info[0].size = size;
-
-       return (size);
-}
-
-/*-----------------------------------------------------------------------
- */
-static void flash_get_offsets (ulong base, flash_info_t *info)
-{
-       int i;
-
-       /* set up sector start address table */
-       if (info->flash_id & FLASH_BTYPE) {
-               /* set sector offsets for bottom boot block type        */
-               info->start[0] = base + 0x00000000;
-               info->start[1] = base + 0x00004000;
-               info->start[2] = base + 0x00006000;
-               info->start[3] = base + 0x00008000;
-               for (i = 4; i < info->sector_count; i++) {
-                       info->start[i] = base + (i * 0x00010000) - 0x00030000;
-               }
-       } else {
-               /* set sector offsets for top boot block type           */
-               i = info->sector_count - 1;
-               info->start[i--] = base + info->size - 0x00004000;
-               info->start[i--] = base + info->size - 0x00006000;
-               info->start[i--] = base + info->size - 0x00008000;
-               for (; i >= 0; i--) {
-                       info->start[i] = base + i * 0x00010000;
-               }
-       }
-
-}
-
-/*-----------------------------------------------------------------------
- */
-void flash_print_info  (flash_info_t *info)
-{
-       int i;
-
-       if (info->flash_id == FLASH_UNKNOWN) {
-               printf ("missing or unknown FLASH type\n");
-               return;
-       }
-
-       switch (info->flash_id & FLASH_VENDMASK) {
-       case FLASH_MAN_AMD:     printf ("AMD ");                break;
-       case FLASH_MAN_FUJ:     printf ("FUJITSU ");            break;
-       default:                printf ("Unknown Vendor ");     break;
-       }
-
-       switch (info->flash_id & FLASH_TYPEMASK) {
-       case FLASH_AM400B:      printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
-                               break;
-       case FLASH_AM400T:      printf ("AM29LV400T (4 Mbit, top boot sector)\n");
-                               break;
-       case FLASH_AM800B:      printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
-                               break;
-       case FLASH_AM800T:      printf ("AM29LV800T (8 Mbit, top boot sector)\n");
-                               break;
-       case FLASH_AM160B:      printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
-                               break;
-       case FLASH_AM160T:      printf ("AM29LV160T (16 Mbit, top boot sector)\n");
-                               break;
-       case FLASH_AM320B:      printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
-                               break;
-       case FLASH_AM320T:      printf ("AM29LV320T (32 Mbit, top boot sector)\n");
-                               break;
-       default:                printf ("Unknown Chip Type\n");
-                               break;
-       }
-
-       printf ("  Size: %ld MB in %d Sectors\n",
-               info->size >> 20, info->sector_count);
-
-       printf ("  Sector Start Addresses:");
-       for (i=0; i<info->sector_count; ++i) {
-               if ((i % 5) == 0)
-                       printf ("\n   ");
-               printf (" %08lX%s",
-                       info->start[i],
-                       info->protect[i] ? " (RO)" : "     "
-               );
-       }
-       printf ("\n");
-       return;
-}
-
-/*-----------------------------------------------------------------------
- */
-
-
-/*-----------------------------------------------------------------------
- */
-
-/*
- * The following code cannot be run from FLASH!
- */
-
-static ulong flash_get_size (vu_long *addr, flash_info_t *info)
-{
-       short i;
-       uchar value;
-       vu_char *caddr = (vu_char *)addr;
-       ulong base = (ulong)addr;
-
-
-       /* Write auto select command: read Manufacturer ID */
-       caddr[0x0AAA] = 0xAA;
-       caddr[0x0555] = 0x55;
-       caddr[0x0AAA] = 0x90;
-
-       value = caddr[0];
-       switch (value) {
-       case (AMD_MANUFACT & 0xFF):
-               info->flash_id = FLASH_MAN_AMD;
-               break;
-       case (FUJ_MANUFACT & 0xFF):
-               info->flash_id = FLASH_MAN_FUJ;
-               break;
-       default:
-               info->flash_id = FLASH_UNKNOWN;
-               info->sector_count = 0;
-               info->size = 0;
-               return (0);                     /* no or unknown flash  */
-       }
-
-       value = caddr[2];                       /* device ID            */
-
-       switch (value) {
-       case (AMD_ID_LV400T & 0xFF):
-               info->flash_id += FLASH_AM400T;
-               info->sector_count = 11;
-               info->size = 0x00080000;
-               break;                          /* => 512 kB            */
-
-       case (AMD_ID_LV400B & 0xFF):
-               info->flash_id += FLASH_AM400B;
-               info->sector_count = 11;
-               info->size = 0x00080000;
-               break;                          /* => 512 kB            */
-
-       case (AMD_ID_LV800T & 0xFF):
-               info->flash_id += FLASH_AM800T;
-               info->sector_count = 19;
-               info->size = 0x00100000;
-               break;                          /* => 1 MB              */
-
-       case (AMD_ID_LV800B & 0xFF):
-               info->flash_id += FLASH_AM800B;
-               info->sector_count = 19;
-               info->size = 0x00100000;
-               break;                          /* => 1 MB              */
-
-       case (AMD_ID_LV160T & 0xFF):
-               info->flash_id += FLASH_AM160T;
-               info->sector_count = 35;
-               info->size = 0x00200000;
-               break;                          /* => 2 MB              */
-
-       case (AMD_ID_LV160B & 0xFF):
-               info->flash_id += FLASH_AM160B;
-               info->sector_count = 35;
-               info->size = 0x00200000;
-               break;                          /* => 2 MB              */
-#if 0  /* enable when device IDs are available */
-       case (AMD_ID_LV320T & 0xFF):
-               info->flash_id += FLASH_AM320T;
-               info->sector_count = 67;
-               info->size = 0x00400000;
-               break;                          /* => 4 MB              */
-
-       case (AMD_ID_LV320B & 0xFF):
-               info->flash_id += FLASH_AM320B;
-               info->sector_count = 67;
-               info->size = 0x00400000;
-               break;                          /* => 4 MB              */
-#endif
-       default:
-               info->flash_id = FLASH_UNKNOWN;
-               return (0);                     /* => no or unknown flash */
-
-       }
-
-       /* set up sector start address table */
-       if (info->flash_id & FLASH_BTYPE) {
-               /* set sector offsets for bottom boot block type        */
-               info->start[0] = base + 0x00000000;
-               info->start[1] = base + 0x00004000;
-               info->start[2] = base + 0x00006000;
-               info->start[3] = base + 0x00008000;
-               for (i = 4; i < info->sector_count; i++) {
-                       info->start[i] = base + (i * 0x00010000) - 0x00030000;
-               }
-       } else {
-               /* set sector offsets for top boot block type           */
-               i = info->sector_count - 1;
-               info->start[i--] = base + info->size - 0x00004000;
-               info->start[i--] = base + info->size - 0x00006000;
-               info->start[i--] = base + info->size - 0x00008000;
-               for (; i >= 0; i--) {
-                       info->start[i] = base + i * 0x00010000;
-               }
-       }
-
-       /* check for protected sectors */
-       for (i = 0; i < info->sector_count; i++) {
-               /* read sector protection: D0 = 1 if protected */
-               caddr = (volatile unsigned char *)(info->start[i]);
-               info->protect[i] = caddr[4] & 1;
-       }
-
-       /*
-        * Prevent writes to uninitialized FLASH.
-        */
-       if (info->flash_id != FLASH_UNKNOWN) {
-               caddr = (vu_char *)info->start[0];
-
-               *caddr = 0xF0;  /* reset bank */
-       }
-
-       return (info->size);
-}
-
-
-/*-----------------------------------------------------------------------
- */
-
-int    flash_erase (flash_info_t *info, int s_first, int s_last)
-{
-       vu_char *addr = (vu_char*)(info->start[0]);
-       int flag, prot, sect, l_sect;
-       ulong start, now, last;
-
-       if ((s_first < 0) || (s_first > s_last)) {
-               if (info->flash_id == FLASH_UNKNOWN) {
-                       printf ("- missing\n");
-               } else {
-                       printf ("- no sectors to erase\n");
-               }
-               return 1;
-       }
-
-       if ((info->flash_id == FLASH_UNKNOWN) ||
-           (info->flash_id > FLASH_AMD_COMP)) {
-               printf ("Can't erase unknown flash type %08lx - aborted\n",
-                       info->flash_id);
-               return 1;
-       }
-
-       prot = 0;
-       for (sect=s_first; sect<=s_last; ++sect) {
-               if (info->protect[sect]) {
-                       prot++;
-               }
-       }
-
-       if (prot) {
-               printf ("- Warning: %d protected sectors will not be erased!\n",
-                       prot);
-       } else {
-               printf ("\n");
-       }
-
-       l_sect = -1;
-
-       /* Disable interrupts which might cause a timeout here */
-       flag = disable_interrupts();
-
-       addr[0x0AAA] = 0xAA;
-       addr[0x0555] = 0x55;
-       addr[0x0AAA] = 0x80;
-       addr[0x0AAA] = 0xAA;
-       addr[0x0555] = 0x55;
-
-       /* Start erase on unprotected sectors */
-       for (sect = s_first; sect<=s_last; sect++) {
-               if (info->protect[sect] == 0) { /* not protected */
-                       addr = (vu_char*)(info->start[sect]);
-                       addr[0] = 0x30;
-                       l_sect = sect;
-               }
-       }
-
-       /* re-enable interrupts if necessary */
-       if (flag)
-               enable_interrupts();
-
-       /* wait at least 80us - let's wait 1 ms */
-       udelay (1000);
-
-       /*
-        * We wait for the last triggered sector
-        */
-       if (l_sect < 0)
-               goto DONE;
-
-       start = get_timer (0);
-       last  = start;
-       addr = (vu_char*)(info->start[l_sect]);
-       while ((addr[0] & 0x80) != 0x80) {
-               if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
-                       printf ("Timeout\n");
-                       return 1;
-               }
-               /* show that we're waiting */
-               if ((now - last) > 1000) {      /* every second */
-                       putc ('.');
-                       last = now;
-               }
-       }
-
-DONE:
-       /* reset to read mode */
-       addr = (vu_char *)info->start[0];
-       addr[0] = 0xF0; /* reset bank */
-
-       printf (" done\n");
-       return 0;
-}
-
-/*-----------------------------------------------------------------------
- * Copy memory to flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-
-int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
-{
-       int rc;
-
-       while (cnt > 0) {
-               if ((rc = write_byte(info, addr++, *src++)) != 0) {
-                       return (rc);
-               }
-               --cnt;
-       }
-
-       return (0);
-}
-
-/*-----------------------------------------------------------------------
- * Write a word to Flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-static int write_byte (flash_info_t *info, ulong dest, uchar data)
-{
-       vu_char *addr = (vu_char*)(info->start[0]);
-       ulong start;
-       int flag;
-
-       /* Check if Flash is (sufficiently) erased */
-       if ((*((vu_char *)dest) & data) != data) {
-               return (2);
-       }
-       /* Disable interrupts which might cause a timeout here */
-       flag = disable_interrupts();
-
-       addr[0x0AAA] = 0xAA;
-       addr[0x0555] = 0x55;
-       addr[0x0AAA] = 0xA0;
-
-       *((vu_char *)dest) = data;
-
-       /* re-enable interrupts if necessary */
-       if (flag)
-               enable_interrupts();
-
-       /* data polling for D7 */
-       start = get_timer (0);
-       while ((*((vu_char *)dest) & 0x80) != (data & 0x80)) {
-               if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
-                       return (1);
-               }
-       }
-       return (0);
-}
-
-/*-----------------------------------------------------------------------
- */
diff --git a/board/hermes/hermes.c b/board/hermes/hermes.c
deleted file mode 100644 (file)
index 6126b73..0000000
+++ /dev/null
@@ -1,590 +0,0 @@
-/*
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <commproc.h>
-#include <mpc8xx.h>
-
-#ifdef CONFIG_SHOW_BOOT_PROGRESS
-# include <status_led.h>
-# define SHOW_BOOT_PROGRESS(arg)       bootstage_mark(arg)
-#else
-# define SHOW_BOOT_PROGRESS(arg)
-#endif
-
-DECLARE_GLOBAL_DATA_PTR;
-
-/* ------------------------------------------------------------------------- */
-
-static long int dram_size (long int, long int *, long int);
-static ulong board_init (void);
-static void send_smi_frame (volatile scc_t * sp, volatile cbd_t * bd,
-                                                       uchar * msg);
-
-/* ------------------------------------------------------------------------- */
-
-#define        _NOT_USED_      0xFFFFFFFF
-
-const uint sdram_table[] = {
-       /*
-        * Single Read. (Offset 0 in UPMA RAM)
-        */
-       0x1f07fc04, 0xeeaefc04, 0x11adfc04, 0xefbbbc00,
-       0x1ff77c47,                                     /* last */
-       /*
-        * SDRAM Initialization (offset 5 in UPMA RAM)
-        *
-        * This is no UPM entry point. The following definition uses
-        * the remaining space to establish an initialization
-        * sequence, which is executed by a RUN command.
-        *
-        */
-       0x1fe77c35, 0xffaffc34, 0x1fa57c35,     /* last */
-       /*
-        * Burst Read. (Offset 8 in UPMA RAM)
-        */
-       0x1f07fc04, 0xeeaefc04, 0x10adfc04, 0xf0affc00,
-       0xf0affc00, 0xf1affc00, 0xefbbbc00, 0x1ff77c47, /* last */
-       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
-       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
-       /*
-        * Single Write. (Offset 18 in UPMA RAM)
-        */
-       0x1f27fc04, 0xeeaebc00, 0x01b93c04, 0x1ff77c47, /* last */
-       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
-       /*
-        * Burst Write. (Offset 20 in UPMA RAM)
-        */
-       0x1f07fc04, 0xeeaebc00, 0x10ad4c00, 0xf0afcc00,
-       0xf0afcc00, 0xe1bb8c06, 0x1ff77c47,     /* last */
-       _NOT_USED_,
-       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
-       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
-       /*
-        * Refresh  (Offset 30 in UPMA RAM)
-        */
-       0x1ff5fc84, 0xfffffc04, 0xfffffc04, 0xfffffc04,
-       0xfffffc84, 0xfffffc07,         /* last */
-       _NOT_USED_, _NOT_USED_,
-       _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
-       /*
-        * Exception. (Offset 3c in UPMA RAM)
-        */
-       0x7ffffc07,                                     /* last */
-       _NOT_USED_, _NOT_USED_, _NOT_USED_,
-};
-
-/* ------------------------------------------------------------------------- */
-
-
-/*
- * Check Board Identity:
- *
- * Test ID string (HERMES...)
- *
- * Return code for board revision and network speed
- */
-
-int checkboard (void)
-{
-       char buf[64];
-       int i;
-       int l = getenv_f("serial#", buf, sizeof(buf));
-
-       puts ("Board: ");
-
-       if (l < 0 || strncmp(buf, "HERMES", 6)) {
-               puts ("### No HW ID - assuming HERMES-PRO");
-       } else {
-               for (i = 0; i < l; i++) {
-                       if (buf[i] == ' ')
-                               break;
-                       putc (buf[i]);
-               }
-       }
-
-       gd->board_type = board_init ();
-
-       printf ("  Rev. %ld.x\n", (gd->board_type >> 16));
-
-       return (0);
-}
-
-/* ------------------------------------------------------------------------- */
-
-phys_size_t initdram (int board_type)
-{
-       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-       volatile memctl8xx_t *memctl = &immap->im_memctl;
-       long int size, size8, size9;
-
-       upmconfig (UPMA, (uint *) sdram_table,
-                          sizeof (sdram_table) / sizeof (uint));
-
-       /*
-        * Preliminary prescaler for refresh
-        */
-       memctl->memc_mptpr = 0x0400;
-
-       memctl->memc_mar = 0x00000088;
-
-       /*
-        * Map controller banks 1 to the SDRAM banks at preliminary address
-        */
-       memctl->memc_or1 = CONFIG_SYS_OR1_PRELIM;
-       memctl->memc_br1 = CONFIG_SYS_BR1_PRELIM;
-
-       /* HERMES-PRO boards have only one bank SDRAM */
-
-
-       udelay (200);
-
-       /* perform SDRAM initializsation sequence */
-
-       memctl->memc_mamr = 0xD0802114;
-       memctl->memc_mcr = 0x80002105;
-       udelay (1);
-       memctl->memc_mamr = 0xD0802118;
-       memctl->memc_mcr = 0x80002130;
-       udelay (1);
-       memctl->memc_mamr = 0xD0802114;
-       memctl->memc_mcr = 0x80002106;
-
-       udelay (1000);
-
-       /*
-        * Check Bank 0 Memory Size for re-configuration
-        *
-        * try 8 column mode
-        */
-       size8 = dram_size (CONFIG_SYS_MAMR_8COL, (long *) SDRAM_BASE_PRELIM,
-                                          SDRAM_MAX_SIZE);
-
-       udelay (1000);
-
-       /*
-        * try 9 column mode
-        */
-       size9 = dram_size (CONFIG_SYS_MAMR_9COL, (long *) SDRAM_BASE_PRELIM,
-                                          SDRAM_MAX_SIZE);
-
-       if (size8 < size9) {            /* leave configuration at 9 columns */
-               size = size9;
-/*     debug ("SDRAM Bank 0 in 9 column mode: %ld MB\n", size >> 20);  */
-       } else {                                        /* back to 8 columns            */
-               size = size8;
-               memctl->memc_mamr = CONFIG_SYS_MAMR_8COL;
-               udelay (500);
-/*     debug ("SDRAM Bank 0 in 8 column mode: %ld MB\n", size >> 20);  */
-       }
-
-       udelay (1000);
-
-       memctl->memc_or1 = ((-size) & 0xFFFF0000) | SDRAM_TIMING;
-       memctl->memc_br1 = (CONFIG_SYS_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V;
-
-       udelay (10000);
-
-       return (size);
-}
-
-/* ------------------------------------------------------------------------- */
-
-/*
- * Check memory range for valid RAM. A simple memory test determines
- * the actually available RAM size between addresses `base' and
- * `base + maxsize'. Some (not all) hardware errors are detected:
- * - short between address lines
- * - short between data lines
- */
-
-static long int dram_size (long int mamr_value, long int *base,
-                                                  long int maxsize)
-{
-       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-       volatile memctl8xx_t *memctl = &immap->im_memctl;
-
-       memctl->memc_mamr = mamr_value;
-
-       return (get_ram_size(base, maxsize));
-}
-
-/* ------------------------------------------------------------------------- */
-
-#define        PB_LED_3        0x00020000      /* Status LED's */
-#define PB_LED_2       0x00010000
-#define PB_LED_1       0x00008000
-#define PB_LED_0       0x00004000
-
-#define PB_LED_ALL     (PB_LED_0 | PB_LED_1 | PB_LED_2 | PB_LED_3)
-
-#define        PC_REP_SPD1     0x00000800
-#define PC_REP_SPD0    0x00000400
-
-#define PB_RESET_2081  0x00000020      /* Reset PEB2081 */
-
-#define PB_MAI_4       0x00000010      /* Configuration */
-#define PB_MAI_3       0x00000008
-#define PB_MAI_2       0x00000004
-#define PB_MAI_1       0x00000002
-#define PB_MAI_0       0x00000001
-
-#define PB_MAI_ALL     (PB_MAI_0 | PB_MAI_1 | PB_MAI_2 | PB_MAI_3 | PB_MAI_4)
-
-
-#define        PC_REP_MGRPRS   0x0200
-#define PC_REP_SPD     0x0040          /* Select 100 Mbps */
-#define PC_REP_RES     0x0004
-#define PC_BIT14       0x0002          /* ??? */
-#define PC_BIT15       0x0001          /* ??? ENDSL ?? */
-
-/* ------------------------------------------------------------------------- */
-
-static ulong board_init (void)
-{
-       volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
-       ulong reg, revision, speed = 100;
-       int ethspeed;
-       char *s;
-
-       if ((s = getenv ("ethspeed")) != NULL) {
-               if (strcmp (s, "100") == 0) {
-                       ethspeed = 100;
-               } else if (strcmp (s, "10") == 0) {
-                       ethspeed = 10;
-               } else {
-                       ethspeed = 0;
-               }
-       } else {
-               ethspeed = 0;
-       }
-
-       /* Configure Port B Output Pins => 0x0003cc3F */
-       reg = PB_LED_ALL | PC_REP_SPD1 | PC_REP_SPD0 | PB_RESET_2081 |
-                       PB_MAI_ALL;
-       immr->im_cpm.cp_pbpar &= ~reg;
-       immr->im_cpm.cp_pbodr &= ~reg;
-       immr->im_cpm.cp_pbdat &= ~reg;  /* all 0 */
-       immr->im_cpm.cp_pbdir |= reg;
-
-       /* Check hardware revision */
-       if ((immr->im_ioport.iop_pcdat & 0x0003) == 0x0003) {
-               /*
-                * Revision 3.x hardware
-                */
-               revision = 3;
-
-               immr->im_ioport.iop_pcdat = 0x0240;
-               immr->im_ioport.iop_pcdir = (PC_REP_MGRPRS | PC_REP_SPD | PC_REP_RES | PC_BIT14);       /* = 0x0246 */
-               immr->im_ioport.iop_pcdat |= PC_REP_RES;
-       } else {
-               immr->im_ioport.iop_pcdat = 0x0002;
-               immr->im_ioport.iop_pcdir = (PC_REP_MGRPRS | PC_REP_RES | PC_BIT14 | PC_BIT15); /* = 0x0207 */
-
-               if ((immr->im_ioport.iop_pcdat & PC_REP_SPD) == 0) {
-                       /*
-                        * Revision 2.x hardware: PC9 connected to PB21
-                        */
-                       revision = 2;
-
-                       if (ethspeed == 0) {
-                               /* both 10 and 100 Mbps allowed:
-                                * select 10 Mbps and autonegotiation
-                                */
-                               puts ("  [10+100]");
-                               immr->im_cpm.cp_pbdat = 0;      /* SPD1:SPD0 = 0:0 - autonegot. */
-                               speed = 10;
-                       } else if (ethspeed == 10) {
-                               /* we are asked for 10 Mbps,
-                                * so select 10 Mbps
-                                */
-                               puts ("  [10]");
-                               immr->im_cpm.cp_pbdat = 0;      /* ??? */
-                               speed = 10;
-                       } else {
-                               /* anything else:
-                                * select 100 Mbps
-                                */
-                               puts ("  [100]");
-                               immr->im_cpm.cp_pbdat = PC_REP_SPD0 | PC_REP_SPD1;
-                               /* SPD1:SPD0 = 1:1 - 100 Mbps */
-                               speed = 100;
-                       }
-                       immr->im_ioport.iop_pcdat |= (PC_REP_RES | PC_BIT14);
-
-                       /* must be run from RAM  */
-                       /* start_lxt980 (speed); */
-               /*************************/
-               } else {
-                       /*
-                        * Revision 1.x hardware
-                        */
-                       revision = 1;
-
-                       immr->im_ioport.iop_pcdat = PC_REP_MGRPRS | PC_BIT14;   /* = 0x0202 */
-                       immr->im_ioport.iop_pcdir = (PC_REP_MGRPRS | PC_REP_SPD | PC_REP_RES | PC_BIT14 | PC_BIT15);    /* = 0x0247 */
-
-                       if (ethspeed == 0) {
-                               /* both 10 and 100 Mbps allowed:
-                                * select 100 Mbps and autonegotiation
-                                */
-                               puts ("  [10+100]");
-                               immr->im_cpm.cp_pbdat = 0;      /* SPD1:SPD0 = 0:0 - autonegot. */
-                               immr->im_ioport.iop_pcdat |= PC_REP_SPD;
-                       } else if (ethspeed == 10) {
-                               /* we are asked for 10 Mbps,
-                                  * so select 10 Mbps
-                                */
-                               puts ("  [10]");
-                               immr->im_cpm.cp_pbdat = PC_REP_SPD0;    /* SPD1:SPD0 = 0:1 - 10 Mbps */
-                       } else {
-                               /* anything else:
-                                  * select 100 Mbps
-                                */
-                               puts ("  [100]");
-                               immr->im_cpm.cp_pbdat = PC_REP_SPD0 | PC_REP_SPD1;
-                               /* SPD1:SPD0 = 1:1 - 100 Mbps */
-                               immr->im_ioport.iop_pcdat |= PC_REP_SPD;
-                       }
-
-                       immr->im_ioport.iop_pcdat |= PC_REP_RES;
-               }
-       }
-       SHOW_BOOT_PROGRESS(BOOTSTAGE_ID_CHECK_MAGIC);
-
-       return ((revision << 16) | (speed & 0xFFFF));
-}
-
-/* ------------------------------------------------------------------------- */
-
-#define SCC_SM         1                       /* Index => SCC2 */
-#define        PROFF           PROFF_SCC2
-
-#define SMI_MSGLEN     8                       /* Length of SMI Messages        */
-
-#define PHYGPCR_ADDR   0x109   /* Port Enable               */
-#define PHYPCR_ADDR    0x132           /* PHY Port Control Reg. (port 1)    */
-#define LEDPCR_ADDR    0x141           /* LED Port Control Reg.         */
-#define RPRESET_ADDR   0x144   /* Repeater Reset            */
-
-#define PHYPCR_SPEED   0x2000  /* on for 100 Mbps, off for 10 Mbps  */
-#define PHYPCR_AN      0x1000          /* on to enable  Auto-Negotiation    */
-#define PHYPCR_REST_AN 0x0200  /* on to restart Auto-Negotiation    */
-#define PHYPCR_FDX     0x0100          /* on for Full Duplex, off for HDX   */
-#define PHYPCR_COLT    0x0080          /* on to enable COL signal test      */
-
-/* ------------------------------------------------------------------------- */
-
-/*
- * Must run from RAM:
- * uses parameter RAM area which is used for stack while running from ROM
- */
-void hermes_start_lxt980 (int speed)
-{
-       volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
-       volatile cpm8xx_t *cp = (cpm8xx_t *) & (immr->im_cpm);
-       volatile scc_t *sp = (scc_t *) & (cp->cp_scc[SCC_SM]);
-       volatile cbd_t *bd;
-       volatile hdlc_pram_t *hp;
-       uchar smimsg[SMI_MSGLEN];
-       ushort phypcrval;
-       uint bd_off;
-       int pnr;
-
-       printf ("LXT9880: %3d Mbps\n", speed);
-
-       immr->im_ioport.iop_paodr |= 0x0008;    /* init PAODR: PA12 (TXD2) open drain */
-       immr->im_ioport.iop_papar |= 0x400c;    /* init PAPAR: TXD2, RXD2, BRGO4 */
-       immr->im_ioport.iop_padir &= 0xbff3;    /* init PADIR: BRGO4 */
-       immr->im_ioport.iop_padir |= 0x4000;
-
-       /* get temporary BD; no need for permanent alloc */
-       bd_off = dpram_base_align (8);
-
-       bd = (cbd_t *) (immr->im_cpm.cp_dpmem + bd_off);
-
-       bd->cbd_bufaddr = 0;
-       bd->cbd_datlen = 0;
-       bd->cbd_sc = BD_SC_WRAP | BD_SC_LAST | BD_SC_INTRPT | BD_SC_TC;
-
-       /* init. baudrate generator BRG4 */
-       cp->cp_brgc4 = (0x00010000 | (50 << 1));        /* output 1 MHz */
-
-       cp->cp_sicr &= 0xFFFF00FF;      /* SICR: mask SCC2 */
-       cp->cp_sicr |= 0x00001B00;      /* SICR: SCC2 clk BRG4 */
-
-       /* init SCC_SM register */
-       sp->scc_psmr = 0x0000;          /* init PSMR: no additional flags */
-       sp->scc_todr = 0x0000;
-       sp->scc_dsr = 0x7e7e;
-
-       /* init. SCC_SM parameter area */
-       hp = (hdlc_pram_t *) & cp->cp_dparam[PROFF];
-
-       hp->tbase = bd_off;                     /* offset from beginning of DPRAM */
-
-       hp->rfcr = 0x18;
-       hp->tfcr = 0x18;
-       hp->mrblr = 10;
-
-       hp->c_mask = 0x0000f0b8;
-       hp->c_pres = 0x0000ffff;
-
-       hp->disfc = 0;
-       hp->crcec = 0;
-       hp->abtsc = 0;
-       hp->nmarc = 0;
-       hp->retrc = 0;
-
-       hp->mflr = 10;
-
-       hp->rfthr = 1;
-
-       hp->hmask = 0;
-       hp->haddr1 = 0;
-       hp->haddr2 = 0;
-       hp->haddr3 = 0;
-       hp->haddr4 = 0;
-
-       cp->cp_cpcr = SCC_SM << 6 | 0x0001;     /* SCC_SM: init TX/RX params */
-       while (cp->cp_cpcr & CPM_CR_FLG);
-
-       /* clear all outstanding SCC events */
-       sp->scc_scce = ~0;
-
-       /* enable transmitter: GSMR_L: TPL=2(16bits), TPP=3(all ones), ENT */
-       sp->scc_gsmrh = 0;
-       sp->scc_gsmrl |= SCC_GSMRL_TPL_16 | SCC_GSMRL_TPP_ALL1 |
-                       SCC_GSMRL_ENT | SCC_GSMRL_MODE_HDLC;
-
-#if 0
-       smimsg[0] = 0x00;                       /* CHIP/HUB ID */
-       smimsg[1] = 0x38;                       /* WRITE CMD */
-       smimsg[2] = (RPRESET_ADDR << 4) & 0xf0;
-       smimsg[3] = RPRESET_ADDR >> 4;
-       smimsg[4] = 0x01;
-       smimsg[5] = 0x00;
-       smimsg[6] = 0x00;
-       smimsg[7] = 0x00;
-
-       send_smi_frame (sp, bd, smimsg);
-#endif
-
-       smimsg[0] = 0x7f;                       /* BROADCAST */
-       smimsg[1] = 0x34;                       /* ASSIGN HUB ID */
-       smimsg[2] = 0x00;
-       smimsg[3] = 0x00;
-       smimsg[4] = 0x00;                       /* HUB ID = 0 */
-       smimsg[5] = 0x00;
-       smimsg[6] = 0x00;
-       smimsg[7] = 0x00;
-
-       send_smi_frame (sp, bd, smimsg);
-
-       smimsg[0] = 0x7f;                       /* BROADCAST */
-       smimsg[1] = 0x3c;                       /* SET ARBOUT TO 0 */
-       smimsg[2] = 0x00;                       /* ADDRESS = 0 */
-       smimsg[3] = 0x00;
-       smimsg[4] = 0x00;                       /* DATA = 0 */
-       smimsg[5] = 0x00;
-       smimsg[6] = 0x00;
-       smimsg[7] = 0x00;
-
-       send_smi_frame (sp, bd, smimsg);
-
-       if (speed == 100) {
-               phypcrval = PHYPCR_SPEED;       /* 100 MBIT, disable autoneg. */
-       } else {
-               phypcrval = 0;                  /* 10 MBIT, disable autoneg. */
-       }
-
-       /* send MSGs */
-       for (pnr = 0; pnr < 8; pnr++) {
-               smimsg[0] = 0x00;               /* CHIP/HUB ID */
-               smimsg[1] = 0x38;               /* WRITE CMD */
-               smimsg[2] = ((PHYPCR_ADDR + pnr) << 4) & 0xf0;
-               smimsg[3] = (PHYPCR_ADDR + pnr) >> 4;
-               smimsg[4] = (unsigned char) (phypcrval & 0xff);
-               smimsg[5] = (unsigned char) (phypcrval >> 8);
-               smimsg[6] = 0x00;
-               smimsg[7] = 0x00;
-
-               send_smi_frame (sp, bd, smimsg);
-       }
-
-       smimsg[0] = 0x00;                       /* CHIP/HUB ID */
-       smimsg[1] = 0x38;                       /* WRITE CMD */
-       smimsg[2] = (PHYGPCR_ADDR << 4) & 0xf0;
-       smimsg[3] = PHYGPCR_ADDR >> 4;
-       smimsg[4] = 0xff;                       /* enable port 1-8 */
-       smimsg[5] = 0x01;                       /* enable MII1 (0x01) */
-       smimsg[6] = 0x00;
-       smimsg[7] = 0x00;
-
-       send_smi_frame (sp, bd, smimsg);
-
-       smimsg[0] = 0x00;                       /* CHIP/HUB ID */
-       smimsg[1] = 0x38;                       /* WRITE CMD */
-       smimsg[2] = (LEDPCR_ADDR << 4) & 0xf0;
-       smimsg[3] = LEDPCR_ADDR >> 4;
-       smimsg[4] = 0xaa;                       /* Port 1-8 Conf.bits = 10 (Hardware control) */
-       smimsg[5] = 0xaa;
-       smimsg[6] = 0x00;
-       smimsg[7] = 0x00;
-
-       send_smi_frame (sp, bd, smimsg);
-
-       /*
-        * Disable Transmitter (so that we can free the BD, too)
-        */
-       sp->scc_gsmrl &= ~SCC_GSMRL_ENT;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static void send_smi_frame (volatile scc_t * sp, volatile cbd_t * bd,
-                                                       uchar * msg)
-{
-#ifdef DEBUG
-       unsigned hub, chip, cmd, length, addr;
-
-       hub = msg[0] & 0x1F;
-       chip = msg[0] >> 5;
-       cmd = msg[1] & 0x1F;
-       length = (msg[1] >> 5) | ((msg[2] & 0x0F) << 3);
-       addr = (msg[2] >> 4) | (msg[3] << 4);
-
-       printf ("SMI send: Hub %02x Chip %x Cmd %02x Len %d Addr %03x: "
-                       "%02x %02x %02x %02x\n",
-                       hub, chip, cmd, length, addr, msg[4], msg[5], msg[6], msg[7]);
-#endif /* DEBUG */
-
-       bd->cbd_bufaddr = (uint) msg;
-       bd->cbd_datlen = SMI_MSGLEN;
-       bd->cbd_sc |= BD_SC_READY;
-
-       /* wait for msg transmitted */
-       while ((sp->scc_scce & 0x0002) == 0);
-       /* clear all events */
-       sp->scc_scce = ~0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-void show_boot_progress (int status)
-{
-       volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
-
-       /* let things compatible */
-       if (status < -BOOTSTAGE_ID_POST_FAIL_R)
-               status = -1;
-       status ^= 0x0F;
-       status = (status & 0x0F) << 14;
-       immr->im_cpm.cp_pbdat = (immr->im_cpm.cp_pbdat & ~PB_LED_ALL) | status;
-}
-
-/* ------------------------------------------------------------------------- */
diff --git a/board/hermes/u-boot.lds b/board/hermes/u-boot.lds
deleted file mode 100644 (file)
index 0309860..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * (C) Copyright 2000-2010
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-OUTPUT_ARCH(powerpc)
-
-SECTIONS
-{
-  /* Read-only sections, merged into text segment: */
-  . = + SIZEOF_HEADERS;
-  .text      :
-  {
-    /* WARNING - the following is hand-optimized to fit within */
-    /* the sector layout of our flash chips!   XXX FIXME XXX   */
-    arch/powerpc/cpu/mpc8xx/start.o    (.text*)
-    arch/powerpc/cpu/mpc8xx/traps.o    (.text*)
-    board/hermes/built-in.o            (.text*)
-
-    . = env_offset;
-    common/env_embedded.o              (.text*)
-
-    *(.text*)
-  }
-  _etext = .;
-  PROVIDE (etext = .);
-  .rodata    :
-  {
-    *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
-  }
-
-  /* Read-write section, merged into data segment: */
-  . = (. + 0x00FF) & 0xFFFFFF00;
-  _erotext = .;
-  PROVIDE (erotext = .);
-  .reloc   :
-  {
-    _GOT2_TABLE_ = .;
-    KEEP(*(.got2))
-    KEEP(*(.got))
-    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
-    _FIXUP_TABLE_ = .;
-    KEEP(*(.fixup))
-  }
-  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
-  __fixup_entries = (. - _FIXUP_TABLE_)>>2;
-
-  .data    :
-  {
-    *(.data*)
-    *(.sdata*)
-  }
-  _edata  =  .;
-  PROVIDE (edata = .);
-
-  . = .;
-
-  . = ALIGN(4);
-  .u_boot_list : {
-       KEEP(*(SORT(.u_boot_list*)));
-  }
-
-
-  . = .;
-  __start___ex_table = .;
-  __ex_table : { *(__ex_table) }
-  __stop___ex_table = .;
-
-  . = ALIGN(256);
-  __init_begin = .;
-  .text.init : { *(.text.init) }
-  .data.init : { *(.data.init) }
-  . = ALIGN(256);
-  __init_end = .;
-
-  __bss_start = .;
-  .bss (NOLOAD)       :
-  {
-   *(.bss*)
-   *(.sbss*)
-   *(COMMON)
-   . = ALIGN(4);
-  }
-  __bss_end = . ;
-  PROVIDE (end = .);
-}
diff --git a/board/hermes/u-boot.lds.debug b/board/hermes/u-boot.lds.debug
deleted file mode 100644 (file)
index f34c07b..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-OUTPUT_ARCH(powerpc)
-/* Do we need any of these for elf?
-   __DYNAMIC = 0;    */
-SECTIONS
-{
-  /* Read-only sections, merged into text segment: */
-  . = + SIZEOF_HEADERS;
-  .interp : { *(.interp) }
-  .hash          : { *(.hash)          }
-  .dynsym        : { *(.dynsym)                }
-  .dynstr        : { *(.dynstr)                }
-  .rel.text      : { *(.rel.text)              }
-  .rela.text     : { *(.rela.text)     }
-  .rel.data      : { *(.rel.data)              }
-  .rela.data     : { *(.rela.data)     }
-  .rel.rodata    : { *(.rel.rodata)    }
-  .rela.rodata   : { *(.rela.rodata)   }
-  .rel.got       : { *(.rel.got)               }
-  .rela.got      : { *(.rela.got)              }
-  .rel.ctors     : { *(.rel.ctors)     }
-  .rela.ctors    : { *(.rela.ctors)    }
-  .rel.dtors     : { *(.rel.dtors)     }
-  .rela.dtors    : { *(.rela.dtors)    }
-  .rel.bss       : { *(.rel.bss)               }
-  .rela.bss      : { *(.rela.bss)              }
-  .rel.plt       : { *(.rel.plt)               }
-  .rela.plt      : { *(.rela.plt)              }
-  .init          : { *(.init)  }
-  .plt : { *(.plt) }
-  .text      :
-  {
-    /* WARNING - the following is hand-optimized to fit within */
-    /* the sector layout of our flash chips!   XXX FIXME XXX   */
-
-    arch/powerpc/cpu/mpc8xx/start.o    (.text)
-    arch/powerpc/lib/ppcstring.o       (.text)
-    arch/powerpc/cpu/mpc8xx/interrupts.o (.text)
-    arch/powerpc/lib/time.o            (.text)
-    arch/powerpc/lib/ticks.o           (.text)
-    . = env_offset;
-    common/env_embedded.o(.text)
-
-    *(.text)
-    *(.got1)
-  }
-  _etext = .;
-  PROVIDE (etext = .);
-  .rodata    :
-  {
-    *(.rodata)
-    *(.rodata1)
-    *(.rodata.str1.4)
-    *(.eh_frame)
-  }
-  .fini      : { *(.fini)    } =0
-  .ctors     : { *(.ctors)   }
-  .dtors     : { *(.dtors)   }
-
-  /* Read-write section, merged into data segment: */
-  . = (. + 0x0FFF) & 0xFFFFF000;
-  _erotext = .;
-  PROVIDE (erotext = .);
-  .reloc   :
-  {
-    *(.got)
-    _GOT2_TABLE_ = .;
-    *(.got2)
-    _FIXUP_TABLE_ = .;
-    *(.fixup)
-  }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
-  __fixup_entries = (. - _FIXUP_TABLE_)>>2;
-
-  .data    :
-  {
-    *(.data)
-    *(.data1)
-    *(.sdata)
-    *(.sdata2)
-    *(.dynamic)
-    CONSTRUCTORS
-  }
-  _edata  =  .;
-  PROVIDE (edata = .);
-
-
-  . = ALIGN(4);
-  .u_boot_list : {
-       KEEP(*(SORT(.u_boot_list*)));
-  }
-
-
-  __start___ex_table = .;
-  __ex_table : { *(__ex_table) }
-  __stop___ex_table = .;
-
-  . = ALIGN(4096);
-  __init_begin = .;
-  .text.init : { *(.text.init) }
-  .data.init : { *(.data.init) }
-  . = ALIGN(4096);
-  __init_end = .;
-
-  __bss_start = .;
-  .bss       :
-  {
-   *(.sbss) *(.scommon)
-   *(.dynbss)
-   *(.bss)
-   *(COMMON)
-  }
-  __bss_end = . ;
-  PROVIDE (end = .);
-}
diff --git a/board/raspberrypi/rpi/Kconfig b/board/raspberrypi/rpi/Kconfig
new file mode 100644 (file)
index 0000000..6a538cf
--- /dev/null
@@ -0,0 +1,15 @@
+if TARGET_RPI
+
+config SYS_BOARD
+       default "rpi"
+
+config SYS_VENDOR
+       default "raspberrypi"
+
+config SYS_SOC
+       default "bcm2835"
+
+config SYS_CONFIG_NAME
+       default "rpi"
+
+endif
diff --git a/board/raspberrypi/rpi/MAINTAINERS b/board/raspberrypi/rpi/MAINTAINERS
new file mode 100644 (file)
index 0000000..6dcb7bd
--- /dev/null
@@ -0,0 +1,6 @@
+RPI BOARD
+M:     Stephen Warren <swarren@wwwdotorg.org>
+S:     Maintained
+F:     board/raspberrypi/rpi/
+F:     include/configs/rpi.h
+F:     configs/rpi_defconfig
diff --git a/board/raspberrypi/rpi/Makefile b/board/raspberrypi/rpi/Makefile
new file mode 100644 (file)
index 0000000..c53c92b
--- /dev/null
@@ -0,0 +1,15 @@
+#
+# 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
+# version 2 as published by the Free Software Foundation.
+#
+# 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.
+#
+
+obj-y  := rpi.o
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
new file mode 100644 (file)
index 0000000..51a4fa1
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ * (C) Copyright 2012-2013 Stephen Warren
+ *
+ * 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
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <config.h>
+#include <dm.h>
+#include <fdt_support.h>
+#include <lcd.h>
+#include <mmc.h>
+#include <asm/gpio.h>
+#include <asm/arch/mbox.h>
+#include <asm/arch/sdhci.h>
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct bcm2835_gpio_platdata gpio_platdata = {
+       .base = BCM2835_GPIO_BASE,
+};
+
+U_BOOT_DEVICE(bcm2835_gpios) = {
+       .name = "gpio_bcm2835",
+       .platdata = &gpio_platdata,
+};
+
+struct msg_get_arm_mem {
+       struct bcm2835_mbox_hdr hdr;
+       struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
+       u32 end_tag;
+};
+
+struct msg_get_board_rev {
+       struct bcm2835_mbox_hdr hdr;
+       struct bcm2835_mbox_tag_get_board_rev get_board_rev;
+       u32 end_tag;
+};
+
+struct msg_get_mac_address {
+       struct bcm2835_mbox_hdr hdr;
+       struct bcm2835_mbox_tag_get_mac_address get_mac_address;
+       u32 end_tag;
+};
+
+struct msg_set_power_state {
+       struct bcm2835_mbox_hdr hdr;
+       struct bcm2835_mbox_tag_set_power_state set_power_state;
+       u32 end_tag;
+};
+
+struct msg_get_clock_rate {
+       struct bcm2835_mbox_hdr hdr;
+       struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
+       u32 end_tag;
+};
+
+/* See comments in mbox.h for data source */
+static const struct {
+       const char *name;
+       const char *fdtfile;
+} models[] = {
+       [BCM2835_BOARD_REV_B_I2C0_2] = {
+               "Model B (no P5)",
+               "bcm2835-rpi-b-i2c0.dtb",
+       },
+       [BCM2835_BOARD_REV_B_I2C0_3] = {
+               "Model B (no P5)",
+               "bcm2835-rpi-b-i2c0.dtb",
+       },
+       [BCM2835_BOARD_REV_B_I2C1_4] = {
+               "Model B",
+               "bcm2835-rpi-b.dtb",
+       },
+       [BCM2835_BOARD_REV_B_I2C1_5] = {
+               "Model B",
+               "bcm2835-rpi-b.dtb",
+       },
+       [BCM2835_BOARD_REV_B_I2C1_6] = {
+               "Model B",
+               "bcm2835-rpi-b.dtb",
+       },
+       [BCM2835_BOARD_REV_A_7] = {
+               "Model A",
+               "bcm2835-rpi-a.dtb",
+       },
+       [BCM2835_BOARD_REV_A_8] = {
+               "Model A",
+               "bcm2835-rpi-a.dtb",
+       },
+       [BCM2835_BOARD_REV_A_9] = {
+               "Model A",
+               "bcm2835-rpi-a.dtb",
+       },
+       [BCM2835_BOARD_REV_B_REV2_d] = {
+               "Model B rev2",
+               "bcm2835-rpi-b-rev2.dtb",
+       },
+       [BCM2835_BOARD_REV_B_REV2_e] = {
+               "Model B rev2",
+               "bcm2835-rpi-b-rev2.dtb",
+       },
+       [BCM2835_BOARD_REV_B_REV2_f] = {
+               "Model B rev2",
+               "bcm2835-rpi-b-rev2.dtb",
+       },
+       [BCM2835_BOARD_REV_B_PLUS] = {
+               "Model B+",
+               "bcm2835-rpi-b-plus.dtb",
+       },
+       [BCM2835_BOARD_REV_CM] = {
+               "Compute Module",
+               "bcm2835-rpi-cm.dtb",
+       },
+};
+
+u32 rpi_board_rev = 0;
+
+int dram_init(void)
+{
+       ALLOC_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1, 16);
+       int ret;
+
+       BCM2835_MBOX_INIT_HDR(msg);
+       BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
+
+       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+       if (ret) {
+               printf("bcm2835: Could not query ARM memory size\n");
+               return -1;
+       }
+
+       gd->ram_size = msg->get_arm_mem.body.resp.mem_size;
+
+       return 0;
+}
+
+static void set_fdtfile(void)
+{
+       const char *fdtfile;
+
+       if (getenv("fdtfile"))
+               return;
+
+       fdtfile = models[rpi_board_rev].fdtfile;
+       if (!fdtfile)
+               fdtfile = "bcm2835-rpi-other.dtb";
+
+       setenv("fdtfile", fdtfile);
+}
+
+static void set_usbethaddr(void)
+{
+       ALLOC_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1, 16);
+       int ret;
+
+       if (getenv("usbethaddr"))
+               return;
+
+       BCM2835_MBOX_INIT_HDR(msg);
+       BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS);
+
+       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+       if (ret) {
+               printf("bcm2835: Could not query MAC address\n");
+               /* Ignore error; not critical */
+               return;
+       }
+
+       eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
+
+       return;
+}
+
+int misc_init_r(void)
+{
+       set_fdtfile();
+       set_usbethaddr();
+       return 0;
+}
+
+static int power_on_module(u32 module)
+{
+       ALLOC_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1, 16);
+       int ret;
+
+       BCM2835_MBOX_INIT_HDR(msg_pwr);
+       BCM2835_MBOX_INIT_TAG(&msg_pwr->set_power_state,
+                             SET_POWER_STATE);
+       msg_pwr->set_power_state.body.req.device_id = module;
+       msg_pwr->set_power_state.body.req.state =
+               BCM2835_MBOX_SET_POWER_STATE_REQ_ON |
+               BCM2835_MBOX_SET_POWER_STATE_REQ_WAIT;
+
+       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN,
+                                    &msg_pwr->hdr);
+       if (ret) {
+               printf("bcm2835: Could not set module %u power state\n",
+                      module);
+               return -1;
+       }
+
+       return 0;
+}
+
+static void get_board_rev(void)
+{
+       ALLOC_ALIGN_BUFFER(struct msg_get_board_rev, msg, 1, 16);
+       int ret;
+       const char *name;
+
+       BCM2835_MBOX_INIT_HDR(msg);
+       BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV);
+
+       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+       if (ret) {
+               printf("bcm2835: Could not query board revision\n");
+               /* Ignore error; not critical */
+               return;
+       }
+
+       rpi_board_rev = msg->get_board_rev.body.resp.rev;
+       if (rpi_board_rev >= ARRAY_SIZE(models))
+               rpi_board_rev = 0;
+
+       name = models[rpi_board_rev].name;
+       if (!name)
+               name = "Unknown model";
+       printf("RPI model: %s\n", name);
+}
+
+int board_init(void)
+{
+       get_board_rev();
+
+       gd->bd->bi_boot_params = 0x100;
+
+       return power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
+}
+
+int board_mmc_init(bd_t *bis)
+{
+       ALLOC_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1, 16);
+       int ret;
+
+       power_on_module(BCM2835_MBOX_POWER_DEVID_SDHCI);
+
+       BCM2835_MBOX_INIT_HDR(msg_clk);
+       BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_CLOCK_RATE);
+       msg_clk->get_clock_rate.body.req.clock_id = BCM2835_MBOX_CLOCK_ID_EMMC;
+
+       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr);
+       if (ret) {
+               printf("bcm2835: Could not query eMMC clock rate\n");
+               return -1;
+       }
+
+       return bcm2835_sdhci_init(BCM2835_SDHCI_BASE,
+                                 msg_clk->get_clock_rate.body.resp.rate_hz);
+}
+
+int ft_board_setup(void *blob, bd_t *bd)
+{
+       /*
+        * For now, we simply always add the simplefb DT node. Later, we
+        * should be more intelligent, and e.g. only do this if no enabled DT
+        * node exists for the "real" graphics driver.
+        */
+       lcd_dt_simplefb_add_node(blob);
+
+       return 0;
+}
diff --git a/board/raspberrypi/rpi_b/Kconfig b/board/raspberrypi/rpi_b/Kconfig
deleted file mode 100644 (file)
index 501d511..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-if TARGET_RPI_B
-
-config SYS_BOARD
-       default "rpi_b"
-
-config SYS_VENDOR
-       default "raspberrypi"
-
-config SYS_SOC
-       default "bcm2835"
-
-config SYS_CONFIG_NAME
-       default "rpi_b"
-
-endif
diff --git a/board/raspberrypi/rpi_b/MAINTAINERS b/board/raspberrypi/rpi_b/MAINTAINERS
deleted file mode 100644 (file)
index 14f3948..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-RPI_B BOARD
-M:     Stephen Warren <swarren@wwwdotorg.org>
-S:     Maintained
-F:     board/raspberrypi/rpi_b/
-F:     include/configs/rpi_b.h
-F:     configs/rpi_b_defconfig
diff --git a/board/raspberrypi/rpi_b/Makefile b/board/raspberrypi/rpi_b/Makefile
deleted file mode 100644 (file)
index 7e9bfbf..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# 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
-# version 2 as published by the Free Software Foundation.
-#
-# 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.
-#
-
-obj-y  := rpi_b.o
diff --git a/board/raspberrypi/rpi_b/rpi_b.c b/board/raspberrypi/rpi_b/rpi_b.c
deleted file mode 100644 (file)
index db904a4..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * (C) Copyright 2012-2013 Stephen Warren
- *
- * 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
- * version 2 as published by the Free Software Foundation.
- *
- * 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.
- */
-
-#include <common.h>
-#include <config.h>
-#include <dm.h>
-#include <fdt_support.h>
-#include <lcd.h>
-#include <mmc.h>
-#include <asm/gpio.h>
-#include <asm/arch/mbox.h>
-#include <asm/arch/sdhci.h>
-#include <asm/global_data.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static const struct bcm2835_gpio_platdata gpio_platdata = {
-       .base = BCM2835_GPIO_BASE,
-};
-
-U_BOOT_DEVICE(bcm2835_gpios) = {
-       .name = "gpio_bcm2835",
-       .platdata = &gpio_platdata,
-};
-
-struct msg_get_arm_mem {
-       struct bcm2835_mbox_hdr hdr;
-       struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
-       u32 end_tag;
-};
-
-struct msg_get_mac_address {
-       struct bcm2835_mbox_hdr hdr;
-       struct bcm2835_mbox_tag_get_mac_address get_mac_address;
-       u32 end_tag;
-};
-
-struct msg_set_power_state {
-       struct bcm2835_mbox_hdr hdr;
-       struct bcm2835_mbox_tag_set_power_state set_power_state;
-       u32 end_tag;
-};
-
-struct msg_get_clock_rate {
-       struct bcm2835_mbox_hdr hdr;
-       struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
-       u32 end_tag;
-};
-
-int dram_init(void)
-{
-       ALLOC_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1, 16);
-       int ret;
-
-       BCM2835_MBOX_INIT_HDR(msg);
-       BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
-
-       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
-       if (ret) {
-               printf("bcm2835: Could not query ARM memory size\n");
-               return -1;
-       }
-
-       gd->ram_size = msg->get_arm_mem.body.resp.mem_size;
-
-       return 0;
-}
-
-int misc_init_r(void)
-{
-       ALLOC_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1, 16);
-       int ret;
-
-       if (getenv("usbethaddr"))
-               return 0;
-
-       BCM2835_MBOX_INIT_HDR(msg);
-       BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS);
-
-       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
-       if (ret) {
-               printf("bcm2835: Could not query MAC address\n");
-               /* Ignore error; not critical */
-               return 0;
-       }
-
-       eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
-
-       return 0;
-}
-
-static int power_on_module(u32 module)
-{
-       ALLOC_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1, 16);
-       int ret;
-
-       BCM2835_MBOX_INIT_HDR(msg_pwr);
-       BCM2835_MBOX_INIT_TAG(&msg_pwr->set_power_state,
-                             SET_POWER_STATE);
-       msg_pwr->set_power_state.body.req.device_id = module;
-       msg_pwr->set_power_state.body.req.state =
-               BCM2835_MBOX_SET_POWER_STATE_REQ_ON |
-               BCM2835_MBOX_SET_POWER_STATE_REQ_WAIT;
-
-       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN,
-                                    &msg_pwr->hdr);
-       if (ret) {
-               printf("bcm2835: Could not set module %u power state\n",
-                      module);
-               return -1;
-       }
-
-       return 0;
-}
-
-int board_init(void)
-{
-       gd->bd->bi_boot_params = 0x100;
-
-       return power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
-}
-
-int board_mmc_init(bd_t *bis)
-{
-       ALLOC_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1, 16);
-       int ret;
-
-       power_on_module(BCM2835_MBOX_POWER_DEVID_SDHCI);
-
-       BCM2835_MBOX_INIT_HDR(msg_clk);
-       BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_CLOCK_RATE);
-       msg_clk->get_clock_rate.body.req.clock_id = BCM2835_MBOX_CLOCK_ID_EMMC;
-
-       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr);
-       if (ret) {
-               printf("bcm2835: Could not query eMMC clock rate\n");
-               return -1;
-       }
-
-       return bcm2835_sdhci_init(BCM2835_SDHCI_BASE,
-                                 msg_clk->get_clock_rate.body.resp.rate_hz);
-}
-
-int ft_board_setup(void *blob, bd_t *bd)
-{
-       /*
-        * For now, we simply always add the simplefb DT node. Later, we
-        * should be more intelligent, and e.g. only do this if no enabled DT
-        * node exists for the "real" graphics driver.
-        */
-       lcd_dt_simplefb_add_node(blob);
-
-       return 0;
-}
index 1b8998d093a55812ce3824d0051f7c49f8ef85ed..4eb7a023d4eaf5e2c1bdfee9c48bf65b49fb7c9e 100644 (file)
@@ -291,26 +291,14 @@ static int initr_flash(void)
 {
        ulong flash_size = 0;
        bd_t *bd = gd->bd;
-       int ok;
 
        puts("Flash: ");
 
-       if (board_flash_wp_on()) {
+       if (board_flash_wp_on())
                printf("Uninitialized - Write Protect On\n");
-               /* Since WP is on, we can't find real size.  Set to 0 */
-               ok = 1;
-       } else {
+       else
                flash_size = flash_init();
-               ok = flash_size > 0;
-       }
-       if (!ok) {
-               puts("*** failed ***\n");
-#ifdef CONFIG_PPC
-               /* Why does PPC do this? */
-               hang();
-#endif
-               return -1;
-       }
+
        print_size(flash_size, "");
 #ifdef CONFIG_SYS_FLASH_CHECKSUM
        /*
@@ -454,24 +442,6 @@ static int initr_env(void)
        return 0;
 }
 
-#ifdef CONFIG_HERMES
-static int initr_hermes(void)
-{
-       if ((gd->board_type >> 16) == 2)
-               gd->bd->bi_ethspeed = gd->board_type & 0xFFFF;
-       else
-               gd->bd->bi_ethspeed = 0xFFFF;
-       return 0;
-}
-
-static int initr_hermes_start(void)
-{
-       if (gd->bd->bi_ethspeed != 0xFFFF)
-               hermes_start_lxt980((int) gd->bd->bi_ethspeed);
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_SC3
 /* TODO: with new initcalls, move this into the driver */
 extern void sc3_read_eeprom(void);
@@ -803,9 +773,6 @@ init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_SC3
        initr_sc3_read_eeprom,
 #endif
-#ifdef CONFIG_HERMES
-       initr_hermes,
-#endif
 #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
        mac_read_from_eeprom,
 #endif
@@ -830,9 +797,6 @@ init_fnc_t init_sequence_r[] = {
 #endif
 #ifdef CONFIG_MISC_INIT_R
        misc_init_r,            /* miscellaneous platform-dependent init */
-#endif
-#ifdef CONFIG_HERMES
-       initr_hermes_start,
 #endif
        INIT_FUNC_WATCHDOG_RESET
 #ifdef CONFIG_CMD_KGDB
index 3d37a86a7d550fcb153947cb615588ba5113ac5f..f0b713c1cfd4341bda4e6846337539aab4e920e1 100644 (file)
@@ -144,9 +144,6 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        print_eth(5);
 #endif
 
-#ifdef CONFIG_HERMES
-       print_mhz("ethspeed",           bd->bi_ethspeed);
-#endif
        printf("IP addr     = %s\n", getenv("ipaddr"));
        printf("baudrate    = %6u bps\n", gd->baudrate);
        print_num("relocaddr", gd->relocaddr);
index abab9789b0df4f80c9b723ef0ad03ad04c132732..d4bc0f6c94a17a5e0084dc9ddd7fd5218a7badfc 100644 (file)
@@ -128,7 +128,7 @@ static int do_fuse(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 
 err:
        puts("ERROR\n");
-       return ret;
+       return CMD_RET_FAILURE;
 }
 
 U_BOOT_CMD(
index 0d50dcfe9c1b8083a35f3cc6df5796a12a0149a2..bcb3ee325ac9ceaf217bbbe7f86118b55aa1b116 100644 (file)
@@ -19,6 +19,7 @@
 #include <dataflash.h>
 #endif
 #include <hash.h>
+#include <inttypes.h>
 #include <watchdog.h>
 #include <asm/io.h>
 #include <linux/compiler.h>
@@ -338,7 +339,8 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                if (word1 != word2) {
                        ulong offset = buf1 - base;
 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
-                       printf("%s at 0x%p (%#0*llx) != %s at 0x%p (%#0*llx)\n",
+                       printf("%s at 0x%p (%#0*"PRIx64") != %s at 0x%p (%#0*"
+                              PRIx64 ")\n",
                               type, (void *)(addr1 + offset), size, word1,
                               type, (void *)(addr2 + offset), size, word2);
 #else
@@ -1146,7 +1148,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
                        printf(" %08x", *((u32 *)ptr));
 #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
                else if (size == 8)
-                       printf(" %016llx", *((u64 *)ptr));
+                       printf(" %016" PRIx64, *((u64 *)ptr));
 #endif
                else if (size == 2)
                        printf(" %04x", *((u16 *)ptr));
index 4695386a332ab867c12df32e938d4976ce7f0115..29560c3ebecbf595f813a5dde9fb102afe4dfa55 100644 (file)
@@ -125,12 +125,12 @@ static int console_setfile(int file, struct stdio_dev * dev)
                 */
                switch (file) {
                case stdin:
-                       gd->jt[XF_getc] = dev->getc;
-                       gd->jt[XF_tstc] = dev->tstc;
+                       gd->jt[XF_getc] = getc;
+                       gd->jt[XF_tstc] = tstc;
                        break;
                case stdout:
-                       gd->jt[XF_putc] = dev->putc;
-                       gd->jt[XF_puts] = dev->puts;
+                       gd->jt[XF_putc] = putc;
+                       gd->jt[XF_puts] = puts;
                        gd->jt[XF_printf] = printf;
                        break;
                }
index 6254e342fd26aa3ad78f3d2160f37c6191ff4503..8266bca7d6489a2ca8fb6f1015064184b137d2dd 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <inttypes.h>
 #include <stdio_dev.h>
 #include <linux/ctype.h>
 #include <linux/types.h>
@@ -914,8 +915,6 @@ void fdt_del_node_and_alias(void *blob, const char *alias)
        fdt_delprop(blob, off, alias);
 }
 
-#define PRu64  "%llx"
-
 /* Max address size we deal with */
 #define OF_MAX_ADDR_CELLS      4
 #define OF_BAD_ADDR    ((u64)-1)
@@ -973,8 +972,8 @@ static u64 of_bus_default_map(fdt32_t *addr, const fdt32_t *range,
        s  = of_read_number(range + na + pna, ns);
        da = of_read_number(addr, na);
 
-       debug("OF: default map, cp="PRu64", s="PRu64", da="PRu64"\n",
-           cp, s, da);
+       debug("OF: default map, cp=%" PRIu64 ", s=%" PRIu64
+             ", da=%" PRIu64 "\n", cp, s, da);
 
        if (da < cp || da >= (cp + s))
                return OF_BAD_ADDR;
@@ -1052,7 +1051,7 @@ static int of_translate_one(void * blob, int parent, struct of_bus *bus,
 
  finish:
        of_dump_addr("OF: parent translation for:", addr, pna);
-       debug("OF: with offset: "PRu64"\n", offset);
+       debug("OF: with offset: %" PRIu64 "\n", offset);
 
        /* Translate it into parent bus space */
        return pbus->translate(addr, offset, pna);
@@ -1381,9 +1380,9 @@ int fdt_verify_alias_address(void *fdt, int anode, const char *alias, u64 addr)
 
        dt_addr = fdt_translate_address(fdt, node, reg);
        if (addr != dt_addr) {
-               printf("Warning: U-Boot configured device %s at address %llx,\n"
-                      " but the device tree has it address %llx.\n",
-                      alias, addr, dt_addr);
+               printf("Warning: U-Boot configured device %s at address %"
+                      PRIx64 ",\n but the device tree has it address %"
+                      PRIx64 ".\n", alias, addr, dt_addr);
                return 0;
        }
 
index 8db3ccb4e7404b5b1f4f0bfca22998414157e0bc..e3f06cdd1a28406e8a1a2613d543b71c27d44942 100644 (file)
@@ -237,6 +237,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
        int             fdt_noffset;
 #endif
        const char *select = NULL;
+       int             ok_no_fdt = 0;
 
        *of_flat_tree = NULL;
        *of_size = 0;
@@ -309,7 +310,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
                               fdt_addr);
                        fdt_hdr = image_get_fdt(fdt_addr);
                        if (!fdt_hdr)
-                               goto error;
+                               goto no_fdt;
 
                        /*
                         * move image data to the load address,
@@ -379,7 +380,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
                        break;
                default:
                        puts("ERROR: Did not find a cmdline Flattened Device Tree\n");
-                       goto error;
+                       goto no_fdt;
                }
 
                printf("   Booting using the fdt blob at %#08lx\n", fdt_addr);
@@ -413,11 +414,11 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
                        }
                } else {
                        debug("## No Flattened Device Tree\n");
-                       return 0;
+                       goto no_fdt;
                }
        } else {
                debug("## No Flattened Device Tree\n");
-               return 0;
+               goto no_fdt;
        }
 
        *of_flat_tree = fdt_blob;
@@ -427,9 +428,15 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 
        return 0;
 
+no_fdt:
+       ok_no_fdt = 1;
 error:
        *of_flat_tree = NULL;
        *of_size = 0;
+       if (!select && ok_no_fdt) {
+               debug("Continuing to boot without FDT\n");
+               return 0;
+       }
        return 1;
 }
 
index 28b3fe79184d627eebbe941e46330955d5092fab..3ed504df50df128180211a39186b55f85074de97 100644 (file)
@@ -530,7 +530,7 @@ static int lcd_init(void *lcdbase)
        lcd_ctrl_init(lcdbase);
 
        /*
-        * lcd_ctrl_init() of some drivers (i.e. bcm2835 on rpi_b) ignores
+        * lcd_ctrl_init() of some drivers (i.e. bcm2835 on rpi) ignores
         * the 'lcdbase' argument and uses custom lcd base address
         * by setting up gd->fb_base. Check for this condition and fixup
         * 'lcd_base' address.
index ee71f793a67ff289f7adba10d3db9d83b7d2182f..7bae16beba064472c5f4ebd48d17d4e63b3b78fc 100644 (file)
@@ -15,7 +15,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int mmc_load_image_raw(struct mmc *mmc, unsigned long sector)
+static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
 {
        unsigned long err;
        u32 image_size_sectors;
@@ -51,6 +51,22 @@ end:
        return (err == 0);
 }
 
+#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
+static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
+{
+       disk_partition_t info;
+
+       if (get_partition_info(&mmc->block_dev, partition, &info)) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+               printf("spl: partition error\n");
+#endif
+               return -1;
+       }
+
+       return mmc_load_image_raw_sector(mmc, info.start);
+}
+#endif
+
 #ifdef CONFIG_SPL_OS_BOOT
 static int mmc_load_image_raw_os(struct mmc *mmc)
 {
@@ -64,7 +80,8 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
                return -1;
        }
 
-       return mmc_load_image_raw(mmc, CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
+       return mmc_load_image_raw_sector(mmc,
+                                               CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
 }
 #endif
 
@@ -98,18 +115,24 @@ void spl_mmc_load_image(void)
 #ifdef CONFIG_SPL_OS_BOOT
                if (spl_start_uboot() || mmc_load_image_raw_os(mmc))
 #endif
-               err = mmc_load_image_raw(mmc,
+#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
+               err = mmc_load_image_raw_partition(mmc,
+                       CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
+#else
+               err = mmc_load_image_raw_sector(mmc,
                        CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
+#endif
 #if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
-       } else if (boot_mode == MMCSD_MODE_FS) {
+       }
+       if (err || boot_mode == MMCSD_MODE_FS) {
                debug("boot mode - FS\n");
 #ifdef CONFIG_SPL_FAT_SUPPORT
 #ifdef CONFIG_SPL_OS_BOOT
                if (spl_start_uboot() || spl_load_image_fat_os(&mmc->block_dev,
-                                                               CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION))
+                                                               CONFIG_SYS_MMCSD_FS_BOOT_PARTITION))
 #endif
                err = spl_load_image_fat(&mmc->block_dev,
-                                       CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION,
+                                       CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
                                        CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
                if(err)
 #endif /* CONFIG_SPL_FAT_SUPPORT */
@@ -117,10 +140,10 @@ void spl_mmc_load_image(void)
 #ifdef CONFIG_SPL_EXT_SUPPORT
 #ifdef CONFIG_SPL_OS_BOOT
                if (spl_start_uboot() || spl_load_image_ext_os(&mmc->block_dev,
-                                                               CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION))
+                                                               CONFIG_SYS_MMCSD_FS_BOOT_PARTITION))
 #endif
                err = spl_load_image_ext(&mmc->block_dev,
-                                       CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION,
+                                       CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
                                        CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
 #endif /* CONFIG_SPL_EXT_SUPPORT */
                }
@@ -146,7 +169,7 @@ void spl_mmc_load_image(void)
 #ifdef CONFIG_SPL_OS_BOOT
                if (spl_start_uboot() || mmc_load_image_raw_os(mmc))
 #endif
-               err = mmc_load_image_raw(mmc,
+               err = mmc_load_image_raw_sector(mmc,
                        CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
 #endif
        } else {
index 7d33a0f086915d6cf99169a328b2a4de783138a1..736cd9f00950929c3a269987d8c9c2e32cc80f7e 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
-#include <compiler.h>
 #include <errno.h>
 #include <usb.h>
 #ifdef CONFIG_4xx
diff --git a/configs/hermes_defconfig b/configs/hermes_defconfig
deleted file mode 100644 (file)
index a923a61..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_8xx=y
-CONFIG_TARGET_HERMES=y
index de068e9c59ceeefcd7bcf1e80ab3fb32bd50bb7c..315534065d66fe3da3bae7a0668cb8ad4337f2e4 100644 (file)
@@ -4,6 +4,7 @@ CONFIG_FIT_VERBOSE=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_UNIPHIER=y
 +S:CONFIG_MACH_PH1_LD4=y
++S:CONFIG_DCC_MICRO_SUPPORT_CARD=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BDI=y
 CONFIG_CMD_CONSOLE=y
index f4ddf5f27811f49b298bbd33b6d48c4aeb58ddf2..7ea4e6e879ba505c1cc7fc940c7486e9b2444c53 100644 (file)
@@ -4,6 +4,7 @@ CONFIG_FIT_VERBOSE=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_UNIPHIER=y
 +S:CONFIG_MACH_PH1_PRO4=y
++S:CONFIG_DCC_MICRO_SUPPORT_CARD=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BDI=y
 CONFIG_CMD_CONSOLE=y
index ee14382804027d656ddf91c38c2908272c1f3e2f..ddf210cc0d83d3e7caa1d4447e80246a00e02724 100644 (file)
@@ -4,6 +4,7 @@ CONFIG_FIT_VERBOSE=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_UNIPHIER=y
 +S:CONFIG_MACH_PH1_SLD8=y
++S:CONFIG_DCC_MICRO_SUPPORT_CARD=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BDI=y
 CONFIG_CMD_CONSOLE=y
diff --git a/configs/rpi_b_defconfig b/configs/rpi_b_defconfig
deleted file mode 100644 (file)
index 9a4705e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-CONFIG_ARM=y
-CONFIG_TARGET_RPI_B=y
diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig
new file mode 100644 (file)
index 0000000..9379cf0
--- /dev/null
@@ -0,0 +1,2 @@
+CONFIG_ARM=y
+CONFIG_TARGET_RPI=y
index 612f0926b62bbceb8b35ef9fc6aa259145c35c95..efed58f81dac27ddcd1498a28ca8b80673138bda 100644 (file)
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <command.h>
 #include <ide.h>
+#include <inttypes.h>
 #include <malloc.h>
 #include <part_efi.h>
 #include <linux/ctype.h>
@@ -553,28 +554,28 @@ static int is_gpt_valid(block_dev_desc_t *dev_desc, u64 lba,
 
        /* Check that the my_lba entry points to the LBA that contains the GPT */
        if (le64_to_cpu(pgpt_head->my_lba) != lba) {
-               printf("GPT: my_lba incorrect: %llX != %llX\n",
-                       le64_to_cpu(pgpt_head->my_lba),
-                       lba);
+               printf("GPT: my_lba incorrect: %llX != %" PRIX64 "\n",
+                      le64_to_cpu(pgpt_head->my_lba),
+                      lba);
                return 0;
        }
 
        /* Check the first_usable_lba and last_usable_lba are within the disk. */
        lastlba = (u64)dev_desc->lba;
        if (le64_to_cpu(pgpt_head->first_usable_lba) > lastlba) {
-               printf("GPT: first_usable_lba incorrect: %llX > %llX\n",
-                       le64_to_cpu(pgpt_head->first_usable_lba), lastlba);
+               printf("GPT: first_usable_lba incorrect: %llX > %" PRIX64 "\n",
+                      le64_to_cpu(pgpt_head->first_usable_lba), lastlba);
                return 0;
        }
        if (le64_to_cpu(pgpt_head->last_usable_lba) > lastlba) {
-               printf("GPT: last_usable_lba incorrect: %llX > %llX\n",
-                       le64_to_cpu(pgpt_head->last_usable_lba), lastlba);
+               printf("GPT: last_usable_lba incorrect: %llX > %" PRIX64 "\n",
+                      le64_to_cpu(pgpt_head->last_usable_lba), lastlba);
                return 0;
        }
 
-       debug("GPT: first_usable_lba: %llX last_usable_lba %llX last lba %llX\n",
-               le64_to_cpu(pgpt_head->first_usable_lba),
-               le64_to_cpu(pgpt_head->last_usable_lba), lastlba);
+       debug("GPT: first_usable_lba: %llX last_usable_lba %llX last lba %"
+             PRIX64 "\n", le64_to_cpu(pgpt_head->first_usable_lba),
+             le64_to_cpu(pgpt_head->last_usable_lba), lastlba);
 
        /* Read and allocate Partition Table Entries */
        *pgpt_pte = alloc_read_gpt_entries(dev_desc, pgpt_head);
index 52495d311677f79e5961acfa42aa8e7cd30f6a39..fe36909449cb3a9625a7eba5dfaf8fae75523f72 100644 (file)
@@ -28,7 +28,7 @@ sudo apt-get install clang
 
 To compile U-Boot with clang on linux without IAS use e.g.:
 export TRIPLET=arm-linux-gnueabi && export CROSS_COMPILE="$TRIPLET-"
-make HOSTCC=clang CC="clang -target $TRIPLET -mllvm -arm-use-movt=0 -no-integrated-as" rpi_b_defconfig
+make HOSTCC=clang CC="clang -target $TRIPLET -mllvm -arm-use-movt=0 -no-integrated-as" rpi_defconfig
 make HOSTCC=clang CC="clang -target $TRIPLET -mllvm -arm-use-movt=0 -no-integrated-as" all V=1 -j8
 
 FreeBSD 11 (Current):
@@ -42,7 +42,7 @@ ln -s /usr/local/bin/arm-gnueabi-freebsd-as /usr/bin/arm-freebsd-eabi-as
 # The following commands compile U-Boot using the clang xdev toolchain.
 # NOTE: CROSS_COMPILE and target differ on purpose!
 export CROSS_COMPILE=arm-gnueabi-freebsd-
-gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd -no-integrated-as -mllvm -arm-use-movt=0" rpi_b_defconfig
+gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd -no-integrated-as -mllvm -arm-use-movt=0" rpi_defconfig
 gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd -no-integrated-as -mllvm -arm-use-movt=0" -j8
 
 Given that u-boot will default to gcc, above commands can be
index 8ba6e0ae65c777f66bda0e486f7f7478640fe953..deb4af482b39a75edc1a846f299a1e05cdba303e 100644 (file)
@@ -12,8 +12,9 @@ The list should be sorted in reverse chronological order.
 
 Board            Arch        CPU            Commit      Removed     Last known maintainer/contact
 =================================================================================================
-PRS200          powerpc     mpc5200        -           -
-MCC200          powerpc     mpc5200        -           -
+hermes           powerpc     mpc8xx         -           -           Wolfgang Denk <wd@denx.de>
+PRS200          powerpc     mpc5200        ecfdcee     2014-11-12
+MCC200          powerpc     mpc5200        ecfdcee     2014-11-12
 TOP5200                 powerpc     mpc5200        d58a945     2014-10-28  Reinhard Meyer <reinhard.meyer@emk-elektronik.de>
 TOP860          powerpc     mpc860         d58a945     2014-10-28  Reinhard Meyer <reinhard.meyer@emk-elektronik.de>
 TOP9000                 arm         at91sam9xeXXX  d58a945     2014-10-28  Reinhard Meyer <reinhard.meyer@emk-elektronik.de>
index ad22763960cdc57c0892d23fa5f31a24750169ad..6c79a6d930285aa67d4e42d0272a5245024d0a0e 100644 (file)
@@ -14,6 +14,9 @@ alias aaribaud       Albert Aribaud <albert.u.boot@aribaud.net>
 alias abiessmann     Andreas Bießmann <andreas.devel@googlemail.com>
 alias afleming       Andy Fleming <afleming@gmail.com>
 alias ag             Anatolij Gustschin <agust@denx.de>
+alias alisonwang     Alison Wang <alison.wang@freescale.com>
+alias angelo_ts      Angelo Dureghello <angelo@sysam.it>
+alias danielschwierzeck Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
 alias galak          Kumar Gala <galak@kernel.crashing.org>
 alias gruss          Graeme Russ <graeme.russ@gmail.com>
 alias hs             Heiko Schocher <hs@denx.de>
@@ -72,13 +75,13 @@ alias avr32          uboot, abiessmann
 alias bfin           uboot, vapier, sonic
 alias blackfin       bfin
 
-alias m68k           uboot, jasonjin
+alias m68k           uboot, alisonwang, angelo_ts
 alias coldfire       m68k
 
 alias microblaze     uboot, monstr
 alias mb             microblaze
 
-alias mips           uboot, Shinya Kuribayashi <skuribay@pobox.com>
+alias mips           uboot, danielschwierzeck
 
 alias nds32          uboot, macpaul
 
@@ -119,6 +122,7 @@ alias mmc            uboot, panto
 alias nand           uboot, scottwood
 alias net            uboot, jhersh
 alias spi           uboot, jagan
+alias ubi            uboot, hs
 alias usb            uboot, marex
 alias video          uboot, ag
 alias patman         uboot, sjg
index 2093cf06b4bbda0a3693982499933563e1fc0156..b678f60b2d763df43cf5152215210ebd7b9213b9 100644 (file)
@@ -43,7 +43,6 @@ struct ata_port {
 
 #define DRV_NAME               "pata-bfin"
 #define DRV_VERSION            "0.9"
-#define __iomem
 
 #define ATA_REG_CTRL           0x0E
 #define ATA_REG_ALTSTATUS      ATA_REG_CTRL
index d34b749a5651928d123954e961e782b33b5c3945..41cc3b8fa43b270de0253fe74036f013efd9125d 100644 (file)
@@ -174,11 +174,11 @@ static int i2c_mux_set_all(void)
        return 0;
 }
 
-static int i2c_mux_disconnet_all(void)
+static int i2c_mux_disconnect_all(void)
 {
        struct  i2c_bus_hose *i2c_bus_tmp = &i2c_bus[I2C_BUS];
        int     i;
-       uint8_t buf;
+       uint8_t buf = 0;
 
        if (I2C_ADAP->init_done == 0)
                return 0;
@@ -197,7 +197,7 @@ static int i2c_mux_disconnet_all(void)
 
                        ret = I2C_ADAP->write(I2C_ADAP, chip, 0, 0, &buf, 1);
                        if (ret != 0) {
-                               printf("i2c: mux diconnect error\n");
+                               printf("i2c: mux disconnect error\n");
                                return ret;
                        }
                } while (i > 0);
@@ -293,7 +293,7 @@ int i2c_set_bus_num(unsigned int bus)
        }
 
 #ifndef CONFIG_SYS_I2C_DIRECT_BUS
-       i2c_mux_disconnet_all();
+       i2c_mux_disconnect_all();
 #endif
 
        gd->cur_i2c_bus = bus;
index ed83a14c2defe1a28d291539aa695920149393ad..76ba93b81d4f42e4307aaeca3213e956eef58462 100644 (file)
@@ -103,20 +103,18 @@ static int mmcif_wait_interrupt_flag(struct sh_mmcif_host *host)
 
 static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk)
 {
-       int i;
-
        sh_mmcif_bitclr(CLK_ENABLE, &host->regs->ce_clk_ctrl);
        sh_mmcif_bitclr(CLK_CLEAR, &host->regs->ce_clk_ctrl);
 
        if (!clk)
                return;
-       if (clk == CLKDEV_EMMC_DATA) {
+
+       if (clk == CLKDEV_EMMC_DATA)
                sh_mmcif_bitset(CLK_PCLK, &host->regs->ce_clk_ctrl);
-       } else {
-               for (i = 1; (unsigned int)host->clk / (1 << i) >= clk; i++)
-                       ;
-               sh_mmcif_bitset((i - 1) << 16, &host->regs->ce_clk_ctrl);
-       }
+       else
+               sh_mmcif_bitset((fls(DIV_ROUND_UP(host->clk,
+                                                 clk) - 1) - 1) << 16,
+                               &host->regs->ce_clk_ctrl);
        sh_mmcif_bitset(CLK_ENABLE, &host->regs->ce_clk_ctrl);
 }
 
@@ -581,8 +579,6 @@ static struct mmc_config sh_mmcif_cfg = {
        .host_caps      = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_4BIT |
                          MMC_MODE_8BIT | MMC_MODE_HC,
        .voltages       = MMC_VDD_32_33 | MMC_VDD_33_34,
-       .f_min          = CLKDEV_MMC_INIT,
-       .f_max          = CLKDEV_EMMC_DATA,
        .b_max          = CONFIG_SYS_MMC_MAX_BLK_COUNT,
 };
 
@@ -599,6 +595,9 @@ int mmcif_mmc_init(void)
        host->regs = (struct sh_mmcif_regs *)CONFIG_SH_MMCIF_ADDR;
        host->clk = CONFIG_SH_MMCIF_CLK;
 
+       sh_mmcif_cfg.f_min = MMC_CLK_DIV_MIN(host->clk);
+       sh_mmcif_cfg.f_max = MMC_CLK_DIV_MAX(host->clk);
+
        mmc = mmc_create(&sh_mmcif_cfg, host);
        if (mmc == NULL) {
                free(host);
index bd6fbf7c62e60788bf98da96271efbc4fcf84633..4b6752f7f98a581dd56cfdda46a74c97eee25642 100644 (file)
@@ -199,7 +199,13 @@ struct sh_mmcif_regs {
 #define SOFT_RST_OFF           (0 << 31)
 
 #define CLKDEV_EMMC_DATA       52000000        /* 52MHz */
-#define        CLKDEV_MMC_INIT         400000          /* 100 - 400 KHz */
+#ifdef CONFIG_RMOBILE
+#define MMC_CLK_DIV_MIN(clk)   (clk / (1 << 9))
+#define MMC_CLK_DIV_MAX(clk)   (clk / (1 << 1))
+#else
+#define MMC_CLK_DIV_MIN(clk)   (clk / (1 << 8))
+#define MMC_CLK_DIV_MAX(clk)   CLKDEV_EMMC_DATA
+#endif
 
 #define MMC_BUS_WIDTH_1                0
 #define MMC_BUS_WIDTH_4                2
index 594cd11725e982c9bea441effb1a0c25f3028745..0dcf9fe9187307c4240153c6bada20a808ebdf6c 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/types.h>
 #include <power/pmic.h>
 #include <i2c.h>
-#include <compiler.h>
+#include <linux/compiler.h>
 
 int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
 {
index ebddc124c3dae96195f31eca4bab99f60bc5204a..424743c9906dc5eaa9ab0ef4a10d035bc556c717 100644 (file)
@@ -13,7 +13,7 @@
 #define _MVRTC_H_
 
 #include <asm/arch/soc.h>
-#include <compiler.h>
+#include <linux/compiler.h>
 
 /* RTC registers */
 struct mvrtc_registers {
index 38dda910217652ecf167ad52bbc53af3559e2722..e1bf4965f92123ce0605cbc93d02f0a1d56da1f2 100644 (file)
@@ -72,30 +72,39 @@ static int pl01x_tstc(struct pl01x_regs *regs)
 static int pl01x_generic_serial_init(struct pl01x_regs *regs,
                                     enum pl01x_type type)
 {
-       unsigned int lcr;
-
+       switch (type) {
+       case TYPE_PL010:
+               /* disable everything */
+               writel(0, &regs->pl010_cr);
+               break;
+       case TYPE_PL011:
 #ifdef CONFIG_PL011_SERIAL_FLUSH_ON_INIT
-       if (type == TYPE_PL011) {
                /* Empty RX fifo if necessary */
                if (readl(&regs->pl011_cr) & UART_PL011_CR_UARTEN) {
                        while (!(readl(&regs->fr) & UART_PL01x_FR_RXFE))
                                readl(&regs->dr);
                }
-       }
 #endif
+               /* disable everything */
+               writel(0, &regs->pl011_cr);
+               break;
+       default:
+               return -EINVAL;
+       }
 
-       /* First, disable everything */
-       writel(0, &regs->pl010_cr);
+       return 0;
+}
 
-       /* Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled */
+static int set_line_control(struct pl01x_regs *regs)
+{
+       unsigned int lcr;
+       /*
+        * Internal update of baud rate register require line
+        * control register write
+        */
        lcr = UART_PL011_LCRH_WLEN_8 | UART_PL011_LCRH_FEN;
-       writel(lcr, &regs->pl011_lcrh);
-
-       switch (type) {
-       case TYPE_PL010:
-               break;
-       case TYPE_PL011: {
 #ifdef CONFIG_PL011_SERIAL_RLCR
+       {
                int i;
 
                /*
@@ -107,15 +116,9 @@ static int pl01x_generic_serial_init(struct pl01x_regs *regs,
                        writel(lcr, &regs->fr);
 
                writel(lcr, &regs->pl011_rlcr);
-               /* lcrh needs to be set again for change to be effective */
-               writel(lcr, &regs->pl011_lcrh);
-#endif
-               break;
-       }
-       default:
-               return -EINVAL;
        }
-
+#endif
+       writel(lcr, &regs->pl011_lcrh);
        return 0;
 }
 
@@ -175,6 +178,7 @@ static int pl01x_generic_setbrg(struct pl01x_regs *regs, enum pl01x_type type,
                writel(divider, &regs->pl011_ibrd);
                writel(fraction, &regs->pl011_fbrd);
 
+               set_line_control(regs);
                /* Finally, enable the UART */
                writel(UART_PL011_CR_UARTEN | UART_PL011_CR_TXE |
                       UART_PL011_CR_RXE | UART_PL011_CR_RTS, &regs->pl011_cr);
@@ -201,7 +205,7 @@ static void pl01x_serial_init_baud(int baudrate)
        base_regs = (struct pl01x_regs *)port[CONFIG_CONS_INDEX];
 
        pl01x_generic_serial_init(base_regs, pl01x_type);
-       pl01x_generic_setbrg(base_regs, TYPE_PL010, clock, baudrate);
+       pl01x_generic_setbrg(base_regs, pl01x_type, clock, baudrate);
 }
 
 /*
index bc0f9645b591e9460a74ccdfee947b49338684ba..31761ec33814878f85d817ea4611e3efd2d28089 100644 (file)
@@ -34,7 +34,7 @@
 
 #include <config.h>
 #include <common.h>
-#include <compiler.h>
+#include <linux/compiler.h>
 #include <fdtdec.h>
 #include <i2c.h>
 #include <tpm.h>
index 2dd8501f92d127125dec36d09f9af25a2ecac87b..c1bbed4eb5833054c53db2a9b927e9e3144cd6f8 100644 (file)
@@ -38,7 +38,7 @@
 
 #include <common.h>
 #include <fdtdec.h>
-#include <compiler.h>
+#include <linux/compiler.h>
 #include <i2c.h>
 #include <tpm.h>
 #include <asm-generic/errno.h>
index 94c354b37ce73e50b4a056eb5567dd34a7b0c912..46f07fe1739d4184f2dc0841adfc231ccda495cf 100644 (file)
@@ -445,11 +445,6 @@ extern ssize_t spi_read     (uchar *, int, uchar *, int);
 extern ssize_t spi_write (uchar *, int, uchar *, int);
 #endif
 
-#ifdef CONFIG_HERMES
-/* $(BOARD)/hermes.c */
-void hermes_start_lxt980 (int speed);
-#endif
-
 #ifdef CONFIG_EVB64260
 void  evb64260_init(void);
 void  debug_led(int, int);
index d78ab0081c2e7e724891f29a780c04a817f5fe82..6875c4c7544fe8c9934a7c7719506b01c84b9e77 100644 (file)
@@ -535,34 +535,6 @@ typedef struct scc_enet {
 #define SICR_ENET_CLKRT        ((uint)0x00002600)
 #endif /* CONFIG_FPS850L, CONFIG_FPS860L */
 
-/*** HERMES-PRO ******************************************************/
-
-/* The HERMES-PRO uses the FEC on a MPC860T for Ethernet */
-
-#ifdef CONFIG_HERMES
-
-#define        FEC_ENET        /* use FEC for EThernet */
-#undef SCC_ENET
-
-
-#define PD_MII_TXD1    ((ushort)0x1000)        /* PD  3 */
-#define PD_MII_TXD2    ((ushort)0x0800)        /* PD  4 */
-#define PD_MII_TXD3    ((ushort)0x0400)        /* PD  5 */
-#define PD_MII_RX_DV   ((ushort)0x0200)        /* PD  6 */
-#define PD_MII_RX_ERR  ((ushort)0x0100)        /* PD  7 */
-#define PD_MII_RX_CLK  ((ushort)0x0080)        /* PD  8 */
-#define PD_MII_TXD0    ((ushort)0x0040)        /* PD  9 */
-#define PD_MII_RXD0    ((ushort)0x0020)        /* PD 10 */
-#define PD_MII_TX_ERR  ((ushort)0x0010)        /* PD 11 */
-#define PD_MII_MDC     ((ushort)0x0008)        /* PD 12 */
-#define PD_MII_RXD1    ((ushort)0x0004)        /* PD 13 */
-#define PD_MII_RXD2    ((ushort)0x0002)        /* PD 14 */
-#define PD_MII_RXD3    ((ushort)0x0001)        /* PD 15 */
-
-#define PD_MII_MASK    ((ushort)0x1FFF)        /* PD 3...15 */
-
-#endif /* CONFIG_HERMES */
-
 /***  IP860  **********************************************************/
 
 #if defined(CONFIG_IP860)
index 120fdc6659e2677c17264bd746431e49dbe4cd50..d23d2c4cc5dafd9ebb61f981e056c4d5339fd786 100644 (file)
 #define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_NOR_SUPPORT
 #define CONFIG_SPL_TEXT_BASE   0xfc000000
-#define        CONFIG_SPL_START_S_PATH "arch/powerpc/cpu/mpc5xxx"
-#define CONFIG_SPL_LDSCRIPT    "arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds"
 #define CONFIG_SPL_LIBCOMMON_SUPPORT   /* image.c */
 #define CONFIG_SPL_LIBGENERIC_SUPPORT  /* string.c */
 #define CONFIG_SPL_SERIAL_SUPPORT
index 0fbfa3fb4c42a6d2ef41ac94abf47467b9aa620a..09ee10c0590b48c1260ff9846486dea9ca9504c6 100644 (file)
 
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR        0x300 /* address 0x60000 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     0x200 /* 256 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
index 8719f763dd4e195412241bad594ce9b41a25c463..190ef0e71bfbeaf9441e701cd65146ddc6e5b4f0 100644 (file)
 
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR        0x300 /* address 0x60000 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     0x200 /* 256 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
index 1919cde79fce50b8f08981e2cb936fdd570da03f..ccd9b88adcc68c9a1eb2a3c45fd2b5ddbfb220d1 100644 (file)
 
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR        0x300 /* address 0x60000 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     0x200 /* 256 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 
 #define CONFIG_SPL_BOARD_INIT
index ca624619a0c2a4e9e678e4d7c5d2be0d2658743d..930b08e2f9d951b545b44602566556055bf9f281 100644 (file)
 #define CONFIG_SPL_FAT_SUPPORT
 #define CONFIG_SPL_LDSCRIPT            "$(CPUDIR)/omap-common/u-boot-spl.lds"
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */
 
 #define CONFIG_SPL_TEXT_BASE           0x40200000 /*CONFIG_SYS_SRAM_START*/
diff --git a/include/configs/hermes.h b/include/configs/hermes.h
deleted file mode 100644 (file)
index 736ffb6..0000000
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * board/config.h - configuration options, board specific
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-
-#define CONFIG_MPC860          1       /* This is a MPC860T CPU        */
-#define CONFIG_HERMES          1       /* ...on a HERMES-PRO board     */
-
-#define        CONFIG_SYS_TEXT_BASE    0xFE000000
-
-#define        CONFIG_8xx_CONS_SMC1    1       /* Console is on SMC1           */
-#undef CONFIG_8xx_CONS_SMC2
-#undef CONFIG_8xx_CONS_NONE
-#define CONFIG_BAUDRATE                9600
-#if 0
-#define CONFIG_BOOTDELAY       -1      /* autoboot disabled            */
-#else
-#define CONFIG_BOOTDELAY       5       /* autoboot after 5 seconds     */
-#endif
-
-#define        CONFIG_CLOCKS_IN_MHZ    1       /* clocks passsed to Linux in MHz */
-
-#define CONFIG_BOARD_TYPES     1       /* support board types          */
-
-#define        CONFIG_SHOW_BOOT_PROGRESS 1     /* Show boot progress on LEDs   */
-
-#undef CONFIG_BOOTARGS
-#define CONFIG_BOOTCOMMAND                                                     \
-       "bootp; "                                                               \
-       "setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath} "     \
-       "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; "   \
-       "bootm"
-
-#define CONFIG_LOADS_ECHO      1       /* echo on for serial download  */
-#undef CONFIG_SYS_LOADS_BAUD_CHANGE            /* don't allow baudrate change  */
-
-#undef CONFIG_WATCHDOG                 /* watchdog disabled            */
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_SUBNETMASK
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-#define CONFIG_BOOTP_BOOTPATH
-
-
-/*
- * Miscellaneous configurable options
- */
-#define        CONFIG_SYS_LONGHELP                     /* undef to save memory         */
-#if defined(CONFIG_CMD_KGDB)
-#define        CONFIG_SYS_CBSIZE       1024            /* Console I/O Buffer Size      */
-#else
-#define        CONFIG_SYS_CBSIZE       256             /* Console I/O Buffer Size      */
-#endif
-#define        CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */
-#define        CONFIG_SYS_MAXARGS      16              /* max number of command args   */
-#define CONFIG_SYS_BARGSIZE    CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-
-#define CONFIG_SYS_MEMTEST_START       0x00100000      /* memtest works on     */
-#define CONFIG_SYS_MEMTEST_END         0x00F00000      /* 1 ... 15MB in DRAM   */
-
-#define        CONFIG_SYS_LOAD_ADDR            0x00100000      /* default load address */
-
-#define        CONFIG_SYS_PIO_MODE             0       /* IDE interface in PIO Mode 0  */
-
-#define        CONFIG_SYS_ALLOC_DPRAM          1       /* use allocation routines      */
-/*
- * Low Level Configuration Settings
- * (address mappings, register initial values, etc.)
- * You should know what you are doing if you make changes here.
- */
-/*-----------------------------------------------------------------------
- * Internal Memory Mapped Register
- */
-#define CONFIG_SYS_IMMR                0xFF000000      /* Non-Standard value!  */
-
-/*-----------------------------------------------------------------------
- * Definitions for initial stack pointer and data area (in DPRAM)
- */
-#define CONFIG_SYS_INIT_RAM_ADDR       CONFIG_SYS_IMMR
-#define        CONFIG_SYS_INIT_RAM_SIZE        0x2F00  /* Size of used area in DPRAM   */
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define        CONFIG_SYS_INIT_SP_OFFSET       CONFIG_SYS_GBL_DATA_OFFSET
-
-/*-----------------------------------------------------------------------
- * Start addresses for the final memory configuration
- * (Set up by the startup code)
- * Please note that CONFIG_SYS_SDRAM_BASE _must_ start at 0
- */
-#define        CONFIG_SYS_SDRAM_BASE           0x00000000
-#define CONFIG_SYS_FLASH_BASE          0xFE000000
-#ifdef DEBUG
-#define        CONFIG_SYS_MONITOR_LEN          (256 << 10)     /* Reserve 256 kB for Monitor   */
-#else
-#define        CONFIG_SYS_MONITOR_LEN          (128 << 10)     /* Reserve 128 kB for Monitor   */
-#endif
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_FLASH_BASE
-#define        CONFIG_SYS_MALLOC_LEN           (128 << 10)     /* Reserve 128 kB for malloc()  */
-
-/*
- * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
- * the maximum mapped by the Linux kernel during initialization.
- */
-#define        CONFIG_SYS_BOOTMAPSZ            (8 << 20)       /* Initial Memory map for Linux */
-/*-----------------------------------------------------------------------
- * FLASH organization
- */
-#define CONFIG_SYS_MAX_FLASH_BANKS     1       /* max number of memory banks           */
-#define CONFIG_SYS_MAX_FLASH_SECT      124     /* max number of sectors on one chip    */
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT    120000  /* Timeout for Flash Erase (in ms)      */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    500     /* Timeout for Flash Write (in ms)      */
-
-#define        CONFIG_ENV_IS_IN_FLASH  1
-#define        CONFIG_ENV_OFFSET               0x4000  /*   Offset   of Environment Sector     */
-#define        CONFIG_ENV_SIZE         0x2000  /* Total Size of Environment Sector     */
-/*-----------------------------------------------------------------------
- * Cache Configuration
- */
-#define CONFIG_SYS_CACHELINE_SIZE      16      /* For all MPC8xx CPUs                  */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CACHELINE_SHIFT     4       /* log base 2 of the above value        */
-#endif
-
-/*-----------------------------------------------------------------------
- * SYPCR - System Protection Control                           11-9
- * SYPCR can only be written once after reset!
- *-----------------------------------------------------------------------
- * Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
- * +0x0004
- */
-#if defined(CONFIG_WATCHDOG)
-#define CONFIG_SYS_SYPCR       (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
-                        SYPCR_SWE  | SYPCR_SWRI| SYPCR_SWP)
-#else
-#define CONFIG_SYS_SYPCR       (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
-#endif
-
-/*-----------------------------------------------------------------------
- * SIUMCR - SIU Module Configuration                           11-6
- *-----------------------------------------------------------------------
- * +0x0000 => 0x000000C0
- */
-#define CONFIG_SYS_SIUMCR      0
-
-/*-----------------------------------------------------------------------
- * TBSCR - Time Base Status and Control                                11-26
- *-----------------------------------------------------------------------
- * Clear Reference Interrupt Status, Timebase freezing enabled
- * +0x0200 => 0x00C2
- */
-#define CONFIG_SYS_TBSCR       (TBSCR_REFA | TBSCR_REFB | TBSCR_TBF)
-
-/*-----------------------------------------------------------------------
- * PISCR - Periodic Interrupt Status and Control               11-31
- *-----------------------------------------------------------------------
- * Clear Periodic Interrupt Status, Interrupt Timer freezing enabled
- * +0x0240 => 0x0082
- */
-#define CONFIG_SYS_PISCR       (PISCR_PS | PISCR_PITF)
-
-/*-----------------------------------------------------------------------
- * PLPRCR - PLL, Low-Power, and Reset Control Register         15-30
- *-----------------------------------------------------------------------
- * Reset PLL lock status sticky bit, timer expired status bit and timer
- * interrupt status bit, set PLL multiplication factor !
- */
-/* +0x0286 => 0x00B0D0C0 */
-#define CONFIG_SYS_PLPRCR                                                      \
-               (       (11 << PLPRCR_MF_SHIFT) |                       \
-                       PLPRCR_SPLSS | PLPRCR_TEXPS | PLPRCR_TMIST |    \
-                       /*PLPRCR_CSRC|*/ PLPRCR_LPM_NORMAL |            \
-                       PLPRCR_CSR   | PLPRCR_LOLRE /*|PLPRCR_FIOPD*/   \
-               )
-
-/*-----------------------------------------------------------------------
- * SCCR - System Clock and reset Control Register              15-27
- *-----------------------------------------------------------------------
- * Set clock output, timebase and RTC source and divider,
- * power management and some other internal clocks
- */
-#define SCCR_MASK      SCCR_EBDF11
-/* +0x0282 => 0x03800000 */
-#define CONFIG_SYS_SCCR        (SCCR_COM00     |   SCCR_TBS      |     \
-                        SCCR_RTDIV     |   SCCR_RTSEL    |     \
-                        /*SCCR_CRQEN|*/  /*SCCR_PRQEN|*/       \
-                        SCCR_EBDF00    |   SCCR_DFSYNC00 |     \
-                        SCCR_DFBRG00   |   SCCR_DFNL000  |     \
-                        SCCR_DFNH000)
-
-/*-----------------------------------------------------------------------
- * RTCSC - Real-Time Clock Status and Control Register         11-27
- *-----------------------------------------------------------------------
- */
-/* +0x0220 => 0x00C3 */
-#define CONFIG_SYS_RTCSC       (RTCSC_SEC | RTCSC_ALR | RTCSC_RTF| RTCSC_RTE)
-
-
-/*-----------------------------------------------------------------------
- * RCCR - RISC Controller Configuration Register               19-4
- *-----------------------------------------------------------------------
- */
-/* +0x09C4 => TIMEP=1 */
-#define CONFIG_SYS_RCCR 0x0100
-
-/*-----------------------------------------------------------------------
- * RMDS - RISC Microcode Development Support Control Register
- *-----------------------------------------------------------------------
- */
-#define CONFIG_SYS_RMDS 0
-
-/*-----------------------------------------------------------------------
- *
- *-----------------------------------------------------------------------
- *
- */
-#define CONFIG_SYS_DER 0
-
-/*
- * Init Memory Controller:
- *
- * BR0 and OR0 (FLASH)
- */
-
-#define FLASH_BASE0_PRELIM     0xFE000000      /* FLASH bank #0        */
-
-/* used to re-map FLASH
- * restrict access enough to keep SRAM working (if any)
- * but not too much to meddle with FLASH accesses
- */
-/* allow for max 4 MB of Flash */
-#define CONFIG_SYS_REMAP_OR_AM         0xFFC00000      /* OR addr mask */
-#define CONFIG_SYS_PRELIM_OR_AM        0xFFC00000      /* OR addr mask */
-
-/* FLASH timing: ACS = 11, TRLX = 1, CSNT = 1, SCY = 5, EHTR = 0       */
-#define CONFIG_SYS_OR_TIMING_FLASH     ( OR_CSNT_SAM | /*OR_ACS_DIV4 |*/ OR_BI | \
-                                OR_SCY_5_CLK | OR_TRLX)
-
-#define CONFIG_SYS_OR0_REMAP   (CONFIG_SYS_REMAP_OR_AM  | CONFIG_SYS_OR_TIMING_FLASH)
-#define CONFIG_SYS_OR0_PRELIM  (CONFIG_SYS_PRELIM_OR_AM | CONFIG_SYS_OR_TIMING_FLASH)
-/* 8 bit, bank valid */
-#define CONFIG_SYS_BR0_PRELIM  ((FLASH_BASE0_PRELIM & BR_BA_MSK) | BR_PS_8 | BR_V )
-
-/*
- * BR1/OR1 - SDRAM
- *
- * Multiplexed addresses, GPL5 output to GPL5_A (don't care)
- */
-#define SDRAM_BASE_PRELIM      0x00000000      /* SDRAM bank */
-#define SDRAM_PRELIM_OR_AM     0xF8000000      /* map max. 128 MB */
-#define SDRAM_TIMING           0x00000A00      /* SDRAM-Timing */
-
-#define SDRAM_MAX_SIZE         0x04000000      /* max 64 MB SDRAM */
-
-#define CONFIG_SYS_OR1_PRELIM  (SDRAM_PRELIM_OR_AM | SDRAM_TIMING )
-#define CONFIG_SYS_BR1_PRELIM  ((SDRAM_BASE_PRELIM & BR_BA_MSK) | BR_MS_UPMA | BR_V )
-
-/*
- * BR2/OR2 - HPRO2: PEB2256   @ 0xE0000000, 8 Bit wide
- */
-#define HPRO2_BASE             0xE0000000
-#define HPRO2_OR_AM            0xFFFF8000
-#define HPRO2_TIMING           0x00000934
-
-#define CONFIG_SYS_OR2 (HPRO2_OR_AM | HPRO2_TIMING)
-#define CONFIG_SYS_BR2 ((HPRO2_BASE & BR_BA_MSK) | BR_PS_8 | BR_V )
-
-/*
- * BR3/OR3: not used
- * BR4/OR4: not used
- * BR5/OR5: not used
- * BR6/OR6: not used
- * BR7/OR7: not used
- */
-
-/*
- * MAMR settings for SDRAM
- */
-
-/* periodic timer for refresh */
-#define CONFIG_SYS_MAMR_PTA    97              /* start with divider for 100 MHz       */
-
-/* 8 column SDRAM */
-#define CONFIG_SYS_MAMR_8COL   ((CONFIG_SYS_MAMR_PTA << MAMR_PTA_SHIFT)  | MAMR_PTAE       |   \
-                        MAMR_AMA_TYPE_0 | MAMR_DSA_1_CYCL | MAMR_G0CLA_A11 |   \
-                        MAMR_RLFA_1X    | MAMR_WLFA_1X    | MAMR_TLFA_4X)
-/* 9 column SDRAM */
-#define CONFIG_SYS_MAMR_9COL   ((CONFIG_SYS_MAMR_PTA << MAMR_PTA_SHIFT)  | MAMR_PTAE       |   \
-                        MAMR_AMA_TYPE_1 | MAMR_DSA_1_CYCL | MAMR_G0CLA_A10 |   \
-                        MAMR_RLFA_1X    | MAMR_WLFA_1X    | MAMR_TLFA_4X)
-#endif /* __CONFIG_H */
index 5a5f9400c3d2885a37721c38f8ead46624cf178b..1b9c2773beb8240af44ca465d249f904ac1ae1b2 100644 (file)
@@ -28,7 +28,6 @@
 #define CONFIG_SPL_LDSCRIPT    "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds"
 #define CONFIG_SPL_TEXT_BASE           0x00908000
 #define CONFIG_SPL_MAX_SIZE            0x10000
-#define CONFIG_SPL_START_S_PATH                "arch/arm/cpu/armv7"
 #define CONFIG_SPL_STACK               0x0091FFB8
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBGENERIC_SUPPORT
@@ -46,7 +45,7 @@
 #if defined(CONFIG_SPL_MMC_SUPPORT)
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR        138 /* offset 69KB */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     800 /* 400 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SYS_MONITOR_LEN  (CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS/2*1024)
 #endif
 
index 58e72956908188b0c98991af83d7519e12f7782b..d43db5288e76c6a822087c7b10ae4a9e538848fd 100644 (file)
 #define CONFIG_SPL_TEXT_BASE           0xffff0000 /* last 64 KiB for SPL */
 #define CONFIG_SYS_SPL_MAX_LEN         (64 << 10)
 #define CONFIG_UBOOT_PAD_TO            458752  /* decimal for 'dd' */
-#define        CONFIG_SPL_START_S_PATH "arch/powerpc/cpu/ppc4xx"
-#define CONFIG_SPL_LDSCRIPT    "arch/powerpc/cpu/ppc4xx/u-boot-spl.lds"
 #define CONFIG_SPL_LIBCOMMON_SUPPORT   /* image.c */
 #define CONFIG_SPL_LIBGENERIC_SUPPORT  /* string.c */
 #define CONFIG_SPL_SERIAL_SUPPORT
index b775ebd0edef662ed6dbf87143f02151edab372a..26eb2203540f350b608e392817dc115f8844af28 100644 (file)
 #define CONFIG_SPL_BSS_MAX_SIZE                0x80000
 
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR        0x300 /* address 0x60000 */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 
 /* NAND boot config */
index 27bf89c114c12c5c61bb1f2bc224d4be3216bdff..8bdc08f5864c7f6bf27afaeabec0bbba6c4fa820 100644 (file)
@@ -75,7 +75,7 @@
 #define CONFIG_SPL_FAT_SUPPORT
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR        0x300 /* address 0x60000 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     0x200 /* 256 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 
 /* Partition tables */
index 2daf13c642202da1461510127f98ca4a908ab3fa..1185f425501f8b5e6b39b03341be104df1345fde 100644 (file)
@@ -87,7 +87,7 @@
 #define CONFIG_SPL_FAT_SUPPORT
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR        0x300 /* address 0x60000 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     0x200 /* 256 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 
 #endif /* __OMAP3_EVM_QUICK_MMC_H */
diff --git a/include/configs/ph1_ld4.h b/include/configs/ph1_ld4.h
deleted file mode 100644 (file)
index 73a95e6..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __PH1_XXX_H
-#define __PH1_XXX_H
-
-/*
- * Support Card Select
- *
- *  CONFIG_PFC_MICRO_SUPPORT_CARD - Original Micro Support Card made by PFC.
- *  CONFIG_DCC_MICRO_SUPPORT_CARD - DCC version Micro Support Card.
- *                       CPLD is re-programmed for ARIMA board compatibility.
- *  No define                     - No support card.
- */
-
-#if 0
-#define CONFIG_PFC_MICRO_SUPPORT_CARD
-#else
-#define CONFIG_DCC_MICRO_SUPPORT_CARD
-#endif
-
-/*
- * Serial Configuration
- *   SoC UART     : enable CONFIG_UNIPHIER_SERIAL
- *   On-board UART: enable CONFIG_SYS_NS16550_SERIAL
- */
-#if 0
-#define CONFIG_SYS_NS16550_SERIAL
-#endif
-
-#define CONFIG_SMC911X
-
-#define CONFIG_DDR_NUM_CH0 1
-#define CONFIG_DDR_NUM_CH1 1
-
-/*
- * Memory Size & Mapping
- */
-/* Physical start address of SDRAM */
-#define CONFIG_SDRAM0_BASE     0x80000000
-#define CONFIG_SDRAM0_SIZE     0x10000000
-#define CONFIG_SDRAM1_BASE     0x90000000
-#define CONFIG_SDRAM1_SIZE     0x10000000
-
-#define CONFIG_SPL_TEXT_BASE 0x40000
-
-#include "uniphier-common.h"
-
-#endif /* __PH1_XXX_H */
diff --git a/include/configs/ph1_pro4.h b/include/configs/ph1_pro4.h
deleted file mode 100644 (file)
index fc5132d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __PH1_XXX_H
-#define __PH1_XXX_H
-
-/*
- * Support Card Select
- *
- *  CONFIG_PFC_MICRO_SUPPORT_CARD - Original Micro Support Card made by PFC.
- *  CONFIG_DCC_MICRO_SUPPORT_CARD - DCC version Micro Support Card.
- *                       CPLD is re-programmed for ARIMA board compatibility.
- *  No define                     - No support card.
- */
-
-#if 0
-#define CONFIG_PFC_MICRO_SUPPORT_CARD
-#else
-#define CONFIG_DCC_MICRO_SUPPORT_CARD
-#endif
-
-/*
- * Serial Configuration
- *   SoC UART     : enable CONFIG_UNIPHIER_SERIAL
- *   On-board UART: enable CONFIG_SYS_NS16550_SERIAL
- */
-#if 0
-#define CONFIG_SYS_NS16550_SERIAL
-#endif
-
-#define CONFIG_SMC911X
-
-#define CONFIG_DDR_NUM_CH0 2
-#define CONFIG_DDR_NUM_CH1 2
-
-#define CONFIG_UNIPHIER_SMP
-
-/*
- * Memory Size & Mapping
- */
-/* Physical start address of SDRAM */
-#define CONFIG_SDRAM0_BASE     0x80000000
-#define CONFIG_SDRAM0_SIZE     0x20000000
-#define CONFIG_SDRAM1_BASE     0xa0000000
-#define CONFIG_SDRAM1_SIZE     0x20000000
-
-#define CONFIG_SPL_TEXT_BASE 0x100000
-
-#include "uniphier-common.h"
-
-#endif /* __PH1_XXX_H */
diff --git a/include/configs/ph1_sld8.h b/include/configs/ph1_sld8.h
deleted file mode 100644 (file)
index e2f1102..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __PH1_XXX_H
-#define __PH1_XXX_H
-
-/*
- * Support Card Select
- *
- *  CONFIG_PFC_MICRO_SUPPORT_CARD - Original Micro Support Card made by PFC.
- *  CONFIG_DCC_MICRO_SUPPORT_CARD - DCC version Micro Support Card.
- *                       CPLD is re-programmed for ARIMA board compatibility.
- *  No define                     - No support card.
- */
-
-#if 0
-#define CONFIG_PFC_MICRO_SUPPORT_CARD
-#else
-#define CONFIG_DCC_MICRO_SUPPORT_CARD
-#endif
-
-/*
- * Serial Configuration
- *   SoC UART     : enable CONFIG_UNIPHIER_SERIAL
- *   On-board UART: enable CONFIG_SYS_NS16550_SERIAL
- */
-#if 0
-#define CONFIG_SYS_NS16550_SERIAL
-#endif
-
-#define CONFIG_SMC911X
-
-#define CONFIG_DDR_NUM_CH0 1
-#define CONFIG_DDR_NUM_CH1 1
-
-/* #define CONFIG_DDR_STANDARD */
-
-/*
- * Memory Size & Mapping
- */
-/* Physical start address of SDRAM */
-#define CONFIG_SDRAM0_BASE     0x80000000
-#define CONFIG_SDRAM0_SIZE     0x10000000
-#define CONFIG_SDRAM1_BASE     0x90000000
-#define CONFIG_SDRAM1_SIZE     0x10000000
-
-#define CONFIG_SPL_TEXT_BASE 0x40000
-
-#include "uniphier-common.h"
-
-#endif /* __PH1_XXX_H */
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
new file mode 100644 (file)
index 0000000..4d5426e
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * (C) Copyright 2012 Stephen Warren
+ *
+ * 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
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#include <linux/sizes.h>
+
+/* Architecture, CPU, etc.*/
+#define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_BCM2835
+#define CONFIG_ARCH_CPU_INIT
+#define CONFIG_SYS_DCACHE_OFF
+/*
+ * 2835 is a SKU in a series for which the 2708 is the first or primary SoC,
+ * so 2708 has historically been used rather than a dedicated 2835 ID.
+ */
+#define CONFIG_MACH_TYPE               MACH_TYPE_BCM2708
+
+/* Enable driver model */
+#define CONFIG_DM
+#define CONFIG_CMD_DM
+#define CONFIG_DM_GPIO
+
+/* Memory layout */
+#define CONFIG_NR_DRAM_BANKS           1
+#define CONFIG_SYS_SDRAM_BASE          0x00000000
+#define CONFIG_SYS_TEXT_BASE           0x00008000
+#define CONFIG_SYS_UBOOT_BASE          CONFIG_SYS_TEXT_BASE
+/*
+ * The board really has 256M. However, the VC (VideoCore co-processor) shares
+ * the RAM, and uses a configurable portion at the top. We tell U-Boot that a
+ * smaller amount of RAM is present in order to avoid stomping on the area
+ * the VC uses.
+ */
+#define CONFIG_SYS_SDRAM_SIZE          SZ_128M
+#define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_SDRAM_BASE + \
+                                        CONFIG_SYS_SDRAM_SIZE - \
+                                        GENERATED_GBL_DATA_SIZE)
+#define CONFIG_SYS_MALLOC_LEN          SZ_4M
+#define CONFIG_SYS_MEMTEST_START       0x00100000
+#define CONFIG_SYS_MEMTEST_END         0x00200000
+#define CONFIG_LOADADDR                        0x00200000
+
+/* Flash */
+#define CONFIG_SYS_NO_FLASH
+
+/* Devices */
+/* GPIO */
+#define CONFIG_BCM2835_GPIO
+/* LCD */
+#define CONFIG_LCD
+#define CONFIG_LCD_DT_SIMPLEFB
+#define LCD_BPP                                LCD_COLOR16
+/*
+ * Prevent allocation of RAM for FB; the real FB address is queried
+ * dynamically from the VideoCore co-processor, and comes from RAM
+ * not owned by the ARM CPU.
+ */
+#define CONFIG_FB_ADDR                 0
+#define CONFIG_VIDEO_BCM2835
+#define CONFIG_SYS_WHITE_ON_BLACK
+
+/* SD/MMC configuration */
+#define CONFIG_GENERIC_MMC
+#define CONFIG_MMC
+#define CONFIG_SDHCI
+#define CONFIG_MMC_SDHCI_IO_ACCESSORS
+#define CONFIG_BCM2835_SDHCI
+
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_DWC2
+#define CONFIG_USB_DWC2_REG_ADDR 0x20980000
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_MISC_INIT_R
+#endif
+
+/* Console UART */
+#define CONFIG_PL011_SERIAL
+#define CONFIG_PL011_CLOCK             3000000
+#define CONFIG_PL01x_PORTS             { (void *)0x20201000 }
+#define CONFIG_CONS_INDEX              0
+#define CONFIG_BAUDRATE                        115200
+
+/* Console configuration */
+#define CONFIG_SYS_CBSIZE              1024
+#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE +            \
+                                        sizeof(CONFIG_SYS_PROMPT) + 16)
+
+/* Environment */
+#define CONFIG_ENV_SIZE                        SZ_16K
+#define CONFIG_ENV_IS_IN_FAT
+#define FAT_ENV_INTERFACE              "mmc"
+#define FAT_ENV_DEVICE_AND_PART                "0:1"
+#define FAT_ENV_FILE                   "uboot.env"
+#define CONFIG_FAT_WRITE
+#define CONFIG_ENV_VARS_UBOOT_CONFIG
+#define CONFIG_SYS_LOAD_ADDR           0x1000000
+#define CONFIG_CONSOLE_MUX
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV
+
+/* Shell */
+#define CONFIG_SYS_MAXARGS             8
+#define CONFIG_SYS_PROMPT              "U-Boot> "
+#define CONFIG_COMMAND_HISTORY
+
+/* Commands */
+#include <config_cmd_default.h>
+#define CONFIG_CMD_GPIO
+#define CONFIG_CMD_MMC
+#define CONFIG_PARTITION_UUIDS
+#define CONFIG_CMD_PART
+
+/* Device tree support */
+#define CONFIG_OF_BOARD_SETUP
+/* ATAGs support for bootm/bootz */
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_CMDLINE_TAG
+#define CONFIG_INITRD_TAG
+
+#include <config_distro_defaults.h>
+
+/* Some things don't make sense on this HW or yet */
+#undef CONFIG_CMD_FPGA
+
+/* Environment */
+#define ENV_DEVICE_SETTINGS \
+       "stdin=serial,lcd\0" \
+       "stdout=serial,lcd\0" \
+       "stderr=serial,lcd\0"
+
+/*
+ * Memory layout for where various images get loaded by boot scripts:
+ *
+ * scriptaddr can be pretty much anywhere that doesn't conflict with something
+ *   else. Put it low in memory to avoid conflicts.
+ *
+ * pxefile_addr_r can be pretty much anywhere that doesn't conflict with
+ *   something else. Put it low in memory to avoid conflicts.
+ *
+ * kernel_addr_r must be within the first 128M of RAM in order for the
+ *   kernel's CONFIG_AUTO_ZRELADDR option to work. Since the kernel will
+ *   decompress itself to 0x8000 after the start of RAM, kernel_addr_r
+ *   should not overlap that area, or the kernel will have to copy itself
+ *   somewhere else before decompression. Similarly, the address of any other
+ *   data passed to the kernel shouldn't overlap the start of RAM. Pushing
+ *   this up to 16M allows for a sizable kernel to be decompressed below the
+ *   compressed load address.
+ *
+ * fdt_addr_r simply shouldn't overlap anything else. Choosing 32M allows for
+ *   the compressed kernel to be up to 16M too.
+ *
+ * ramdisk_addr_r simply shouldn't overlap anything else. Choosing 33M allows
+ *   for the FDT/DTB to be up to 1M, which is hopefully plenty.
+ */
+#define ENV_MEM_LAYOUT_SETTINGS \
+       "scriptaddr=0x00000000\0" \
+       "pxefile_addr_r=0x00100000\0" \
+       "kernel_addr_r=0x01000000\0" \
+       "fdt_addr_r=0x02000000\0" \
+       "ramdisk_addr_r=0x02100000\0" \
+
+#define BOOT_TARGET_DEVICES(func) \
+       func(MMC, mmc, 0) \
+       func(USB, usb, 0) \
+       func(PXE, pxe, na) \
+       func(DHCP, dhcp, na)
+#include <config_distro_bootcmd.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+       ENV_DEVICE_SETTINGS \
+       ENV_MEM_LAYOUT_SETTINGS \
+       BOOTENV
+
+#define CONFIG_BOOTDELAY 2
+
+#endif
diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h
deleted file mode 100644 (file)
index 41e975f..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * (C) Copyright 2012 Stephen Warren
- *
- * 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
- * version 2 as published by the Free Software Foundation.
- *
- * 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.
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#include <linux/sizes.h>
-
-/* Architecture, CPU, etc.*/
-#define CONFIG_SYS_GENERIC_BOARD
-#define CONFIG_BCM2835
-#define CONFIG_ARCH_CPU_INIT
-#define CONFIG_SYS_DCACHE_OFF
-/*
- * 2835 is a SKU in a series for which the 2708 is the first or primary SoC,
- * so 2708 has historically been used rather than a dedicated 2835 ID.
- */
-#define CONFIG_MACH_TYPE               MACH_TYPE_BCM2708
-
-/* Enable driver model */
-#define CONFIG_DM
-#define CONFIG_CMD_DM
-#define CONFIG_DM_GPIO
-
-/* Memory layout */
-#define CONFIG_NR_DRAM_BANKS           1
-#define CONFIG_SYS_SDRAM_BASE          0x00000000
-#define CONFIG_SYS_TEXT_BASE           0x00008000
-#define CONFIG_SYS_UBOOT_BASE          CONFIG_SYS_TEXT_BASE
-/*
- * The board really has 256M. However, the VC (VideoCore co-processor) shares
- * the RAM, and uses a configurable portion at the top. We tell U-Boot that a
- * smaller amount of RAM is present in order to avoid stomping on the area
- * the VC uses.
- */
-#define CONFIG_SYS_SDRAM_SIZE          SZ_128M
-#define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_SDRAM_BASE + \
-                                        CONFIG_SYS_SDRAM_SIZE - \
-                                        GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_MALLOC_LEN          SZ_4M
-#define CONFIG_SYS_MEMTEST_START       0x00100000
-#define CONFIG_SYS_MEMTEST_END         0x00200000
-#define CONFIG_LOADADDR                        0x00200000
-
-/* Flash */
-#define CONFIG_SYS_NO_FLASH
-
-/* Devices */
-/* GPIO */
-#define CONFIG_BCM2835_GPIO
-/* LCD */
-#define CONFIG_LCD
-#define CONFIG_LCD_DT_SIMPLEFB
-#define LCD_BPP                                LCD_COLOR16
-/*
- * Prevent allocation of RAM for FB; the real FB address is queried
- * dynamically from the VideoCore co-processor, and comes from RAM
- * not owned by the ARM CPU.
- */
-#define CONFIG_FB_ADDR                 0
-#define CONFIG_VIDEO_BCM2835
-#define CONFIG_SYS_WHITE_ON_BLACK
-
-/* SD/MMC configuration */
-#define CONFIG_GENERIC_MMC
-#define CONFIG_MMC
-#define CONFIG_SDHCI
-#define CONFIG_MMC_SDHCI_IO_ACCESSORS
-#define CONFIG_BCM2835_SDHCI
-
-#define CONFIG_CMD_USB
-#ifdef CONFIG_CMD_USB
-#define CONFIG_USB_DWC2
-#define CONFIG_USB_DWC2_REG_ADDR 0x20980000
-#define CONFIG_USB_STORAGE
-#define CONFIG_USB_HOST_ETHER
-#define CONFIG_USB_ETHER_SMSC95XX
-#define CONFIG_MISC_INIT_R
-#endif
-
-/* Console UART */
-#define CONFIG_PL011_SERIAL
-#define CONFIG_PL011_CLOCK             3000000
-#define CONFIG_PL01x_PORTS             { (void *)0x20201000 }
-#define CONFIG_CONS_INDEX              0
-#define CONFIG_BAUDRATE                        115200
-
-/* Console configuration */
-#define CONFIG_SYS_CBSIZE              1024
-#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE +            \
-                                        sizeof(CONFIG_SYS_PROMPT) + 16)
-
-/* Environment */
-#define CONFIG_ENV_SIZE                        SZ_16K
-#define CONFIG_ENV_IS_NOWHERE
-#define CONFIG_ENV_VARS_UBOOT_CONFIG
-#define CONFIG_SYS_LOAD_ADDR           0x1000000
-#define CONFIG_CONSOLE_MUX
-#define CONFIG_SYS_CONSOLE_IS_IN_ENV
-#define CONFIG_PREBOOT \
-       "if load mmc 0:1 ${loadaddr} /uEnv.txt; then " \
-               "env import -t -r ${loadaddr} ${filesize}; " \
-       "fi"
-
-/* Shell */
-#define CONFIG_SYS_MAXARGS             8
-#define CONFIG_SYS_PROMPT              "U-Boot> "
-#define CONFIG_COMMAND_HISTORY
-
-/* Commands */
-#include <config_cmd_default.h>
-#define CONFIG_CMD_GPIO
-#define CONFIG_CMD_MMC
-#define CONFIG_PARTITION_UUIDS
-#define CONFIG_CMD_PART
-
-/* Device tree support */
-#define CONFIG_OF_BOARD_SETUP
-/* ATAGs support for bootm/bootz */
-#define CONFIG_SETUP_MEMORY_TAGS
-#define CONFIG_CMDLINE_TAG
-#define CONFIG_INITRD_TAG
-
-#include <config_distro_defaults.h>
-
-/* Some things don't make sense on this HW or yet */
-#undef CONFIG_CMD_FPGA
-#undef CONFIG_CMD_SAVEENV
-
-/* Environment */
-#define ENV_DEVICE_SETTINGS \
-       "stdin=serial,lcd\0" \
-       "stdout=serial,lcd\0" \
-       "stderr=serial,lcd\0"
-
-/*
- * Memory layout for where various images get loaded by boot scripts:
- *
- * scriptaddr can be pretty much anywhere that doesn't conflict with something
- *   else. Put it low in memory to avoid conflicts.
- *
- * pxefile_addr_r can be pretty much anywhere that doesn't conflict with
- *   something else. Put it low in memory to avoid conflicts.
- *
- * kernel_addr_r must be within the first 128M of RAM in order for the
- *   kernel's CONFIG_AUTO_ZRELADDR option to work. Since the kernel will
- *   decompress itself to 0x8000 after the start of RAM, kernel_addr_r
- *   should not overlap that area, or the kernel will have to copy itself
- *   somewhere else before decompression. Similarly, the address of any other
- *   data passed to the kernel shouldn't overlap the start of RAM. Pushing
- *   this up to 16M allows for a sizable kernel to be decompressed below the
- *   compressed load address.
- *
- * fdt_addr_r simply shouldn't overlap anything else. Choosing 32M allows for
- *   the compressed kernel to be up to 16M too.
- *
- * ramdisk_addr_r simply shouldn't overlap anything else. Choosing 33M allows
- *   for the FDT/DTB to be up to 1M, which is hopefully plenty.
- */
-#define ENV_MEM_LAYOUT_SETTINGS \
-       "scriptaddr=0x00000000\0" \
-       "pxefile_addr_r=0x00100000\0" \
-       "kernel_addr_r=0x01000000\0" \
-       "fdt_addr_r=0x02000000\0" \
-       "fdtfile=bcm2835-rpi-b.dtb\0" \
-       "ramdisk_addr_r=0x02100000\0" \
-
-#define BOOT_TARGET_DEVICES(func) \
-       func(MMC, mmc, 0) \
-       func(USB, usb, 0) \
-       func(PXE, pxe, na) \
-       func(DHCP, dhcp, na)
-#include <config_distro_bootcmd.h>
-
-#define CONFIG_EXTRA_ENV_SETTINGS \
-       ENV_DEVICE_SETTINGS \
-       ENV_MEM_LAYOUT_SETTINGS \
-       BOOTENV
-
-#define CONFIG_BOOTDELAY 2
-
-#endif
index 5b77db269857468cb42cc27a1aeb030e31d6178c..d5588b12414c54c3dadba4d86ecc450223169695 100644 (file)
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     0x400
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 #define CONFIG_SPL_FAT_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
index dfbf3cb78611ccfc0c7d3659de498e8d34e67973..f2849d794e7fcab4e068ba736654c008b1e3614c 100644 (file)
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     0x400
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 #define CONFIG_SPL_FAT_SUPPORT
 #define CONFIG_SPL_LIBDISK_SUPPORT
index 0d5dba18b1f5972155633071ec0b8d9e94011b87..21e13e54730e35294b88043c26fd31ac25983d16 100644 (file)
 #define CONFIG_SPL_BSS_MAX_SIZE                0x80000         /* 512 KB */
 
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR        0x300 /* address 0x60000 */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SPL_FAT_SUPPORT
index a160329c1d71d39c797e44af03fb46c20ee0c728..7d2c0d2fa75c2e87b49a2d2bb4d6bd6f15e4a95f 100644 (file)
 
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR        0x300 /* address 0x60000 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     0x200 /* 256 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 
 #define CONFIG_SPL_BOARD_INIT
index 2fddef3cab7b5206f3c4f630b56c4360357549dd..deb6bb2b8f643f4e92cc3bf8ce8ff151cb99c822 100644 (file)
 
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS      0x200 /* 256 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SPL_FAT_SUPPORT
index aeabb1b7d5f4ceba8f1d8da8c695fd051bd2d752..87a4efcd5a89377dbe72b91c861d40ee5f9beb88 100644 (file)
 
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS      0x200 /* 256 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SPL_FAT_SUPPORT
index a8790c2f8f40140da7c2fc74af219d0637c6adc3..bc751722e86622abd3ef2db253284a98879a99c5 100644 (file)
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS     0x200 /* 256 KB */
 
 /* FAT sd card locations. */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
 
 #ifdef CONFIG_SPL_OS_BOOT
index 6e7a7fbf28f1d7727d0529dfcad6e19dae21766b..36621a553cdf961ccd677c7b1194d86029567ada 100644 (file)
 #define CONFIG_SPL_FAT_SUPPORT
 #define CONFIG_SPL_LDSCRIPT            "$(CPUDIR)/omap-common/u-boot-spl.lds"
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME        "u-boot.img"
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */
 
 #define CONFIG_SPL_TEXT_BASE           0x40200000 /*CONFIG_SYS_SRAM_START*/
diff --git a/include/configs/uniphier-common.h b/include/configs/uniphier-common.h
deleted file mode 100644 (file)
index 2140fcc..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/* U-boot - Common settings for UniPhier Family */
-
-#ifndef __CONFIG_UNIPHIER_COMMON_H__
-#define __CONFIG_UNIPHIER_COMMON_H__
-
-#if defined(CONFIG_PFC_MICRO_SUPPORT_CARD) &&  \
-                               defined(CONFIG_DCC_MICRO_SUPPORT_CARD)
-# error "Both CONFIG_PFC_MICRO_SUPPORT_CARD and CONFIG_DCC_MICRO_SUPPORT_CARD \
-are defined. Select only one of them."
-#endif
-
-/*
- * Support card address map
- */
-#if defined(CONFIG_PFC_MICRO_SUPPORT_CARD)
-# define CONFIG_SUPPORT_CARD_BASE      0x03f00000
-# define CONFIG_SUPPORT_CARD_ETHER_BASE        (CONFIG_SUPPORT_CARD_BASE + 0x00000000)
-# define CONFIG_SUPPORT_CARD_LED_BASE  (CONFIG_SUPPORT_CARD_BASE + 0x00090000)
-# define CONFIG_SUPPORT_CARD_UART_BASE (CONFIG_SUPPORT_CARD_BASE + 0x000b0000)
-#endif
-
-#if defined(CONFIG_DCC_MICRO_SUPPORT_CARD)
-# define CONFIG_SUPPORT_CARD_BASE      0x08000000
-# define CONFIG_SUPPORT_CARD_ETHER_BASE        (CONFIG_SUPPORT_CARD_BASE + 0x00000000)
-# define CONFIG_SUPPORT_CARD_LED_BASE  (CONFIG_SUPPORT_CARD_BASE + 0x00401630)
-# define CONFIG_SUPPORT_CARD_UART_BASE (CONFIG_SUPPORT_CARD_BASE + 0x00200000)
-#endif
-
-#ifdef CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550
-#define CONFIG_SYS_NS16550_COM1                CONFIG_SUPPORT_CARD_UART_BASE
-#define CONFIG_SYS_NS16550_CLK         12288000
-#define CONFIG_SYS_NS16550_REG_SIZE    -2
-#endif
-
-#define CONFIG_SMC911X_BASE            CONFIG_SUPPORT_CARD_ETHER_BASE
-#define CONFIG_SMC911X_32_BIT
-
-#define CONFIG_SYS_MALLOC_F_LEN  0x2000
-
-/*-----------------------------------------------------------------------
- * MMU and Cache Setting
- *----------------------------------------------------------------------*/
-
-/* Comment out the following to enable L1 cache */
-/* #define CONFIG_SYS_ICACHE_OFF */
-/* #define CONFIG_SYS_DCACHE_OFF */
-
-/* Comment out the following to enable L2 cache */
-#define CONFIG_UNIPHIER_L2CACHE_ON
-
-#define CONFIG_DISPLAY_CPUINFO
-#define CONFIG_DISPLAY_BOARDINFO
-#define CONFIG_BOARD_LATE_INIT
-
-#define CONFIG_SYS_MALLOC_LEN          (4 * 1024 * 1024)
-
-#define CONFIG_TIMESTAMP
-
-/* FLASH related */
-#define CONFIG_MTD_DEVICE
-
-/*
- * uncomment the following to disable FLASH related code.
- */
-/* #define CONFIG_SYS_NO_FLASH */
-
-#define CONFIG_FLASH_CFI_DRIVER
-#define CONFIG_SYS_FLASH_CFI
-
-#define CONFIG_SYS_MAX_FLASH_SECT      256
-#define CONFIG_SYS_MONITOR_BASE                0
-#define CONFIG_SYS_FLASH_BASE          0
-
-/*
- * flash_toggle does not work for out supoort card.
- * We need to use flash_status_poll.
- */
-#define CONFIG_SYS_CFI_FLASH_STATUS_POLL
-
-#define CONFIG_FLASH_SHOW_PROGRESS     45 /* count down from 45/5: 9..1 */
-
-#if defined(CONFIG_PFC_MICRO_SUPPORT_CARD)
-# define CONFIG_SYS_MAX_FLASH_BANKS    1
-# define CONFIG_SYS_FLASH_BANKS_LIST   {0x00000000}
-# define CONFIG_SYS_FLASH_BANKS_SIZES  {0x02000000}
-#endif
-
-#if defined(CONFIG_DCC_MICRO_SUPPORT_CARD)
-# define CONFIG_SYS_MAX_FLASH_BANKS    1
-# define CONFIG_SYS_FLASH_BANKS_LIST   {0x04000000}
-# define CONFIG_SYS_FLASH_BANKS_SIZES  {0x04000000}
-#endif
-
-/* serial console configuration */
-#define CONFIG_BAUDRATE                        115200
-
-#define CONFIG_SYS_GENERIC_BOARD
-
-#if !defined(CONFIG_SPL_BUILD)
-#define CONFIG_USE_ARCH_MEMSET
-#define CONFIG_USE_ARCH_MEMCPY
-#endif
-
-#define CONFIG_SYS_LONGHELP            /* undef to save memory */
-
-#define CONFIG_CMDLINE_EDITING         /* add command line history     */
-#define CONFIG_SYS_CBSIZE              1024    /* Console I/O Buffer Size */
-/* Print Buffer Size */
-#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
-#define CONFIG_SYS_MAXARGS             16      /* max number of command */
-/* Boot Argument Buffer Size */
-#define CONFIG_SYS_BARGSIZE            (CONFIG_SYS_CBSIZE)
-
-#define CONFIG_CONS_INDEX              1
-
-/*
- * For NAND booting the environment is embedded in the U-Boot image. Please take
- * look at the file board/amcc/canyonlands/u-boot-nand.lds for details.
- */
-/* #define CONFIG_ENV_IS_IN_NAND */
-#define CONFIG_ENV_IS_NOWHERE
-#define CONFIG_ENV_SIZE                                0x2000
-#define CONFIG_ENV_OFFSET                      0x0
-/* #define CONFIG_ENV_OFFSET_REDUND    (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) */
-
-/* Time clock 1MHz */
-#define CONFIG_SYS_TIMER_RATE                  1000000
-
-/*
- * By default, ARP timeout is 5 sec.
- * The first ARP request does not seem to work.
- * So we need to retry ARP request anyway.
- * We want to shrink the interval until the second ARP request.
- */
-#define CONFIG_ARP_TIMEOUT     500UL  /* 0.5 msec */
-
-#define CONFIG_SYS_MAX_NAND_DEVICE                     1
-#define CONFIG_SYS_NAND_MAX_CHIPS                      2
-#define CONFIG_SYS_NAND_ONFI_DETECTION
-
-#define CONFIG_NAND_DENALI_ECC_SIZE                    1024
-
-#define CONFIG_SYS_NAND_REGS_BASE                      0x68100000
-#define CONFIG_SYS_NAND_DATA_BASE                      0x68000000
-
-#define CONFIG_SYS_NAND_BASE           (CONFIG_SYS_NAND_DATA_BASE + 0x10)
-
-#define CONFIG_SYS_NAND_USE_FLASH_BBT
-#define CONFIG_SYS_NAND_BAD_BLOCK_POS                  0
-
-/* USB */
-#define CONFIG_USB_MAX_CONTROLLER_COUNT                2
-#define CONFIG_CMD_FAT
-#define CONFIG_FAT_WRITE
-#define CONFIG_DOS_PARTITION
-
-/* memtest works on */
-#define CONFIG_SYS_MEMTEST_START       CONFIG_SYS_SDRAM_BASE
-#define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_SDRAM_BASE + 0x01000000)
-
-#define CONFIG_BOOTDELAY                       3
-#define CONFIG_ZERO_BOOTDELAY_CHECK    /* check for keypress on bootdelay==0 */
-#define CONFIG_AUTOBOOT_KEYED                  1
-#define CONFIG_AUTOBOOT_PROMPT \
-       "Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR              "d"
-#define CONFIG_AUTOBOOT_STOP_STR               " "
-
-/*
- * Network Configuration
- */
-#define CONFIG_ETHADDR                 00:21:83:24:00:00
-#define CONFIG_SERVERIP                        192.168.11.1
-#define CONFIG_IPADDR                  192.168.11.10
-#define CONFIG_GATEWAYIP               192.168.11.1
-#define CONFIG_NETMASK                 255.255.255.0
-
-#define CONFIG_LOADADDR                        0x84000000
-#define CONFIG_SYS_LOAD_ADDR           CONFIG_LOADADDR
-#define CONFIG_BOOTFILE                        "fit.itb"
-
-#define CONFIG_CMDLINE_EDITING         /* add command line history     */
-
-#define CONFIG_BOOTCOMMAND             "run $bootmode"
-
-#define CONFIG_ROOTPATH                        "/nfs/root/path"
-#define CONFIG_NFSBOOTCOMMAND                                          \
-       "setenv bootargs $bootargs root=/dev/nfs rw "                   \
-       "nfsroot=$serverip:$rootpath "                                  \
-       "ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off;" \
-       "tftpboot; bootm;"
-
-#define CONFIG_BOOTARGS                " user_debug=0x1f init=/sbin/init"
-
-#define        CONFIG_EXTRA_ENV_SETTINGS               \
-       "netdev=eth0\0"                         \
-       "image_offset=0x00080000\0"             \
-       "image_size=0x00f00000\0"               \
-       "verify=n\0"                            \
-       "autostart=yes\0"                       \
-       "norboot=run add_default_bootargs;"                             \
-               "bootm $image_offset\0"                                 \
-       "nandboot=run add_default_bootargs;"                            \
-               "nand read $loadaddr $image_offset $image_size;"        \
-               "bootm\0"                                               \
-       "add_default_bootargs=setenv bootargs $bootargs"                \
-               " console=ttyS0,$baudrate\0"                            \
-
-/* Open Firmware flat tree */
-#define CONFIG_OF_LIBFDT
-
-#define CONFIG_HAVE_ARM_SECURE
-
-/* Memory Size & Mapping */
-#define CONFIG_SYS_SDRAM_BASE          CONFIG_SDRAM0_BASE
-
-#if CONFIG_SDRAM0_BASE + CONFIG_SDRAM0_SIZE >= CONFIG_SDRAM1_BASE
-/* Thre is no memory hole */
-#define CONFIG_NR_DRAM_BANKS           1
-#define CONFIG_SYS_SDRAM_SIZE  (CONFIG_SDRAM0_SIZE + CONFIG_SDRAM1_SIZE)
-#else
-#define CONFIG_NR_DRAM_BANKS           2
-#define CONFIG_SYS_SDRAM_SIZE  (CONFIG_SDRAM0_SIZE)
-#endif
-
-#define CONFIG_SYS_TEXT_BASE           0x84000000
-
-#define CONFIG_BOARD_POSTCLK_INIT
-
-#ifndef CONFIG_SPL_BUILD
-#define CONFIG_SKIP_LOWLEVEL_INIT
-#endif
-
-#define CONFIG_SYS_SPL_MALLOC_START    (0x0ff00000)
-#define CONFIG_SYS_SPL_MALLOC_SIZE     (0x00004000)
-
-#define CONFIG_SYS_INIT_SP_ADDR                (0x0ff08000)
-
-#define CONFIG_SPL_FRAMEWORK
-#define CONFIG_SPL_NAND_SUPPORT
-
-#define CONFIG_SPL_LIBCOMMON_SUPPORT   /* for mem_malloc_init */
-#define CONFIG_SPL_LIBGENERIC_SUPPORT
-
-#define CONFIG_SPL_BOARD_INIT
-
-#define CONFIG_SYS_NAND_U_BOOT_OFFS            0x10000
-
-#endif /* __CONFIG_UNIPHIER_COMMON_H__ */
diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h
new file mode 100644 (file)
index 0000000..dd022fb
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * Copyright (C) 2012-2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/* U-boot - Common settings for UniPhier Family */
+
+#ifndef __CONFIG_UNIPHIER_COMMON_H__
+#define __CONFIG_UNIPHIER_COMMON_H__
+
+#if defined(CONFIG_MACH_PH1_PRO4)
+#define CONFIG_DDR_NUM_CH0 2
+#define CONFIG_DDR_NUM_CH1 2
+
+/* Physical start address of SDRAM */
+#define CONFIG_SDRAM0_BASE     0x80000000
+#define CONFIG_SDRAM0_SIZE     0x20000000
+#define CONFIG_SDRAM1_BASE     0xa0000000
+#define CONFIG_SDRAM1_SIZE     0x20000000
+#endif
+
+#if defined(CONFIG_MACH_PH1_LD4)
+#define CONFIG_DDR_NUM_CH0 1
+#define CONFIG_DDR_NUM_CH1 1
+
+/* Physical start address of SDRAM */
+#define CONFIG_SDRAM0_BASE     0x80000000
+#define CONFIG_SDRAM0_SIZE     0x10000000
+#define CONFIG_SDRAM1_BASE     0x90000000
+#define CONFIG_SDRAM1_SIZE     0x10000000
+#endif
+
+#if defined(CONFIG_MACH_PH1_SLD8)
+#define CONFIG_DDR_NUM_CH0 1
+#define CONFIG_DDR_NUM_CH1 1
+
+/* Physical start address of SDRAM */
+#define CONFIG_SDRAM0_BASE     0x80000000
+#define CONFIG_SDRAM0_SIZE     0x10000000
+#define CONFIG_SDRAM1_BASE     0x90000000
+#define CONFIG_SDRAM1_SIZE     0x10000000
+#endif
+
+/*
+ * Support card address map
+ */
+#if defined(CONFIG_PFC_MICRO_SUPPORT_CARD)
+# define CONFIG_SUPPORT_CARD_BASE      0x03f00000
+# define CONFIG_SUPPORT_CARD_ETHER_BASE        (CONFIG_SUPPORT_CARD_BASE + 0x00000000)
+# define CONFIG_SUPPORT_CARD_LED_BASE  (CONFIG_SUPPORT_CARD_BASE + 0x00090000)
+# define CONFIG_SUPPORT_CARD_UART_BASE (CONFIG_SUPPORT_CARD_BASE + 0x000b0000)
+#endif
+
+#if defined(CONFIG_DCC_MICRO_SUPPORT_CARD)
+# define CONFIG_SUPPORT_CARD_BASE      0x08000000
+# define CONFIG_SUPPORT_CARD_ETHER_BASE        (CONFIG_SUPPORT_CARD_BASE + 0x00000000)
+# define CONFIG_SUPPORT_CARD_LED_BASE  (CONFIG_SUPPORT_CARD_BASE + 0x00401630)
+# define CONFIG_SUPPORT_CARD_UART_BASE (CONFIG_SUPPORT_CARD_BASE + 0x00200000)
+#endif
+
+#ifdef CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550
+#define CONFIG_SYS_NS16550_COM1                CONFIG_SUPPORT_CARD_UART_BASE
+#define CONFIG_SYS_NS16550_CLK         12288000
+#define CONFIG_SYS_NS16550_REG_SIZE    -2
+#endif
+
+/* TODO: move to Kconfig and device tree */
+#if 0
+#define CONFIG_SYS_NS16550_SERIAL
+#endif
+
+#define CONFIG_SMC911X
+
+#define CONFIG_SMC911X_BASE            CONFIG_SUPPORT_CARD_ETHER_BASE
+#define CONFIG_SMC911X_32_BIT
+
+#define CONFIG_SYS_MALLOC_F_LEN  0x2000
+
+/*-----------------------------------------------------------------------
+ * MMU and Cache Setting
+ *----------------------------------------------------------------------*/
+
+/* Comment out the following to enable L1 cache */
+/* #define CONFIG_SYS_ICACHE_OFF */
+/* #define CONFIG_SYS_DCACHE_OFF */
+
+/* Comment out the following to enable L2 cache */
+#define CONFIG_UNIPHIER_L2CACHE_ON
+
+#define CONFIG_DISPLAY_CPUINFO
+#define CONFIG_DISPLAY_BOARDINFO
+#define CONFIG_BOARD_EARLY_INIT_R
+#define CONFIG_BOARD_LATE_INIT
+
+#define CONFIG_SYS_MALLOC_LEN          (4 * 1024 * 1024)
+
+#define CONFIG_TIMESTAMP
+
+/* FLASH related */
+#define CONFIG_MTD_DEVICE
+
+/*
+ * uncomment the following to disable FLASH related code.
+ */
+/* #define CONFIG_SYS_NO_FLASH */
+
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_FLASH_CFI
+
+#define CONFIG_SYS_MAX_FLASH_SECT      256
+#define CONFIG_SYS_MONITOR_BASE                0
+#define CONFIG_SYS_FLASH_BASE          0
+
+/*
+ * flash_toggle does not work for out supoort card.
+ * We need to use flash_status_poll.
+ */
+#define CONFIG_SYS_CFI_FLASH_STATUS_POLL
+
+#define CONFIG_FLASH_SHOW_PROGRESS     45 /* count down from 45/5: 9..1 */
+
+#define CONFIG_SYS_MAX_FLASH_BANKS_DETECT 2
+
+/* serial console configuration */
+#define CONFIG_BAUDRATE                        115200
+
+#define CONFIG_SYS_GENERIC_BOARD
+
+#if !defined(CONFIG_SPL_BUILD)
+#define CONFIG_USE_ARCH_MEMSET
+#define CONFIG_USE_ARCH_MEMCPY
+#endif
+
+#define CONFIG_SYS_LONGHELP            /* undef to save memory */
+
+#define CONFIG_CMDLINE_EDITING         /* add command line history     */
+#define CONFIG_SYS_CBSIZE              1024    /* Console I/O Buffer Size */
+/* Print Buffer Size */
+#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_MAXARGS             16      /* max number of command */
+/* Boot Argument Buffer Size */
+#define CONFIG_SYS_BARGSIZE            (CONFIG_SYS_CBSIZE)
+
+#define CONFIG_CONS_INDEX              1
+
+/*
+ * For NAND booting the environment is embedded in the U-Boot image. Please take
+ * look at the file board/amcc/canyonlands/u-boot-nand.lds for details.
+ */
+/* #define CONFIG_ENV_IS_IN_NAND */
+#define CONFIG_ENV_IS_NOWHERE
+#define CONFIG_ENV_SIZE                                0x2000
+#define CONFIG_ENV_OFFSET                      0x0
+/* #define CONFIG_ENV_OFFSET_REDUND    (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) */
+
+/* Time clock 1MHz */
+#define CONFIG_SYS_TIMER_RATE                  1000000
+
+/*
+ * By default, ARP timeout is 5 sec.
+ * The first ARP request does not seem to work.
+ * So we need to retry ARP request anyway.
+ * We want to shrink the interval until the second ARP request.
+ */
+#define CONFIG_ARP_TIMEOUT     500UL  /* 0.5 msec */
+
+#define CONFIG_SYS_MAX_NAND_DEVICE                     1
+#define CONFIG_SYS_NAND_MAX_CHIPS                      2
+#define CONFIG_SYS_NAND_ONFI_DETECTION
+
+#define CONFIG_NAND_DENALI_ECC_SIZE                    1024
+
+#define CONFIG_SYS_NAND_REGS_BASE                      0x68100000
+#define CONFIG_SYS_NAND_DATA_BASE                      0x68000000
+
+#define CONFIG_SYS_NAND_BASE           (CONFIG_SYS_NAND_DATA_BASE + 0x10)
+
+#define CONFIG_SYS_NAND_USE_FLASH_BBT
+#define CONFIG_SYS_NAND_BAD_BLOCK_POS                  0
+
+/* USB */
+#define CONFIG_USB_MAX_CONTROLLER_COUNT                2
+#define CONFIG_CMD_FAT
+#define CONFIG_FAT_WRITE
+#define CONFIG_DOS_PARTITION
+
+/* memtest works on */
+#define CONFIG_SYS_MEMTEST_START       CONFIG_SYS_SDRAM_BASE
+#define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_SDRAM_BASE + 0x01000000)
+
+#define CONFIG_BOOTDELAY                       3
+#define CONFIG_ZERO_BOOTDELAY_CHECK    /* check for keypress on bootdelay==0 */
+#define CONFIG_AUTOBOOT_KEYED                  1
+#define CONFIG_AUTOBOOT_PROMPT \
+       "Press SPACE to abort autoboot in %d seconds\n", bootdelay
+#define CONFIG_AUTOBOOT_DELAY_STR              "d"
+#define CONFIG_AUTOBOOT_STOP_STR               " "
+
+/*
+ * Network Configuration
+ */
+#define CONFIG_ETHADDR                 00:21:83:24:00:00
+#define CONFIG_SERVERIP                        192.168.11.1
+#define CONFIG_IPADDR                  192.168.11.10
+#define CONFIG_GATEWAYIP               192.168.11.1
+#define CONFIG_NETMASK                 255.255.255.0
+
+#define CONFIG_LOADADDR                        0x84000000
+#define CONFIG_SYS_LOAD_ADDR           CONFIG_LOADADDR
+#define CONFIG_BOOTFILE                        "fit.itb"
+
+#define CONFIG_CMDLINE_EDITING         /* add command line history     */
+
+#define CONFIG_BOOTCOMMAND             "run $bootmode"
+
+#define CONFIG_ROOTPATH                        "/nfs/root/path"
+#define CONFIG_NFSBOOTCOMMAND                                          \
+       "setenv bootargs $bootargs root=/dev/nfs rw "                   \
+       "nfsroot=$serverip:$rootpath "                                  \
+       "ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off;" \
+       "tftpboot; bootm;"
+
+#define CONFIG_BOOTARGS                " user_debug=0x1f init=/sbin/init"
+
+#define        CONFIG_EXTRA_ENV_SETTINGS               \
+       "netdev=eth0\0"                         \
+       "image_offset=0x00080000\0"             \
+       "image_size=0x00f00000\0"               \
+       "verify=n\0"                            \
+       "norboot=run add_default_bootargs;"                             \
+               "bootm $image_offset\0"                                 \
+       "nandboot=run add_default_bootargs;"                            \
+               "nand read $loadaddr $image_offset $image_size;"        \
+               "bootm\0"                                               \
+       "add_default_bootargs=setenv bootargs $bootargs"                \
+               " console=ttyS0,$baudrate\0"                            \
+
+/* Open Firmware flat tree */
+#define CONFIG_OF_LIBFDT
+
+#define CONFIG_HAVE_ARM_SECURE
+
+/* Memory Size & Mapping */
+#define CONFIG_SYS_SDRAM_BASE          CONFIG_SDRAM0_BASE
+
+#if CONFIG_SDRAM0_BASE + CONFIG_SDRAM0_SIZE >= CONFIG_SDRAM1_BASE
+/* Thre is no memory hole */
+#define CONFIG_NR_DRAM_BANKS           1
+#define CONFIG_SYS_SDRAM_SIZE  (CONFIG_SDRAM0_SIZE + CONFIG_SDRAM1_SIZE)
+#else
+#define CONFIG_NR_DRAM_BANKS           2
+#define CONFIG_SYS_SDRAM_SIZE  (CONFIG_SDRAM0_SIZE)
+#endif
+
+#define CONFIG_SYS_TEXT_BASE           0x84000000
+
+#if defined(CONFIG_MACH_PH1_LD4) || defined(CONFIG_MACH_PH1_SLD8)
+#define CONFIG_SPL_TEXT_BASE           0x00040000
+#endif
+#if defined(CONFIG_MACH_PH1_PRO4)
+#define CONFIG_SPL_TEXT_BASE           0x00100000
+#endif
+
+#define CONFIG_BOARD_POSTCLK_INIT
+
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_SKIP_LOWLEVEL_INIT
+#endif
+
+#define CONFIG_SYS_SPL_MALLOC_START    (0x0ff00000)
+#define CONFIG_SYS_SPL_MALLOC_SIZE     (0x00004000)
+
+#define CONFIG_SYS_INIT_SP_ADDR                (0x0ff08000)
+
+#define CONFIG_SPL_FRAMEWORK
+#define CONFIG_SPL_NAND_SUPPORT
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT   /* for mem_malloc_init */
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+
+#define CONFIG_SPL_BOARD_INIT
+
+#define CONFIG_SYS_NAND_U_BOOT_OFFS            0x10000
+
+#endif /* __CONFIG_UNIPHIER_COMMON_H__ */
index c39c568ff88435fd9b1c30549707d6ce6fc86417..87b4fffeb9fb262143edaae2599220c04255a959 100644 (file)
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */
 #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS      0x200 /* 256 KB */
-#define CONFIG_SYS_MMC_SD_FS_BOOT_PARTITION    1
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
 #define CONFIG_SPL_LIBDISK_SUPPORT
 #define CONFIG_SPL_FAT_SUPPORT
 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME     "u-boot-dtb.img"
index 47b088973944404ba9e432308f1bcdb14d7a82b9..b40133cb3cd160e66ca66516e1c47e49300a9aff 100644 (file)
@@ -215,13 +215,11 @@ typedef int       wait_queue_head_t;
 #define cond_resched()                 do { } while (0)
 #define yield()                                do { } while (0)
 
-#define __user
 #define __init
 #define __exit
 #define __devinit
 #define __devinitdata
 #define __devinitconst
-#define __iomem
 
 #define kthread_create(...)    __builtin_return_address(0)
 #define kthread_stop(...)      do { } while (0)
@@ -252,8 +250,6 @@ struct cdev {
 #define cdev_add(...)          0
 #define cdev_del(...)          do { } while (0)
 
-#define MAX_ERRNO              4095
-
 #define prandom_u32(...)       0
 
 typedef struct {
index 320197a5209ce8fea5a8dc13ba7b1ecf4e730285..3ceb69752c68a82ed7bde23909dfceabaeae4fe2 100644 (file)
@@ -11,14 +11,12 @@ obj-$(CONFIG_RSA) += rsa/
 obj-$(CONFIG_LZMA) += lzma/
 obj-$(CONFIG_LZO) += lzo/
 obj-$(CONFIG_ZLIB) += zlib/
+obj-$(CONFIG_BZIP2) += bzip2/
 obj-$(CONFIG_TIZEN) += tizen/
+obj-$(CONFIG_OF_LIBFDT) += libfdt/
+obj-$(CONFIG_FIT) += libfdt/
 
 obj-$(CONFIG_AES) += aes.o
-obj-$(CONFIG_BZIP2) += bzlib.o
-obj-$(CONFIG_BZIP2) += bzlib_crctable.o
-obj-$(CONFIG_BZIP2) += bzlib_decompress.o
-obj-$(CONFIG_BZIP2) += bzlib_randtable.o
-obj-$(CONFIG_BZIP2) += bzlib_huffman.o
 obj-$(CONFIG_USB_TTY) += circbuf.o
 obj-y += crc7.o
 obj-y += crc8.o
diff --git a/lib/bzip2/Makefile b/lib/bzip2/Makefile
new file mode 100644 (file)
index 0000000..929c24e
--- /dev/null
@@ -0,0 +1,2 @@
+obj-y += bzlib.o bzlib_crctable.o bzlib_decompress.o \
+       bzlib_randtable.o bzlib_huffman.o
diff --git a/lib/bzip2/bzlib.c b/lib/bzip2/bzlib.c
new file mode 100644 (file)
index 0000000..5844e18
--- /dev/null
@@ -0,0 +1,1601 @@
+#include <config.h>
+#include <common.h>
+#include <watchdog.h>
+
+/*
+ * This file is a modified version of bzlib.c from the bzip2-1.0.2
+ * distribution which can be found at http://sources.redhat.com/bzip2/
+ */
+
+/*-------------------------------------------------------------*/
+/*--- Library top-level functions.                          ---*/
+/*---                                               bzlib.c ---*/
+/*-------------------------------------------------------------*/
+
+/*--
+  This file is a part of bzip2 and/or libbzip2, a program and
+  library for lossless, block-sorting data compression.
+
+  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+
+  2. The origin of this software must not be misrepresented; you must
+     not claim that you wrote the original software.  If you use this
+     software in a product, an acknowledgment in the product
+     documentation would be appreciated but is not required.
+
+  3. Altered source versions must be plainly marked as such, and must
+     not be misrepresented as being the original software.
+
+  4. The name of the author may not be used to endorse or promote
+     products derived from this software without specific prior written
+     permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+  Julian Seward, Cambridge, UK.
+  jseward@acm.org
+  bzip2/libbzip2 version 1.0 of 21 March 2000
+
+  This program is based on (at least) the work of:
+     Mike Burrows
+     David Wheeler
+     Peter Fenwick
+     Alistair Moffat
+     Radford Neal
+     Ian H. Witten
+     Robert Sedgewick
+     Jon L. Bentley
+
+  For more information on these sources, see the manual.
+--*/
+
+/*--
+   CHANGES
+   ~~~~~~~
+   0.9.0 -- original version.
+
+   0.9.0a/b -- no changes in this file.
+
+   0.9.0c
+      * made zero-length BZ_FLUSH work correctly in bzCompress().
+      * fixed bzWrite/bzRead to ignore zero-length requests.
+      * fixed bzread to correctly handle read requests after EOF.
+      * wrong parameter order in call to bzDecompressInit in
+       bzBuffToBuffDecompress.  Fixed.
+--*/
+
+#include "bzlib_private.h"
+
+/*---------------------------------------------------*/
+/*--- Compression stuff                           ---*/
+/*---------------------------------------------------*/
+
+
+/*---------------------------------------------------*/
+#ifndef BZ_NO_STDIO
+void BZ2_bz__AssertH__fail ( int errcode )
+{
+   fprintf(stderr,
+      "\n\nbzip2/libbzip2: internal error number %d.\n"
+      "This is a bug in bzip2/libbzip2, %s.\n"
+      "Please report it to me at: jseward@acm.org.  If this happened\n"
+      "when you were using some program which uses libbzip2 as a\n"
+      "component, you should also report this bug to the author(s)\n"
+      "of that program.  Please make an effort to report this bug;\n"
+      "timely and accurate bug reports eventually lead to higher\n"
+      "quality software.  Thanks.  Julian Seward, 30 December 2001.\n\n",
+      errcode,
+      BZ2_bzlibVersion()
+   );
+
+   if (errcode == 1007) {
+   fprintf(stderr,
+      "\n*** A special note about internal error number 1007 ***\n"
+      "\n"
+      "Experience suggests that a common cause of i.e. 1007\n"
+      "is unreliable memory or other hardware.  The 1007 assertion\n"
+      "just happens to cross-check the results of huge numbers of\n"
+      "memory reads/writes, and so acts (unintendedly) as a stress\n"
+      "test of your memory system.\n"
+      "\n"
+      "I suggest the following: try compressing the file again,\n"
+      "possibly monitoring progress in detail with the -vv flag.\n"
+      "\n"
+      "* If the error cannot be reproduced, and/or happens at different\n"
+      "  points in compression, you may have a flaky memory system.\n"
+      "  Try a memory-test program.  I have used Memtest86\n"
+      "  (www.memtest86.com).  At the time of writing it is free (GPLd).\n"
+      "  Memtest86 tests memory much more thorougly than your BIOSs\n"
+      "  power-on test, and may find failures that the BIOS doesn't.\n"
+      "\n"
+      "* If the error can be repeatably reproduced, this is a bug in\n"
+      "  bzip2, and I would very much like to hear about it.  Please\n"
+      "  let me know, and, ideally, save a copy of the file causing the\n"
+      "  problem -- without which I will be unable to investigate it.\n"
+      "\n"
+   );
+   }
+
+   exit(3);
+}
+#endif
+
+
+/*---------------------------------------------------*/
+static
+int bz_config_ok ( void )
+{
+   if (sizeof(int)   != 4) return 0;
+   if (sizeof(short) != 2) return 0;
+   if (sizeof(char)  != 1) return 0;
+   return 1;
+}
+
+
+/*---------------------------------------------------*/
+static
+void* default_bzalloc ( void* opaque, Int32 items, Int32 size )
+{
+   void* v = malloc ( items * size );
+   return v;
+}
+
+static
+void default_bzfree ( void* opaque, void* addr )
+{
+   if (addr != NULL) free ( addr );
+}
+
+#ifndef BZ_NO_COMPRESS
+/*---------------------------------------------------*/
+static
+void prepare_new_block ( EState* s )
+{
+   Int32 i;
+   s->nblock = 0;
+   s->numZ = 0;
+   s->state_out_pos = 0;
+   BZ_INITIALISE_CRC ( s->blockCRC );
+   for (i = 0; i < 256; i++) s->inUse[i] = False;
+   s->blockNo++;
+}
+
+
+/*---------------------------------------------------*/
+static
+void init_RL ( EState* s )
+{
+   s->state_in_ch  = 256;
+   s->state_in_len = 0;
+}
+
+
+static
+Bool isempty_RL ( EState* s )
+{
+   if (s->state_in_ch < 256 && s->state_in_len > 0)
+      return False; else
+      return True;
+}
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzCompressInit)
+                   ( bz_stream* strm,
+                    int        blockSize100k,
+                    int        verbosity,
+                    int        workFactor )
+{
+   Int32   n;
+   EState* s;
+
+   if (!bz_config_ok()) return BZ_CONFIG_ERROR;
+
+   if (strm == NULL ||
+       blockSize100k < 1 || blockSize100k > 9 ||
+       workFactor < 0 || workFactor > 250)
+     return BZ_PARAM_ERROR;
+
+   if (workFactor == 0) workFactor = 30;
+   if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
+   if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
+
+   s = BZALLOC( sizeof(EState) );
+   if (s == NULL) return BZ_MEM_ERROR;
+   s->strm = strm;
+
+   s->arr1 = NULL;
+   s->arr2 = NULL;
+   s->ftab = NULL;
+
+   n       = 100000 * blockSize100k;
+   s->arr1 = BZALLOC( n                  * sizeof(UInt32) );
+   s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
+   s->ftab = BZALLOC( 65537              * sizeof(UInt32) );
+
+   if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
+      if (s->arr1 != NULL) BZFREE(s->arr1);
+      if (s->arr2 != NULL) BZFREE(s->arr2);
+      if (s->ftab != NULL) BZFREE(s->ftab);
+      if (s       != NULL) BZFREE(s);
+      return BZ_MEM_ERROR;
+   }
+
+   s->blockNo           = 0;
+   s->state             = BZ_S_INPUT;
+   s->mode              = BZ_M_RUNNING;
+   s->combinedCRC       = 0;
+   s->blockSize100k     = blockSize100k;
+   s->nblockMAX         = 100000 * blockSize100k - 19;
+   s->verbosity         = verbosity;
+   s->workFactor        = workFactor;
+
+   s->block             = (UChar*)s->arr2;
+   s->mtfv              = (UInt16*)s->arr1;
+   s->zbits             = NULL;
+   s->ptr               = (UInt32*)s->arr1;
+
+   strm->state          = s;
+   strm->total_in_lo32  = 0;
+   strm->total_in_hi32  = 0;
+   strm->total_out_lo32 = 0;
+   strm->total_out_hi32 = 0;
+   init_RL ( s );
+   prepare_new_block ( s );
+   return BZ_OK;
+}
+
+
+/*---------------------------------------------------*/
+static
+void add_pair_to_block ( EState* s )
+{
+   Int32 i;
+   UChar ch = (UChar)(s->state_in_ch);
+   for (i = 0; i < s->state_in_len; i++) {
+      BZ_UPDATE_CRC( s->blockCRC, ch );
+   }
+   s->inUse[s->state_in_ch] = True;
+   switch (s->state_in_len) {
+      case 1:
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        break;
+      case 2:
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        break;
+      case 3:
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        break;
+      default:
+        s->inUse[s->state_in_len-4] = True;
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        s->block[s->nblock] = (UChar)ch; s->nblock++;
+        s->block[s->nblock] = ((UChar)(s->state_in_len-4));
+        s->nblock++;
+        break;
+   }
+}
+
+
+/*---------------------------------------------------*/
+static
+void flush_RL ( EState* s )
+{
+   if (s->state_in_ch < 256) add_pair_to_block ( s );
+   init_RL ( s );
+}
+
+
+/*---------------------------------------------------*/
+#define ADD_CHAR_TO_BLOCK(zs,zchh0)               \
+{                                                 \
+   UInt32 zchh = (UInt32)(zchh0);                 \
+   /*-- fast track the common case --*/           \
+   if (zchh != zs->state_in_ch &&                 \
+       zs->state_in_len == 1) {                   \
+      UChar ch = (UChar)(zs->state_in_ch);        \
+      BZ_UPDATE_CRC( zs->blockCRC, ch );          \
+      zs->inUse[zs->state_in_ch] = True;          \
+      zs->block[zs->nblock] = (UChar)ch;          \
+      zs->nblock++;                               \
+      zs->state_in_ch = zchh;                     \
+   }                                              \
+   else                                           \
+   /*-- general, uncommon cases --*/              \
+   if (zchh != zs->state_in_ch ||                 \
+      zs->state_in_len == 255) {                  \
+      if (zs->state_in_ch < 256)                  \
+        add_pair_to_block ( zs );                \
+      zs->state_in_ch = zchh;                     \
+      zs->state_in_len = 1;                       \
+   } else {                                       \
+      zs->state_in_len++;                         \
+   }                                              \
+}
+
+
+/*---------------------------------------------------*/
+static
+Bool copy_input_until_stop ( EState* s )
+{
+   Bool progress_in = False;
+
+   if (s->mode == BZ_M_RUNNING) {
+
+      /*-- fast track the common case --*/
+      while (True) {
+        /*-- block full? --*/
+        if (s->nblock >= s->nblockMAX) break;
+        /*-- no input? --*/
+        if (s->strm->avail_in == 0) break;
+        progress_in = True;
+        ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
+        s->strm->next_in++;
+        s->strm->avail_in--;
+        s->strm->total_in_lo32++;
+        if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
+      }
+
+   } else {
+
+      /*-- general, uncommon case --*/
+      while (True) {
+        /*-- block full? --*/
+        if (s->nblock >= s->nblockMAX) break;
+        /*-- no input? --*/
+        if (s->strm->avail_in == 0) break;
+        /*-- flush/finish end? --*/
+        if (s->avail_in_expect == 0) break;
+        progress_in = True;
+        ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
+        s->strm->next_in++;
+        s->strm->avail_in--;
+        s->strm->total_in_lo32++;
+        if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
+        s->avail_in_expect--;
+      }
+   }
+   return progress_in;
+}
+
+
+/*---------------------------------------------------*/
+static
+Bool copy_output_until_stop ( EState* s )
+{
+   Bool progress_out = False;
+
+   while (True) {
+
+      /*-- no output space? --*/
+      if (s->strm->avail_out == 0) break;
+
+      /*-- block done? --*/
+      if (s->state_out_pos >= s->numZ) break;
+
+      progress_out = True;
+      *(s->strm->next_out) = s->zbits[s->state_out_pos];
+      s->state_out_pos++;
+      s->strm->avail_out--;
+      s->strm->next_out++;
+      s->strm->total_out_lo32++;
+      if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
+   }
+
+   return progress_out;
+}
+
+
+/*---------------------------------------------------*/
+static
+Bool handle_compress ( bz_stream* strm )
+{
+   Bool progress_in  = False;
+   Bool progress_out = False;
+   EState* s = strm->state;
+
+   while (True) {
+
+      if (s->state == BZ_S_OUTPUT) {
+        progress_out |= copy_output_until_stop ( s );
+        if (s->state_out_pos < s->numZ) break;
+        if (s->mode == BZ_M_FINISHING &&
+            s->avail_in_expect == 0 &&
+            isempty_RL(s)) break;
+        prepare_new_block ( s );
+        s->state = BZ_S_INPUT;
+        if (s->mode == BZ_M_FLUSHING &&
+            s->avail_in_expect == 0 &&
+            isempty_RL(s)) break;
+      }
+
+      if (s->state == BZ_S_INPUT) {
+        progress_in |= copy_input_until_stop ( s );
+        if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
+           flush_RL ( s );
+           BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) );
+           s->state = BZ_S_OUTPUT;
+        }
+        else
+        if (s->nblock >= s->nblockMAX) {
+           BZ2_compressBlock ( s, False );
+           s->state = BZ_S_OUTPUT;
+        }
+        else
+        if (s->strm->avail_in == 0) {
+           break;
+        }
+      }
+
+   }
+
+   return progress_in || progress_out;
+}
+
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
+{
+   Bool progress;
+   EState* s;
+   if (strm == NULL) return BZ_PARAM_ERROR;
+   s = strm->state;
+   if (s == NULL) return BZ_PARAM_ERROR;
+   if (s->strm != strm) return BZ_PARAM_ERROR;
+
+   preswitch:
+   switch (s->mode) {
+
+      case BZ_M_IDLE:
+        return BZ_SEQUENCE_ERROR;
+
+      case BZ_M_RUNNING:
+        if (action == BZ_RUN) {
+           progress = handle_compress ( strm );
+           return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
+        }
+        else
+        if (action == BZ_FLUSH) {
+           s->avail_in_expect = strm->avail_in;
+           s->mode = BZ_M_FLUSHING;
+           goto preswitch;
+        }
+        else
+        if (action == BZ_FINISH) {
+           s->avail_in_expect = strm->avail_in;
+           s->mode = BZ_M_FINISHING;
+           goto preswitch;
+        }
+        else
+           return BZ_PARAM_ERROR;
+
+      case BZ_M_FLUSHING:
+        if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
+        if (s->avail_in_expect != s->strm->avail_in)
+           return BZ_SEQUENCE_ERROR;
+        progress = handle_compress ( strm );
+        if (s->avail_in_expect > 0 || !isempty_RL(s) ||
+            s->state_out_pos < s->numZ) return BZ_FLUSH_OK;
+        s->mode = BZ_M_RUNNING;
+        return BZ_RUN_OK;
+
+      case BZ_M_FINISHING:
+        if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
+        if (s->avail_in_expect != s->strm->avail_in)
+           return BZ_SEQUENCE_ERROR;
+        progress = handle_compress ( strm );
+        if (!progress) return BZ_SEQUENCE_ERROR;
+        if (s->avail_in_expect > 0 || !isempty_RL(s) ||
+            s->state_out_pos < s->numZ) return BZ_FINISH_OK;
+        s->mode = BZ_M_IDLE;
+        return BZ_STREAM_END;
+   }
+   return BZ_OK; /*--not reached--*/
+}
+
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzCompressEnd)  ( bz_stream *strm )
+{
+   EState* s;
+   if (strm == NULL) return BZ_PARAM_ERROR;
+   s = strm->state;
+   if (s == NULL) return BZ_PARAM_ERROR;
+   if (s->strm != strm) return BZ_PARAM_ERROR;
+
+   if (s->arr1 != NULL) BZFREE(s->arr1);
+   if (s->arr2 != NULL) BZFREE(s->arr2);
+   if (s->ftab != NULL) BZFREE(s->ftab);
+   BZFREE(strm->state);
+
+   strm->state = NULL;
+
+   return BZ_OK;
+}
+#endif /* BZ_NO_COMPRESS */
+
+/*---------------------------------------------------*/
+/*--- Decompression stuff                         ---*/
+/*---------------------------------------------------*/
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzDecompressInit)
+                    ( bz_stream* strm,
+                      int        verbosity,
+                      int        small )
+{
+   DState* s;
+
+   if (!bz_config_ok()) return BZ_CONFIG_ERROR;
+
+   if (strm == NULL) return BZ_PARAM_ERROR;
+   if (small != 0 && small != 1) return BZ_PARAM_ERROR;
+   if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR;
+
+   if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
+   if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
+
+   s = BZALLOC( sizeof(DState) );
+   if (s == NULL) return BZ_MEM_ERROR;
+   s->strm                  = strm;
+   strm->state              = s;
+   s->state                 = BZ_X_MAGIC_1;
+   s->bsLive                = 0;
+   s->bsBuff                = 0;
+   s->calculatedCombinedCRC = 0;
+   strm->total_in_lo32      = 0;
+   strm->total_in_hi32      = 0;
+   strm->total_out_lo32     = 0;
+   strm->total_out_hi32     = 0;
+   s->smallDecompress       = (Bool)small;
+   s->ll4                   = NULL;
+   s->ll16                  = NULL;
+   s->tt                    = NULL;
+   s->currBlockNo           = 0;
+   s->verbosity             = verbosity;
+
+   return BZ_OK;
+}
+
+
+/*---------------------------------------------------*/
+static
+void unRLE_obuf_to_output_FAST ( DState* s )
+{
+   UChar k1;
+
+   if (s->blockRandomised) {
+
+      while (True) {
+        /* try to finish existing run */
+        while (True) {
+           if (s->strm->avail_out == 0) return;
+           if (s->state_out_len == 0) break;
+           *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
+           BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
+           s->state_out_len--;
+           s->strm->next_out++;
+           s->strm->avail_out--;
+           s->strm->total_out_lo32++;
+           if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
+        }
+
+        /* can a new run be started? */
+        if (s->nblock_used == s->save_nblock+1) return;
+
+
+        s->state_out_len = 1;
+        s->state_out_ch = s->k0;
+        BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+        k1 ^= BZ_RAND_MASK; s->nblock_used++;
+        if (s->nblock_used == s->save_nblock+1) continue;
+        if (k1 != s->k0) { s->k0 = k1; continue; };
+
+        s->state_out_len = 2;
+        BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+        k1 ^= BZ_RAND_MASK; s->nblock_used++;
+        if (s->nblock_used == s->save_nblock+1) continue;
+        if (k1 != s->k0) { s->k0 = k1; continue; };
+
+        s->state_out_len = 3;
+        BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+        k1 ^= BZ_RAND_MASK; s->nblock_used++;
+        if (s->nblock_used == s->save_nblock+1) continue;
+        if (k1 != s->k0) { s->k0 = k1; continue; };
+
+        BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+        k1 ^= BZ_RAND_MASK; s->nblock_used++;
+        s->state_out_len = ((Int32)k1) + 4;
+        BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
+        s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
+      }
+
+   } else {
+
+      /* restore */
+      UInt32        c_calculatedBlockCRC = s->calculatedBlockCRC;
+      UChar         c_state_out_ch       = s->state_out_ch;
+      Int32         c_state_out_len      = s->state_out_len;
+      Int32         c_nblock_used        = s->nblock_used;
+      Int32         c_k0                 = s->k0;
+      UInt32*       c_tt                 = s->tt;
+      UInt32        c_tPos               = s->tPos;
+      char*         cs_next_out          = s->strm->next_out;
+      unsigned int  cs_avail_out         = s->strm->avail_out;
+      /* end restore */
+
+      UInt32       avail_out_INIT = cs_avail_out;
+      Int32        s_save_nblockPP = s->save_nblock+1;
+      unsigned int total_out_lo32_old;
+
+      while (True) {
+
+        /* try to finish existing run */
+        if (c_state_out_len > 0) {
+           while (True) {
+              if (cs_avail_out == 0) goto return_notr;
+              if (c_state_out_len == 1) break;
+              *( (UChar*)(cs_next_out) ) = c_state_out_ch;
+              BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
+              c_state_out_len--;
+              cs_next_out++;
+              cs_avail_out--;
+           }
+           s_state_out_len_eq_one:
+           {
+              if (cs_avail_out == 0) {
+                 c_state_out_len = 1; goto return_notr;
+              };
+              *( (UChar*)(cs_next_out) ) = c_state_out_ch;
+              BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
+              cs_next_out++;
+              cs_avail_out--;
+           }
+        }
+        /* can a new run be started? */
+        if (c_nblock_used == s_save_nblockPP) {
+           c_state_out_len = 0; goto return_notr;
+        };
+        c_state_out_ch = c_k0;
+        BZ_GET_FAST_C(k1); c_nblock_used++;
+        if (k1 != c_k0) {
+           c_k0 = k1; goto s_state_out_len_eq_one;
+        };
+        if (c_nblock_used == s_save_nblockPP)
+           goto s_state_out_len_eq_one;
+
+        c_state_out_len = 2;
+        BZ_GET_FAST_C(k1); c_nblock_used++;
+        if (c_nblock_used == s_save_nblockPP) continue;
+        if (k1 != c_k0) { c_k0 = k1; continue; };
+
+        c_state_out_len = 3;
+        BZ_GET_FAST_C(k1); c_nblock_used++;
+        if (c_nblock_used == s_save_nblockPP) continue;
+        if (k1 != c_k0) { c_k0 = k1; continue; };
+
+        BZ_GET_FAST_C(k1); c_nblock_used++;
+        c_state_out_len = ((Int32)k1) + 4;
+        BZ_GET_FAST_C(c_k0); c_nblock_used++;
+      }
+
+      return_notr:
+      total_out_lo32_old = s->strm->total_out_lo32;
+      s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out);
+      if (s->strm->total_out_lo32 < total_out_lo32_old)
+        s->strm->total_out_hi32++;
+
+      /* save */
+      s->calculatedBlockCRC = c_calculatedBlockCRC;
+      s->state_out_ch       = c_state_out_ch;
+      s->state_out_len      = c_state_out_len;
+      s->nblock_used        = c_nblock_used;
+      s->k0                 = c_k0;
+      s->tt                 = c_tt;
+      s->tPos               = c_tPos;
+      s->strm->next_out     = cs_next_out;
+      s->strm->avail_out    = cs_avail_out;
+      /* end save */
+   }
+}
+
+
+/*---------------------------------------------------*/
+__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
+{
+   Int32 nb, na, mid;
+   nb = 0;
+   na = 256;
+   do {
+      mid = (nb + na) >> 1;
+      if (indx >= cftab[mid]) nb = mid; else na = mid;
+   }
+   while (na - nb != 1);
+   return nb;
+}
+
+
+/*---------------------------------------------------*/
+static
+void unRLE_obuf_to_output_SMALL ( DState* s )
+{
+   UChar k1;
+
+   if (s->blockRandomised) {
+
+      while (True) {
+        /* try to finish existing run */
+        while (True) {
+           if (s->strm->avail_out == 0) return;
+           if (s->state_out_len == 0) break;
+           *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
+           BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
+           s->state_out_len--;
+           s->strm->next_out++;
+           s->strm->avail_out--;
+           s->strm->total_out_lo32++;
+           if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
+        }
+
+        /* can a new run be started? */
+        if (s->nblock_used == s->save_nblock+1) return;
+
+
+        s->state_out_len = 1;
+        s->state_out_ch = s->k0;
+        BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+        k1 ^= BZ_RAND_MASK; s->nblock_used++;
+        if (s->nblock_used == s->save_nblock+1) continue;
+        if (k1 != s->k0) { s->k0 = k1; continue; };
+
+        s->state_out_len = 2;
+        BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+        k1 ^= BZ_RAND_MASK; s->nblock_used++;
+        if (s->nblock_used == s->save_nblock+1) continue;
+        if (k1 != s->k0) { s->k0 = k1; continue; };
+
+        s->state_out_len = 3;
+        BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+        k1 ^= BZ_RAND_MASK; s->nblock_used++;
+        if (s->nblock_used == s->save_nblock+1) continue;
+        if (k1 != s->k0) { s->k0 = k1; continue; };
+
+        BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+        k1 ^= BZ_RAND_MASK; s->nblock_used++;
+        s->state_out_len = ((Int32)k1) + 4;
+        BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
+        s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
+      }
+
+   } else {
+
+      while (True) {
+        /* try to finish existing run */
+        while (True) {
+           if (s->strm->avail_out == 0) return;
+           if (s->state_out_len == 0) break;
+           *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
+           BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
+           s->state_out_len--;
+           s->strm->next_out++;
+           s->strm->avail_out--;
+           s->strm->total_out_lo32++;
+           if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
+        }
+
+        /* can a new run be started? */
+        if (s->nblock_used == s->save_nblock+1) return;
+
+        s->state_out_len = 1;
+        s->state_out_ch = s->k0;
+        BZ_GET_SMALL(k1); s->nblock_used++;
+        if (s->nblock_used == s->save_nblock+1) continue;
+        if (k1 != s->k0) { s->k0 = k1; continue; };
+
+        s->state_out_len = 2;
+        BZ_GET_SMALL(k1); s->nblock_used++;
+        if (s->nblock_used == s->save_nblock+1) continue;
+        if (k1 != s->k0) { s->k0 = k1; continue; };
+
+        s->state_out_len = 3;
+        BZ_GET_SMALL(k1); s->nblock_used++;
+        if (s->nblock_used == s->save_nblock+1) continue;
+        if (k1 != s->k0) { s->k0 = k1; continue; };
+
+        BZ_GET_SMALL(k1); s->nblock_used++;
+        s->state_out_len = ((Int32)k1) + 4;
+        BZ_GET_SMALL(s->k0); s->nblock_used++;
+      }
+
+   }
+}
+
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
+{
+   DState* s;
+   if (strm == NULL) return BZ_PARAM_ERROR;
+   s = strm->state;
+   if (s == NULL) return BZ_PARAM_ERROR;
+   if (s->strm != strm) return BZ_PARAM_ERROR;
+
+   while (True) {
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+       WATCHDOG_RESET();
+#endif
+      if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
+      if (s->state == BZ_X_OUTPUT) {
+        if (s->smallDecompress)
+           unRLE_obuf_to_output_SMALL ( s ); else
+           unRLE_obuf_to_output_FAST  ( s );
+        if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
+           BZ_FINALISE_CRC ( s->calculatedBlockCRC );
+           if (s->verbosity >= 3)
+              VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC,
+                         s->calculatedBlockCRC );
+           if (s->verbosity >= 2) VPrintf0 ( "]" );
+           if (s->calculatedBlockCRC != s->storedBlockCRC)
+              return BZ_DATA_ERROR;
+           s->calculatedCombinedCRC
+              = (s->calculatedCombinedCRC << 1) |
+                   (s->calculatedCombinedCRC >> 31);
+           s->calculatedCombinedCRC ^= s->calculatedBlockCRC;
+           s->state = BZ_X_BLKHDR_1;
+        } else {
+           return BZ_OK;
+        }
+      }
+      if (s->state >= BZ_X_MAGIC_1) {
+        Int32 r = BZ2_decompress ( s );
+        if (r == BZ_STREAM_END) {
+           if (s->verbosity >= 3)
+              VPrintf2 ( "\n    combined CRCs: stored = 0x%x, computed = 0x%x",
+                         s->storedCombinedCRC, s->calculatedCombinedCRC );
+           if (s->calculatedCombinedCRC != s->storedCombinedCRC)
+              return BZ_DATA_ERROR;
+           return r;
+        }
+        if (s->state != BZ_X_OUTPUT) return r;
+      }
+   }
+
+   AssertH ( 0, 6001 );
+
+   return 0;  /*NOTREACHED*/
+}
+
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzDecompressEnd)  ( bz_stream *strm )
+{
+   DState* s;
+   if (strm == NULL) return BZ_PARAM_ERROR;
+   s = strm->state;
+   if (s == NULL) return BZ_PARAM_ERROR;
+   if (s->strm != strm) return BZ_PARAM_ERROR;
+
+   if (s->tt   != NULL) BZFREE(s->tt);
+   if (s->ll16 != NULL) BZFREE(s->ll16);
+   if (s->ll4  != NULL) BZFREE(s->ll4);
+
+   BZFREE(strm->state);
+   strm->state = NULL;
+
+   return BZ_OK;
+}
+
+
+#ifndef BZ_NO_STDIO
+/*---------------------------------------------------*/
+/*--- File I/O stuff                              ---*/
+/*---------------------------------------------------*/
+
+#define BZ_SETERR(eee)                    \
+{                                         \
+   if (bzerror != NULL) *bzerror = eee;   \
+   if (bzf != NULL) bzf->lastErr = eee;   \
+}
+
+typedef
+   struct {
+      FILE*     handle;
+      Char      buf[BZ_MAX_UNUSED];
+      Int32     bufN;
+      Bool      writing;
+      bz_stream strm;
+      Int32     lastErr;
+      Bool      initialisedOk;
+   }
+   bzFile;
+
+
+/*---------------------------------------------*/
+static Bool myfeof ( FILE* f )
+{
+   Int32 c = fgetc ( f );
+   if (c == EOF) return True;
+   ungetc ( c, f );
+   return False;
+}
+
+
+/*---------------------------------------------------*/
+BZFILE* BZ_API(BZ2_bzWriteOpen)
+                   ( int*  bzerror,
+                     FILE* f,
+                     int   blockSize100k,
+                     int   verbosity,
+                     int   workFactor )
+{
+   Int32   ret;
+   bzFile* bzf = NULL;
+
+   BZ_SETERR(BZ_OK);
+
+   if (f == NULL ||
+       (blockSize100k < 1 || blockSize100k > 9) ||
+       (workFactor < 0 || workFactor > 250) ||
+       (verbosity < 0 || verbosity > 4))
+      { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
+
+   if (ferror(f))
+      { BZ_SETERR(BZ_IO_ERROR); return NULL; };
+
+   bzf = malloc ( sizeof(bzFile) );
+   if (bzf == NULL)
+      { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
+
+   BZ_SETERR(BZ_OK);
+   bzf->initialisedOk = False;
+   bzf->bufN          = 0;
+   bzf->handle        = f;
+   bzf->writing       = True;
+   bzf->strm.bzalloc  = NULL;
+   bzf->strm.bzfree   = NULL;
+   bzf->strm.opaque   = NULL;
+
+   if (workFactor == 0) workFactor = 30;
+   ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k,
+                             verbosity, workFactor );
+   if (ret != BZ_OK)
+      { BZ_SETERR(ret); free(bzf); return NULL; };
+
+   bzf->strm.avail_in = 0;
+   bzf->initialisedOk = True;
+   return bzf;
+}
+
+
+/*---------------------------------------------------*/
+void BZ_API(BZ2_bzWrite)
+            ( int*    bzerror,
+              BZFILE* b,
+              void*   buf,
+              int     len )
+{
+   Int32 n, n2, ret;
+   bzFile* bzf = (bzFile*)b;
+
+   BZ_SETERR(BZ_OK);
+   if (bzf == NULL || buf == NULL || len < 0)
+      { BZ_SETERR(BZ_PARAM_ERROR); return; };
+   if (!(bzf->writing))
+      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
+   if (ferror(bzf->handle))
+      { BZ_SETERR(BZ_IO_ERROR); return; };
+
+   if (len == 0)
+      { BZ_SETERR(BZ_OK); return; };
+
+   bzf->strm.avail_in = len;
+   bzf->strm.next_in  = buf;
+
+   while (True) {
+      bzf->strm.avail_out = BZ_MAX_UNUSED;
+      bzf->strm.next_out = bzf->buf;
+      ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN );
+      if (ret != BZ_RUN_OK)
+        { BZ_SETERR(ret); return; };
+
+      if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
+        n = BZ_MAX_UNUSED - bzf->strm.avail_out;
+        n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
+                      n, bzf->handle );
+        if (n != n2 || ferror(bzf->handle))
+           { BZ_SETERR(BZ_IO_ERROR); return; };
+      }
+
+      if (bzf->strm.avail_in == 0)
+        { BZ_SETERR(BZ_OK); return; };
+   }
+}
+
+
+/*---------------------------------------------------*/
+void BZ_API(BZ2_bzWriteClose)
+                 ( int*          bzerror,
+                   BZFILE*       b,
+                   int           abandon,
+                   unsigned int* nbytes_in,
+                   unsigned int* nbytes_out )
+{
+   BZ2_bzWriteClose64 ( bzerror, b, abandon,
+                       nbytes_in, NULL, nbytes_out, NULL );
+}
+
+
+void BZ_API(BZ2_bzWriteClose64)
+                 ( int*          bzerror,
+                   BZFILE*       b,
+                   int           abandon,
+                   unsigned int* nbytes_in_lo32,
+                   unsigned int* nbytes_in_hi32,
+                   unsigned int* nbytes_out_lo32,
+                   unsigned int* nbytes_out_hi32 )
+{
+   Int32   n, n2, ret;
+   bzFile* bzf = (bzFile*)b;
+
+   if (bzf == NULL)
+      { BZ_SETERR(BZ_OK); return; };
+   if (!(bzf->writing))
+      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
+   if (ferror(bzf->handle))
+      { BZ_SETERR(BZ_IO_ERROR); return; };
+
+   if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0;
+   if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0;
+   if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0;
+   if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0;
+
+   if ((!abandon) && bzf->lastErr == BZ_OK) {
+      while (True) {
+        bzf->strm.avail_out = BZ_MAX_UNUSED;
+        bzf->strm.next_out = bzf->buf;
+        ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH );
+        if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END)
+           { BZ_SETERR(ret); return; };
+
+        if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
+           n = BZ_MAX_UNUSED - bzf->strm.avail_out;
+           n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
+                         n, bzf->handle );
+           if (n != n2 || ferror(bzf->handle))
+              { BZ_SETERR(BZ_IO_ERROR); return; };
+        }
+
+        if (ret == BZ_STREAM_END) break;
+      }
+   }
+
+   if ( !abandon && !ferror ( bzf->handle ) ) {
+      fflush ( bzf->handle );
+      if (ferror(bzf->handle))
+        { BZ_SETERR(BZ_IO_ERROR); return; };
+   }
+
+   if (nbytes_in_lo32 != NULL)
+      *nbytes_in_lo32 = bzf->strm.total_in_lo32;
+   if (nbytes_in_hi32 != NULL)
+      *nbytes_in_hi32 = bzf->strm.total_in_hi32;
+   if (nbytes_out_lo32 != NULL)
+      *nbytes_out_lo32 = bzf->strm.total_out_lo32;
+   if (nbytes_out_hi32 != NULL)
+      *nbytes_out_hi32 = bzf->strm.total_out_hi32;
+
+   BZ_SETERR(BZ_OK);
+   BZ2_bzCompressEnd ( &(bzf->strm) );
+   free ( bzf );
+}
+
+
+/*---------------------------------------------------*/
+BZFILE* BZ_API(BZ2_bzReadOpen)
+                  ( int*  bzerror,
+                    FILE* f,
+                    int   verbosity,
+                    int   small,
+                    void* unused,
+                    int   nUnused )
+{
+   bzFile* bzf = NULL;
+   int     ret;
+
+   BZ_SETERR(BZ_OK);
+
+   if (f == NULL ||
+       (small != 0 && small != 1) ||
+       (verbosity < 0 || verbosity > 4) ||
+       (unused == NULL && nUnused != 0) ||
+       (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED)))
+      { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
+
+   if (ferror(f))
+      { BZ_SETERR(BZ_IO_ERROR); return NULL; };
+
+   bzf = malloc ( sizeof(bzFile) );
+   if (bzf == NULL)
+      { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
+
+   BZ_SETERR(BZ_OK);
+
+   bzf->initialisedOk = False;
+   bzf->handle        = f;
+   bzf->bufN          = 0;
+   bzf->writing       = False;
+   bzf->strm.bzalloc  = NULL;
+   bzf->strm.bzfree   = NULL;
+   bzf->strm.opaque   = NULL;
+
+   while (nUnused > 0) {
+      bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
+      unused = ((void*)( 1 + ((UChar*)(unused))  ));
+      nUnused--;
+   }
+
+   ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small );
+   if (ret != BZ_OK)
+      { BZ_SETERR(ret); free(bzf); return NULL; };
+
+   bzf->strm.avail_in = bzf->bufN;
+   bzf->strm.next_in  = bzf->buf;
+
+   bzf->initialisedOk = True;
+   return bzf;
+}
+
+
+/*---------------------------------------------------*/
+void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
+{
+   bzFile* bzf = (bzFile*)b;
+
+   BZ_SETERR(BZ_OK);
+   if (bzf == NULL)
+      { BZ_SETERR(BZ_OK); return; };
+
+   if (bzf->writing)
+      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
+
+   if (bzf->initialisedOk)
+      (void)BZ2_bzDecompressEnd ( &(bzf->strm) );
+   free ( bzf );
+}
+
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzRead)
+          ( int*    bzerror,
+            BZFILE* b,
+            void*   buf,
+            int     len )
+{
+   Int32   n, ret;
+   bzFile* bzf = (bzFile*)b;
+
+   BZ_SETERR(BZ_OK);
+
+   if (bzf == NULL || buf == NULL || len < 0)
+      { BZ_SETERR(BZ_PARAM_ERROR); return 0; };
+
+   if (bzf->writing)
+      { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; };
+
+   if (len == 0)
+      { BZ_SETERR(BZ_OK); return 0; };
+
+   bzf->strm.avail_out = len;
+   bzf->strm.next_out = buf;
+
+   while (True) {
+
+      if (ferror(bzf->handle))
+        { BZ_SETERR(BZ_IO_ERROR); return 0; };
+
+      if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
+        n = fread ( bzf->buf, sizeof(UChar),
+                    BZ_MAX_UNUSED, bzf->handle );
+        if (ferror(bzf->handle))
+           { BZ_SETERR(BZ_IO_ERROR); return 0; };
+        bzf->bufN = n;
+        bzf->strm.avail_in = bzf->bufN;
+        bzf->strm.next_in = bzf->buf;
+      }
+
+      ret = BZ2_bzDecompress ( &(bzf->strm) );
+
+      if (ret != BZ_OK && ret != BZ_STREAM_END)
+        { BZ_SETERR(ret); return 0; };
+
+      if (ret == BZ_OK && myfeof(bzf->handle) &&
+         bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
+        { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
+
+      if (ret == BZ_STREAM_END)
+        { BZ_SETERR(BZ_STREAM_END);
+          return len - bzf->strm.avail_out; };
+      if (bzf->strm.avail_out == 0)
+        { BZ_SETERR(BZ_OK); return len; };
+
+   }
+
+   return 0; /*not reached*/
+}
+
+
+/*---------------------------------------------------*/
+void BZ_API(BZ2_bzReadGetUnused)
+                    ( int*    bzerror,
+                      BZFILE* b,
+                      void**  unused,
+                      int*    nUnused )
+{
+   bzFile* bzf = (bzFile*)b;
+   if (bzf == NULL)
+      { BZ_SETERR(BZ_PARAM_ERROR); return; };
+   if (bzf->lastErr != BZ_STREAM_END)
+      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
+   if (unused == NULL || nUnused == NULL)
+      { BZ_SETERR(BZ_PARAM_ERROR); return; };
+
+   BZ_SETERR(BZ_OK);
+   *nUnused = bzf->strm.avail_in;
+   *unused = bzf->strm.next_in;
+}
+#endif
+
+
+/*---------------------------------------------------*/
+/*--- Misc convenience stuff                      ---*/
+/*---------------------------------------------------*/
+#ifndef BZ_NO_COMPRESS
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzBuffToBuffCompress)
+                        ( char*         dest,
+                          unsigned int* destLen,
+                          char*         source,
+                          unsigned int  sourceLen,
+                          int           blockSize100k,
+                          int           verbosity,
+                          int           workFactor )
+{
+   bz_stream strm;
+   int ret;
+
+   if (dest == NULL || destLen == NULL ||
+       source == NULL ||
+       blockSize100k < 1 || blockSize100k > 9 ||
+       verbosity < 0 || verbosity > 4 ||
+       workFactor < 0 || workFactor > 250)
+      return BZ_PARAM_ERROR;
+
+   if (workFactor == 0) workFactor = 30;
+   strm.bzalloc = NULL;
+   strm.bzfree = NULL;
+   strm.opaque = NULL;
+   ret = BZ2_bzCompressInit ( &strm, blockSize100k,
+                             verbosity, workFactor );
+   if (ret != BZ_OK) return ret;
+
+   strm.next_in = source;
+   strm.next_out = dest;
+   strm.avail_in = sourceLen;
+   strm.avail_out = *destLen;
+
+   ret = BZ2_bzCompress ( &strm, BZ_FINISH );
+   if (ret == BZ_FINISH_OK) goto output_overflow;
+   if (ret != BZ_STREAM_END) goto errhandler;
+
+   /* normal termination */
+   *destLen -= strm.avail_out;
+   BZ2_bzCompressEnd ( &strm );
+   return BZ_OK;
+
+   output_overflow:
+   BZ2_bzCompressEnd ( &strm );
+   return BZ_OUTBUFF_FULL;
+
+   errhandler:
+   BZ2_bzCompressEnd ( &strm );
+   return ret;
+}
+#endif /* BZ_NO_COMPRESS */
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzBuffToBuffDecompress)
+                          ( char*         dest,
+                            unsigned int* destLen,
+                            char*         source,
+                            unsigned int  sourceLen,
+                            int           small,
+                            int           verbosity )
+{
+   bz_stream strm;
+   int ret;
+
+   if (destLen == NULL || source == NULL)
+         return BZ_PARAM_ERROR;
+
+   strm.bzalloc = NULL;
+   strm.bzfree = NULL;
+   strm.opaque = NULL;
+   ret = BZ2_bzDecompressInit ( &strm, verbosity, small );
+   if (ret != BZ_OK) return ret;
+
+   strm.next_in = source;
+   strm.next_out = dest;
+   strm.avail_in = sourceLen;
+   strm.avail_out = *destLen;
+
+   ret = BZ2_bzDecompress ( &strm );
+   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;
+
+   output_overflow_or_eof:
+   if (strm.avail_out > 0) {
+      BZ2_bzDecompressEnd ( &strm );
+      return BZ_UNEXPECTED_EOF;
+   } else {
+      BZ2_bzDecompressEnd ( &strm );
+      return BZ_OUTBUFF_FULL;
+   };
+
+   errhandler:
+   BZ2_bzDecompressEnd ( &strm );
+   return ret;
+}
+
+
+/*---------------------------------------------------*/
+/*--
+   Code contributed by Yoshioka Tsuneo
+   (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
+   to support better zlib compatibility.
+   This code is not _officially_ part of libbzip2 (yet);
+   I haven't tested it, documented it, or considered the
+   threading-safeness of it.
+   If this code breaks, please contact both Yoshioka and me.
+--*/
+/*---------------------------------------------------*/
+
+/*---------------------------------------------------*/
+/*--
+   return version like "0.9.0c".
+--*/
+const char * BZ_API(BZ2_bzlibVersion)(void)
+{
+   return BZ_VERSION;
+}
+
+
+#ifndef BZ_NO_STDIO
+/*---------------------------------------------------*/
+
+#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
+#   include <fcntl.h>
+#   include <io.h>
+#   define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
+#else
+#   define SET_BINARY_MODE(file)
+#endif
+static
+BZFILE * bzopen_or_bzdopen
+              ( const char *path,   /* no use when bzdopen */
+                int fd,             /* no use when bzdopen */
+                const char *mode,
+                int open_mode)      /* bzopen: 0, bzdopen:1 */
+{
+   int    bzerr;
+   char   unused[BZ_MAX_UNUSED];
+   int    blockSize100k = 9;
+   int    writing       = 0;
+   char   mode2[10]     = "";
+   FILE   *fp           = NULL;
+   BZFILE *bzfp         = NULL;
+   int    verbosity     = 0;
+   int    workFactor    = 30;
+   int    smallMode     = 0;
+   int    nUnused       = 0;
+
+   if (mode == NULL) return NULL;
+   while (*mode) {
+      switch (*mode) {
+      case 'r':
+        writing = 0; break;
+      case 'w':
+        writing = 1; break;
+      case 's':
+        smallMode = 1; break;
+      default:
+        if (isdigit((int)(*mode))) {
+           blockSize100k = *mode-BZ_HDR_0;
+        }
+      }
+      mode++;
+   }
+   strcat(mode2, writing ? "w" : "r" );
+   strcat(mode2,"b");   /* binary mode */
+
+   if (open_mode==0) {
+      if (path==NULL || strcmp(path,"")==0) {
+       fp = (writing ? stdout : stdin);
+       SET_BINARY_MODE(fp);
+      } else {
+       fp = fopen(path,mode2);
+      }
+   } else {
+#ifdef BZ_STRICT_ANSI
+      fp = NULL;
+#else
+      fp = fdopen(fd,mode2);
+#endif
+   }
+   if (fp == NULL) return NULL;
+
+   if (writing) {
+      /* Guard against total chaos and anarchy -- JRS */
+      if (blockSize100k < 1) blockSize100k = 1;
+      if (blockSize100k > 9) blockSize100k = 9;
+      bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k,
+                            verbosity,workFactor);
+   } else {
+      bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode,
+                           unused,nUnused);
+   }
+   if (bzfp == NULL) {
+      if (fp != stdin && fp != stdout) fclose(fp);
+      return NULL;
+   }
+   return bzfp;
+}
+
+
+/*---------------------------------------------------*/
+/*--
+   open file for read or write.
+      ex) bzopen("file","w9")
+      case path="" or NULL => use stdin or stdout.
+--*/
+BZFILE * BZ_API(BZ2_bzopen)
+              ( const char *path,
+                const char *mode )
+{
+   return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0);
+}
+
+
+/*---------------------------------------------------*/
+BZFILE * BZ_API(BZ2_bzdopen)
+              ( int fd,
+                const char *mode )
+{
+   return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1);
+}
+
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len )
+{
+   int bzerr, nread;
+   if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0;
+   nread = BZ2_bzRead(&bzerr,b,buf,len);
+   if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) {
+      return nread;
+   } else {
+      return -1;
+   }
+}
+
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len )
+{
+   int bzerr;
+
+   BZ2_bzWrite(&bzerr,b,buf,len);
+   if(bzerr == BZ_OK){
+      return len;
+   }else{
+      return -1;
+   }
+}
+
+
+/*---------------------------------------------------*/
+int BZ_API(BZ2_bzflush) (BZFILE *b)
+{
+   /* do nothing now... */
+   return 0;
+}
+
+
+/*---------------------------------------------------*/
+void BZ_API(BZ2_bzclose) (BZFILE* b)
+{
+   int bzerr;
+   FILE *fp = ((bzFile *)b)->handle;
+
+   if (b==NULL) {return;}
+   if(((bzFile*)b)->writing){
+      BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
+      if(bzerr != BZ_OK){
+        BZ2_bzWriteClose(NULL,b,1,NULL,NULL);
+      }
+   }else{
+      BZ2_bzReadClose(&bzerr,b);
+   }
+   if(fp!=stdin && fp!=stdout){
+      fclose(fp);
+   }
+}
+
+
+/*---------------------------------------------------*/
+/*--
+   return last error code
+--*/
+static char *bzerrorstrings[] = {
+       "OK"
+      ,"SEQUENCE_ERROR"
+      ,"PARAM_ERROR"
+      ,"MEM_ERROR"
+      ,"DATA_ERROR"
+      ,"DATA_ERROR_MAGIC"
+      ,"IO_ERROR"
+      ,"UNEXPECTED_EOF"
+      ,"OUTBUFF_FULL"
+      ,"CONFIG_ERROR"
+      ,"???"   /* for future */
+      ,"???"   /* for future */
+      ,"???"   /* for future */
+      ,"???"   /* for future */
+      ,"???"   /* for future */
+      ,"???"   /* for future */
+};
+
+
+const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum)
+{
+   int err = ((bzFile *)b)->lastErr;
+
+   if(err>0) err = 0;
+   *errnum = err;
+   return bzerrorstrings[err*-1];
+}
+#endif
+
+void bz_internal_error(int errcode)
+{
+       printf ("BZIP2 internal error %d\n", errcode);
+}
+
+/*-------------------------------------------------------------*/
+/*--- end                                           bzlib.c ---*/
+/*-------------------------------------------------------------*/
diff --git a/lib/bzip2/bzlib_crctable.c b/lib/bzip2/bzlib_crctable.c
new file mode 100644 (file)
index 0000000..325b966
--- /dev/null
@@ -0,0 +1,145 @@
+#include <config.h>
+
+/*-------------------------------------------------------------*/
+/*--- Table for doing CRCs                                  ---*/
+/*---                                            crctable.c ---*/
+/*-------------------------------------------------------------*/
+
+/*--
+  This file is a part of bzip2 and/or libbzip2, a program and
+  library for lossless, block-sorting data compression.
+
+  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+
+  2. The origin of this software must not be misrepresented; you must
+     not claim that you wrote the original software.  If you use this
+     software in a product, an acknowledgment in the product
+     documentation would be appreciated but is not required.
+
+  3. Altered source versions must be plainly marked as such, and must
+     not be misrepresented as being the original software.
+
+  4. The name of the author may not be used to endorse or promote
+     products derived from this software without specific prior written
+     permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+  Julian Seward, Cambridge, UK.
+  jseward@acm.org
+  bzip2/libbzip2 version 1.0 of 21 March 2000
+
+  This program is based on (at least) the work of:
+     Mike Burrows
+     David Wheeler
+     Peter Fenwick
+     Alistair Moffat
+     Radford Neal
+     Ian H. Witten
+     Robert Sedgewick
+     Jon L. Bentley
+
+  For more information on these sources, see the manual.
+--*/
+
+
+#include "bzlib_private.h"
+
+/*--
+  I think this is an implementation of the AUTODIN-II,
+  Ethernet & FDDI 32-bit CRC standard.  Vaguely derived
+  from code by Rob Warnock, in Section 51 of the
+  comp.compression FAQ.
+--*/
+
+UInt32 BZ2_crc32Table[256] = {
+
+   /*-- Ugly, innit? --*/
+
+   0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
+   0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
+   0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
+   0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
+   0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
+   0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
+   0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
+   0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
+   0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
+   0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
+   0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
+   0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
+   0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
+   0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
+   0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
+   0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
+   0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
+   0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
+   0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
+   0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
+   0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
+   0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
+   0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
+   0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
+   0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
+   0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
+   0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
+   0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
+   0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
+   0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
+   0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
+   0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
+   0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
+   0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
+   0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
+   0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
+   0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
+   0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
+   0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
+   0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
+   0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
+   0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
+   0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
+   0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
+   0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
+   0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
+   0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
+   0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
+   0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
+   0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
+   0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
+   0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
+   0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
+   0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
+   0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
+   0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
+   0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
+   0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
+   0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
+   0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
+   0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
+   0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
+   0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
+   0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
+};
+
+
+/*-------------------------------------------------------------*/
+/*--- end                                        crctable.c ---*/
+/*-------------------------------------------------------------*/
diff --git a/lib/bzip2/bzlib_decompress.c b/lib/bzip2/bzlib_decompress.c
new file mode 100644 (file)
index 0000000..4412b8a
--- /dev/null
@@ -0,0 +1,674 @@
+#include <config.h>
+#include <common.h>
+#include <watchdog.h>
+
+/*-------------------------------------------------------------*/
+/*--- Decompression machinery                               ---*/
+/*---                                          decompress.c ---*/
+/*-------------------------------------------------------------*/
+
+/*--
+  This file is a part of bzip2 and/or libbzip2, a program and
+  library for lossless, block-sorting data compression.
+
+  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+
+  2. The origin of this software must not be misrepresented; you must
+     not claim that you wrote the original software.  If you use this
+     software in a product, an acknowledgment in the product
+     documentation would be appreciated but is not required.
+
+  3. Altered source versions must be plainly marked as such, and must
+     not be misrepresented as being the original software.
+
+  4. The name of the author may not be used to endorse or promote
+     products derived from this software without specific prior written
+     permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+  Julian Seward, Cambridge, UK.
+  jseward@acm.org
+  bzip2/libbzip2 version 1.0 of 21 March 2000
+
+  This program is based on (at least) the work of:
+     Mike Burrows
+     David Wheeler
+     Peter Fenwick
+     Alistair Moffat
+     Radford Neal
+     Ian H. Witten
+     Robert Sedgewick
+     Jon L. Bentley
+
+  For more information on these sources, see the manual.
+--*/
+
+
+#include "bzlib_private.h"
+
+
+/*---------------------------------------------------*/
+static
+void makeMaps_d ( DState* s )
+{
+   Int32 i;
+   s->nInUse = 0;
+   for (i = 0; i < 256; i++)
+      if (s->inUse[i]) {
+        s->seqToUnseq[s->nInUse] = i;
+        s->nInUse++;
+      }
+}
+
+
+/*---------------------------------------------------*/
+#define RETURN(rrr)                               \
+   { retVal = rrr; goto save_state_and_return; };
+
+#define GET_BITS(lll,vvv,nnn)                     \
+   case lll: s->state = lll;                      \
+   while (True) {                                 \
+      if (s->bsLive >= nnn) {                     \
+        UInt32 v;                                \
+        v = (s->bsBuff >>                        \
+            (s->bsLive-nnn)) & ((1 << nnn)-1);   \
+        s->bsLive -= nnn;                        \
+        vvv = v;                                 \
+        break;                                   \
+      }                                           \
+      if (s->strm->avail_in == 0) RETURN(BZ_OK);  \
+      s->bsBuff                                   \
+        = (s->bsBuff << 8) |                     \
+          ((UInt32)                              \
+             (*((UChar*)(s->strm->next_in))));   \
+      s->bsLive += 8;                             \
+      s->strm->next_in++;                         \
+      s->strm->avail_in--;                        \
+      s->strm->total_in_lo32++;                   \
+      if (s->strm->total_in_lo32 == 0)            \
+        s->strm->total_in_hi32++;                \
+   }
+
+#define GET_UCHAR(lll,uuu)                        \
+   GET_BITS(lll,uuu,8)
+
+#define GET_BIT(lll,uuu)                          \
+   GET_BITS(lll,uuu,1)
+
+/*---------------------------------------------------*/
+#define GET_MTF_VAL(label1,label2,lval)           \
+{                                                 \
+   if (groupPos == 0) {                           \
+      groupNo++;                                  \
+      if (groupNo >= nSelectors)                  \
+        RETURN(BZ_DATA_ERROR);                   \
+      groupPos = BZ_G_SIZE;                       \
+      gSel = s->selector[groupNo];                \
+      gMinlen = s->minLens[gSel];                 \
+      gLimit = &(s->limit[gSel][0]);              \
+      gPerm = &(s->perm[gSel][0]);                \
+      gBase = &(s->base[gSel][0]);                \
+   }                                              \
+   groupPos--;                                    \
+   zn = gMinlen;                                  \
+   GET_BITS(label1, zvec, zn);                    \
+   while (1) {                                    \
+      if (zn > 20 /* the longest code */)         \
+        RETURN(BZ_DATA_ERROR);                   \
+      if (zvec <= gLimit[zn]) break;              \
+      zn++;                                       \
+      GET_BIT(label2, zj);                        \
+      zvec = (zvec << 1) | zj;                    \
+   };                                             \
+   if (zvec - gBase[zn] < 0                       \
+       || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE)  \
+      RETURN(BZ_DATA_ERROR);                      \
+   lval = gPerm[zvec - gBase[zn]];                \
+}
+
+
+/*---------------------------------------------------*/
+Int32 BZ2_decompress ( DState* s )
+{
+   UChar      uc;
+   Int32      retVal;
+   Int32      minLen, maxLen;
+   bz_stream* strm = s->strm;
+
+   /* stuff that needs to be saved/restored */
+   Int32  i;
+   Int32  j;
+   Int32  t;
+   Int32  alphaSize;
+   Int32  nGroups;
+   Int32  nSelectors;
+   Int32  EOB;
+   Int32  groupNo;
+   Int32  groupPos;
+   Int32  nextSym;
+   Int32  nblockMAX;
+   Int32  nblock;
+   Int32  es;
+   Int32  N;
+   Int32  curr;
+   Int32  zt;
+   Int32  zn;
+   Int32  zvec;
+   Int32  zj;
+   Int32  gSel;
+   Int32  gMinlen;
+   Int32* gLimit;
+   Int32* gBase;
+   Int32* gPerm;
+
+   if (s->state == BZ_X_MAGIC_1) {
+      /*initialise the save area*/
+      s->save_i           = 0;
+      s->save_j           = 0;
+      s->save_t           = 0;
+      s->save_alphaSize   = 0;
+      s->save_nGroups     = 0;
+      s->save_nSelectors  = 0;
+      s->save_EOB         = 0;
+      s->save_groupNo     = 0;
+      s->save_groupPos    = 0;
+      s->save_nextSym     = 0;
+      s->save_nblockMAX   = 0;
+      s->save_nblock      = 0;
+      s->save_es          = 0;
+      s->save_N           = 0;
+      s->save_curr        = 0;
+      s->save_zt          = 0;
+      s->save_zn          = 0;
+      s->save_zvec        = 0;
+      s->save_zj          = 0;
+      s->save_gSel        = 0;
+      s->save_gMinlen     = 0;
+      s->save_gLimit      = NULL;
+      s->save_gBase       = NULL;
+      s->save_gPerm       = NULL;
+   }
+
+   /*restore from the save area*/
+   i           = s->save_i;
+   j           = s->save_j;
+   t           = s->save_t;
+   alphaSize   = s->save_alphaSize;
+   nGroups     = s->save_nGroups;
+   nSelectors  = s->save_nSelectors;
+   EOB         = s->save_EOB;
+   groupNo     = s->save_groupNo;
+   groupPos    = s->save_groupPos;
+   nextSym     = s->save_nextSym;
+   nblockMAX   = s->save_nblockMAX;
+   nblock      = s->save_nblock;
+   es          = s->save_es;
+   N           = s->save_N;
+   curr        = s->save_curr;
+   zt          = s->save_zt;
+   zn          = s->save_zn;
+   zvec        = s->save_zvec;
+   zj          = s->save_zj;
+   gSel        = s->save_gSel;
+   gMinlen     = s->save_gMinlen;
+   gLimit      = s->save_gLimit;
+   gBase       = s->save_gBase;
+   gPerm       = s->save_gPerm;
+
+   retVal = BZ_OK;
+
+   switch (s->state) {
+
+      GET_UCHAR(BZ_X_MAGIC_1, uc);
+      if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
+
+      GET_UCHAR(BZ_X_MAGIC_2, uc);
+      if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC);
+
+      GET_UCHAR(BZ_X_MAGIC_3, uc)
+      if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
+
+      GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
+      if (s->blockSize100k < (BZ_HDR_0 + 1) ||
+         s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
+      s->blockSize100k -= BZ_HDR_0;
+
+      if (s->smallDecompress) {
+        s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
+        s->ll4  = BZALLOC(
+                     ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
+                  );
+        if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
+      } else {
+        s->tt  = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
+        if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
+      }
+
+      GET_UCHAR(BZ_X_BLKHDR_1, uc);
+
+      if (uc == 0x17) goto endhdr_2;
+      if (uc != 0x31) RETURN(BZ_DATA_ERROR);
+      GET_UCHAR(BZ_X_BLKHDR_2, uc);
+      if (uc != 0x41) RETURN(BZ_DATA_ERROR);
+      GET_UCHAR(BZ_X_BLKHDR_3, uc);
+      if (uc != 0x59) RETURN(BZ_DATA_ERROR);
+      GET_UCHAR(BZ_X_BLKHDR_4, uc);
+      if (uc != 0x26) RETURN(BZ_DATA_ERROR);
+      GET_UCHAR(BZ_X_BLKHDR_5, uc);
+      if (uc != 0x53) RETURN(BZ_DATA_ERROR);
+      GET_UCHAR(BZ_X_BLKHDR_6, uc);
+      if (uc != 0x59) RETURN(BZ_DATA_ERROR);
+
+      s->currBlockNo++;
+      if (s->verbosity >= 2)
+        VPrintf1 ( "\n    [%d: huff+mtf ", s->currBlockNo );
+
+      s->storedBlockCRC = 0;
+      GET_UCHAR(BZ_X_BCRC_1, uc);
+      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
+      GET_UCHAR(BZ_X_BCRC_2, uc);
+      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
+      GET_UCHAR(BZ_X_BCRC_3, uc);
+      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
+      GET_UCHAR(BZ_X_BCRC_4, uc);
+      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
+
+      GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
+
+      s->origPtr = 0;
+      GET_UCHAR(BZ_X_ORIGPTR_1, uc);
+      s->origPtr = (s->origPtr << 8) | ((Int32)uc);
+      GET_UCHAR(BZ_X_ORIGPTR_2, uc);
+      s->origPtr = (s->origPtr << 8) | ((Int32)uc);
+      GET_UCHAR(BZ_X_ORIGPTR_3, uc);
+      s->origPtr = (s->origPtr << 8) | ((Int32)uc);
+
+      if (s->origPtr < 0)
+        RETURN(BZ_DATA_ERROR);
+      if (s->origPtr > 10 + 100000*s->blockSize100k)
+        RETURN(BZ_DATA_ERROR);
+
+      /*--- Receive the mapping table ---*/
+      for (i = 0; i < 16; i++) {
+        GET_BIT(BZ_X_MAPPING_1, uc);
+        if (uc == 1)
+           s->inUse16[i] = True; else
+           s->inUse16[i] = False;
+      }
+
+      for (i = 0; i < 256; i++) s->inUse[i] = False;
+
+      for (i = 0; i < 16; i++)
+        if (s->inUse16[i])
+           for (j = 0; j < 16; j++) {
+              GET_BIT(BZ_X_MAPPING_2, uc);
+              if (uc == 1) s->inUse[i * 16 + j] = True;
+           }
+      makeMaps_d ( s );
+      if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
+      alphaSize = s->nInUse+2;
+
+      /*--- Now the selectors ---*/
+      GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
+      if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
+      GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
+      if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
+      for (i = 0; i < nSelectors; i++) {
+        j = 0;
+        while (True) {
+           GET_BIT(BZ_X_SELECTOR_3, uc);
+           if (uc == 0) break;
+           j++;
+           if (j >= nGroups) RETURN(BZ_DATA_ERROR);
+        }
+        s->selectorMtf[i] = j;
+      }
+
+      /*--- Undo the MTF values for the selectors. ---*/
+      {
+        UChar pos[BZ_N_GROUPS], tmp, v;
+        for (v = 0; v < nGroups; v++) pos[v] = v;
+
+        for (i = 0; i < nSelectors; i++) {
+           v = s->selectorMtf[i];
+           tmp = pos[v];
+           while (v > 0) { pos[v] = pos[v-1]; v--; }
+           pos[0] = tmp;
+           s->selector[i] = tmp;
+        }
+      }
+
+      /*--- Now the coding tables ---*/
+      for (t = 0; t < nGroups; t++) {
+        GET_BITS(BZ_X_CODING_1, curr, 5);
+        for (i = 0; i < alphaSize; i++) {
+           while (True) {
+              if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
+              GET_BIT(BZ_X_CODING_2, uc);
+              if (uc == 0) break;
+              GET_BIT(BZ_X_CODING_3, uc);
+              if (uc == 0) curr++; else curr--;
+           }
+           s->len[t][i] = curr;
+        }
+      }
+
+      /*--- Create the Huffman decoding tables ---*/
+      for (t = 0; t < nGroups; t++) {
+        minLen = 32;
+        maxLen = 0;
+        for (i = 0; i < alphaSize; i++) {
+           if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
+           if (s->len[t][i] < minLen) minLen = s->len[t][i];
+        }
+        BZ2_hbCreateDecodeTables (
+           &(s->limit[t][0]),
+           &(s->base[t][0]),
+           &(s->perm[t][0]),
+           &(s->len[t][0]),
+           minLen, maxLen, alphaSize
+        );
+        s->minLens[t] = minLen;
+      }
+
+      /*--- Now the MTF values ---*/
+
+      EOB      = s->nInUse+1;
+      nblockMAX = 100000 * s->blockSize100k;
+      groupNo  = -1;
+      groupPos = 0;
+
+      for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
+
+      /*-- MTF init --*/
+      {
+        Int32 ii, jj, kk;
+        kk = MTFA_SIZE-1;
+        for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
+           for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
+              s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
+              kk--;
+           }
+           s->mtfbase[ii] = kk + 1;
+        }
+      }
+      /*-- end MTF init --*/
+
+      nblock = 0;
+      GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
+
+      while (True) {
+
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+       WATCHDOG_RESET();
+#endif
+        if (nextSym == EOB) break;
+
+        if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
+
+           es = -1;
+           N = 1;
+           do {
+              if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
+              if (nextSym == BZ_RUNB) es = es + (1+1) * N;
+              N = N * 2;
+              GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
+           }
+              while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
+
+           es++;
+           uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ];
+           s->unzftab[uc] += es;
+
+           if (s->smallDecompress)
+              while (es > 0) {
+                 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
+                 s->ll16[nblock] = (UInt16)uc;
+                 nblock++;
+                 es--;
+              }
+           else
+              while (es > 0) {
+                 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
+                 s->tt[nblock] = (UInt32)uc;
+                 nblock++;
+                 es--;
+              };
+
+           continue;
+
+        } else {
+
+           if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
+
+           /*-- uc = MTF ( nextSym-1 ) --*/
+           {
+              Int32 ii, jj, kk, pp, lno, off;
+              UInt32 nn;
+              nn = (UInt32)(nextSym - 1);
+
+              if (nn < MTFL_SIZE) {
+                 /* avoid general-case expense */
+                 pp = s->mtfbase[0];
+                 uc = s->mtfa[pp+nn];
+                 while (nn > 3) {
+                    Int32 z = pp+nn;
+                    s->mtfa[(z)  ] = s->mtfa[(z)-1];
+                    s->mtfa[(z)-1] = s->mtfa[(z)-2];
+                    s->mtfa[(z)-2] = s->mtfa[(z)-3];
+                    s->mtfa[(z)-3] = s->mtfa[(z)-4];
+                    nn -= 4;
+                 }
+                 while (nn > 0) {
+                    s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
+                 };
+                 s->mtfa[pp] = uc;
+              } else {
+                 /* general case */
+                 lno = nn / MTFL_SIZE;
+                 off = nn % MTFL_SIZE;
+                 pp = s->mtfbase[lno] + off;
+                 uc = s->mtfa[pp];
+                 while (pp > s->mtfbase[lno]) {
+                    s->mtfa[pp] = s->mtfa[pp-1]; pp--;
+                 };
+                 s->mtfbase[lno]++;
+                 while (lno > 0) {
+                    s->mtfbase[lno]--;
+                    s->mtfa[s->mtfbase[lno]]
+                       = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
+                    lno--;
+                 }
+                 s->mtfbase[0]--;
+                 s->mtfa[s->mtfbase[0]] = uc;
+                 if (s->mtfbase[0] == 0) {
+                    kk = MTFA_SIZE-1;
+                    for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+                       WATCHDOG_RESET();
+#endif
+                       for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
+                          s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj];
+                          kk--;
+                       }
+                       s->mtfbase[ii] = kk + 1;
+                    }
+                 }
+              }
+           }
+           /*-- end uc = MTF ( nextSym-1 ) --*/
+
+           s->unzftab[s->seqToUnseq[uc]]++;
+           if (s->smallDecompress)
+              s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else
+              s->tt[nblock]   = (UInt32)(s->seqToUnseq[uc]);
+           nblock++;
+
+           GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
+           continue;
+        }
+      }
+
+      /* Now we know what nblock is, we can do a better sanity
+        check on s->origPtr.
+      */
+      if (s->origPtr < 0 || s->origPtr >= nblock)
+        RETURN(BZ_DATA_ERROR);
+
+      s->state_out_len = 0;
+      s->state_out_ch  = 0;
+      BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
+      s->state = BZ_X_OUTPUT;
+      if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
+
+      /*-- Set up cftab to facilitate generation of T^(-1) --*/
+      s->cftab[0] = 0;
+      for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
+      for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
+
+      if (s->smallDecompress) {
+
+        /*-- Make a copy of cftab, used in generation of T --*/
+        for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
+
+        /*-- compute the T vector --*/
+        for (i = 0; i < nblock; i++) {
+           uc = (UChar)(s->ll16[i]);
+           SET_LL(i, s->cftabCopy[uc]);
+           s->cftabCopy[uc]++;
+        }
+
+        /*-- Compute T^(-1) by pointer reversal on T --*/
+        i = s->origPtr;
+        j = GET_LL(i);
+        do {
+           Int32 tmp = GET_LL(j);
+           SET_LL(j, i);
+           i = j;
+           j = tmp;
+        }
+           while (i != s->origPtr);
+
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+       WATCHDOG_RESET();
+#endif
+        s->tPos = s->origPtr;
+        s->nblock_used = 0;
+        if (s->blockRandomised) {
+           BZ_RAND_INIT_MASK;
+           BZ_GET_SMALL(s->k0); s->nblock_used++;
+           BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
+        } else {
+           BZ_GET_SMALL(s->k0); s->nblock_used++;
+        }
+
+      } else {
+
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+       WATCHDOG_RESET();
+#endif
+        /*-- compute the T^(-1) vector --*/
+        for (i = 0; i < nblock; i++) {
+           uc = (UChar)(s->tt[i] & 0xff);
+           s->tt[s->cftab[uc]] |= (i << 8);
+           s->cftab[uc]++;
+        }
+
+        s->tPos = s->tt[s->origPtr] >> 8;
+        s->nblock_used = 0;
+        if (s->blockRandomised) {
+           BZ_RAND_INIT_MASK;
+           BZ_GET_FAST(s->k0); s->nblock_used++;
+           BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
+        } else {
+           BZ_GET_FAST(s->k0); s->nblock_used++;
+        }
+
+      }
+
+      RETURN(BZ_OK);
+
+
+    endhdr_2:
+
+      GET_UCHAR(BZ_X_ENDHDR_2, uc);
+      if (uc != 0x72) RETURN(BZ_DATA_ERROR);
+      GET_UCHAR(BZ_X_ENDHDR_3, uc);
+      if (uc != 0x45) RETURN(BZ_DATA_ERROR);
+      GET_UCHAR(BZ_X_ENDHDR_4, uc);
+      if (uc != 0x38) RETURN(BZ_DATA_ERROR);
+      GET_UCHAR(BZ_X_ENDHDR_5, uc);
+      if (uc != 0x50) RETURN(BZ_DATA_ERROR);
+      GET_UCHAR(BZ_X_ENDHDR_6, uc);
+      if (uc != 0x90) RETURN(BZ_DATA_ERROR);
+
+      s->storedCombinedCRC = 0;
+      GET_UCHAR(BZ_X_CCRC_1, uc);
+      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
+      GET_UCHAR(BZ_X_CCRC_2, uc);
+      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
+      GET_UCHAR(BZ_X_CCRC_3, uc);
+      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
+      GET_UCHAR(BZ_X_CCRC_4, uc);
+      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
+
+      s->state = BZ_X_IDLE;
+      RETURN(BZ_STREAM_END);
+
+      default: AssertH ( False, 4001 );
+   }
+
+   AssertH ( False, 4002 );
+
+   save_state_and_return:
+
+   s->save_i           = i;
+   s->save_j           = j;
+   s->save_t           = t;
+   s->save_alphaSize   = alphaSize;
+   s->save_nGroups     = nGroups;
+   s->save_nSelectors  = nSelectors;
+   s->save_EOB         = EOB;
+   s->save_groupNo     = groupNo;
+   s->save_groupPos    = groupPos;
+   s->save_nextSym     = nextSym;
+   s->save_nblockMAX   = nblockMAX;
+   s->save_nblock      = nblock;
+   s->save_es          = es;
+   s->save_N           = N;
+   s->save_curr        = curr;
+   s->save_zt          = zt;
+   s->save_zn          = zn;
+   s->save_zvec        = zvec;
+   s->save_zj          = zj;
+   s->save_gSel        = gSel;
+   s->save_gMinlen     = gMinlen;
+   s->save_gLimit      = gLimit;
+   s->save_gBase       = gBase;
+   s->save_gPerm       = gPerm;
+
+   return retVal;
+}
+
+
+/*-------------------------------------------------------------*/
+/*--- end                                      decompress.c ---*/
+/*-------------------------------------------------------------*/
diff --git a/lib/bzip2/bzlib_huffman.c b/lib/bzip2/bzlib_huffman.c
new file mode 100644 (file)
index 0000000..801b8ec
--- /dev/null
@@ -0,0 +1,229 @@
+#include <config.h>
+
+/*-------------------------------------------------------------*/
+/*--- Huffman coding low-level stuff                        ---*/
+/*---                                             huffman.c ---*/
+/*-------------------------------------------------------------*/
+
+/*--
+  This file is a part of bzip2 and/or libbzip2, a program and
+  library for lossless, block-sorting data compression.
+
+  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+
+  2. The origin of this software must not be misrepresented; you must
+     not claim that you wrote the original software.  If you use this
+     software in a product, an acknowledgment in the product
+     documentation would be appreciated but is not required.
+
+  3. Altered source versions must be plainly marked as such, and must
+     not be misrepresented as being the original software.
+
+  4. The name of the author may not be used to endorse or promote
+     products derived from this software without specific prior written
+     permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+  Julian Seward, Cambridge, UK.
+  jseward@acm.org
+  bzip2/libbzip2 version 1.0 of 21 March 2000
+
+  This program is based on (at least) the work of:
+     Mike Burrows
+     David Wheeler
+     Peter Fenwick
+     Alistair Moffat
+     Radford Neal
+     Ian H. Witten
+     Robert Sedgewick
+     Jon L. Bentley
+
+  For more information on these sources, see the manual.
+--*/
+
+
+#include "bzlib_private.h"
+
+/*---------------------------------------------------*/
+#define WEIGHTOF(zz0)  ((zz0) & 0xffffff00)
+#define DEPTHOF(zz1)   ((zz1) & 0x000000ff)
+#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
+
+#define ADDWEIGHTS(zw1,zw2)                           \
+   (WEIGHTOF(zw1)+WEIGHTOF(zw2)) |                    \
+   (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
+
+#define UPHEAP(z)                                     \
+{                                                     \
+   Int32 zz, tmp;                                     \
+   zz = z; tmp = heap[zz];                            \
+   while (weight[tmp] < weight[heap[zz >> 1]]) {      \
+      heap[zz] = heap[zz >> 1];                       \
+      zz >>= 1;                                       \
+   }                                                  \
+   heap[zz] = tmp;                                    \
+}
+
+#define DOWNHEAP(z)                                   \
+{                                                     \
+   Int32 zz, yy, tmp;                                 \
+   zz = z; tmp = heap[zz];                            \
+   while (True) {                                     \
+      yy = zz << 1;                                   \
+      if (yy > nHeap) break;                          \
+      if (yy < nHeap &&                               \
+         weight[heap[yy+1]] < weight[heap[yy]])      \
+        yy++;                                        \
+      if (weight[tmp] < weight[heap[yy]]) break;      \
+      heap[zz] = heap[yy];                            \
+      zz = yy;                                        \
+   }                                                  \
+   heap[zz] = tmp;                                    \
+}
+
+
+/*---------------------------------------------------*/
+void BZ2_hbMakeCodeLengths ( UChar *len,
+                            Int32 *freq,
+                            Int32 alphaSize,
+                            Int32 maxLen )
+{
+   /*--
+      Nodes and heap entries run from 1.  Entry 0
+      for both the heap and nodes is a sentinel.
+   --*/
+   Int32 nNodes, nHeap, n1, n2, i, j, k;
+   Bool  tooLong;
+
+   Int32 heap   [ BZ_MAX_ALPHA_SIZE + 2 ];
+   Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
+   Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
+
+   for (i = 0; i < alphaSize; i++)
+      weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
+
+   while (True) {
+
+      nNodes = alphaSize;
+      nHeap = 0;
+
+      heap[0] = 0;
+      weight[0] = 0;
+      parent[0] = -2;
+
+      for (i = 1; i <= alphaSize; i++) {
+        parent[i] = -1;
+        nHeap++;
+        heap[nHeap] = i;
+        UPHEAP(nHeap);
+      }
+
+      AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
+
+      while (nHeap > 1) {
+        n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
+        n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
+        nNodes++;
+        parent[n1] = parent[n2] = nNodes;
+        weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
+        parent[nNodes] = -1;
+        nHeap++;
+        heap[nHeap] = nNodes;
+        UPHEAP(nHeap);
+      }
+
+      AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
+
+      tooLong = False;
+      for (i = 1; i <= alphaSize; i++) {
+        j = 0;
+        k = i;
+        while (parent[k] >= 0) { k = parent[k]; j++; }
+        len[i-1] = j;
+        if (j > maxLen) tooLong = True;
+      }
+
+      if (! tooLong) break;
+
+      for (i = 1; i < alphaSize; i++) {
+        j = weight[i] >> 8;
+        j = 1 + (j / 2);
+        weight[i] = j << 8;
+      }
+   }
+}
+
+
+/*---------------------------------------------------*/
+void BZ2_hbAssignCodes ( Int32 *code,
+                        UChar *length,
+                        Int32 minLen,
+                        Int32 maxLen,
+                        Int32 alphaSize )
+{
+   Int32 n, vec, i;
+
+   vec = 0;
+   for (n = minLen; n <= maxLen; n++) {
+      for (i = 0; i < alphaSize; i++)
+        if (length[i] == n) { code[i] = vec; vec++; };
+      vec <<= 1;
+   }
+}
+
+
+/*---------------------------------------------------*/
+void BZ2_hbCreateDecodeTables ( Int32 *limit,
+                               Int32 *base,
+                               Int32 *perm,
+                               UChar *length,
+                               Int32 minLen,
+                               Int32 maxLen,
+                               Int32 alphaSize )
+{
+   Int32 pp, i, j, vec;
+
+   pp = 0;
+   for (i = minLen; i <= maxLen; i++)
+      for (j = 0; j < alphaSize; j++)
+        if (length[j] == i) { perm[pp] = j; pp++; };
+
+   for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
+   for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
+
+   for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
+
+   for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
+   vec = 0;
+
+   for (i = minLen; i <= maxLen; i++) {
+      vec += (base[i+1] - base[i]);
+      limit[i] = vec-1;
+      vec <<= 1;
+   }
+   for (i = minLen + 1; i <= maxLen; i++)
+      base[i] = ((limit[i-1] + 1) << 1) - base[i];
+}
+
+
+/*-------------------------------------------------------------*/
+/*--- end                                         huffman.c ---*/
+/*-------------------------------------------------------------*/
diff --git a/lib/bzip2/bzlib_private.h b/lib/bzip2/bzlib_private.h
new file mode 100644 (file)
index 0000000..87d8f94
--- /dev/null
@@ -0,0 +1,530 @@
+/*
+ * This file is a modified version of bzlib_private.h from the bzip2-1.0.2
+ * distribution which can be found at http://sources.redhat.com/bzip2/
+ */
+
+/*-------------------------------------------------------------*/
+/*--- Private header file for the library.                  ---*/
+/*---                                       bzlib_private.h ---*/
+/*-------------------------------------------------------------*/
+
+/*--
+  This file is a part of bzip2 and/or libbzip2, a program and
+  library for lossless, block-sorting data compression.
+
+  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+
+  2. The origin of this software must not be misrepresented; you must
+     not claim that you wrote the original software.  If you use this
+     software in a product, an acknowledgment in the product
+     documentation would be appreciated but is not required.
+
+  3. Altered source versions must be plainly marked as such, and must
+     not be misrepresented as being the original software.
+
+  4. The name of the author may not be used to endorse or promote
+     products derived from this software without specific prior written
+     permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+  Julian Seward, Cambridge, UK.
+  jseward@acm.org
+  bzip2/libbzip2 version 1.0 of 21 March 2000
+
+  This program is based on (at least) the work of:
+     Mike Burrows
+     David Wheeler
+     Peter Fenwick
+     Alistair Moffat
+     Radford Neal
+     Ian H. Witten
+     Robert Sedgewick
+     Jon L. Bentley
+
+  For more information on these sources, see the manual.
+--*/
+
+
+#ifndef _BZLIB_PRIVATE_H
+#define _BZLIB_PRIVATE_H
+
+#include <malloc.h>
+
+#include "bzlib.h"
+
+#ifndef BZ_NO_STDIO
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#endif
+
+
+/*-- General stuff. --*/
+
+#define BZ_VERSION  "1.0.2, 30-Dec-2001"
+
+typedef char            Char;
+typedef unsigned char   Bool;
+typedef unsigned char   UChar;
+typedef int             Int32;
+typedef unsigned int    UInt32;
+typedef short           Int16;
+typedef unsigned short  UInt16;
+
+#define True  ((Bool)1)
+#define False ((Bool)0)
+
+#ifndef __GNUC__
+#define __inline__  /* */
+#endif
+
+#ifndef BZ_NO_STDIO
+extern void BZ2_bz__AssertH__fail ( int errcode );
+#define AssertH(cond,errcode) \
+   { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
+#if BZ_DEBUG
+#define AssertD(cond,msg) \
+   { if (!(cond)) {       \
+      fprintf ( stderr,   \
+       "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
+      exit(1); \
+   }}
+#else
+#define AssertD(cond,msg) /* */
+#endif
+#define VPrintf0(zf) \
+   fprintf(stderr,zf)
+#define VPrintf1(zf,za1) \
+   fprintf(stderr,zf,za1)
+#define VPrintf2(zf,za1,za2) \
+   fprintf(stderr,zf,za1,za2)
+#define VPrintf3(zf,za1,za2,za3) \
+   fprintf(stderr,zf,za1,za2,za3)
+#define VPrintf4(zf,za1,za2,za3,za4) \
+   fprintf(stderr,zf,za1,za2,za3,za4)
+#define VPrintf5(zf,za1,za2,za3,za4,za5) \
+   fprintf(stderr,zf,za1,za2,za3,za4,za5)
+#else
+extern void bz_internal_error ( int errcode );
+#define AssertH(cond,errcode) \
+   { if (!(cond)) bz_internal_error ( errcode ); }
+#define AssertD(cond,msg) /* */
+#define VPrintf0(zf) /* */
+#define VPrintf1(zf,za1) /* */
+#define VPrintf2(zf,za1,za2) /* */
+#define VPrintf3(zf,za1,za2,za3) /* */
+#define VPrintf4(zf,za1,za2,za3,za4) /* */
+#define VPrintf5(zf,za1,za2,za3,za4,za5) /* */
+#endif
+
+
+#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
+#define BZFREE(ppp)  (strm->bzfree)(strm->opaque,(ppp))
+
+
+/*-- Header bytes. --*/
+
+#define BZ_HDR_B 0x42   /* 'B' */
+#define BZ_HDR_Z 0x5a   /* 'Z' */
+#define BZ_HDR_h 0x68   /* 'h' */
+#define BZ_HDR_0 0x30   /* '0' */
+
+/*-- Constants for the back end. --*/
+
+#define BZ_MAX_ALPHA_SIZE 258
+#define BZ_MAX_CODE_LEN    23
+
+#define BZ_RUNA 0
+#define BZ_RUNB 1
+
+#define BZ_N_GROUPS 6
+#define BZ_G_SIZE   50
+#define BZ_N_ITERS  4
+
+#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
+
+
+/*-- Stuff for randomising repetitive blocks. --*/
+
+extern Int32 BZ2_rNums[512];
+
+#define BZ_RAND_DECLS                          \
+   Int32 rNToGo;                               \
+   Int32 rTPos                                 \
+
+#define BZ_RAND_INIT_MASK                      \
+   s->rNToGo = 0;                              \
+   s->rTPos  = 0                               \
+
+#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
+
+#define BZ_RAND_UPD_MASK                       \
+   if (s->rNToGo == 0) {                       \
+      s->rNToGo = BZ2_rNums[s->rTPos];         \
+      s->rTPos++;                              \
+      if (s->rTPos == 512) s->rTPos = 0;       \
+   }                                           \
+   s->rNToGo--;
+
+
+/*-- Stuff for doing CRCs. --*/
+
+extern UInt32 BZ2_crc32Table[256];
+
+#define BZ_INITIALISE_CRC(crcVar)              \
+{                                              \
+   crcVar = 0xffffffffL;                       \
+}
+
+#define BZ_FINALISE_CRC(crcVar)                \
+{                                              \
+   crcVar = ~(crcVar);                         \
+}
+
+#define BZ_UPDATE_CRC(crcVar,cha)              \
+{                                              \
+   crcVar = (crcVar << 8) ^                    \
+           BZ2_crc32Table[(crcVar >> 24) ^    \
+                          ((UChar)cha)];      \
+}
+
+
+/*-- States and modes for compression. --*/
+
+#define BZ_M_IDLE      1
+#define BZ_M_RUNNING   2
+#define BZ_M_FLUSHING  3
+#define BZ_M_FINISHING 4
+
+#define BZ_S_OUTPUT    1
+#define BZ_S_INPUT     2
+
+#define BZ_N_RADIX 2
+#define BZ_N_QSORT 12
+#define BZ_N_SHELL 18
+#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
+
+
+/*-- Structure holding all the compression-side stuff. --*/
+
+typedef
+   struct {
+      /* pointer back to the struct bz_stream */
+      bz_stream* strm;
+
+      /* mode this stream is in, and whether inputting */
+      /* or outputting data */
+      Int32    mode;
+      Int32    state;
+
+      /* remembers avail_in when flush/finish requested */
+      UInt32   avail_in_expect;
+
+      /* for doing the block sorting */
+      UInt32*  arr1;
+      UInt32*  arr2;
+      UInt32*  ftab;
+      Int32    origPtr;
+
+      /* aliases for arr1 and arr2 */
+      UInt32*  ptr;
+      UChar*   block;
+      UInt16*  mtfv;
+      UChar*   zbits;
+
+      /* for deciding when to use the fallback sorting algorithm */
+      Int32    workFactor;
+
+      /* run-length-encoding of the input */
+      UInt32   state_in_ch;
+      Int32    state_in_len;
+      BZ_RAND_DECLS;
+
+      /* input and output limits and current posns */
+      Int32    nblock;
+      Int32    nblockMAX;
+      Int32    numZ;
+      Int32    state_out_pos;
+
+      /* map of bytes used in block */
+      Int32    nInUse;
+      Bool     inUse[256];
+      UChar    unseqToSeq[256];
+
+      /* the buffer for bit stream creation */
+      UInt32   bsBuff;
+      Int32    bsLive;
+
+      /* block and combined CRCs */
+      UInt32   blockCRC;
+      UInt32   combinedCRC;
+
+      /* misc administratium */
+      Int32    verbosity;
+      Int32    blockNo;
+      Int32    blockSize100k;
+
+      /* stuff for coding the MTF values */
+      Int32    nMTF;
+      Int32    mtfFreq    [BZ_MAX_ALPHA_SIZE];
+      UChar    selector   [BZ_MAX_SELECTORS];
+      UChar    selectorMtf[BZ_MAX_SELECTORS];
+
+      UChar    len     [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
+      Int32    code    [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
+      Int32    rfreq   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
+      /* second dimension: only 3 needed; 4 makes index calculations faster */
+      UInt32   len_pack[BZ_MAX_ALPHA_SIZE][4];
+
+   }
+   EState;
+
+
+/*-- externs for compression. --*/
+
+extern void
+BZ2_blockSort ( EState* );
+
+extern void
+BZ2_compressBlock ( EState*, Bool );
+
+extern void
+BZ2_bsInitWrite ( EState* );
+
+extern void
+BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
+
+extern void
+BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
+
+
+/*-- states for decompression. --*/
+
+#define BZ_X_IDLE        1
+#define BZ_X_OUTPUT      2
+
+#define BZ_X_MAGIC_1     10
+#define BZ_X_MAGIC_2     11
+#define BZ_X_MAGIC_3     12
+#define BZ_X_MAGIC_4     13
+#define BZ_X_BLKHDR_1    14
+#define BZ_X_BLKHDR_2    15
+#define BZ_X_BLKHDR_3    16
+#define BZ_X_BLKHDR_4    17
+#define BZ_X_BLKHDR_5    18
+#define BZ_X_BLKHDR_6    19
+#define BZ_X_BCRC_1      20
+#define BZ_X_BCRC_2      21
+#define BZ_X_BCRC_3      22
+#define BZ_X_BCRC_4      23
+#define BZ_X_RANDBIT     24
+#define BZ_X_ORIGPTR_1   25
+#define BZ_X_ORIGPTR_2   26
+#define BZ_X_ORIGPTR_3   27
+#define BZ_X_MAPPING_1   28
+#define BZ_X_MAPPING_2   29
+#define BZ_X_SELECTOR_1  30
+#define BZ_X_SELECTOR_2  31
+#define BZ_X_SELECTOR_3  32
+#define BZ_X_CODING_1    33
+#define BZ_X_CODING_2    34
+#define BZ_X_CODING_3    35
+#define BZ_X_MTF_1       36
+#define BZ_X_MTF_2       37
+#define BZ_X_MTF_3       38
+#define BZ_X_MTF_4       39
+#define BZ_X_MTF_5       40
+#define BZ_X_MTF_6       41
+#define BZ_X_ENDHDR_2    42
+#define BZ_X_ENDHDR_3    43
+#define BZ_X_ENDHDR_4    44
+#define BZ_X_ENDHDR_5    45
+#define BZ_X_ENDHDR_6    46
+#define BZ_X_CCRC_1      47
+#define BZ_X_CCRC_2      48
+#define BZ_X_CCRC_3      49
+#define BZ_X_CCRC_4      50
+
+
+/*-- Constants for the fast MTF decoder. --*/
+
+#define MTFA_SIZE 4096
+#define MTFL_SIZE 16
+
+
+/*-- Structure holding all the decompression-side stuff. --*/
+
+typedef
+   struct {
+      /* pointer back to the struct bz_stream */
+      bz_stream* strm;
+
+      /* state indicator for this stream */
+      Int32    state;
+
+      /* for doing the final run-length decoding */
+      UChar    state_out_ch;
+      Int32    state_out_len;
+      Bool     blockRandomised;
+      BZ_RAND_DECLS;
+
+      /* the buffer for bit stream reading */
+      UInt32   bsBuff;
+      Int32    bsLive;
+
+      /* misc administratium */
+      Int32    blockSize100k;
+      Bool     smallDecompress;
+      Int32    currBlockNo;
+      Int32    verbosity;
+
+      /* for undoing the Burrows-Wheeler transform */
+      Int32    origPtr;
+      UInt32   tPos;
+      Int32    k0;
+      Int32    unzftab[256];
+      Int32    nblock_used;
+      Int32    cftab[257];
+      Int32    cftabCopy[257];
+
+      /* for undoing the Burrows-Wheeler transform (FAST) */
+      UInt32   *tt;
+
+      /* for undoing the Burrows-Wheeler transform (SMALL) */
+      UInt16   *ll16;
+      UChar    *ll4;
+
+      /* stored and calculated CRCs */
+      UInt32   storedBlockCRC;
+      UInt32   storedCombinedCRC;
+      UInt32   calculatedBlockCRC;
+      UInt32   calculatedCombinedCRC;
+
+      /* map of bytes used in block */
+      Int32    nInUse;
+      Bool     inUse[256];
+      Bool     inUse16[16];
+      UChar    seqToUnseq[256];
+
+      /* for decoding the MTF values */
+      UChar    mtfa   [MTFA_SIZE];
+      Int32    mtfbase[256 / MTFL_SIZE];
+      UChar    selector   [BZ_MAX_SELECTORS];
+      UChar    selectorMtf[BZ_MAX_SELECTORS];
+      UChar    len  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
+
+      Int32    limit  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
+      Int32    base   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
+      Int32    perm   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
+      Int32    minLens[BZ_N_GROUPS];
+
+      /* save area for scalars in the main decompress code */
+      Int32    save_i;
+      Int32    save_j;
+      Int32    save_t;
+      Int32    save_alphaSize;
+      Int32    save_nGroups;
+      Int32    save_nSelectors;
+      Int32    save_EOB;
+      Int32    save_groupNo;
+      Int32    save_groupPos;
+      Int32    save_nextSym;
+      Int32    save_nblockMAX;
+      Int32    save_nblock;
+      Int32    save_es;
+      Int32    save_N;
+      Int32    save_curr;
+      Int32    save_zt;
+      Int32    save_zn;
+      Int32    save_zvec;
+      Int32    save_zj;
+      Int32    save_gSel;
+      Int32    save_gMinlen;
+      Int32*   save_gLimit;
+      Int32*   save_gBase;
+      Int32*   save_gPerm;
+
+   }
+   DState;
+
+
+/*-- Macros for decompression. --*/
+
+#define BZ_GET_FAST(cccc)                     \
+    s->tPos = s->tt[s->tPos];                 \
+    cccc = (UChar)(s->tPos & 0xff);           \
+    s->tPos >>= 8;
+
+#define BZ_GET_FAST_C(cccc)                   \
+    c_tPos = c_tt[c_tPos];                    \
+    cccc = (UChar)(c_tPos & 0xff);            \
+    c_tPos >>= 8;
+
+#define SET_LL4(i,n)                                          \
+   { if (((i) & 0x1) == 0)                                    \
+       s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else    \
+       s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4);  \
+   }
+
+#define GET_LL4(i)                             \
+   ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
+
+#define SET_LL(i,n)                          \
+   { s->ll16[i] = (UInt16)(n & 0x0000ffff);  \
+     SET_LL4(i, n >> 16);                    \
+   }
+
+#define GET_LL(i) \
+   (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
+
+#define BZ_GET_SMALL(cccc)                            \
+      cccc = BZ2_indexIntoF ( s->tPos, s->cftab );    \
+      s->tPos = GET_LL(s->tPos);
+
+
+/*-- externs for decompression. --*/
+
+extern Int32
+BZ2_indexIntoF ( Int32, Int32* );
+
+extern Int32
+BZ2_decompress ( DState* );
+
+extern void
+BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
+                          Int32,  Int32, Int32 );
+
+
+#endif
+
+
+/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
+
+#ifdef BZ_NO_STDIO
+#ifndef NULL
+#define NULL 0
+#endif
+#endif
+
+
+/*-------------------------------------------------------------*/
+/*--- end                                   bzlib_private.h ---*/
+/*-------------------------------------------------------------*/
diff --git a/lib/bzip2/bzlib_randtable.c b/lib/bzip2/bzlib_randtable.c
new file mode 100644 (file)
index 0000000..c3dc7e4
--- /dev/null
@@ -0,0 +1,125 @@
+#include <config.h>
+
+/*-------------------------------------------------------------*/
+/*--- Table for randomising repetitive blocks               ---*/
+/*---                                           randtable.c ---*/
+/*-------------------------------------------------------------*/
+
+/*--
+  This file is a part of bzip2 and/or libbzip2, a program and
+  library for lossless, block-sorting data compression.
+
+  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+
+  2. The origin of this software must not be misrepresented; you must
+     not claim that you wrote the original software.  If you use this
+     software in a product, an acknowledgment in the product
+     documentation would be appreciated but is not required.
+
+  3. Altered source versions must be plainly marked as such, and must
+     not be misrepresented as being the original software.
+
+  4. The name of the author may not be used to endorse or promote
+     products derived from this software without specific prior written
+     permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+  Julian Seward, Cambridge, UK.
+  jseward@acm.org
+  bzip2/libbzip2 version 1.0 of 21 March 2000
+
+  This program is based on (at least) the work of:
+     Mike Burrows
+     David Wheeler
+     Peter Fenwick
+     Alistair Moffat
+     Radford Neal
+     Ian H. Witten
+     Robert Sedgewick
+     Jon L. Bentley
+
+  For more information on these sources, see the manual.
+--*/
+
+
+#include "bzlib_private.h"
+
+
+/*---------------------------------------------*/
+Int32 BZ2_rNums[512] = {
+   619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
+   985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
+   733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
+   419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
+   878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
+   862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
+   150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
+   170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
+   73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
+   909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
+   641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
+   161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
+   382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
+   98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
+   227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
+   469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
+   184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
+   715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
+   951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
+   652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
+   645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
+   609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
+   653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
+   411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
+   170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
+   857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
+   669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
+   944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
+   344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
+   897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
+   433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
+   686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
+   946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
+   978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
+   680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
+   707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
+   297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
+   134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
+   343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
+   140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
+   170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
+   369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
+   804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
+   896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
+   661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
+   768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
+   61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
+   372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
+   780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
+   920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
+   645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
+   936, 638
+};
+
+
+/*-------------------------------------------------------------*/
+/*--- end                                       randtable.c ---*/
+/*-------------------------------------------------------------*/
diff --git a/lib/bzlib.c b/lib/bzlib.c
deleted file mode 100644 (file)
index 5844e18..0000000
+++ /dev/null
@@ -1,1601 +0,0 @@
-#include <config.h>
-#include <common.h>
-#include <watchdog.h>
-
-/*
- * This file is a modified version of bzlib.c from the bzip2-1.0.2
- * distribution which can be found at http://sources.redhat.com/bzip2/
- */
-
-/*-------------------------------------------------------------*/
-/*--- Library top-level functions.                          ---*/
-/*---                                               bzlib.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. The origin of this software must not be misrepresented; you must
-     not claim that you wrote the original software.  If you use this
-     software in a product, an acknowledgment in the product
-     documentation would be appreciated but is not required.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote
-     products derived from this software without specific prior written
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-  Julian Seward, Cambridge, UK.
-  jseward@acm.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-/*--
-   CHANGES
-   ~~~~~~~
-   0.9.0 -- original version.
-
-   0.9.0a/b -- no changes in this file.
-
-   0.9.0c
-      * made zero-length BZ_FLUSH work correctly in bzCompress().
-      * fixed bzWrite/bzRead to ignore zero-length requests.
-      * fixed bzread to correctly handle read requests after EOF.
-      * wrong parameter order in call to bzDecompressInit in
-       bzBuffToBuffDecompress.  Fixed.
---*/
-
-#include "bzlib_private.h"
-
-/*---------------------------------------------------*/
-/*--- Compression stuff                           ---*/
-/*---------------------------------------------------*/
-
-
-/*---------------------------------------------------*/
-#ifndef BZ_NO_STDIO
-void BZ2_bz__AssertH__fail ( int errcode )
-{
-   fprintf(stderr,
-      "\n\nbzip2/libbzip2: internal error number %d.\n"
-      "This is a bug in bzip2/libbzip2, %s.\n"
-      "Please report it to me at: jseward@acm.org.  If this happened\n"
-      "when you were using some program which uses libbzip2 as a\n"
-      "component, you should also report this bug to the author(s)\n"
-      "of that program.  Please make an effort to report this bug;\n"
-      "timely and accurate bug reports eventually lead to higher\n"
-      "quality software.  Thanks.  Julian Seward, 30 December 2001.\n\n",
-      errcode,
-      BZ2_bzlibVersion()
-   );
-
-   if (errcode == 1007) {
-   fprintf(stderr,
-      "\n*** A special note about internal error number 1007 ***\n"
-      "\n"
-      "Experience suggests that a common cause of i.e. 1007\n"
-      "is unreliable memory or other hardware.  The 1007 assertion\n"
-      "just happens to cross-check the results of huge numbers of\n"
-      "memory reads/writes, and so acts (unintendedly) as a stress\n"
-      "test of your memory system.\n"
-      "\n"
-      "I suggest the following: try compressing the file again,\n"
-      "possibly monitoring progress in detail with the -vv flag.\n"
-      "\n"
-      "* If the error cannot be reproduced, and/or happens at different\n"
-      "  points in compression, you may have a flaky memory system.\n"
-      "  Try a memory-test program.  I have used Memtest86\n"
-      "  (www.memtest86.com).  At the time of writing it is free (GPLd).\n"
-      "  Memtest86 tests memory much more thorougly than your BIOSs\n"
-      "  power-on test, and may find failures that the BIOS doesn't.\n"
-      "\n"
-      "* If the error can be repeatably reproduced, this is a bug in\n"
-      "  bzip2, and I would very much like to hear about it.  Please\n"
-      "  let me know, and, ideally, save a copy of the file causing the\n"
-      "  problem -- without which I will be unable to investigate it.\n"
-      "\n"
-   );
-   }
-
-   exit(3);
-}
-#endif
-
-
-/*---------------------------------------------------*/
-static
-int bz_config_ok ( void )
-{
-   if (sizeof(int)   != 4) return 0;
-   if (sizeof(short) != 2) return 0;
-   if (sizeof(char)  != 1) return 0;
-   return 1;
-}
-
-
-/*---------------------------------------------------*/
-static
-void* default_bzalloc ( void* opaque, Int32 items, Int32 size )
-{
-   void* v = malloc ( items * size );
-   return v;
-}
-
-static
-void default_bzfree ( void* opaque, void* addr )
-{
-   if (addr != NULL) free ( addr );
-}
-
-#ifndef BZ_NO_COMPRESS
-/*---------------------------------------------------*/
-static
-void prepare_new_block ( EState* s )
-{
-   Int32 i;
-   s->nblock = 0;
-   s->numZ = 0;
-   s->state_out_pos = 0;
-   BZ_INITIALISE_CRC ( s->blockCRC );
-   for (i = 0; i < 256; i++) s->inUse[i] = False;
-   s->blockNo++;
-}
-
-
-/*---------------------------------------------------*/
-static
-void init_RL ( EState* s )
-{
-   s->state_in_ch  = 256;
-   s->state_in_len = 0;
-}
-
-
-static
-Bool isempty_RL ( EState* s )
-{
-   if (s->state_in_ch < 256 && s->state_in_len > 0)
-      return False; else
-      return True;
-}
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressInit)
-                   ( bz_stream* strm,
-                    int        blockSize100k,
-                    int        verbosity,
-                    int        workFactor )
-{
-   Int32   n;
-   EState* s;
-
-   if (!bz_config_ok()) return BZ_CONFIG_ERROR;
-
-   if (strm == NULL ||
-       blockSize100k < 1 || blockSize100k > 9 ||
-       workFactor < 0 || workFactor > 250)
-     return BZ_PARAM_ERROR;
-
-   if (workFactor == 0) workFactor = 30;
-   if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
-   if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
-   s = BZALLOC( sizeof(EState) );
-   if (s == NULL) return BZ_MEM_ERROR;
-   s->strm = strm;
-
-   s->arr1 = NULL;
-   s->arr2 = NULL;
-   s->ftab = NULL;
-
-   n       = 100000 * blockSize100k;
-   s->arr1 = BZALLOC( n                  * sizeof(UInt32) );
-   s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
-   s->ftab = BZALLOC( 65537              * sizeof(UInt32) );
-
-   if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
-      if (s->arr1 != NULL) BZFREE(s->arr1);
-      if (s->arr2 != NULL) BZFREE(s->arr2);
-      if (s->ftab != NULL) BZFREE(s->ftab);
-      if (s       != NULL) BZFREE(s);
-      return BZ_MEM_ERROR;
-   }
-
-   s->blockNo           = 0;
-   s->state             = BZ_S_INPUT;
-   s->mode              = BZ_M_RUNNING;
-   s->combinedCRC       = 0;
-   s->blockSize100k     = blockSize100k;
-   s->nblockMAX         = 100000 * blockSize100k - 19;
-   s->verbosity         = verbosity;
-   s->workFactor        = workFactor;
-
-   s->block             = (UChar*)s->arr2;
-   s->mtfv              = (UInt16*)s->arr1;
-   s->zbits             = NULL;
-   s->ptr               = (UInt32*)s->arr1;
-
-   strm->state          = s;
-   strm->total_in_lo32  = 0;
-   strm->total_in_hi32  = 0;
-   strm->total_out_lo32 = 0;
-   strm->total_out_hi32 = 0;
-   init_RL ( s );
-   prepare_new_block ( s );
-   return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-static
-void add_pair_to_block ( EState* s )
-{
-   Int32 i;
-   UChar ch = (UChar)(s->state_in_ch);
-   for (i = 0; i < s->state_in_len; i++) {
-      BZ_UPDATE_CRC( s->blockCRC, ch );
-   }
-   s->inUse[s->state_in_ch] = True;
-   switch (s->state_in_len) {
-      case 1:
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        break;
-      case 2:
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        break;
-      case 3:
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        break;
-      default:
-        s->inUse[s->state_in_len-4] = True;
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        s->block[s->nblock] = (UChar)ch; s->nblock++;
-        s->block[s->nblock] = ((UChar)(s->state_in_len-4));
-        s->nblock++;
-        break;
-   }
-}
-
-
-/*---------------------------------------------------*/
-static
-void flush_RL ( EState* s )
-{
-   if (s->state_in_ch < 256) add_pair_to_block ( s );
-   init_RL ( s );
-}
-
-
-/*---------------------------------------------------*/
-#define ADD_CHAR_TO_BLOCK(zs,zchh0)               \
-{                                                 \
-   UInt32 zchh = (UInt32)(zchh0);                 \
-   /*-- fast track the common case --*/           \
-   if (zchh != zs->state_in_ch &&                 \
-       zs->state_in_len == 1) {                   \
-      UChar ch = (UChar)(zs->state_in_ch);        \
-      BZ_UPDATE_CRC( zs->blockCRC, ch );          \
-      zs->inUse[zs->state_in_ch] = True;          \
-      zs->block[zs->nblock] = (UChar)ch;          \
-      zs->nblock++;                               \
-      zs->state_in_ch = zchh;                     \
-   }                                              \
-   else                                           \
-   /*-- general, uncommon cases --*/              \
-   if (zchh != zs->state_in_ch ||                 \
-      zs->state_in_len == 255) {                  \
-      if (zs->state_in_ch < 256)                  \
-        add_pair_to_block ( zs );                \
-      zs->state_in_ch = zchh;                     \
-      zs->state_in_len = 1;                       \
-   } else {                                       \
-      zs->state_in_len++;                         \
-   }                                              \
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool copy_input_until_stop ( EState* s )
-{
-   Bool progress_in = False;
-
-   if (s->mode == BZ_M_RUNNING) {
-
-      /*-- fast track the common case --*/
-      while (True) {
-        /*-- block full? --*/
-        if (s->nblock >= s->nblockMAX) break;
-        /*-- no input? --*/
-        if (s->strm->avail_in == 0) break;
-        progress_in = True;
-        ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
-        s->strm->next_in++;
-        s->strm->avail_in--;
-        s->strm->total_in_lo32++;
-        if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
-      }
-
-   } else {
-
-      /*-- general, uncommon case --*/
-      while (True) {
-        /*-- block full? --*/
-        if (s->nblock >= s->nblockMAX) break;
-        /*-- no input? --*/
-        if (s->strm->avail_in == 0) break;
-        /*-- flush/finish end? --*/
-        if (s->avail_in_expect == 0) break;
-        progress_in = True;
-        ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
-        s->strm->next_in++;
-        s->strm->avail_in--;
-        s->strm->total_in_lo32++;
-        if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
-        s->avail_in_expect--;
-      }
-   }
-   return progress_in;
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool copy_output_until_stop ( EState* s )
-{
-   Bool progress_out = False;
-
-   while (True) {
-
-      /*-- no output space? --*/
-      if (s->strm->avail_out == 0) break;
-
-      /*-- block done? --*/
-      if (s->state_out_pos >= s->numZ) break;
-
-      progress_out = True;
-      *(s->strm->next_out) = s->zbits[s->state_out_pos];
-      s->state_out_pos++;
-      s->strm->avail_out--;
-      s->strm->next_out++;
-      s->strm->total_out_lo32++;
-      if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
-   }
-
-   return progress_out;
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool handle_compress ( bz_stream* strm )
-{
-   Bool progress_in  = False;
-   Bool progress_out = False;
-   EState* s = strm->state;
-
-   while (True) {
-
-      if (s->state == BZ_S_OUTPUT) {
-        progress_out |= copy_output_until_stop ( s );
-        if (s->state_out_pos < s->numZ) break;
-        if (s->mode == BZ_M_FINISHING &&
-            s->avail_in_expect == 0 &&
-            isempty_RL(s)) break;
-        prepare_new_block ( s );
-        s->state = BZ_S_INPUT;
-        if (s->mode == BZ_M_FLUSHING &&
-            s->avail_in_expect == 0 &&
-            isempty_RL(s)) break;
-      }
-
-      if (s->state == BZ_S_INPUT) {
-        progress_in |= copy_input_until_stop ( s );
-        if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
-           flush_RL ( s );
-           BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) );
-           s->state = BZ_S_OUTPUT;
-        }
-        else
-        if (s->nblock >= s->nblockMAX) {
-           BZ2_compressBlock ( s, False );
-           s->state = BZ_S_OUTPUT;
-        }
-        else
-        if (s->strm->avail_in == 0) {
-           break;
-        }
-      }
-
-   }
-
-   return progress_in || progress_out;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
-{
-   Bool progress;
-   EState* s;
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   s = strm->state;
-   if (s == NULL) return BZ_PARAM_ERROR;
-   if (s->strm != strm) return BZ_PARAM_ERROR;
-
-   preswitch:
-   switch (s->mode) {
-
-      case BZ_M_IDLE:
-        return BZ_SEQUENCE_ERROR;
-
-      case BZ_M_RUNNING:
-        if (action == BZ_RUN) {
-           progress = handle_compress ( strm );
-           return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
-        }
-        else
-        if (action == BZ_FLUSH) {
-           s->avail_in_expect = strm->avail_in;
-           s->mode = BZ_M_FLUSHING;
-           goto preswitch;
-        }
-        else
-        if (action == BZ_FINISH) {
-           s->avail_in_expect = strm->avail_in;
-           s->mode = BZ_M_FINISHING;
-           goto preswitch;
-        }
-        else
-           return BZ_PARAM_ERROR;
-
-      case BZ_M_FLUSHING:
-        if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
-        if (s->avail_in_expect != s->strm->avail_in)
-           return BZ_SEQUENCE_ERROR;
-        progress = handle_compress ( strm );
-        if (s->avail_in_expect > 0 || !isempty_RL(s) ||
-            s->state_out_pos < s->numZ) return BZ_FLUSH_OK;
-        s->mode = BZ_M_RUNNING;
-        return BZ_RUN_OK;
-
-      case BZ_M_FINISHING:
-        if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
-        if (s->avail_in_expect != s->strm->avail_in)
-           return BZ_SEQUENCE_ERROR;
-        progress = handle_compress ( strm );
-        if (!progress) return BZ_SEQUENCE_ERROR;
-        if (s->avail_in_expect > 0 || !isempty_RL(s) ||
-            s->state_out_pos < s->numZ) return BZ_FINISH_OK;
-        s->mode = BZ_M_IDLE;
-        return BZ_STREAM_END;
-   }
-   return BZ_OK; /*--not reached--*/
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressEnd)  ( bz_stream *strm )
-{
-   EState* s;
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   s = strm->state;
-   if (s == NULL) return BZ_PARAM_ERROR;
-   if (s->strm != strm) return BZ_PARAM_ERROR;
-
-   if (s->arr1 != NULL) BZFREE(s->arr1);
-   if (s->arr2 != NULL) BZFREE(s->arr2);
-   if (s->ftab != NULL) BZFREE(s->ftab);
-   BZFREE(strm->state);
-
-   strm->state = NULL;
-
-   return BZ_OK;
-}
-#endif /* BZ_NO_COMPRESS */
-
-/*---------------------------------------------------*/
-/*--- Decompression stuff                         ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressInit)
-                    ( bz_stream* strm,
-                      int        verbosity,
-                      int        small )
-{
-   DState* s;
-
-   if (!bz_config_ok()) return BZ_CONFIG_ERROR;
-
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   if (small != 0 && small != 1) return BZ_PARAM_ERROR;
-   if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR;
-
-   if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
-   if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
-   s = BZALLOC( sizeof(DState) );
-   if (s == NULL) return BZ_MEM_ERROR;
-   s->strm                  = strm;
-   strm->state              = s;
-   s->state                 = BZ_X_MAGIC_1;
-   s->bsLive                = 0;
-   s->bsBuff                = 0;
-   s->calculatedCombinedCRC = 0;
-   strm->total_in_lo32      = 0;
-   strm->total_in_hi32      = 0;
-   strm->total_out_lo32     = 0;
-   strm->total_out_hi32     = 0;
-   s->smallDecompress       = (Bool)small;
-   s->ll4                   = NULL;
-   s->ll16                  = NULL;
-   s->tt                    = NULL;
-   s->currBlockNo           = 0;
-   s->verbosity             = verbosity;
-
-   return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-static
-void unRLE_obuf_to_output_FAST ( DState* s )
-{
-   UChar k1;
-
-   if (s->blockRandomised) {
-
-      while (True) {
-        /* try to finish existing run */
-        while (True) {
-           if (s->strm->avail_out == 0) return;
-           if (s->state_out_len == 0) break;
-           *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
-           BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
-           s->state_out_len--;
-           s->strm->next_out++;
-           s->strm->avail_out--;
-           s->strm->total_out_lo32++;
-           if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
-        }
-
-        /* can a new run be started? */
-        if (s->nblock_used == s->save_nblock+1) return;
-
-
-        s->state_out_len = 1;
-        s->state_out_ch = s->k0;
-        BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
-        k1 ^= BZ_RAND_MASK; s->nblock_used++;
-        if (s->nblock_used == s->save_nblock+1) continue;
-        if (k1 != s->k0) { s->k0 = k1; continue; };
-
-        s->state_out_len = 2;
-        BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
-        k1 ^= BZ_RAND_MASK; s->nblock_used++;
-        if (s->nblock_used == s->save_nblock+1) continue;
-        if (k1 != s->k0) { s->k0 = k1; continue; };
-
-        s->state_out_len = 3;
-        BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
-        k1 ^= BZ_RAND_MASK; s->nblock_used++;
-        if (s->nblock_used == s->save_nblock+1) continue;
-        if (k1 != s->k0) { s->k0 = k1; continue; };
-
-        BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
-        k1 ^= BZ_RAND_MASK; s->nblock_used++;
-        s->state_out_len = ((Int32)k1) + 4;
-        BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
-        s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
-      }
-
-   } else {
-
-      /* restore */
-      UInt32        c_calculatedBlockCRC = s->calculatedBlockCRC;
-      UChar         c_state_out_ch       = s->state_out_ch;
-      Int32         c_state_out_len      = s->state_out_len;
-      Int32         c_nblock_used        = s->nblock_used;
-      Int32         c_k0                 = s->k0;
-      UInt32*       c_tt                 = s->tt;
-      UInt32        c_tPos               = s->tPos;
-      char*         cs_next_out          = s->strm->next_out;
-      unsigned int  cs_avail_out         = s->strm->avail_out;
-      /* end restore */
-
-      UInt32       avail_out_INIT = cs_avail_out;
-      Int32        s_save_nblockPP = s->save_nblock+1;
-      unsigned int total_out_lo32_old;
-
-      while (True) {
-
-        /* try to finish existing run */
-        if (c_state_out_len > 0) {
-           while (True) {
-              if (cs_avail_out == 0) goto return_notr;
-              if (c_state_out_len == 1) break;
-              *( (UChar*)(cs_next_out) ) = c_state_out_ch;
-              BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
-              c_state_out_len--;
-              cs_next_out++;
-              cs_avail_out--;
-           }
-           s_state_out_len_eq_one:
-           {
-              if (cs_avail_out == 0) {
-                 c_state_out_len = 1; goto return_notr;
-              };
-              *( (UChar*)(cs_next_out) ) = c_state_out_ch;
-              BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
-              cs_next_out++;
-              cs_avail_out--;
-           }
-        }
-        /* can a new run be started? */
-        if (c_nblock_used == s_save_nblockPP) {
-           c_state_out_len = 0; goto return_notr;
-        };
-        c_state_out_ch = c_k0;
-        BZ_GET_FAST_C(k1); c_nblock_used++;
-        if (k1 != c_k0) {
-           c_k0 = k1; goto s_state_out_len_eq_one;
-        };
-        if (c_nblock_used == s_save_nblockPP)
-           goto s_state_out_len_eq_one;
-
-        c_state_out_len = 2;
-        BZ_GET_FAST_C(k1); c_nblock_used++;
-        if (c_nblock_used == s_save_nblockPP) continue;
-        if (k1 != c_k0) { c_k0 = k1; continue; };
-
-        c_state_out_len = 3;
-        BZ_GET_FAST_C(k1); c_nblock_used++;
-        if (c_nblock_used == s_save_nblockPP) continue;
-        if (k1 != c_k0) { c_k0 = k1; continue; };
-
-        BZ_GET_FAST_C(k1); c_nblock_used++;
-        c_state_out_len = ((Int32)k1) + 4;
-        BZ_GET_FAST_C(c_k0); c_nblock_used++;
-      }
-
-      return_notr:
-      total_out_lo32_old = s->strm->total_out_lo32;
-      s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out);
-      if (s->strm->total_out_lo32 < total_out_lo32_old)
-        s->strm->total_out_hi32++;
-
-      /* save */
-      s->calculatedBlockCRC = c_calculatedBlockCRC;
-      s->state_out_ch       = c_state_out_ch;
-      s->state_out_len      = c_state_out_len;
-      s->nblock_used        = c_nblock_used;
-      s->k0                 = c_k0;
-      s->tt                 = c_tt;
-      s->tPos               = c_tPos;
-      s->strm->next_out     = cs_next_out;
-      s->strm->avail_out    = cs_avail_out;
-      /* end save */
-   }
-}
-
-
-/*---------------------------------------------------*/
-__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
-{
-   Int32 nb, na, mid;
-   nb = 0;
-   na = 256;
-   do {
-      mid = (nb + na) >> 1;
-      if (indx >= cftab[mid]) nb = mid; else na = mid;
-   }
-   while (na - nb != 1);
-   return nb;
-}
-
-
-/*---------------------------------------------------*/
-static
-void unRLE_obuf_to_output_SMALL ( DState* s )
-{
-   UChar k1;
-
-   if (s->blockRandomised) {
-
-      while (True) {
-        /* try to finish existing run */
-        while (True) {
-           if (s->strm->avail_out == 0) return;
-           if (s->state_out_len == 0) break;
-           *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
-           BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
-           s->state_out_len--;
-           s->strm->next_out++;
-           s->strm->avail_out--;
-           s->strm->total_out_lo32++;
-           if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
-        }
-
-        /* can a new run be started? */
-        if (s->nblock_used == s->save_nblock+1) return;
-
-
-        s->state_out_len = 1;
-        s->state_out_ch = s->k0;
-        BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
-        k1 ^= BZ_RAND_MASK; s->nblock_used++;
-        if (s->nblock_used == s->save_nblock+1) continue;
-        if (k1 != s->k0) { s->k0 = k1; continue; };
-
-        s->state_out_len = 2;
-        BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
-        k1 ^= BZ_RAND_MASK; s->nblock_used++;
-        if (s->nblock_used == s->save_nblock+1) continue;
-        if (k1 != s->k0) { s->k0 = k1; continue; };
-
-        s->state_out_len = 3;
-        BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
-        k1 ^= BZ_RAND_MASK; s->nblock_used++;
-        if (s->nblock_used == s->save_nblock+1) continue;
-        if (k1 != s->k0) { s->k0 = k1; continue; };
-
-        BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
-        k1 ^= BZ_RAND_MASK; s->nblock_used++;
-        s->state_out_len = ((Int32)k1) + 4;
-        BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
-        s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
-      }
-
-   } else {
-
-      while (True) {
-        /* try to finish existing run */
-        while (True) {
-           if (s->strm->avail_out == 0) return;
-           if (s->state_out_len == 0) break;
-           *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
-           BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
-           s->state_out_len--;
-           s->strm->next_out++;
-           s->strm->avail_out--;
-           s->strm->total_out_lo32++;
-           if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
-        }
-
-        /* can a new run be started? */
-        if (s->nblock_used == s->save_nblock+1) return;
-
-        s->state_out_len = 1;
-        s->state_out_ch = s->k0;
-        BZ_GET_SMALL(k1); s->nblock_used++;
-        if (s->nblock_used == s->save_nblock+1) continue;
-        if (k1 != s->k0) { s->k0 = k1; continue; };
-
-        s->state_out_len = 2;
-        BZ_GET_SMALL(k1); s->nblock_used++;
-        if (s->nblock_used == s->save_nblock+1) continue;
-        if (k1 != s->k0) { s->k0 = k1; continue; };
-
-        s->state_out_len = 3;
-        BZ_GET_SMALL(k1); s->nblock_used++;
-        if (s->nblock_used == s->save_nblock+1) continue;
-        if (k1 != s->k0) { s->k0 = k1; continue; };
-
-        BZ_GET_SMALL(k1); s->nblock_used++;
-        s->state_out_len = ((Int32)k1) + 4;
-        BZ_GET_SMALL(s->k0); s->nblock_used++;
-      }
-
-   }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
-{
-   DState* s;
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   s = strm->state;
-   if (s == NULL) return BZ_PARAM_ERROR;
-   if (s->strm != strm) return BZ_PARAM_ERROR;
-
-   while (True) {
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-       WATCHDOG_RESET();
-#endif
-      if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
-      if (s->state == BZ_X_OUTPUT) {
-        if (s->smallDecompress)
-           unRLE_obuf_to_output_SMALL ( s ); else
-           unRLE_obuf_to_output_FAST  ( s );
-        if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
-           BZ_FINALISE_CRC ( s->calculatedBlockCRC );
-           if (s->verbosity >= 3)
-              VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC,
-                         s->calculatedBlockCRC );
-           if (s->verbosity >= 2) VPrintf0 ( "]" );
-           if (s->calculatedBlockCRC != s->storedBlockCRC)
-              return BZ_DATA_ERROR;
-           s->calculatedCombinedCRC
-              = (s->calculatedCombinedCRC << 1) |
-                   (s->calculatedCombinedCRC >> 31);
-           s->calculatedCombinedCRC ^= s->calculatedBlockCRC;
-           s->state = BZ_X_BLKHDR_1;
-        } else {
-           return BZ_OK;
-        }
-      }
-      if (s->state >= BZ_X_MAGIC_1) {
-        Int32 r = BZ2_decompress ( s );
-        if (r == BZ_STREAM_END) {
-           if (s->verbosity >= 3)
-              VPrintf2 ( "\n    combined CRCs: stored = 0x%x, computed = 0x%x",
-                         s->storedCombinedCRC, s->calculatedCombinedCRC );
-           if (s->calculatedCombinedCRC != s->storedCombinedCRC)
-              return BZ_DATA_ERROR;
-           return r;
-        }
-        if (s->state != BZ_X_OUTPUT) return r;
-      }
-   }
-
-   AssertH ( 0, 6001 );
-
-   return 0;  /*NOTREACHED*/
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressEnd)  ( bz_stream *strm )
-{
-   DState* s;
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   s = strm->state;
-   if (s == NULL) return BZ_PARAM_ERROR;
-   if (s->strm != strm) return BZ_PARAM_ERROR;
-
-   if (s->tt   != NULL) BZFREE(s->tt);
-   if (s->ll16 != NULL) BZFREE(s->ll16);
-   if (s->ll4  != NULL) BZFREE(s->ll4);
-
-   BZFREE(strm->state);
-   strm->state = NULL;
-
-   return BZ_OK;
-}
-
-
-#ifndef BZ_NO_STDIO
-/*---------------------------------------------------*/
-/*--- File I/O stuff                              ---*/
-/*---------------------------------------------------*/
-
-#define BZ_SETERR(eee)                    \
-{                                         \
-   if (bzerror != NULL) *bzerror = eee;   \
-   if (bzf != NULL) bzf->lastErr = eee;   \
-}
-
-typedef
-   struct {
-      FILE*     handle;
-      Char      buf[BZ_MAX_UNUSED];
-      Int32     bufN;
-      Bool      writing;
-      bz_stream strm;
-      Int32     lastErr;
-      Bool      initialisedOk;
-   }
-   bzFile;
-
-
-/*---------------------------------------------*/
-static Bool myfeof ( FILE* f )
-{
-   Int32 c = fgetc ( f );
-   if (c == EOF) return True;
-   ungetc ( c, f );
-   return False;
-}
-
-
-/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzWriteOpen)
-                   ( int*  bzerror,
-                     FILE* f,
-                     int   blockSize100k,
-                     int   verbosity,
-                     int   workFactor )
-{
-   Int32   ret;
-   bzFile* bzf = NULL;
-
-   BZ_SETERR(BZ_OK);
-
-   if (f == NULL ||
-       (blockSize100k < 1 || blockSize100k > 9) ||
-       (workFactor < 0 || workFactor > 250) ||
-       (verbosity < 0 || verbosity > 4))
-      { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
-
-   if (ferror(f))
-      { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
-   bzf = malloc ( sizeof(bzFile) );
-   if (bzf == NULL)
-      { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
-   BZ_SETERR(BZ_OK);
-   bzf->initialisedOk = False;
-   bzf->bufN          = 0;
-   bzf->handle        = f;
-   bzf->writing       = True;
-   bzf->strm.bzalloc  = NULL;
-   bzf->strm.bzfree   = NULL;
-   bzf->strm.opaque   = NULL;
-
-   if (workFactor == 0) workFactor = 30;
-   ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k,
-                             verbosity, workFactor );
-   if (ret != BZ_OK)
-      { BZ_SETERR(ret); free(bzf); return NULL; };
-
-   bzf->strm.avail_in = 0;
-   bzf->initialisedOk = True;
-   return bzf;
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzWrite)
-            ( int*    bzerror,
-              BZFILE* b,
-              void*   buf,
-              int     len )
-{
-   Int32 n, n2, ret;
-   bzFile* bzf = (bzFile*)b;
-
-   BZ_SETERR(BZ_OK);
-   if (bzf == NULL || buf == NULL || len < 0)
-      { BZ_SETERR(BZ_PARAM_ERROR); return; };
-   if (!(bzf->writing))
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-   if (ferror(bzf->handle))
-      { BZ_SETERR(BZ_IO_ERROR); return; };
-
-   if (len == 0)
-      { BZ_SETERR(BZ_OK); return; };
-
-   bzf->strm.avail_in = len;
-   bzf->strm.next_in  = buf;
-
-   while (True) {
-      bzf->strm.avail_out = BZ_MAX_UNUSED;
-      bzf->strm.next_out = bzf->buf;
-      ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN );
-      if (ret != BZ_RUN_OK)
-        { BZ_SETERR(ret); return; };
-
-      if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
-        n = BZ_MAX_UNUSED - bzf->strm.avail_out;
-        n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
-                      n, bzf->handle );
-        if (n != n2 || ferror(bzf->handle))
-           { BZ_SETERR(BZ_IO_ERROR); return; };
-      }
-
-      if (bzf->strm.avail_in == 0)
-        { BZ_SETERR(BZ_OK); return; };
-   }
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzWriteClose)
-                 ( int*          bzerror,
-                   BZFILE*       b,
-                   int           abandon,
-                   unsigned int* nbytes_in,
-                   unsigned int* nbytes_out )
-{
-   BZ2_bzWriteClose64 ( bzerror, b, abandon,
-                       nbytes_in, NULL, nbytes_out, NULL );
-}
-
-
-void BZ_API(BZ2_bzWriteClose64)
-                 ( int*          bzerror,
-                   BZFILE*       b,
-                   int           abandon,
-                   unsigned int* nbytes_in_lo32,
-                   unsigned int* nbytes_in_hi32,
-                   unsigned int* nbytes_out_lo32,
-                   unsigned int* nbytes_out_hi32 )
-{
-   Int32   n, n2, ret;
-   bzFile* bzf = (bzFile*)b;
-
-   if (bzf == NULL)
-      { BZ_SETERR(BZ_OK); return; };
-   if (!(bzf->writing))
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-   if (ferror(bzf->handle))
-      { BZ_SETERR(BZ_IO_ERROR); return; };
-
-   if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0;
-   if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0;
-   if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0;
-   if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0;
-
-   if ((!abandon) && bzf->lastErr == BZ_OK) {
-      while (True) {
-        bzf->strm.avail_out = BZ_MAX_UNUSED;
-        bzf->strm.next_out = bzf->buf;
-        ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH );
-        if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END)
-           { BZ_SETERR(ret); return; };
-
-        if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
-           n = BZ_MAX_UNUSED - bzf->strm.avail_out;
-           n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
-                         n, bzf->handle );
-           if (n != n2 || ferror(bzf->handle))
-              { BZ_SETERR(BZ_IO_ERROR); return; };
-        }
-
-        if (ret == BZ_STREAM_END) break;
-      }
-   }
-
-   if ( !abandon && !ferror ( bzf->handle ) ) {
-      fflush ( bzf->handle );
-      if (ferror(bzf->handle))
-        { BZ_SETERR(BZ_IO_ERROR); return; };
-   }
-
-   if (nbytes_in_lo32 != NULL)
-      *nbytes_in_lo32 = bzf->strm.total_in_lo32;
-   if (nbytes_in_hi32 != NULL)
-      *nbytes_in_hi32 = bzf->strm.total_in_hi32;
-   if (nbytes_out_lo32 != NULL)
-      *nbytes_out_lo32 = bzf->strm.total_out_lo32;
-   if (nbytes_out_hi32 != NULL)
-      *nbytes_out_hi32 = bzf->strm.total_out_hi32;
-
-   BZ_SETERR(BZ_OK);
-   BZ2_bzCompressEnd ( &(bzf->strm) );
-   free ( bzf );
-}
-
-
-/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzReadOpen)
-                  ( int*  bzerror,
-                    FILE* f,
-                    int   verbosity,
-                    int   small,
-                    void* unused,
-                    int   nUnused )
-{
-   bzFile* bzf = NULL;
-   int     ret;
-
-   BZ_SETERR(BZ_OK);
-
-   if (f == NULL ||
-       (small != 0 && small != 1) ||
-       (verbosity < 0 || verbosity > 4) ||
-       (unused == NULL && nUnused != 0) ||
-       (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED)))
-      { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
-
-   if (ferror(f))
-      { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
-   bzf = malloc ( sizeof(bzFile) );
-   if (bzf == NULL)
-      { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
-   BZ_SETERR(BZ_OK);
-
-   bzf->initialisedOk = False;
-   bzf->handle        = f;
-   bzf->bufN          = 0;
-   bzf->writing       = False;
-   bzf->strm.bzalloc  = NULL;
-   bzf->strm.bzfree   = NULL;
-   bzf->strm.opaque   = NULL;
-
-   while (nUnused > 0) {
-      bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
-      unused = ((void*)( 1 + ((UChar*)(unused))  ));
-      nUnused--;
-   }
-
-   ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small );
-   if (ret != BZ_OK)
-      { BZ_SETERR(ret); free(bzf); return NULL; };
-
-   bzf->strm.avail_in = bzf->bufN;
-   bzf->strm.next_in  = bzf->buf;
-
-   bzf->initialisedOk = True;
-   return bzf;
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
-{
-   bzFile* bzf = (bzFile*)b;
-
-   BZ_SETERR(BZ_OK);
-   if (bzf == NULL)
-      { BZ_SETERR(BZ_OK); return; };
-
-   if (bzf->writing)
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-
-   if (bzf->initialisedOk)
-      (void)BZ2_bzDecompressEnd ( &(bzf->strm) );
-   free ( bzf );
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzRead)
-          ( int*    bzerror,
-            BZFILE* b,
-            void*   buf,
-            int     len )
-{
-   Int32   n, ret;
-   bzFile* bzf = (bzFile*)b;
-
-   BZ_SETERR(BZ_OK);
-
-   if (bzf == NULL || buf == NULL || len < 0)
-      { BZ_SETERR(BZ_PARAM_ERROR); return 0; };
-
-   if (bzf->writing)
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; };
-
-   if (len == 0)
-      { BZ_SETERR(BZ_OK); return 0; };
-
-   bzf->strm.avail_out = len;
-   bzf->strm.next_out = buf;
-
-   while (True) {
-
-      if (ferror(bzf->handle))
-        { BZ_SETERR(BZ_IO_ERROR); return 0; };
-
-      if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
-        n = fread ( bzf->buf, sizeof(UChar),
-                    BZ_MAX_UNUSED, bzf->handle );
-        if (ferror(bzf->handle))
-           { BZ_SETERR(BZ_IO_ERROR); return 0; };
-        bzf->bufN = n;
-        bzf->strm.avail_in = bzf->bufN;
-        bzf->strm.next_in = bzf->buf;
-      }
-
-      ret = BZ2_bzDecompress ( &(bzf->strm) );
-
-      if (ret != BZ_OK && ret != BZ_STREAM_END)
-        { BZ_SETERR(ret); return 0; };
-
-      if (ret == BZ_OK && myfeof(bzf->handle) &&
-         bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
-        { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
-
-      if (ret == BZ_STREAM_END)
-        { BZ_SETERR(BZ_STREAM_END);
-          return len - bzf->strm.avail_out; };
-      if (bzf->strm.avail_out == 0)
-        { BZ_SETERR(BZ_OK); return len; };
-
-   }
-
-   return 0; /*not reached*/
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadGetUnused)
-                    ( int*    bzerror,
-                      BZFILE* b,
-                      void**  unused,
-                      int*    nUnused )
-{
-   bzFile* bzf = (bzFile*)b;
-   if (bzf == NULL)
-      { BZ_SETERR(BZ_PARAM_ERROR); return; };
-   if (bzf->lastErr != BZ_STREAM_END)
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-   if (unused == NULL || nUnused == NULL)
-      { BZ_SETERR(BZ_PARAM_ERROR); return; };
-
-   BZ_SETERR(BZ_OK);
-   *nUnused = bzf->strm.avail_in;
-   *unused = bzf->strm.next_in;
-}
-#endif
-
-
-/*---------------------------------------------------*/
-/*--- Misc convenience stuff                      ---*/
-/*---------------------------------------------------*/
-#ifndef BZ_NO_COMPRESS
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffCompress)
-                        ( char*         dest,
-                          unsigned int* destLen,
-                          char*         source,
-                          unsigned int  sourceLen,
-                          int           blockSize100k,
-                          int           verbosity,
-                          int           workFactor )
-{
-   bz_stream strm;
-   int ret;
-
-   if (dest == NULL || destLen == NULL ||
-       source == NULL ||
-       blockSize100k < 1 || blockSize100k > 9 ||
-       verbosity < 0 || verbosity > 4 ||
-       workFactor < 0 || workFactor > 250)
-      return BZ_PARAM_ERROR;
-
-   if (workFactor == 0) workFactor = 30;
-   strm.bzalloc = NULL;
-   strm.bzfree = NULL;
-   strm.opaque = NULL;
-   ret = BZ2_bzCompressInit ( &strm, blockSize100k,
-                             verbosity, workFactor );
-   if (ret != BZ_OK) return ret;
-
-   strm.next_in = source;
-   strm.next_out = dest;
-   strm.avail_in = sourceLen;
-   strm.avail_out = *destLen;
-
-   ret = BZ2_bzCompress ( &strm, BZ_FINISH );
-   if (ret == BZ_FINISH_OK) goto output_overflow;
-   if (ret != BZ_STREAM_END) goto errhandler;
-
-   /* normal termination */
-   *destLen -= strm.avail_out;
-   BZ2_bzCompressEnd ( &strm );
-   return BZ_OK;
-
-   output_overflow:
-   BZ2_bzCompressEnd ( &strm );
-   return BZ_OUTBUFF_FULL;
-
-   errhandler:
-   BZ2_bzCompressEnd ( &strm );
-   return ret;
-}
-#endif /* BZ_NO_COMPRESS */
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffDecompress)
-                          ( char*         dest,
-                            unsigned int* destLen,
-                            char*         source,
-                            unsigned int  sourceLen,
-                            int           small,
-                            int           verbosity )
-{
-   bz_stream strm;
-   int ret;
-
-   if (destLen == NULL || source == NULL)
-         return BZ_PARAM_ERROR;
-
-   strm.bzalloc = NULL;
-   strm.bzfree = NULL;
-   strm.opaque = NULL;
-   ret = BZ2_bzDecompressInit ( &strm, verbosity, small );
-   if (ret != BZ_OK) return ret;
-
-   strm.next_in = source;
-   strm.next_out = dest;
-   strm.avail_in = sourceLen;
-   strm.avail_out = *destLen;
-
-   ret = BZ2_bzDecompress ( &strm );
-   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;
-
-   output_overflow_or_eof:
-   if (strm.avail_out > 0) {
-      BZ2_bzDecompressEnd ( &strm );
-      return BZ_UNEXPECTED_EOF;
-   } else {
-      BZ2_bzDecompressEnd ( &strm );
-      return BZ_OUTBUFF_FULL;
-   };
-
-   errhandler:
-   BZ2_bzDecompressEnd ( &strm );
-   return ret;
-}
-
-
-/*---------------------------------------------------*/
-/*--
-   Code contributed by Yoshioka Tsuneo
-   (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
-   to support better zlib compatibility.
-   This code is not _officially_ part of libbzip2 (yet);
-   I haven't tested it, documented it, or considered the
-   threading-safeness of it.
-   If this code breaks, please contact both Yoshioka and me.
---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-/*--
-   return version like "0.9.0c".
---*/
-const char * BZ_API(BZ2_bzlibVersion)(void)
-{
-   return BZ_VERSION;
-}
-
-
-#ifndef BZ_NO_STDIO
-/*---------------------------------------------------*/
-
-#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
-#   include <fcntl.h>
-#   include <io.h>
-#   define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
-#else
-#   define SET_BINARY_MODE(file)
-#endif
-static
-BZFILE * bzopen_or_bzdopen
-              ( const char *path,   /* no use when bzdopen */
-                int fd,             /* no use when bzdopen */
-                const char *mode,
-                int open_mode)      /* bzopen: 0, bzdopen:1 */
-{
-   int    bzerr;
-   char   unused[BZ_MAX_UNUSED];
-   int    blockSize100k = 9;
-   int    writing       = 0;
-   char   mode2[10]     = "";
-   FILE   *fp           = NULL;
-   BZFILE *bzfp         = NULL;
-   int    verbosity     = 0;
-   int    workFactor    = 30;
-   int    smallMode     = 0;
-   int    nUnused       = 0;
-
-   if (mode == NULL) return NULL;
-   while (*mode) {
-      switch (*mode) {
-      case 'r':
-        writing = 0; break;
-      case 'w':
-        writing = 1; break;
-      case 's':
-        smallMode = 1; break;
-      default:
-        if (isdigit((int)(*mode))) {
-           blockSize100k = *mode-BZ_HDR_0;
-        }
-      }
-      mode++;
-   }
-   strcat(mode2, writing ? "w" : "r" );
-   strcat(mode2,"b");   /* binary mode */
-
-   if (open_mode==0) {
-      if (path==NULL || strcmp(path,"")==0) {
-       fp = (writing ? stdout : stdin);
-       SET_BINARY_MODE(fp);
-      } else {
-       fp = fopen(path,mode2);
-      }
-   } else {
-#ifdef BZ_STRICT_ANSI
-      fp = NULL;
-#else
-      fp = fdopen(fd,mode2);
-#endif
-   }
-   if (fp == NULL) return NULL;
-
-   if (writing) {
-      /* Guard against total chaos and anarchy -- JRS */
-      if (blockSize100k < 1) blockSize100k = 1;
-      if (blockSize100k > 9) blockSize100k = 9;
-      bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k,
-                            verbosity,workFactor);
-   } else {
-      bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode,
-                           unused,nUnused);
-   }
-   if (bzfp == NULL) {
-      if (fp != stdin && fp != stdout) fclose(fp);
-      return NULL;
-   }
-   return bzfp;
-}
-
-
-/*---------------------------------------------------*/
-/*--
-   open file for read or write.
-      ex) bzopen("file","w9")
-      case path="" or NULL => use stdin or stdout.
---*/
-BZFILE * BZ_API(BZ2_bzopen)
-              ( const char *path,
-                const char *mode )
-{
-   return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0);
-}
-
-
-/*---------------------------------------------------*/
-BZFILE * BZ_API(BZ2_bzdopen)
-              ( int fd,
-                const char *mode )
-{
-   return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1);
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len )
-{
-   int bzerr, nread;
-   if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0;
-   nread = BZ2_bzRead(&bzerr,b,buf,len);
-   if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) {
-      return nread;
-   } else {
-      return -1;
-   }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len )
-{
-   int bzerr;
-
-   BZ2_bzWrite(&bzerr,b,buf,len);
-   if(bzerr == BZ_OK){
-      return len;
-   }else{
-      return -1;
-   }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzflush) (BZFILE *b)
-{
-   /* do nothing now... */
-   return 0;
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzclose) (BZFILE* b)
-{
-   int bzerr;
-   FILE *fp = ((bzFile *)b)->handle;
-
-   if (b==NULL) {return;}
-   if(((bzFile*)b)->writing){
-      BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
-      if(bzerr != BZ_OK){
-        BZ2_bzWriteClose(NULL,b,1,NULL,NULL);
-      }
-   }else{
-      BZ2_bzReadClose(&bzerr,b);
-   }
-   if(fp!=stdin && fp!=stdout){
-      fclose(fp);
-   }
-}
-
-
-/*---------------------------------------------------*/
-/*--
-   return last error code
---*/
-static char *bzerrorstrings[] = {
-       "OK"
-      ,"SEQUENCE_ERROR"
-      ,"PARAM_ERROR"
-      ,"MEM_ERROR"
-      ,"DATA_ERROR"
-      ,"DATA_ERROR_MAGIC"
-      ,"IO_ERROR"
-      ,"UNEXPECTED_EOF"
-      ,"OUTBUFF_FULL"
-      ,"CONFIG_ERROR"
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-};
-
-
-const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum)
-{
-   int err = ((bzFile *)b)->lastErr;
-
-   if(err>0) err = 0;
-   *errnum = err;
-   return bzerrorstrings[err*-1];
-}
-#endif
-
-void bz_internal_error(int errcode)
-{
-       printf ("BZIP2 internal error %d\n", errcode);
-}
-
-/*-------------------------------------------------------------*/
-/*--- end                                           bzlib.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/lib/bzlib_crctable.c b/lib/bzlib_crctable.c
deleted file mode 100644 (file)
index 325b966..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-#include <config.h>
-
-/*-------------------------------------------------------------*/
-/*--- Table for doing CRCs                                  ---*/
-/*---                                            crctable.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. The origin of this software must not be misrepresented; you must
-     not claim that you wrote the original software.  If you use this
-     software in a product, an acknowledgment in the product
-     documentation would be appreciated but is not required.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote
-     products derived from this software without specific prior written
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-  Julian Seward, Cambridge, UK.
-  jseward@acm.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#include "bzlib_private.h"
-
-/*--
-  I think this is an implementation of the AUTODIN-II,
-  Ethernet & FDDI 32-bit CRC standard.  Vaguely derived
-  from code by Rob Warnock, in Section 51 of the
-  comp.compression FAQ.
---*/
-
-UInt32 BZ2_crc32Table[256] = {
-
-   /*-- Ugly, innit? --*/
-
-   0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
-   0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
-   0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
-   0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
-   0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
-   0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
-   0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
-   0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
-   0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
-   0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
-   0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
-   0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
-   0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
-   0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
-   0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
-   0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
-   0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
-   0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
-   0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
-   0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
-   0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
-   0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
-   0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
-   0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
-   0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
-   0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
-   0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
-   0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
-   0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
-   0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
-   0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
-   0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
-   0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
-   0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
-   0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
-   0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
-   0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
-   0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
-   0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
-   0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
-   0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
-   0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
-   0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
-   0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
-   0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
-   0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
-   0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
-   0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
-   0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
-   0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
-   0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
-   0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
-   0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
-   0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
-   0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
-   0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
-   0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
-   0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
-   0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
-   0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
-   0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
-   0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
-   0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
-   0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
-};
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                        crctable.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/lib/bzlib_decompress.c b/lib/bzlib_decompress.c
deleted file mode 100644 (file)
index 4412b8a..0000000
+++ /dev/null
@@ -1,674 +0,0 @@
-#include <config.h>
-#include <common.h>
-#include <watchdog.h>
-
-/*-------------------------------------------------------------*/
-/*--- Decompression machinery                               ---*/
-/*---                                          decompress.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. The origin of this software must not be misrepresented; you must
-     not claim that you wrote the original software.  If you use this
-     software in a product, an acknowledgment in the product
-     documentation would be appreciated but is not required.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote
-     products derived from this software without specific prior written
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-  Julian Seward, Cambridge, UK.
-  jseward@acm.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-static
-void makeMaps_d ( DState* s )
-{
-   Int32 i;
-   s->nInUse = 0;
-   for (i = 0; i < 256; i++)
-      if (s->inUse[i]) {
-        s->seqToUnseq[s->nInUse] = i;
-        s->nInUse++;
-      }
-}
-
-
-/*---------------------------------------------------*/
-#define RETURN(rrr)                               \
-   { retVal = rrr; goto save_state_and_return; };
-
-#define GET_BITS(lll,vvv,nnn)                     \
-   case lll: s->state = lll;                      \
-   while (True) {                                 \
-      if (s->bsLive >= nnn) {                     \
-        UInt32 v;                                \
-        v = (s->bsBuff >>                        \
-            (s->bsLive-nnn)) & ((1 << nnn)-1);   \
-        s->bsLive -= nnn;                        \
-        vvv = v;                                 \
-        break;                                   \
-      }                                           \
-      if (s->strm->avail_in == 0) RETURN(BZ_OK);  \
-      s->bsBuff                                   \
-        = (s->bsBuff << 8) |                     \
-          ((UInt32)                              \
-             (*((UChar*)(s->strm->next_in))));   \
-      s->bsLive += 8;                             \
-      s->strm->next_in++;                         \
-      s->strm->avail_in--;                        \
-      s->strm->total_in_lo32++;                   \
-      if (s->strm->total_in_lo32 == 0)            \
-        s->strm->total_in_hi32++;                \
-   }
-
-#define GET_UCHAR(lll,uuu)                        \
-   GET_BITS(lll,uuu,8)
-
-#define GET_BIT(lll,uuu)                          \
-   GET_BITS(lll,uuu,1)
-
-/*---------------------------------------------------*/
-#define GET_MTF_VAL(label1,label2,lval)           \
-{                                                 \
-   if (groupPos == 0) {                           \
-      groupNo++;                                  \
-      if (groupNo >= nSelectors)                  \
-        RETURN(BZ_DATA_ERROR);                   \
-      groupPos = BZ_G_SIZE;                       \
-      gSel = s->selector[groupNo];                \
-      gMinlen = s->minLens[gSel];                 \
-      gLimit = &(s->limit[gSel][0]);              \
-      gPerm = &(s->perm[gSel][0]);                \
-      gBase = &(s->base[gSel][0]);                \
-   }                                              \
-   groupPos--;                                    \
-   zn = gMinlen;                                  \
-   GET_BITS(label1, zvec, zn);                    \
-   while (1) {                                    \
-      if (zn > 20 /* the longest code */)         \
-        RETURN(BZ_DATA_ERROR);                   \
-      if (zvec <= gLimit[zn]) break;              \
-      zn++;                                       \
-      GET_BIT(label2, zj);                        \
-      zvec = (zvec << 1) | zj;                    \
-   };                                             \
-   if (zvec - gBase[zn] < 0                       \
-       || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE)  \
-      RETURN(BZ_DATA_ERROR);                      \
-   lval = gPerm[zvec - gBase[zn]];                \
-}
-
-
-/*---------------------------------------------------*/
-Int32 BZ2_decompress ( DState* s )
-{
-   UChar      uc;
-   Int32      retVal;
-   Int32      minLen, maxLen;
-   bz_stream* strm = s->strm;
-
-   /* stuff that needs to be saved/restored */
-   Int32  i;
-   Int32  j;
-   Int32  t;
-   Int32  alphaSize;
-   Int32  nGroups;
-   Int32  nSelectors;
-   Int32  EOB;
-   Int32  groupNo;
-   Int32  groupPos;
-   Int32  nextSym;
-   Int32  nblockMAX;
-   Int32  nblock;
-   Int32  es;
-   Int32  N;
-   Int32  curr;
-   Int32  zt;
-   Int32  zn;
-   Int32  zvec;
-   Int32  zj;
-   Int32  gSel;
-   Int32  gMinlen;
-   Int32* gLimit;
-   Int32* gBase;
-   Int32* gPerm;
-
-   if (s->state == BZ_X_MAGIC_1) {
-      /*initialise the save area*/
-      s->save_i           = 0;
-      s->save_j           = 0;
-      s->save_t           = 0;
-      s->save_alphaSize   = 0;
-      s->save_nGroups     = 0;
-      s->save_nSelectors  = 0;
-      s->save_EOB         = 0;
-      s->save_groupNo     = 0;
-      s->save_groupPos    = 0;
-      s->save_nextSym     = 0;
-      s->save_nblockMAX   = 0;
-      s->save_nblock      = 0;
-      s->save_es          = 0;
-      s->save_N           = 0;
-      s->save_curr        = 0;
-      s->save_zt          = 0;
-      s->save_zn          = 0;
-      s->save_zvec        = 0;
-      s->save_zj          = 0;
-      s->save_gSel        = 0;
-      s->save_gMinlen     = 0;
-      s->save_gLimit      = NULL;
-      s->save_gBase       = NULL;
-      s->save_gPerm       = NULL;
-   }
-
-   /*restore from the save area*/
-   i           = s->save_i;
-   j           = s->save_j;
-   t           = s->save_t;
-   alphaSize   = s->save_alphaSize;
-   nGroups     = s->save_nGroups;
-   nSelectors  = s->save_nSelectors;
-   EOB         = s->save_EOB;
-   groupNo     = s->save_groupNo;
-   groupPos    = s->save_groupPos;
-   nextSym     = s->save_nextSym;
-   nblockMAX   = s->save_nblockMAX;
-   nblock      = s->save_nblock;
-   es          = s->save_es;
-   N           = s->save_N;
-   curr        = s->save_curr;
-   zt          = s->save_zt;
-   zn          = s->save_zn;
-   zvec        = s->save_zvec;
-   zj          = s->save_zj;
-   gSel        = s->save_gSel;
-   gMinlen     = s->save_gMinlen;
-   gLimit      = s->save_gLimit;
-   gBase       = s->save_gBase;
-   gPerm       = s->save_gPerm;
-
-   retVal = BZ_OK;
-
-   switch (s->state) {
-
-      GET_UCHAR(BZ_X_MAGIC_1, uc);
-      if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
-
-      GET_UCHAR(BZ_X_MAGIC_2, uc);
-      if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC);
-
-      GET_UCHAR(BZ_X_MAGIC_3, uc)
-      if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
-
-      GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
-      if (s->blockSize100k < (BZ_HDR_0 + 1) ||
-         s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
-      s->blockSize100k -= BZ_HDR_0;
-
-      if (s->smallDecompress) {
-        s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
-        s->ll4  = BZALLOC(
-                     ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
-                  );
-        if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
-      } else {
-        s->tt  = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
-        if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
-      }
-
-      GET_UCHAR(BZ_X_BLKHDR_1, uc);
-
-      if (uc == 0x17) goto endhdr_2;
-      if (uc != 0x31) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_2, uc);
-      if (uc != 0x41) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_3, uc);
-      if (uc != 0x59) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_4, uc);
-      if (uc != 0x26) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_5, uc);
-      if (uc != 0x53) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_6, uc);
-      if (uc != 0x59) RETURN(BZ_DATA_ERROR);
-
-      s->currBlockNo++;
-      if (s->verbosity >= 2)
-        VPrintf1 ( "\n    [%d: huff+mtf ", s->currBlockNo );
-
-      s->storedBlockCRC = 0;
-      GET_UCHAR(BZ_X_BCRC_1, uc);
-      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_BCRC_2, uc);
-      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_BCRC_3, uc);
-      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_BCRC_4, uc);
-      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-
-      GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
-
-      s->origPtr = 0;
-      GET_UCHAR(BZ_X_ORIGPTR_1, uc);
-      s->origPtr = (s->origPtr << 8) | ((Int32)uc);
-      GET_UCHAR(BZ_X_ORIGPTR_2, uc);
-      s->origPtr = (s->origPtr << 8) | ((Int32)uc);
-      GET_UCHAR(BZ_X_ORIGPTR_3, uc);
-      s->origPtr = (s->origPtr << 8) | ((Int32)uc);
-
-      if (s->origPtr < 0)
-        RETURN(BZ_DATA_ERROR);
-      if (s->origPtr > 10 + 100000*s->blockSize100k)
-        RETURN(BZ_DATA_ERROR);
-
-      /*--- Receive the mapping table ---*/
-      for (i = 0; i < 16; i++) {
-        GET_BIT(BZ_X_MAPPING_1, uc);
-        if (uc == 1)
-           s->inUse16[i] = True; else
-           s->inUse16[i] = False;
-      }
-
-      for (i = 0; i < 256; i++) s->inUse[i] = False;
-
-      for (i = 0; i < 16; i++)
-        if (s->inUse16[i])
-           for (j = 0; j < 16; j++) {
-              GET_BIT(BZ_X_MAPPING_2, uc);
-              if (uc == 1) s->inUse[i * 16 + j] = True;
-           }
-      makeMaps_d ( s );
-      if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
-      alphaSize = s->nInUse+2;
-
-      /*--- Now the selectors ---*/
-      GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
-      if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
-      GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
-      if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
-      for (i = 0; i < nSelectors; i++) {
-        j = 0;
-        while (True) {
-           GET_BIT(BZ_X_SELECTOR_3, uc);
-           if (uc == 0) break;
-           j++;
-           if (j >= nGroups) RETURN(BZ_DATA_ERROR);
-        }
-        s->selectorMtf[i] = j;
-      }
-
-      /*--- Undo the MTF values for the selectors. ---*/
-      {
-        UChar pos[BZ_N_GROUPS], tmp, v;
-        for (v = 0; v < nGroups; v++) pos[v] = v;
-
-        for (i = 0; i < nSelectors; i++) {
-           v = s->selectorMtf[i];
-           tmp = pos[v];
-           while (v > 0) { pos[v] = pos[v-1]; v--; }
-           pos[0] = tmp;
-           s->selector[i] = tmp;
-        }
-      }
-
-      /*--- Now the coding tables ---*/
-      for (t = 0; t < nGroups; t++) {
-        GET_BITS(BZ_X_CODING_1, curr, 5);
-        for (i = 0; i < alphaSize; i++) {
-           while (True) {
-              if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
-              GET_BIT(BZ_X_CODING_2, uc);
-              if (uc == 0) break;
-              GET_BIT(BZ_X_CODING_3, uc);
-              if (uc == 0) curr++; else curr--;
-           }
-           s->len[t][i] = curr;
-        }
-      }
-
-      /*--- Create the Huffman decoding tables ---*/
-      for (t = 0; t < nGroups; t++) {
-        minLen = 32;
-        maxLen = 0;
-        for (i = 0; i < alphaSize; i++) {
-           if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
-           if (s->len[t][i] < minLen) minLen = s->len[t][i];
-        }
-        BZ2_hbCreateDecodeTables (
-           &(s->limit[t][0]),
-           &(s->base[t][0]),
-           &(s->perm[t][0]),
-           &(s->len[t][0]),
-           minLen, maxLen, alphaSize
-        );
-        s->minLens[t] = minLen;
-      }
-
-      /*--- Now the MTF values ---*/
-
-      EOB      = s->nInUse+1;
-      nblockMAX = 100000 * s->blockSize100k;
-      groupNo  = -1;
-      groupPos = 0;
-
-      for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
-
-      /*-- MTF init --*/
-      {
-        Int32 ii, jj, kk;
-        kk = MTFA_SIZE-1;
-        for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
-           for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
-              s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
-              kk--;
-           }
-           s->mtfbase[ii] = kk + 1;
-        }
-      }
-      /*-- end MTF init --*/
-
-      nblock = 0;
-      GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
-
-      while (True) {
-
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-       WATCHDOG_RESET();
-#endif
-        if (nextSym == EOB) break;
-
-        if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
-
-           es = -1;
-           N = 1;
-           do {
-              if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
-              if (nextSym == BZ_RUNB) es = es + (1+1) * N;
-              N = N * 2;
-              GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
-           }
-              while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
-
-           es++;
-           uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ];
-           s->unzftab[uc] += es;
-
-           if (s->smallDecompress)
-              while (es > 0) {
-                 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
-                 s->ll16[nblock] = (UInt16)uc;
-                 nblock++;
-                 es--;
-              }
-           else
-              while (es > 0) {
-                 if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
-                 s->tt[nblock] = (UInt32)uc;
-                 nblock++;
-                 es--;
-              };
-
-           continue;
-
-        } else {
-
-           if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
-
-           /*-- uc = MTF ( nextSym-1 ) --*/
-           {
-              Int32 ii, jj, kk, pp, lno, off;
-              UInt32 nn;
-              nn = (UInt32)(nextSym - 1);
-
-              if (nn < MTFL_SIZE) {
-                 /* avoid general-case expense */
-                 pp = s->mtfbase[0];
-                 uc = s->mtfa[pp+nn];
-                 while (nn > 3) {
-                    Int32 z = pp+nn;
-                    s->mtfa[(z)  ] = s->mtfa[(z)-1];
-                    s->mtfa[(z)-1] = s->mtfa[(z)-2];
-                    s->mtfa[(z)-2] = s->mtfa[(z)-3];
-                    s->mtfa[(z)-3] = s->mtfa[(z)-4];
-                    nn -= 4;
-                 }
-                 while (nn > 0) {
-                    s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
-                 };
-                 s->mtfa[pp] = uc;
-              } else {
-                 /* general case */
-                 lno = nn / MTFL_SIZE;
-                 off = nn % MTFL_SIZE;
-                 pp = s->mtfbase[lno] + off;
-                 uc = s->mtfa[pp];
-                 while (pp > s->mtfbase[lno]) {
-                    s->mtfa[pp] = s->mtfa[pp-1]; pp--;
-                 };
-                 s->mtfbase[lno]++;
-                 while (lno > 0) {
-                    s->mtfbase[lno]--;
-                    s->mtfa[s->mtfbase[lno]]
-                       = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
-                    lno--;
-                 }
-                 s->mtfbase[0]--;
-                 s->mtfa[s->mtfbase[0]] = uc;
-                 if (s->mtfbase[0] == 0) {
-                    kk = MTFA_SIZE-1;
-                    for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-                       WATCHDOG_RESET();
-#endif
-                       for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
-                          s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj];
-                          kk--;
-                       }
-                       s->mtfbase[ii] = kk + 1;
-                    }
-                 }
-              }
-           }
-           /*-- end uc = MTF ( nextSym-1 ) --*/
-
-           s->unzftab[s->seqToUnseq[uc]]++;
-           if (s->smallDecompress)
-              s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else
-              s->tt[nblock]   = (UInt32)(s->seqToUnseq[uc]);
-           nblock++;
-
-           GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
-           continue;
-        }
-      }
-
-      /* Now we know what nblock is, we can do a better sanity
-        check on s->origPtr.
-      */
-      if (s->origPtr < 0 || s->origPtr >= nblock)
-        RETURN(BZ_DATA_ERROR);
-
-      s->state_out_len = 0;
-      s->state_out_ch  = 0;
-      BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
-      s->state = BZ_X_OUTPUT;
-      if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
-
-      /*-- Set up cftab to facilitate generation of T^(-1) --*/
-      s->cftab[0] = 0;
-      for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
-      for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
-
-      if (s->smallDecompress) {
-
-        /*-- Make a copy of cftab, used in generation of T --*/
-        for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
-
-        /*-- compute the T vector --*/
-        for (i = 0; i < nblock; i++) {
-           uc = (UChar)(s->ll16[i]);
-           SET_LL(i, s->cftabCopy[uc]);
-           s->cftabCopy[uc]++;
-        }
-
-        /*-- Compute T^(-1) by pointer reversal on T --*/
-        i = s->origPtr;
-        j = GET_LL(i);
-        do {
-           Int32 tmp = GET_LL(j);
-           SET_LL(j, i);
-           i = j;
-           j = tmp;
-        }
-           while (i != s->origPtr);
-
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-       WATCHDOG_RESET();
-#endif
-        s->tPos = s->origPtr;
-        s->nblock_used = 0;
-        if (s->blockRandomised) {
-           BZ_RAND_INIT_MASK;
-           BZ_GET_SMALL(s->k0); s->nblock_used++;
-           BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
-        } else {
-           BZ_GET_SMALL(s->k0); s->nblock_used++;
-        }
-
-      } else {
-
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-       WATCHDOG_RESET();
-#endif
-        /*-- compute the T^(-1) vector --*/
-        for (i = 0; i < nblock; i++) {
-           uc = (UChar)(s->tt[i] & 0xff);
-           s->tt[s->cftab[uc]] |= (i << 8);
-           s->cftab[uc]++;
-        }
-
-        s->tPos = s->tt[s->origPtr] >> 8;
-        s->nblock_used = 0;
-        if (s->blockRandomised) {
-           BZ_RAND_INIT_MASK;
-           BZ_GET_FAST(s->k0); s->nblock_used++;
-           BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
-        } else {
-           BZ_GET_FAST(s->k0); s->nblock_used++;
-        }
-
-      }
-
-      RETURN(BZ_OK);
-
-
-    endhdr_2:
-
-      GET_UCHAR(BZ_X_ENDHDR_2, uc);
-      if (uc != 0x72) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_ENDHDR_3, uc);
-      if (uc != 0x45) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_ENDHDR_4, uc);
-      if (uc != 0x38) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_ENDHDR_5, uc);
-      if (uc != 0x50) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_ENDHDR_6, uc);
-      if (uc != 0x90) RETURN(BZ_DATA_ERROR);
-
-      s->storedCombinedCRC = 0;
-      GET_UCHAR(BZ_X_CCRC_1, uc);
-      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_CCRC_2, uc);
-      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_CCRC_3, uc);
-      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_CCRC_4, uc);
-      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-
-      s->state = BZ_X_IDLE;
-      RETURN(BZ_STREAM_END);
-
-      default: AssertH ( False, 4001 );
-   }
-
-   AssertH ( False, 4002 );
-
-   save_state_and_return:
-
-   s->save_i           = i;
-   s->save_j           = j;
-   s->save_t           = t;
-   s->save_alphaSize   = alphaSize;
-   s->save_nGroups     = nGroups;
-   s->save_nSelectors  = nSelectors;
-   s->save_EOB         = EOB;
-   s->save_groupNo     = groupNo;
-   s->save_groupPos    = groupPos;
-   s->save_nextSym     = nextSym;
-   s->save_nblockMAX   = nblockMAX;
-   s->save_nblock      = nblock;
-   s->save_es          = es;
-   s->save_N           = N;
-   s->save_curr        = curr;
-   s->save_zt          = zt;
-   s->save_zn          = zn;
-   s->save_zvec        = zvec;
-   s->save_zj          = zj;
-   s->save_gSel        = gSel;
-   s->save_gMinlen     = gMinlen;
-   s->save_gLimit      = gLimit;
-   s->save_gBase       = gBase;
-   s->save_gPerm       = gPerm;
-
-   return retVal;
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                      decompress.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/lib/bzlib_huffman.c b/lib/bzlib_huffman.c
deleted file mode 100644 (file)
index 801b8ec..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-#include <config.h>
-
-/*-------------------------------------------------------------*/
-/*--- Huffman coding low-level stuff                        ---*/
-/*---                                             huffman.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. The origin of this software must not be misrepresented; you must
-     not claim that you wrote the original software.  If you use this
-     software in a product, an acknowledgment in the product
-     documentation would be appreciated but is not required.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote
-     products derived from this software without specific prior written
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-  Julian Seward, Cambridge, UK.
-  jseward@acm.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#include "bzlib_private.h"
-
-/*---------------------------------------------------*/
-#define WEIGHTOF(zz0)  ((zz0) & 0xffffff00)
-#define DEPTHOF(zz1)   ((zz1) & 0x000000ff)
-#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
-
-#define ADDWEIGHTS(zw1,zw2)                           \
-   (WEIGHTOF(zw1)+WEIGHTOF(zw2)) |                    \
-   (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
-
-#define UPHEAP(z)                                     \
-{                                                     \
-   Int32 zz, tmp;                                     \
-   zz = z; tmp = heap[zz];                            \
-   while (weight[tmp] < weight[heap[zz >> 1]]) {      \
-      heap[zz] = heap[zz >> 1];                       \
-      zz >>= 1;                                       \
-   }                                                  \
-   heap[zz] = tmp;                                    \
-}
-
-#define DOWNHEAP(z)                                   \
-{                                                     \
-   Int32 zz, yy, tmp;                                 \
-   zz = z; tmp = heap[zz];                            \
-   while (True) {                                     \
-      yy = zz << 1;                                   \
-      if (yy > nHeap) break;                          \
-      if (yy < nHeap &&                               \
-         weight[heap[yy+1]] < weight[heap[yy]])      \
-        yy++;                                        \
-      if (weight[tmp] < weight[heap[yy]]) break;      \
-      heap[zz] = heap[yy];                            \
-      zz = yy;                                        \
-   }                                                  \
-   heap[zz] = tmp;                                    \
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbMakeCodeLengths ( UChar *len,
-                            Int32 *freq,
-                            Int32 alphaSize,
-                            Int32 maxLen )
-{
-   /*--
-      Nodes and heap entries run from 1.  Entry 0
-      for both the heap and nodes is a sentinel.
-   --*/
-   Int32 nNodes, nHeap, n1, n2, i, j, k;
-   Bool  tooLong;
-
-   Int32 heap   [ BZ_MAX_ALPHA_SIZE + 2 ];
-   Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
-   Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
-
-   for (i = 0; i < alphaSize; i++)
-      weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
-
-   while (True) {
-
-      nNodes = alphaSize;
-      nHeap = 0;
-
-      heap[0] = 0;
-      weight[0] = 0;
-      parent[0] = -2;
-
-      for (i = 1; i <= alphaSize; i++) {
-        parent[i] = -1;
-        nHeap++;
-        heap[nHeap] = i;
-        UPHEAP(nHeap);
-      }
-
-      AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
-
-      while (nHeap > 1) {
-        n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
-        n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
-        nNodes++;
-        parent[n1] = parent[n2] = nNodes;
-        weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
-        parent[nNodes] = -1;
-        nHeap++;
-        heap[nHeap] = nNodes;
-        UPHEAP(nHeap);
-      }
-
-      AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
-
-      tooLong = False;
-      for (i = 1; i <= alphaSize; i++) {
-        j = 0;
-        k = i;
-        while (parent[k] >= 0) { k = parent[k]; j++; }
-        len[i-1] = j;
-        if (j > maxLen) tooLong = True;
-      }
-
-      if (! tooLong) break;
-
-      for (i = 1; i < alphaSize; i++) {
-        j = weight[i] >> 8;
-        j = 1 + (j / 2);
-        weight[i] = j << 8;
-      }
-   }
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbAssignCodes ( Int32 *code,
-                        UChar *length,
-                        Int32 minLen,
-                        Int32 maxLen,
-                        Int32 alphaSize )
-{
-   Int32 n, vec, i;
-
-   vec = 0;
-   for (n = minLen; n <= maxLen; n++) {
-      for (i = 0; i < alphaSize; i++)
-        if (length[i] == n) { code[i] = vec; vec++; };
-      vec <<= 1;
-   }
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbCreateDecodeTables ( Int32 *limit,
-                               Int32 *base,
-                               Int32 *perm,
-                               UChar *length,
-                               Int32 minLen,
-                               Int32 maxLen,
-                               Int32 alphaSize )
-{
-   Int32 pp, i, j, vec;
-
-   pp = 0;
-   for (i = minLen; i <= maxLen; i++)
-      for (j = 0; j < alphaSize; j++)
-        if (length[j] == i) { perm[pp] = j; pp++; };
-
-   for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
-   for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
-
-   for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
-
-   for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
-   vec = 0;
-
-   for (i = minLen; i <= maxLen; i++) {
-      vec += (base[i+1] - base[i]);
-      limit[i] = vec-1;
-      vec <<= 1;
-   }
-   for (i = minLen + 1; i <= maxLen; i++)
-      base[i] = ((limit[i-1] + 1) << 1) - base[i];
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                         huffman.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/lib/bzlib_private.h b/lib/bzlib_private.h
deleted file mode 100644 (file)
index 87d8f94..0000000
+++ /dev/null
@@ -1,530 +0,0 @@
-/*
- * This file is a modified version of bzlib_private.h from the bzip2-1.0.2
- * distribution which can be found at http://sources.redhat.com/bzip2/
- */
-
-/*-------------------------------------------------------------*/
-/*--- Private header file for the library.                  ---*/
-/*---                                       bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. The origin of this software must not be misrepresented; you must
-     not claim that you wrote the original software.  If you use this
-     software in a product, an acknowledgment in the product
-     documentation would be appreciated but is not required.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote
-     products derived from this software without specific prior written
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-  Julian Seward, Cambridge, UK.
-  jseward@acm.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#ifndef _BZLIB_PRIVATE_H
-#define _BZLIB_PRIVATE_H
-
-#include <malloc.h>
-
-#include "bzlib.h"
-
-#ifndef BZ_NO_STDIO
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#endif
-
-
-/*-- General stuff. --*/
-
-#define BZ_VERSION  "1.0.2, 30-Dec-2001"
-
-typedef char            Char;
-typedef unsigned char   Bool;
-typedef unsigned char   UChar;
-typedef int             Int32;
-typedef unsigned int    UInt32;
-typedef short           Int16;
-typedef unsigned short  UInt16;
-
-#define True  ((Bool)1)
-#define False ((Bool)0)
-
-#ifndef __GNUC__
-#define __inline__  /* */
-#endif
-
-#ifndef BZ_NO_STDIO
-extern void BZ2_bz__AssertH__fail ( int errcode );
-#define AssertH(cond,errcode) \
-   { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
-#if BZ_DEBUG
-#define AssertD(cond,msg) \
-   { if (!(cond)) {       \
-      fprintf ( stderr,   \
-       "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
-      exit(1); \
-   }}
-#else
-#define AssertD(cond,msg) /* */
-#endif
-#define VPrintf0(zf) \
-   fprintf(stderr,zf)
-#define VPrintf1(zf,za1) \
-   fprintf(stderr,zf,za1)
-#define VPrintf2(zf,za1,za2) \
-   fprintf(stderr,zf,za1,za2)
-#define VPrintf3(zf,za1,za2,za3) \
-   fprintf(stderr,zf,za1,za2,za3)
-#define VPrintf4(zf,za1,za2,za3,za4) \
-   fprintf(stderr,zf,za1,za2,za3,za4)
-#define VPrintf5(zf,za1,za2,za3,za4,za5) \
-   fprintf(stderr,zf,za1,za2,za3,za4,za5)
-#else
-extern void bz_internal_error ( int errcode );
-#define AssertH(cond,errcode) \
-   { if (!(cond)) bz_internal_error ( errcode ); }
-#define AssertD(cond,msg) /* */
-#define VPrintf0(zf) /* */
-#define VPrintf1(zf,za1) /* */
-#define VPrintf2(zf,za1,za2) /* */
-#define VPrintf3(zf,za1,za2,za3) /* */
-#define VPrintf4(zf,za1,za2,za3,za4) /* */
-#define VPrintf5(zf,za1,za2,za3,za4,za5) /* */
-#endif
-
-
-#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
-#define BZFREE(ppp)  (strm->bzfree)(strm->opaque,(ppp))
-
-
-/*-- Header bytes. --*/
-
-#define BZ_HDR_B 0x42   /* 'B' */
-#define BZ_HDR_Z 0x5a   /* 'Z' */
-#define BZ_HDR_h 0x68   /* 'h' */
-#define BZ_HDR_0 0x30   /* '0' */
-
-/*-- Constants for the back end. --*/
-
-#define BZ_MAX_ALPHA_SIZE 258
-#define BZ_MAX_CODE_LEN    23
-
-#define BZ_RUNA 0
-#define BZ_RUNB 1
-
-#define BZ_N_GROUPS 6
-#define BZ_G_SIZE   50
-#define BZ_N_ITERS  4
-
-#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
-
-
-/*-- Stuff for randomising repetitive blocks. --*/
-
-extern Int32 BZ2_rNums[512];
-
-#define BZ_RAND_DECLS                          \
-   Int32 rNToGo;                               \
-   Int32 rTPos                                 \
-
-#define BZ_RAND_INIT_MASK                      \
-   s->rNToGo = 0;                              \
-   s->rTPos  = 0                               \
-
-#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
-
-#define BZ_RAND_UPD_MASK                       \
-   if (s->rNToGo == 0) {                       \
-      s->rNToGo = BZ2_rNums[s->rTPos];         \
-      s->rTPos++;                              \
-      if (s->rTPos == 512) s->rTPos = 0;       \
-   }                                           \
-   s->rNToGo--;
-
-
-/*-- Stuff for doing CRCs. --*/
-
-extern UInt32 BZ2_crc32Table[256];
-
-#define BZ_INITIALISE_CRC(crcVar)              \
-{                                              \
-   crcVar = 0xffffffffL;                       \
-}
-
-#define BZ_FINALISE_CRC(crcVar)                \
-{                                              \
-   crcVar = ~(crcVar);                         \
-}
-
-#define BZ_UPDATE_CRC(crcVar,cha)              \
-{                                              \
-   crcVar = (crcVar << 8) ^                    \
-           BZ2_crc32Table[(crcVar >> 24) ^    \
-                          ((UChar)cha)];      \
-}
-
-
-/*-- States and modes for compression. --*/
-
-#define BZ_M_IDLE      1
-#define BZ_M_RUNNING   2
-#define BZ_M_FLUSHING  3
-#define BZ_M_FINISHING 4
-
-#define BZ_S_OUTPUT    1
-#define BZ_S_INPUT     2
-
-#define BZ_N_RADIX 2
-#define BZ_N_QSORT 12
-#define BZ_N_SHELL 18
-#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
-
-
-/*-- Structure holding all the compression-side stuff. --*/
-
-typedef
-   struct {
-      /* pointer back to the struct bz_stream */
-      bz_stream* strm;
-
-      /* mode this stream is in, and whether inputting */
-      /* or outputting data */
-      Int32    mode;
-      Int32    state;
-
-      /* remembers avail_in when flush/finish requested */
-      UInt32   avail_in_expect;
-
-      /* for doing the block sorting */
-      UInt32*  arr1;
-      UInt32*  arr2;
-      UInt32*  ftab;
-      Int32    origPtr;
-
-      /* aliases for arr1 and arr2 */
-      UInt32*  ptr;
-      UChar*   block;
-      UInt16*  mtfv;
-      UChar*   zbits;
-
-      /* for deciding when to use the fallback sorting algorithm */
-      Int32    workFactor;
-
-      /* run-length-encoding of the input */
-      UInt32   state_in_ch;
-      Int32    state_in_len;
-      BZ_RAND_DECLS;
-
-      /* input and output limits and current posns */
-      Int32    nblock;
-      Int32    nblockMAX;
-      Int32    numZ;
-      Int32    state_out_pos;
-
-      /* map of bytes used in block */
-      Int32    nInUse;
-      Bool     inUse[256];
-      UChar    unseqToSeq[256];
-
-      /* the buffer for bit stream creation */
-      UInt32   bsBuff;
-      Int32    bsLive;
-
-      /* block and combined CRCs */
-      UInt32   blockCRC;
-      UInt32   combinedCRC;
-
-      /* misc administratium */
-      Int32    verbosity;
-      Int32    blockNo;
-      Int32    blockSize100k;
-
-      /* stuff for coding the MTF values */
-      Int32    nMTF;
-      Int32    mtfFreq    [BZ_MAX_ALPHA_SIZE];
-      UChar    selector   [BZ_MAX_SELECTORS];
-      UChar    selectorMtf[BZ_MAX_SELECTORS];
-
-      UChar    len     [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    code    [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    rfreq   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      /* second dimension: only 3 needed; 4 makes index calculations faster */
-      UInt32   len_pack[BZ_MAX_ALPHA_SIZE][4];
-
-   }
-   EState;
-
-
-/*-- externs for compression. --*/
-
-extern void
-BZ2_blockSort ( EState* );
-
-extern void
-BZ2_compressBlock ( EState*, Bool );
-
-extern void
-BZ2_bsInitWrite ( EState* );
-
-extern void
-BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
-
-extern void
-BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
-
-
-/*-- states for decompression. --*/
-
-#define BZ_X_IDLE        1
-#define BZ_X_OUTPUT      2
-
-#define BZ_X_MAGIC_1     10
-#define BZ_X_MAGIC_2     11
-#define BZ_X_MAGIC_3     12
-#define BZ_X_MAGIC_4     13
-#define BZ_X_BLKHDR_1    14
-#define BZ_X_BLKHDR_2    15
-#define BZ_X_BLKHDR_3    16
-#define BZ_X_BLKHDR_4    17
-#define BZ_X_BLKHDR_5    18
-#define BZ_X_BLKHDR_6    19
-#define BZ_X_BCRC_1      20
-#define BZ_X_BCRC_2      21
-#define BZ_X_BCRC_3      22
-#define BZ_X_BCRC_4      23
-#define BZ_X_RANDBIT     24
-#define BZ_X_ORIGPTR_1   25
-#define BZ_X_ORIGPTR_2   26
-#define BZ_X_ORIGPTR_3   27
-#define BZ_X_MAPPING_1   28
-#define BZ_X_MAPPING_2   29
-#define BZ_X_SELECTOR_1  30
-#define BZ_X_SELECTOR_2  31
-#define BZ_X_SELECTOR_3  32
-#define BZ_X_CODING_1    33
-#define BZ_X_CODING_2    34
-#define BZ_X_CODING_3    35
-#define BZ_X_MTF_1       36
-#define BZ_X_MTF_2       37
-#define BZ_X_MTF_3       38
-#define BZ_X_MTF_4       39
-#define BZ_X_MTF_5       40
-#define BZ_X_MTF_6       41
-#define BZ_X_ENDHDR_2    42
-#define BZ_X_ENDHDR_3    43
-#define BZ_X_ENDHDR_4    44
-#define BZ_X_ENDHDR_5    45
-#define BZ_X_ENDHDR_6    46
-#define BZ_X_CCRC_1      47
-#define BZ_X_CCRC_2      48
-#define BZ_X_CCRC_3      49
-#define BZ_X_CCRC_4      50
-
-
-/*-- Constants for the fast MTF decoder. --*/
-
-#define MTFA_SIZE 4096
-#define MTFL_SIZE 16
-
-
-/*-- Structure holding all the decompression-side stuff. --*/
-
-typedef
-   struct {
-      /* pointer back to the struct bz_stream */
-      bz_stream* strm;
-
-      /* state indicator for this stream */
-      Int32    state;
-
-      /* for doing the final run-length decoding */
-      UChar    state_out_ch;
-      Int32    state_out_len;
-      Bool     blockRandomised;
-      BZ_RAND_DECLS;
-
-      /* the buffer for bit stream reading */
-      UInt32   bsBuff;
-      Int32    bsLive;
-
-      /* misc administratium */
-      Int32    blockSize100k;
-      Bool     smallDecompress;
-      Int32    currBlockNo;
-      Int32    verbosity;
-
-      /* for undoing the Burrows-Wheeler transform */
-      Int32    origPtr;
-      UInt32   tPos;
-      Int32    k0;
-      Int32    unzftab[256];
-      Int32    nblock_used;
-      Int32    cftab[257];
-      Int32    cftabCopy[257];
-
-      /* for undoing the Burrows-Wheeler transform (FAST) */
-      UInt32   *tt;
-
-      /* for undoing the Burrows-Wheeler transform (SMALL) */
-      UInt16   *ll16;
-      UChar    *ll4;
-
-      /* stored and calculated CRCs */
-      UInt32   storedBlockCRC;
-      UInt32   storedCombinedCRC;
-      UInt32   calculatedBlockCRC;
-      UInt32   calculatedCombinedCRC;
-
-      /* map of bytes used in block */
-      Int32    nInUse;
-      Bool     inUse[256];
-      Bool     inUse16[16];
-      UChar    seqToUnseq[256];
-
-      /* for decoding the MTF values */
-      UChar    mtfa   [MTFA_SIZE];
-      Int32    mtfbase[256 / MTFL_SIZE];
-      UChar    selector   [BZ_MAX_SELECTORS];
-      UChar    selectorMtf[BZ_MAX_SELECTORS];
-      UChar    len  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-
-      Int32    limit  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    base   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    perm   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    minLens[BZ_N_GROUPS];
-
-      /* save area for scalars in the main decompress code */
-      Int32    save_i;
-      Int32    save_j;
-      Int32    save_t;
-      Int32    save_alphaSize;
-      Int32    save_nGroups;
-      Int32    save_nSelectors;
-      Int32    save_EOB;
-      Int32    save_groupNo;
-      Int32    save_groupPos;
-      Int32    save_nextSym;
-      Int32    save_nblockMAX;
-      Int32    save_nblock;
-      Int32    save_es;
-      Int32    save_N;
-      Int32    save_curr;
-      Int32    save_zt;
-      Int32    save_zn;
-      Int32    save_zvec;
-      Int32    save_zj;
-      Int32    save_gSel;
-      Int32    save_gMinlen;
-      Int32*   save_gLimit;
-      Int32*   save_gBase;
-      Int32*   save_gPerm;
-
-   }
-   DState;
-
-
-/*-- Macros for decompression. --*/
-
-#define BZ_GET_FAST(cccc)                     \
-    s->tPos = s->tt[s->tPos];                 \
-    cccc = (UChar)(s->tPos & 0xff);           \
-    s->tPos >>= 8;
-
-#define BZ_GET_FAST_C(cccc)                   \
-    c_tPos = c_tt[c_tPos];                    \
-    cccc = (UChar)(c_tPos & 0xff);            \
-    c_tPos >>= 8;
-
-#define SET_LL4(i,n)                                          \
-   { if (((i) & 0x1) == 0)                                    \
-       s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else    \
-       s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4);  \
-   }
-
-#define GET_LL4(i)                             \
-   ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
-
-#define SET_LL(i,n)                          \
-   { s->ll16[i] = (UInt16)(n & 0x0000ffff);  \
-     SET_LL4(i, n >> 16);                    \
-   }
-
-#define GET_LL(i) \
-   (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
-
-#define BZ_GET_SMALL(cccc)                            \
-      cccc = BZ2_indexIntoF ( s->tPos, s->cftab );    \
-      s->tPos = GET_LL(s->tPos);
-
-
-/*-- externs for decompression. --*/
-
-extern Int32
-BZ2_indexIntoF ( Int32, Int32* );
-
-extern Int32
-BZ2_decompress ( DState* );
-
-extern void
-BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
-                          Int32,  Int32, Int32 );
-
-
-#endif
-
-
-/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
-
-#ifdef BZ_NO_STDIO
-#ifndef NULL
-#define NULL 0
-#endif
-#endif
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                   bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
diff --git a/lib/bzlib_randtable.c b/lib/bzlib_randtable.c
deleted file mode 100644 (file)
index c3dc7e4..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <config.h>
-
-/*-------------------------------------------------------------*/
-/*--- Table for randomising repetitive blocks               ---*/
-/*---                                           randtable.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. The origin of this software must not be misrepresented; you must
-     not claim that you wrote the original software.  If you use this
-     software in a product, an acknowledgment in the product
-     documentation would be appreciated but is not required.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote
-     products derived from this software without specific prior written
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-  Julian Seward, Cambridge, UK.
-  jseward@acm.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------*/
-Int32 BZ2_rNums[512] = {
-   619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
-   985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
-   733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
-   419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
-   878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
-   862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
-   150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
-   170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
-   73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
-   909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
-   641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
-   161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
-   382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
-   98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
-   227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
-   469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
-   184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
-   715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
-   951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
-   652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
-   645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
-   609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
-   653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
-   411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
-   170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
-   857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
-   669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
-   944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
-   344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
-   897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
-   433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
-   686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
-   946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
-   978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
-   680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
-   707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
-   297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
-   134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
-   343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
-   140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
-   170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
-   369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
-   804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
-   896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
-   661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
-   768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
-   61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
-   372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
-   780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
-   920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
-   645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
-   936, 638
-};
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                       randtable.c ---*/
-/*-------------------------------------------------------------*/
index 6fe79e0b06e9c422b6bfcfffd8fdd968872960dc..2f5413f90d6797122875dfc9d8c547dee5162406 100644 (file)
@@ -5,8 +5,5 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-COBJS-libfdt += fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_sw.o fdt_wip.o \
+obj-y += fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_sw.o fdt_wip.o \
        fdt_empty_tree.o fdt_addresses.o
-
-obj-$(CONFIG_OF_LIBFDT) += $(COBJS-libfdt)
-obj-$(CONFIG_FIT) += $(COBJS-libfdt)
index 556be3275477c3523143d01dd12c0771ddf1fac6..af3703e6d7706b5f2a7e8e6c9e97323ea8a48438 100644 (file)
@@ -3,7 +3,7 @@
 #define __GLUE_ZLIB_H__
 
 #include <common.h>
-#include <compiler.h>
+#include <linux/compiler.h>
 #include <asm/unaligned.h>
 #include <watchdog.h>
 #include "u-boot/zlib.h"
index d4c86cf1794e7d78feafc837195f41a596a7dd6d..81066015f1c2ed28a4fb0ea1ec4bbeecec08047f 100644 (file)
@@ -145,8 +145,6 @@ static void BootpCopyNetParams(struct Bootp_t *bp)
        if (tmp_ip != 0)
                NetCopyIP(&NetServerIP, &bp->bp_siaddr);
        memcpy(NetServerEther, ((struct ethernet_hdr *)NetRxPacket)->et_src, 6);
-#endif
-       NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
        if (strlen(bp->bp_file) > 0)
                copy_filename(BootFile, bp->bp_file, sizeof(BootFile));
 
@@ -158,6 +156,8 @@ static void BootpCopyNetParams(struct Bootp_t *bp)
         */
        if (*BootFile)
                setenv("bootfile", BootFile);
+#endif
+       NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
 }
 
 static int truncate_sz(const char *name, int maxlen, int curlen)
index 190544688016c7f856826896098986526f3b53b4..ecf3037cb89b032712f6ba9c9bf673664ed4fa96 100644 (file)
@@ -34,6 +34,7 @@ SPL_BIN := u-boot-spl
 endif
 
 include $(srctree)/config.mk
+include $(srctree)/arch/$(ARCH)/Makefile
 
 # Enable garbage collection of un-used sections for SPL
 KBUILD_CFLAGS += -ffunction-sections -fdata-sections
@@ -45,21 +46,6 @@ cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
 
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
 
-ifdef  CONFIG_SPL_START_S_PATH
-START_PATH := $(CONFIG_SPL_START_S_PATH:"%"=%)
-else
-START_PATH := $(CPUDIR)
-endif
-
-head-y := $(START_PATH)/start.o
-head-$(CONFIG_X86) += $(START_PATH)/start16.o $(START_PATH)/resetvec.o
-head-$(CONFIG_4xx) += $(START_PATH)/resetvec.o
-head-$(CONFIG_MPC85xx) += $(START_PATH)/resetvec.o
-
-libs-y += arch/$(ARCH)/lib/
-
-libs-y += $(CPUDIR)/
-
 libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
 libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
 
@@ -94,13 +80,6 @@ libs-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/
 libs-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/
 libs-$(CONFIG_SPL_SATA_SUPPORT) += drivers/block/
 
-ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
-libs-y += arch/$(ARCH)/imx-common/
-endif
-
-libs-$(CONFIG_ARM) += arch/arm/cpu/
-libs-$(CONFIG_PPC) += arch/powerpc/cpu/
-
 head-y         := $(addprefix $(obj)/,$(head-y))
 libs-y         := $(addprefix $(obj)/,$(libs-y))
 u-boot-spl-dirs        := $(patsubst %/,%,$(filter %/, $(libs-y)))
index 7717d689bfc5053d8ecd4318deaae7673fc18f46..368a20e2ccf3aad2ac43eef3847373d36d626f5b 100755 (executable)
@@ -835,8 +835,7 @@ sub top_of_kernel_tree {
     if ($lk_path ne "" && substr($lk_path,length($lk_path)-1,1) ne "/") {
        $lk_path .= "/";
     }
-    if (   (-f "${lk_path}CREDITS")
-       && (-f "${lk_path}Kbuild")
+    if (   (-f "${lk_path}Kbuild")
        && (-f "${lk_path}MAINTAINERS")
        && (-f "${lk_path}Makefile")
        && (-f "${lk_path}README")
index a26cc5d2a9b0217d9c3d52bf0dab21b7337e95d2..72c9dba84c5dbd46cb8ae2824a85d54603dbaafe 100644 (file)
@@ -548,7 +548,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
 {
        int i, j;
        struct menu *submenu[8], *menu, *location = NULL;
-       struct jump_key *jump;
+       struct jump_key *jump = NULL;
 
        str_printf(r, _("Prompt: %s\n"), _(prop->text));
        menu = prop->menu->parent;
@@ -586,7 +586,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
                str_printf(r, _("  Location:\n"));
                for (j = 4; --i >= 0; j += 2) {
                        menu = submenu[i];
-                       if (head && location && menu == location)
+                       if (jump && menu == location)
                                jump->offset = strlen(r->s);
                        str_printf(r, "%*c-> %s", j, ' ',
                                   _(menu_get_prompt(menu)));
index 8ba19ec1030d8bf82a10ef1b8534ddb9c849955d..bfb2f180c28c05717f3199f5a0ec2c0c6c909e61 100644 (file)
@@ -85,10 +85,10 @@ branch. Put all your commits in a branch, set the branch's upstream to a
 valid value, and all will be well. Otherwise buildman will perform random
 actions. Use -n to check what the random actions might be.
 
-If you just want to build the current source tree, leave off the -b flag.
-This will display results and errors as they happen. You can still look
-at them later using -s. Note that buildman will assume that the source
-has changed, and will build all specified boards in this case.
+If you just want to build the current source tree, leave off the -b flag
+and add -e. This will display results and errors as they happen. You can
+still look at them later using -se. Note that buildman will assume that the
+source has changed, and will build all specified boards in this case.
 
 Buildman is optimised for building many commits at once, for many boards.
 On multi-core machines, Buildman is fast because it uses most of the
@@ -693,9 +693,9 @@ Quick Sanity Check
 ==================
 
 If you have made changes and want to do a quick sanity check of the
-currently-checked-out source, run buildman without the -b flag. This will
-build the selected boards and display build status and errors as it runs
-(i.e. -v amd -e are enabled automatically).
+currently checked-out source, run buildman without the -b flag. This will
+build the selected boards and display build status as it runs (i.e. -v is
+enabled automatically). Use -e to see errors/warnings as well.
 
 
 Other options
@@ -752,7 +752,7 @@ an error and green indicating that a commit fixed an error. Use the -e
 flag to see the full errors and -l to see which boards caused which errors.
 
 If you really want to see build results as they happen, use -v when doing a
-build (-e will be enabled automatically).
+build (and -e to see the errors/warnings too).
 
 You don't need to stick around on that branch while buildman is running. It
 checks out its own copy of the source code, so you can change branches,
@@ -816,11 +816,10 @@ TODO
 
 This has mostly be written in my spare time as a response to my difficulties
 in testing large series of patches. Apart from tidying up there is quite a
-bit of scope for improvement. Things like better error diffs, easier access
-to log files, error display while building. Also it would be nice it buildman
-could 'hunt' for problems, perhaps by building a few boards for each arch,
-or checking commits for changed files and building only boards which use
-those files.
+bit of scope for improvement. Things like better error diffs and easier
+access to log files. Also it would be nice it buildman could 'hunt' for
+problems, perhaps by building a few boards for each arch, or checking
+commits for changed files and building only boards which use those files.
 
 
 Credits
index 8155c1681eab8191ded875154a2f21c9af83d394..7002034221d12789473d33e7f62cb21cbe296be7 100644 (file)
@@ -918,7 +918,8 @@ class Builder:
             if self._list_error_boards:
                 names = []
                 for board in line_boards[line]:
-                    names.append(board.target)
+                    if not board.target in names:
+                        names.append(board.target)
                 names_str = '(%s) ' % ','.join(names)
             else:
                 names_str = ''
index a9cf68a8016c4ea9c066ea9527986d56f0465266..bc4541cb3eb90b357e4608aca5ceae583eee1c05 100644 (file)
@@ -332,7 +332,7 @@ class BuilderThread(threading.Thread):
 
         # Now write the actual build output
         if keep_outputs:
-            patterns = ['u-boot', '*.bin', 'u-boot.dtb', '*.map',
+            patterns = ['u-boot', '*.bin', 'u-boot.dtb', '*.map', '*.img',
                         'include/autoconf.mk', 'spl/u-boot-spl',
                         'spl/u-boot-spl.bin']
             for pattern in patterns:
index 8b8c826002f51aca985e6d2b493e0c6f4692363f..2c3ba8b77fb1d9cf304b5e5ca61a451fd6634c2c 100644 (file)
@@ -70,7 +70,7 @@ def ShowActions(series, why_selected, boards_selected, builder, options):
     if commits:
         for upto in range(0, len(series.commits), options.step):
             commit = series.commits[upto]
-            print '   ', col.Color(col.YELLOW, commit.hash, bright=False),
+            print '   ', col.Color(col.YELLOW, commit.hash[:8], bright=False),
             print commit.subject
     print
     for arg in why_selected:
@@ -188,7 +188,6 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
     else:
         series = None
         options.verbose = True
-        options.show_errors = True
 
     # By default we have one thread per CPU. But if there are not enough jobs
     # we can have fewer threads and use a high '-j' value for make.
index d630157f8f70f640858a28d66e0f00b61d74e82a..da0488337b29a5fd4db542b58892a14c4e637ee9 100644 (file)
@@ -248,8 +248,7 @@ class PatchStream:
         # Detect the start of a new commit
         elif commit_match:
             self.CloseCommit()
-            # TODO: We should store the whole hash, and just display a subset
-            self.commit = commit.Commit(commit_match.group(1)[:8])
+            self.commit = commit.Commit(commit_match.group(1))
 
         # Detect tags in the commit message
         elif tag_match: