U-Boot
Threads by month
- ----- 2025 -----
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2000 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
April 2009
- 184 participants
- 475 discussions

28 Apr '09
From: David Brownell <dbrownell(a)users.sourceforge.net>
Make the headers in the "mtdparts" command output line up
with their columns ... strike the extra TAB character.
Signed-off-by: David Brownell <dbrownell(a)users.sourceforge.net>
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -1314,7 +1314,7 @@ static void list_partitions(void)
printf("\ndevice %s%d <%s>, # parts = %d\n",
MTD_DEV_TYPE(dev->id->type), dev->id->num,
dev->id->mtd_id, dev->num_parts);
- printf(" #: name\t\t\tsize\t\toffset\t\tmask_flags\n");
+ printf(" #: name\t\tsize\t\toffset\t\tmask_flags\n");
/* list partitions for given device */
part_num = 0;
2
1

[U-Boot] [PATCH 1/2 V5] cmd_bdinfo: move implementation to arch instead of common
by Jean-Christophe PLAGNIOL-VILLARD 28 Apr '09
by Jean-Christophe PLAGNIOL-VILLARD 28 Apr '09
28 Apr '09
introduce 3 new weak functions board_bdinfo, cpu_bdinfo and soc_bdinfo to allow
board, cpu and soc to print more information
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj(a)jcrosoft.com>
Acked-by: Mike Frysinger <vapier(a)gentoo.org>
Acked-by: Haavard Skinnemoen <haavard.skinnemoen(a)atmel.com>
---
V4 -> V5
Rebase
common/cmd_bdinfo.c | 464 ++++++++---------------------------------------
include/bdinfo.h | 49 +++++
lib_arm/Makefile | 1 +
lib_arm/bdinfo.c | 50 +++++
lib_avr32/Makefile | 1 +
lib_avr32/bdinfo.c | 44 +++++
lib_blackfin/Makefile | 1 +
lib_blackfin/bdinfo.c | 52 ++++++
lib_i386/Makefile | 1 +
lib_i386/bdinfo.c | 44 +++++
lib_m68k/Makefile | 1 +
lib_m68k/bdinfo.c | 72 ++++++++
lib_microblaze/Makefile | 1 +
lib_microblaze/bdinfo.c | 47 +++++
lib_mips/Makefile | 1 +
lib_mips/bdinfo.c | 44 +++++
lib_nios/Makefile | 1 +
lib_nios/bdinfo.c | 43 +++++
lib_nios2/Makefile | 1 +
lib_nios2/bdinfo.c | 51 +++++
lib_ppc/Makefile | 1 +
lib_ppc/bdinfo.c | 104 +++++++++++
lib_sh/Makefile | 1 +
lib_sh/bdinfo.c | 44 +++++
lib_sparc/Makefile | 13 +-
lib_sparc/bdinfo.c | 58 ++++++
26 files changed, 798 insertions(+), 392 deletions(-)
rewrite common/cmd_bdinfo.c (89%)
create mode 100644 include/bdinfo.h
create mode 100644 lib_arm/bdinfo.c
create mode 100644 lib_avr32/bdinfo.c
create mode 100644 lib_blackfin/bdinfo.c
create mode 100644 lib_i386/bdinfo.c
create mode 100644 lib_m68k/bdinfo.c
create mode 100644 lib_microblaze/bdinfo.c
create mode 100644 lib_mips/bdinfo.c
create mode 100644 lib_nios/bdinfo.c
create mode 100644 lib_nios2/bdinfo.c
create mode 100644 lib_ppc/bdinfo.c
create mode 100644 lib_sh/bdinfo.c
create mode 100644 lib_sparc/bdinfo.c
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
dissimilarity index 89%
index b230924..2609854 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -1,388 +1,76 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-/*
- * Boot support
- */
-#include <common.h>
-#include <command.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static void print_num(const char *, ulong);
-
-#if !defined(CONFIG_ARM) || defined(CONFIG_CMD_NET)
-static void print_eth(int idx);
-#endif
-
-#ifndef CONFIG_ARM /* PowerPC and other */
-static void print_lnum(const char *, u64);
-
-#ifdef CONFIG_PPC
-static void print_str(const char *, const char *);
-
-int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- bd_t *bd = gd->bd;
- char buf[32];
-
-#ifdef DEBUG
- print_num ("bd address", (ulong)bd );
-#endif
- print_num ("memstart", bd->bi_memstart );
- print_lnum ("memsize", bd->bi_memsize );
- print_num ("flashstart", bd->bi_flashstart );
- print_num ("flashsize", bd->bi_flashsize );
- print_num ("flashoffset", bd->bi_flashoffset );
- print_num ("sramstart", bd->bi_sramstart );
- print_num ("sramsize", bd->bi_sramsize );
-#if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \
- defined(CONFIG_8260) || defined(CONFIG_E500)
- print_num ("immr_base", bd->bi_immr_base );
-#endif
- print_num ("bootflags", bd->bi_bootflags );
-#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
- defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \
- defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
- defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
- defined(CONFIG_440SP) || defined(CONFIG_440SPE)
- print_str ("procfreq", strmhz(buf, bd->bi_procfreq));
- print_str ("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq));
-#if defined(CONFIG_405GP) || defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \
- defined(CONFIG_440EP) || defined(CONFIG_440GR) || defined(CONFIG_440SPE) || \
- defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
- print_str ("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq));
-#endif
-#else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
-#if defined(CONFIG_CPM2)
- print_str ("vco", strmhz(buf, bd->bi_vco));
- print_str ("sccfreq", strmhz(buf, bd->bi_sccfreq));
- print_str ("brgfreq", strmhz(buf, bd->bi_brgfreq));
-#endif
- print_str ("intfreq", strmhz(buf, bd->bi_intfreq));
-#if defined(CONFIG_CPM2)
- print_str ("cpmfreq", strmhz(buf, bd->bi_cpmfreq));
-#endif
- print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
-#endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
-#if defined(CONFIG_MPC8220)
- print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
- print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
- print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
- print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
- print_str ("pevfreq", strmhz(buf, bd->bi_pevfreq));
-#endif
-
- print_eth(0);
-#if defined(CONFIG_HAS_ETH1)
- print_eth(1);
-#endif
-#if defined(CONFIG_HAS_ETH2)
- print_eth(2);
-#endif
-#if defined(CONFIG_HAS_ETH3)
- print_eth(3);
-#endif
-#if defined(CONFIG_HAS_ETH4)
- print_eth(4);
-#endif
-#if defined(CONFIG_HAS_ETH5)
- print_eth(5);
-#endif
-
-#ifdef CONFIG_HERMES
- print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed));
-#endif
- printf ("IP addr = %pI4\n", &bd->bi_ip_addr);
- printf ("baudrate = %6ld bps\n", bd->bi_baudrate );
- return 0;
-}
-
-#elif defined(CONFIG_NIOS) /* NIOS*/
-
-int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- bd_t *bd = gd->bd;
-
- print_num ("memstart", (ulong)bd->bi_memstart);
- print_lnum ("memsize", (u64)bd->bi_memsize);
- print_num ("flashstart", (ulong)bd->bi_flashstart);
- print_num ("flashsize", (ulong)bd->bi_flashsize);
- print_num ("flashoffset", (ulong)bd->bi_flashoffset);
-
- print_eth(0);
- printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
- printf ("baudrate = %ld bps\n", bd->bi_baudrate);
-
- return 0;
-}
-
-#elif defined(CONFIG_NIOS2) /* Nios-II */
-
-int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- bd_t *bd = gd->bd;
-
- print_num ("mem start", (ulong)bd->bi_memstart);
- print_lnum ("mem size", (u64)bd->bi_memsize);
- print_num ("flash start", (ulong)bd->bi_flashstart);
- print_num ("flash size", (ulong)bd->bi_flashsize);
- print_num ("flash offset", (ulong)bd->bi_flashoffset);
-
-#if defined(CONFIG_SYS_SRAM_BASE)
- print_num ("sram start", (ulong)bd->bi_sramstart);
- print_num ("sram size", (ulong)bd->bi_sramsize);
-#endif
-
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
-#endif
-
- printf ("baudrate = %ld bps\n", bd->bi_baudrate);
-
- return 0;
-}
-#elif defined(CONFIG_MICROBLAZE) /* ! PPC, which leaves Microblaze */
-
-int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- bd_t *bd = gd->bd;
- print_num ("mem start ", (ulong)bd->bi_memstart);
- print_lnum ("mem size ", (u64)bd->bi_memsize);
- print_num ("flash start ", (ulong)bd->bi_flashstart);
- print_num ("flash size ", (ulong)bd->bi_flashsize);
- print_num ("flash offset ", (ulong)bd->bi_flashoffset);
-#if defined(CONFIG_SYS_SRAM_BASE)
- print_num ("sram start ", (ulong)bd->bi_sramstart);
- print_num ("sram size ", (ulong)bd->bi_sramsize);
-#endif
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
-#endif
- printf ("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
- return 0;
-}
-
-#elif defined(CONFIG_SPARC) /* SPARC */
-int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
-{
- bd_t *bd = gd->bd;
-
-#ifdef DEBUG
- print_num("bd address ", (ulong) bd);
-#endif
- print_num("memstart ", bd->bi_memstart);
- print_lnum("memsize ", bd->bi_memsize);
- print_num("flashstart ", bd->bi_flashstart);
- print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE);
- print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR);
- printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
- CONFIG_SYS_MONITOR_LEN);
- printf("CONFIG_SYS_MALLOC_BASE = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE,
- CONFIG_SYS_MALLOC_LEN);
- printf("CONFIG_SYS_INIT_SP_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
- CONFIG_SYS_STACK_SIZE);
- printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET,
- CONFIG_SYS_PROM_SIZE);
- printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
- CONFIG_SYS_GBL_DATA_SIZE);
-
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
-#endif
- printf("baudrate = %6ld bps\n", bd->bi_baudrate);
- return 0;
-}
-
-#elif defined(CONFIG_M68K) /* M68K */
-static void print_str(const char *, const char *);
-
-int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- bd_t *bd = gd->bd;
- char buf[32];
-
- print_num ("memstart", (ulong)bd->bi_memstart);
- print_lnum ("memsize", (u64)bd->bi_memsize);
- print_num ("flashstart", (ulong)bd->bi_flashstart);
- print_num ("flashsize", (ulong)bd->bi_flashsize);
- print_num ("flashoffset", (ulong)bd->bi_flashoffset);
-#if defined(CONFIG_SYS_INIT_RAM_ADDR)
- print_num ("sramstart", (ulong)bd->bi_sramstart);
- print_num ("sramsize", (ulong)bd->bi_sramsize);
-#endif
-#if defined(CONFIG_SYS_MBAR)
- print_num ("mbar", bd->bi_mbar_base);
-#endif
- print_str ("cpufreq", strmhz(buf, bd->bi_intfreq));
- print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
-#ifdef CONFIG_PCI
- print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
-#endif
-#ifdef CONFIG_EXTRA_CLOCK
- print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
- print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
- print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
-#endif
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
-#if defined(CONFIG_HAS_ETH1)
- print_eth(1);
-#endif
-#if defined(CONFIG_HAS_ETH2)
- print_eth(2);
-#endif
-#if defined(CONFIG_HAS_ETH3)
- print_eth(3);
-#endif
-
- printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
-#endif
- printf ("baudrate = %ld bps\n", bd->bi_baudrate);
-
- return 0;
-}
-
-#elif defined(CONFIG_BLACKFIN)
-static void print_str(const char *, const char *);
-
-int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- bd_t *bd = gd->bd;
- char buf[32];
-
- printf("U-Boot = %s\n", bd->bi_r_version);
- printf("CPU = %s\n", bd->bi_cpu);
- printf("Board = %s\n", bd->bi_board_name);
- print_str("VCO", strmhz(buf, bd->bi_vco));
- print_str("CCLK", strmhz(buf, bd->bi_cclk));
- print_str("SCLK", strmhz(buf, bd->bi_sclk));
-
- print_num("boot_params", (ulong)bd->bi_boot_params);
- print_num("memstart", (ulong)bd->bi_memstart);
- print_lnum("memsize", (u64)bd->bi_memsize);
- print_num("flashstart", (ulong)bd->bi_flashstart);
- print_num("flashsize", (ulong)bd->bi_flashsize);
- print_num("flashoffset", (ulong)bd->bi_flashoffset);
-
- print_eth(0);
- printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
- printf("baudrate = %d bps\n", bd->bi_baudrate);
-
- return 0;
-}
-
-#else /* ! PPC, which leaves MIPS */
-
-int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- bd_t *bd = gd->bd;
-
- print_num ("boot_params", (ulong)bd->bi_boot_params);
- print_num ("memstart", (ulong)bd->bi_memstart);
- print_lnum ("memsize", (u64)bd->bi_memsize);
- print_num ("flashstart", (ulong)bd->bi_flashstart);
- print_num ("flashsize", (ulong)bd->bi_flashsize);
- print_num ("flashoffset", (ulong)bd->bi_flashoffset);
-
- print_eth(0);
- printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
- printf ("baudrate = %d bps\n", bd->bi_baudrate);
-
- return 0;
-}
-#endif /* MIPS */
-
-#else /* ARM */
-
-int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
- int i;
- bd_t *bd = gd->bd;
-
- print_num ("arch_number", bd->bi_arch_number);
- print_num ("env_t", (ulong)bd->bi_env);
- print_num ("boot_params", (ulong)bd->bi_boot_params);
-
- for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
- print_num("DRAM bank", i);
- print_num("-> start", bd->bi_dram[i].start);
- print_num("-> size", bd->bi_dram[i].size);
- }
-
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
-#endif
- printf ("baudrate = %d bps\n", bd->bi_baudrate);
-
- return 0;
-}
-
-#endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
-
-static void print_num(const char *name, ulong value)
-{
- printf ("%-12s= 0x%08lX\n", name, value);
-}
-
-#if !defined(CONFIG_ARM) || defined(CONFIG_CMD_NET)
-static void print_eth(int idx)
-{
- char name[10], *val;
- if (idx)
- sprintf(name, "eth%iaddr", idx);
- else
- strcpy(name, "ethaddr");
- val = getenv(name);
- if (!val)
- val = "(not set)";
- printf("%-12s= %s\n", name, val);
-}
-#endif
-
-#ifndef CONFIG_ARM
-static void print_lnum(const char *name, u64 value)
-{
- printf ("%-12s= 0x%.8llX\n", name, value);
-}
-#endif
-
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_BLACKFIN)
-static void print_str(const char *name, const char *str)
-{
- printf ("%-12s= %6s MHz\n", name, str);
-}
-#endif /* CONFIG_PPC */
-
-
-/* -------------------------------------------------------------------- */
-
-U_BOOT_CMD(
- bdinfo, 1, 1, do_bdinfo,
- "print Board Info structure",
- NULL
-);
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+void board_bdinfo(cmd_tbl_t *, int, int, char **) __attribute__((weak));
+void cpu_bdinfo(cmd_tbl_t *, int, int, char **) __attribute__((weak));
+void soc_bdinfo(cmd_tbl_t *, int, int, char **) __attribute__((weak));
+
+int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+
+ /* call arch bdinfo */
+ arch_bdinfo(cmdtp, flag, argc, argv);
+
+ /* call cpu bdinfo */
+ if (cpu_bdinfo) {
+ printf("CPU Info\n");
+ cpu_bdinfo(cmdtp, flag, argc, argv);
+ }
+
+ /* call soc bdinfo */
+ if (soc_bdinfo) {
+ printf("SOC Info\n");
+ soc_bdinfo(cmdtp, flag, argc, argv);
+ }
+
+ /* call board bdinfo */
+ if (board_bdinfo) {
+ printf("Board Info\n");
+ board_bdinfo(cmdtp, flag, argc, argv);
+ }
+
+ return 0;
+}
+
+void print_eth(int idx)
+{
+ char name[10], *val;
+ if (idx)
+ sprintf(name, "eth%iaddr", idx);
+ else
+ strcpy(name, "ethaddr");
+ val = getenv(name);
+ if (!val)
+ val = "(not set)";
+ printf("%-12s= %s\n", name, val);
+}
+
+U_BOOT_CMD(
+ bdinfo, 1, 1, do_bdinfo,
+ "print Board Info structure",
+ NULL
+);
diff --git a/include/bdinfo.h b/include/bdinfo.h
new file mode 100644
index 0000000..cc44544
--- /dev/null
+++ b/include/bdinfo.h
@@ -0,0 +1,49 @@
+/*
+ * (C) Copyright 2008
+ * Jean-Christophe PLAGNIOL-VILLARD <plagnioj(a)jcrosoft.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _BDINFO_H_
+#define _BDINFO_H_
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char **argv);
+void board_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char **argv);
+void cpu_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char **argv);
+void soc_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char **argv);
+
+static inline void print_num(const char *name, ulong value)
+{
+ printf ("%-12s= 0x%08lX\n", name, value);
+}
+
+static inline void print_lnum(const char *name, u64 value)
+{
+ printf ("%-12s= 0x%.8llX\n", name, value);
+}
+
+static inline void print_str(const char *name, const char *str)
+{
+ printf ("%-12s= %6s MHz\n", name, str);
+}
+
+void print_eth(int idx);
+
+#endif /* _BDINFO_H_ */
diff --git a/lib_arm/Makefile b/lib_arm/Makefile
index c8795b2..1f36f58 100644
--- a/lib_arm/Makefile
+++ b/lib_arm/Makefile
@@ -32,6 +32,7 @@ SOBJS-y += _modsi3.o
SOBJS-y += _udivsi3.o
SOBJS-y += _umodsi3.o
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
COBJS-y += bootm.o
COBJS-y += cache.o
diff --git a/lib_arm/bdinfo.c b/lib_arm/bdinfo.c
new file mode 100644
index 0000000..7065bbb
--- /dev/null
+++ b/lib_arm/bdinfo.c
@@ -0,0 +1,50 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ int i;
+ bd_t *bd = gd->bd;
+
+ print_num ("arch_number", bd->bi_arch_number);
+ print_num ("env_t", (ulong)bd->bi_env);
+ print_num ("boot_params", (ulong)bd->bi_boot_params);
+
+ for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
+ print_num("DRAM bank", i);
+ print_num("-> start", bd->bi_dram[i].start);
+ print_num("-> size", bd->bi_dram[i].size);
+ }
+
+#if defined(CONFIG_CMD_NET)
+ print_eth(0);
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+#endif
+ printf ("baudrate = %d bps\n", bd->bi_baudrate);
+}
diff --git a/lib_avr32/Makefile b/lib_avr32/Makefile
index 37b8051..856d450 100644
--- a/lib_avr32/Makefile
+++ b/lib_avr32/Makefile
@@ -29,6 +29,7 @@ LIB = $(obj)lib$(ARCH).a
SOBJS-y += memset.o
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
COBJS-y += bootm.o
COBJS-y += interrupts.o
diff --git a/lib_avr32/bdinfo.c b/lib_avr32/bdinfo.c
new file mode 100644
index 0000000..fac5b33
--- /dev/null
+++ b/lib_avr32/bdinfo.c
@@ -0,0 +1,44 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+
+ print_num ("boot_params", (ulong)bd->bi_boot_params);
+ print_num ("memstart", (ulong)bd->bi_memstart);
+ print_lnum ("memsize", (u64)bd->bi_memsize);
+ print_num ("flashstart", (ulong)bd->bi_flashstart);
+ print_num ("flashsize", (ulong)bd->bi_flashsize);
+ print_num ("flashoffset", (ulong)bd->bi_flashoffset);
+
+ print_eth(0);
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf ("baudrate = %d bps\n", bd->bi_baudrate);
+}
diff --git a/lib_blackfin/Makefile b/lib_blackfin/Makefile
index 46ef7f3..8c6d13c 100644
--- a/lib_blackfin/Makefile
+++ b/lib_blackfin/Makefile
@@ -36,6 +36,7 @@ SOBJS-y += memcpy.o
SOBJS-y += memmove.o
SOBJS-y += memset.o
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
COBJS-y += boot.o
COBJS-y += cache.o
diff --git a/lib_blackfin/bdinfo.c b/lib_blackfin/bdinfo.c
new file mode 100644
index 0000000..c5a4ed0
--- /dev/null
+++ b/lib_blackfin/bdinfo.c
@@ -0,0 +1,52 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+ char buf[32];
+
+ printf("U-Boot = %s\n", bd->bi_r_version);
+ printf("CPU = %s\n", bd->bi_cpu);
+ printf("Board = %s\n", bd->bi_board_name);
+ print_str("VCO", strmhz(buf, bd->bi_vco));
+ print_str("CCLK", strmhz(buf, bd->bi_cclk));
+ print_str("SCLK", strmhz(buf, bd->bi_sclk));
+
+ print_num("boot_params", (ulong)bd->bi_boot_params);
+ print_num("memstart", (ulong)bd->bi_memstart);
+ print_lnum("memsize", (u64)bd->bi_memsize);
+ print_num("flashstart", (ulong)bd->bi_flashstart);
+ print_num("flashsize", (ulong)bd->bi_flashsize);
+ print_num("flashoffset", (ulong)bd->bi_flashoffset);
+
+ print_eth(0);
+ printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf("baudrate = %d bps\n", bd->bi_baudrate);
+}
diff --git a/lib_i386/Makefile b/lib_i386/Makefile
index ec6f236..3f8a831 100644
--- a/lib_i386/Makefile
+++ b/lib_i386/Makefile
@@ -29,6 +29,7 @@ SOBJS-y += bios.o
SOBJS-y += bios_pci.o
SOBJS-y += realmode_switch.o
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += bios_setup.o
COBJS-y += board.o
COBJS-y += bootm.o
diff --git a/lib_i386/bdinfo.c b/lib_i386/bdinfo.c
new file mode 100644
index 0000000..fac5b33
--- /dev/null
+++ b/lib_i386/bdinfo.c
@@ -0,0 +1,44 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+
+ print_num ("boot_params", (ulong)bd->bi_boot_params);
+ print_num ("memstart", (ulong)bd->bi_memstart);
+ print_lnum ("memsize", (u64)bd->bi_memsize);
+ print_num ("flashstart", (ulong)bd->bi_flashstart);
+ print_num ("flashsize", (ulong)bd->bi_flashsize);
+ print_num ("flashoffset", (ulong)bd->bi_flashoffset);
+
+ print_eth(0);
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf ("baudrate = %d bps\n", bd->bi_baudrate);
+}
diff --git a/lib_m68k/Makefile b/lib_m68k/Makefile
index 6db35ed..f11b601 100644
--- a/lib_m68k/Makefile
+++ b/lib_m68k/Makefile
@@ -27,6 +27,7 @@ LIB = $(obj)lib$(ARCH).a
SOBJS-y +=
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
COBJS-y += bootm.o
COBJS-y += cache.o
diff --git a/lib_m68k/bdinfo.c b/lib_m68k/bdinfo.c
new file mode 100644
index 0000000..65d582b
--- /dev/null
+++ b/lib_m68k/bdinfo.c
@@ -0,0 +1,72 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+ char buf[32];
+
+ print_num ("memstart", (ulong)bd->bi_memstart);
+ print_lnum ("memsize", (u64)bd->bi_memsize);
+ print_num ("flashstart", (ulong)bd->bi_flashstart);
+ print_num ("flashsize", (ulong)bd->bi_flashsize);
+ print_num ("flashoffset", (ulong)bd->bi_flashoffset);
+#if defined(CONFIG_SYS_INIT_RAM_ADDR)
+ print_num ("sramstart", (ulong)bd->bi_sramstart);
+ print_num ("sramsize", (ulong)bd->bi_sramsize);
+#endif
+#if defined(CONFIG_SYS_MBAR)
+ print_num ("mbar", bd->bi_mbar_base);
+#endif
+ print_str ("cpufreq", strmhz(buf, bd->bi_intfreq));
+ print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
+#ifdef CONFIG_PCI
+ print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
+#endif
+#ifdef CONFIG_EXTRA_CLOCK
+ print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
+ print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
+ print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
+#endif
+#if defined(CONFIG_CMD_NET)
+ print_eth(0);
+#if defined(CONFIG_HAS_ETH1)
+ print_eth(1);
+#endif
+#if defined(CONFIG_HAS_ETH2)
+ print_eth(2);
+#endif
+#if defined(CONFIG_HAS_ETH3)
+ print_eth(3);
+#endif
+
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+#endif
+ printf ("baudrate = %ld bps\n", bd->bi_baudrate);
+}
diff --git a/lib_microblaze/Makefile b/lib_microblaze/Makefile
index 9b0f296..b9c5088 100644
--- a/lib_microblaze/Makefile
+++ b/lib_microblaze/Makefile
@@ -27,6 +27,7 @@ LIB = $(obj)lib$(ARCH).a
SOBJS-y +=
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
COBJS-y += bootm.o
COBJS-y += cache.o
diff --git a/lib_microblaze/bdinfo.c b/lib_microblaze/bdinfo.c
new file mode 100644
index 0000000..fa7c62a
--- /dev/null
+++ b/lib_microblaze/bdinfo.c
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+ print_num ("mem start ", (ulong)bd->bi_memstart);
+ print_lnum ("mem size ", (u64)bd->bi_memsize);
+ print_num ("flash start ", (ulong)bd->bi_flashstart);
+ print_num ("flash size ", (ulong)bd->bi_flashsize);
+ print_num ("flash offset ", (ulong)bd->bi_flashoffset);
+#if defined(CONFIG_SYS_SRAM_BASE)
+ print_num ("sram start ", (ulong)bd->bi_sramstart);
+ print_num ("sram size ", (ulong)bd->bi_sramsize);
+#endif
+#if defined(CONFIG_CMD_NET)
+ print_eth(0);
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+#endif
+ printf ("baudrate = %ld bps\n", (ulong)bd->bi_baudrate);
+}
diff --git a/lib_mips/Makefile b/lib_mips/Makefile
index 7967e58..5dc75c0 100644
--- a/lib_mips/Makefile
+++ b/lib_mips/Makefile
@@ -27,6 +27,7 @@ LIB = $(obj)lib$(ARCH).a
SOBJS-y +=
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
ifeq ($(CONFIG_QEMU_MIPS),y)
COBJS-y += bootm_qemu_mips.o
diff --git a/lib_mips/bdinfo.c b/lib_mips/bdinfo.c
new file mode 100644
index 0000000..fac5b33
--- /dev/null
+++ b/lib_mips/bdinfo.c
@@ -0,0 +1,44 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+
+ print_num ("boot_params", (ulong)bd->bi_boot_params);
+ print_num ("memstart", (ulong)bd->bi_memstart);
+ print_lnum ("memsize", (u64)bd->bi_memsize);
+ print_num ("flashstart", (ulong)bd->bi_flashstart);
+ print_num ("flashsize", (ulong)bd->bi_flashsize);
+ print_num ("flashoffset", (ulong)bd->bi_flashoffset);
+
+ print_eth(0);
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf ("baudrate = %d bps\n", bd->bi_baudrate);
+}
diff --git a/lib_nios/Makefile b/lib_nios/Makefile
index f66e989..b665eb7 100644
--- a/lib_nios/Makefile
+++ b/lib_nios/Makefile
@@ -27,6 +27,7 @@ LIB = $(obj)lib$(ARCH).a
SOBJS-y +=
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
COBJS-y += bootm.o
COBJS-y += cache.o
diff --git a/lib_nios/bdinfo.c b/lib_nios/bdinfo.c
new file mode 100644
index 0000000..637bd4f
--- /dev/null
+++ b/lib_nios/bdinfo.c
@@ -0,0 +1,43 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+
+ print_num ("memstart", (ulong)bd->bi_memstart);
+ print_lnum ("memsize", (u64)bd->bi_memsize);
+ print_num ("flashstart", (ulong)bd->bi_flashstart);
+ print_num ("flashsize", (ulong)bd->bi_flashsize);
+ print_num ("flashoffset", (ulong)bd->bi_flashoffset);
+
+ print_eth(0);
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf ("baudrate = %ld bps\n", bd->bi_baudrate);
+}
diff --git a/lib_nios2/Makefile b/lib_nios2/Makefile
index b69bc38..fd9a60e 100644
--- a/lib_nios2/Makefile
+++ b/lib_nios2/Makefile
@@ -27,6 +27,7 @@ LIB = $(obj)lib$(ARCH).a
SOBJS-y += cache.o
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
COBJS-y += bootm.o
COBJS-y += divmod.o
diff --git a/lib_nios2/bdinfo.c b/lib_nios2/bdinfo.c
new file mode 100644
index 0000000..def6a4b
--- /dev/null
+++ b/lib_nios2/bdinfo.c
@@ -0,0 +1,51 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+
+ print_num ("mem start", (ulong)bd->bi_memstart);
+ print_lnum ("mem size", (u64)bd->bi_memsize);
+ print_num ("flash start", (ulong)bd->bi_flashstart);
+ print_num ("flash size", (ulong)bd->bi_flashsize);
+ print_num ("flash offset", (ulong)bd->bi_flashoffset);
+
+#if defined(CONFIG_SYS_SRAM_BASE)
+ print_num ("sram start", (ulong)bd->bi_sramstart);
+ print_num ("sram size", (ulong)bd->bi_sramsize);
+#endif
+
+#if defined(CONFIG_CMD_NET)
+ print_eth(0);
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+#endif
+
+ printf ("baudrate = %ld bps\n", bd->bi_baudrate);
+}
diff --git a/lib_ppc/Makefile b/lib_ppc/Makefile
index 60ea0c9..b53bf29 100644
--- a/lib_ppc/Makefile
+++ b/lib_ppc/Makefile
@@ -30,6 +30,7 @@ SOBJS-y += ppcstring.o
SOBJS-y += ticks.o
COBJS-y += bat_rw.o
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
COBJS-y += bootm.o
COBJS-y += cache.o
diff --git a/lib_ppc/bdinfo.c b/lib_ppc/bdinfo.c
new file mode 100644
index 0000000..dac9d2b
--- /dev/null
+++ b/lib_ppc/bdinfo.c
@@ -0,0 +1,104 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+ char buf[32];
+
+#ifdef DEBUG
+ print_num ("bd address", (ulong)bd );
+#endif
+ print_num ("memstart", bd->bi_memstart );
+ print_lnum ("memsize", bd->bi_memsize );
+ print_num ("flashstart", bd->bi_flashstart );
+ print_num ("flashsize", bd->bi_flashsize );
+ print_num ("flashoffset", bd->bi_flashoffset );
+ print_num ("sramstart", bd->bi_sramstart );
+ print_num ("sramsize", bd->bi_sramsize );
+#if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \
+ defined(CONFIG_8260) || defined(CONFIG_E500)
+ print_num ("immr_base", bd->bi_immr_base );
+#endif
+ print_num ("bootflags", bd->bi_bootflags );
+#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
+ defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \
+ defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
+ defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
+ defined(CONFIG_440SP) || defined(CONFIG_440SPE)
+ print_str ("procfreq", strmhz(buf, bd->bi_procfreq));
+ print_str ("plb_busfreq", strmhz(buf, bd->bi_plb_busfreq));
+#if defined(CONFIG_405GP) || defined(CONFIG_405EP) || defined(CONFIG_XILINX_405) || \
+ defined(CONFIG_440EP) || defined(CONFIG_440GR) || defined(CONFIG_440SPE) || \
+ defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
+ print_str ("pci_busfreq", strmhz(buf, bd->bi_pci_busfreq));
+#endif
+#else /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
+#if defined(CONFIG_CPM2)
+ print_str ("vco", strmhz(buf, bd->bi_vco));
+ print_str ("sccfreq", strmhz(buf, bd->bi_sccfreq));
+ print_str ("brgfreq", strmhz(buf, bd->bi_brgfreq));
+#endif
+ print_str ("intfreq", strmhz(buf, bd->bi_intfreq));
+#if defined(CONFIG_CPM2)
+ print_str ("cpmfreq", strmhz(buf, bd->bi_cpmfreq));
+#endif
+ print_str ("busfreq", strmhz(buf, bd->bi_busfreq));
+#endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
+#if defined(CONFIG_MPC8220)
+ print_str ("inpfreq", strmhz(buf, bd->bi_inpfreq));
+ print_str ("flbfreq", strmhz(buf, bd->bi_flbfreq));
+ print_str ("pcifreq", strmhz(buf, bd->bi_pcifreq));
+ print_str ("vcofreq", strmhz(buf, bd->bi_vcofreq));
+ print_str ("pevfreq", strmhz(buf, bd->bi_pevfreq));
+#endif
+
+ print_eth(0);
+#if defined(CONFIG_HAS_ETH1)
+ print_eth(1);
+#endif
+#if defined(CONFIG_HAS_ETH2)
+ print_eth(2);
+#endif
+#if defined(CONFIG_HAS_ETH3)
+ print_eth(3);
+#endif
+#if defined(CONFIG_HAS_ETH4)
+ print_eth(4);
+#endif
+#if defined(CONFIG_HAS_ETH5)
+ print_eth(5);
+#endif
+
+#ifdef CONFIG_HERMES
+ print_str ("ethspeed", strmhz(buf, bd->bi_ethspeed));
+#endif
+ printf ("IP addr = %pI4\n", &bd->bi_ip_addr);
+ printf ("baudrate = %6ld bps\n", bd->bi_baudrate );
+}
diff --git a/lib_sh/Makefile b/lib_sh/Makefile
index f7c6479..54df402 100644
--- a/lib_sh/Makefile
+++ b/lib_sh/Makefile
@@ -24,6 +24,7 @@ LIB = $(obj)lib$(ARCH).a
SOBJS-y +=
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
COBJS-y += board.o
COBJS-y += bootm.o
ifeq ($(CONFIG_SH2),y)
diff --git a/lib_sh/bdinfo.c b/lib_sh/bdinfo.c
new file mode 100644
index 0000000..fac5b33
--- /dev/null
+++ b/lib_sh/bdinfo.c
@@ -0,0 +1,44 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+
+ print_num ("boot_params", (ulong)bd->bi_boot_params);
+ print_num ("memstart", (ulong)bd->bi_memstart);
+ print_lnum ("memsize", (u64)bd->bi_memsize);
+ print_num ("flashstart", (ulong)bd->bi_flashstart);
+ print_num ("flashsize", (ulong)bd->bi_flashsize);
+ print_num ("flashoffset", (ulong)bd->bi_flashoffset);
+
+ print_eth(0);
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf ("baudrate = %d bps\n", bd->bi_baudrate);
+}
diff --git a/lib_sparc/Makefile b/lib_sparc/Makefile
index 040ca10..67a68da 100644
--- a/lib_sparc/Makefile
+++ b/lib_sparc/Makefile
@@ -25,12 +25,17 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(ARCH).a
-SOBJS =
+SOBJS-y =
-COBJS = board.o cache.o interrupts.o time.o bootm.o
+COBJS-$(CONFIG_CMD_BDI) += bdinfo.o
+COBJS-y = board.o
+COBJS-y = bootm.o
+COBJS-y = cache.o
+COBJS-y = interrupts.o
+COBJS-y = time.o
-SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
$(LIB): $(obj).depend $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
diff --git a/lib_sparc/bdinfo.c b/lib_sparc/bdinfo.c
new file mode 100644
index 0000000..4614fea
--- /dev/null
+++ b/lib_sparc/bdinfo.c
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <bdinfo.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+
+#ifdef DEBUG
+ print_num("bd address ", (ulong) bd);
+#endif
+ print_num("memstart ", bd->bi_memstart);
+ print_lnum("memsize ", bd->bi_memsize);
+ print_num("flashstart ", bd->bi_flashstart);
+ print_num("CONFIG_SYS_MONITOR_BASE ", CONFIG_SYS_MONITOR_BASE);
+ print_num("CONFIG_ENV_ADDR ", CONFIG_ENV_ADDR);
+ printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%lx (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
+ CONFIG_SYS_MONITOR_LEN);
+ printf("CONFIG_SYS_MALLOC_BASE = 0x%lx (%d)\n", CONFIG_SYS_MALLOC_BASE,
+ CONFIG_SYS_MALLOC_LEN);
+ printf("CONFIG_SYS_INIT_SP_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
+ CONFIG_SYS_STACK_SIZE);
+ printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET,
+ CONFIG_SYS_PROM_SIZE);
+ printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
+ CONFIG_SYS_GBL_DATA_SIZE);
+
+#if defined(CONFIG_CMD_NET)
+ print_eth(0);
+ printf("ip_addr = %pI4\n", &bd->bi_ip_addr);
+#endif
+ printf("baudrate = %6ld bps\n", bd->bi_baudrate);
+}
--
1.6.1.3
2
4

[U-Boot] [PATCH/next v3 00/28] tools/Makefile cleanup and win32 tool support
by Peter Tyser 28 Apr '09
by Peter Tyser 28 Apr '09
28 Apr '09
This patch series attempts to do 2 things:
1. Add support for generating win32 versions of the tools in tools/
2. Cleanup tools/Makefile somewhat
In the process of #1 I couldn't help but work on #2 a bit:) Let me
know if people would prefer the patches split up.
The win32 tools support is based on the patch found in the email thread
"Add native win32 mkimage support". It is different from the original
patch in that it:
1. Supports all tools in tools/ (original only supported mkimage)
2. Uses common swap routines instead of re-implementing
3. Got rid of MINGW_COMPILE variable and used HOST* variables instead
4. Updated top-level Makefile to remove all generated *.exe files
Changes since v1:
- Made changes recommended by Mike Frysinger
* Rewordings, generic os_support.[ch] files, style changes, define
__KERNEL_STRICT_NAMES for tool builds
- Removed symlinking of header/source files into tools/
* The original code created build rules for files to be symlinked into
the tools directory which had some shortcomings:
- 2 make rules for every file - 1 for linking, 1 for compilation
- Ugly clean target (rm specific files which were symlinks)
- dependencies weren't auto-generated
- Auto-generated dependencies for tools/ files
- Remove individual file build rules in favor of a few generic build rules
- Cleaned up HOSTARCH, HOSTOS, HOST_CFLAGS, and HOST_LDFLAGS
- Rebased on TOT
Changes since v2:
- Rebased on "next" branch
- Updated tools/.gitignore
- Moved zlib.h and bzlib.h into include/u-boot/
The changeset seem to grow with every revision, I hope third time's
the charm:)
Peter Tyser (28):
Makefile: Make autoconf.mk a dependency of the depend target
Makefile: Add removal of *.exe files to clean target
common/Makefile: Conditionally compile env_embedded.o
elf.h: Use stdint.h to provide standard typedefs for WIN32
Rename include/zlib.h to include/u-boot/zlib.h
Rename include/bzlib.h to include/u-boot/bzlib.h
gen_eth_addr: Use POSIX rand() and srand()
tools/Makefile: Remove HOSTARCH HOSTOS defines
tools/Makefile: Remove inappropriate double-tabs
tools/Makefile: Split variable declarations into multiple lines
tools/Makefile: Build bmp_logo only when LCD or VIDEO logos are
enabled
tools/Makefile: Make img2srec dependent upon CONFIG_CMD_LOADS
tools/Makefile: Make ubsha1 dependent upon CONFIG_SHA1_CHECK_UB_IMG
tools/Makefile: Make inca-swap-bytes dependent on CONFIG_INCA_IP
tools/Makefile: Make envcrc dependent upon CONFIG_ENV_IS_EMBEDDED
tools/Makefile: Make gen_eth_addr dependent upon CONFIG_CMD_NET
tools/Makefile: Compile ncb when CONFIG_NETCONSOLE
tools/Makefile: Add tools/ to the include search path
tools: Remove unecessary symlinking of zlib.h
tools/Makefile: Add libfdt/ to the include search path
tools/Makefile: Remove symlinks for fdt targets
tools/Makefile: Dynamically generate libfdt object dependencies
tools/Makefile: Remove symlinks for remaining source files
tools/Makefile: Use auto-generated object file dependencies
tools/Makefile: Create generic build rules
tools/Makefile: Simplify HOST_CFLAGS/HOST_LDFLAGS generation
Add support for building native win32 tools
Delete now unused tools/Makefile.win32
Makefile | 22 ++--
README | 10 ++
board/mpl/common/common_util.c | 2 +-
common/Makefile | 2 +-
common/cmd_bootm.c | 4 +-
doc/README.NetConsole | 6 +-
fs/cramfs/uncompress.c | 2 +-
include/elf.h | 7 +-
include/image.h | 2 +
include/libfdt_env.h | 12 ++
include/{ => u-boot}/bzlib.h | 0
include/{ => u-boot}/zlib.h | 0
lib_arm/bootm.c | 2 +-
lib_avr32/bootm.c | 2 +-
lib_generic/bzlib_private.h | 2 +-
lib_generic/crc32.c | 2 +-
lib_generic/gunzip.c | 2 +-
lib_generic/zlib.c | 2 +-
lib_i386/bootm.c | 2 +-
lib_m68k/bootm.c | 4 +-
lib_microblaze/bootm.c | 2 +-
lib_mips/bootm.c | 2 +-
lib_ppc/bootm.c | 4 +-
tools/.gitignore | 12 --
tools/Makefile | 313 ++++++++++++++++------------------------
tools/Makefile.win32 | 37 -----
tools/gen_eth_addr.c | 6 +-
tools/mingw_support.c | 79 ++++++++++
tools/mingw_support.h | 51 +++++++
tools/mkimage.h | 5 +
tools/os_support.c | 24 +++
tools/os_support.h | 29 ++++
tools/ubsha1.c | 3 +
33 files changed, 370 insertions(+), 284 deletions(-)
rename include/{ => u-boot}/bzlib.h (100%)
rename include/{ => u-boot}/zlib.h (100%)
delete mode 100644 tools/Makefile.win32
create mode 100644 tools/mingw_support.c
create mode 100644 tools/mingw_support.h
create mode 100644 tools/os_support.c
create mode 100644 tools/os_support.h
5
68
sa1100.h is not used anywhere, then remove it.
$ find . -name '*.h' -empty -print
./include/sa1100.h
$ git grep 'sa1100.h' .
$
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi(a)necel.com>
---
include/sa1100.h | 0
1 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 include/sa1100.h
diff --git a/include/sa1100.h b/include/sa1100.h
deleted file mode 100644
index e69de29..0000000
--
Shinya Kuribayashi
NEC Electronics
3
2

[U-Boot] [PATCH] UBIFS: Remove tnc_commit.c which is not used in the read-only version
by Stefan Roese 28 Apr '09
by Stefan Roese 28 Apr '09
28 Apr '09
I missed removing this file while implementing the UBIFS support. It's
not referenced at all, so let's remove it. Thanks to Artem Bityutskiy
for spotting.
Signed-off-by: Stefan Roese <sr(a)denx.de>
---
fs/ubifs/tnc_commit.c | 1102 -------------------------------------------------
1 files changed, 0 insertions(+), 1102 deletions(-)
delete mode 100644 fs/ubifs/tnc_commit.c
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
deleted file mode 100644
index 8ac76b1..0000000
--- a/fs/ubifs/tnc_commit.c
+++ /dev/null
@@ -1,1102 +0,0 @@
-/*
- * This file is part of UBIFS.
- *
- * Copyright (C) 2006-2008 Nokia Corporation.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Adrian Hunter
- * Artem Bityutskiy (Битюцкий Артём)
- */
-
-/* This file implements TNC functions for committing */
-
-#include "ubifs.h"
-
-/**
- * make_idx_node - make an index node for fill-the-gaps method of TNC commit.
- * @c: UBIFS file-system description object
- * @idx: buffer in which to place new index node
- * @znode: znode from which to make new index node
- * @lnum: LEB number where new index node will be written
- * @offs: offset where new index node will be written
- * @len: length of new index node
- */
-static int make_idx_node(struct ubifs_info *c, struct ubifs_idx_node *idx,
- struct ubifs_znode *znode, int lnum, int offs, int len)
-{
- struct ubifs_znode *zp;
- int i, err;
-
- /* Make index node */
- idx->ch.node_type = UBIFS_IDX_NODE;
- idx->child_cnt = cpu_to_le16(znode->child_cnt);
- idx->level = cpu_to_le16(znode->level);
- for (i = 0; i < znode->child_cnt; i++) {
- struct ubifs_branch *br = ubifs_idx_branch(c, idx, i);
- struct ubifs_zbranch *zbr = &znode->zbranch[i];
-
- key_write_idx(c, &zbr->key, &br->key);
- br->lnum = cpu_to_le32(zbr->lnum);
- br->offs = cpu_to_le32(zbr->offs);
- br->len = cpu_to_le32(zbr->len);
- if (!zbr->lnum || !zbr->len) {
- ubifs_err("bad ref in znode");
- dbg_dump_znode(c, znode);
- if (zbr->znode)
- dbg_dump_znode(c, zbr->znode);
- }
- }
- ubifs_prepare_node(c, idx, len, 0);
-
-#ifdef CONFIG_UBIFS_FS_DEBUG
- znode->lnum = lnum;
- znode->offs = offs;
- znode->len = len;
-#endif
-
- err = insert_old_idx_znode(c, znode);
-
- /* Update the parent */
- zp = znode->parent;
- if (zp) {
- struct ubifs_zbranch *zbr;
-
- zbr = &zp->zbranch[znode->iip];
- zbr->lnum = lnum;
- zbr->offs = offs;
- zbr->len = len;
- } else {
- c->zroot.lnum = lnum;
- c->zroot.offs = offs;
- c->zroot.len = len;
- }
- c->calc_idx_sz += ALIGN(len, 8);
-
- atomic_long_dec(&c->dirty_zn_cnt);
-
- ubifs_assert(ubifs_zn_dirty(znode));
- ubifs_assert(test_bit(COW_ZNODE, &znode->flags));
-
- __clear_bit(DIRTY_ZNODE, &znode->flags);
- __clear_bit(COW_ZNODE, &znode->flags);
-
- return err;
-}
-
-/**
- * fill_gap - make index nodes in gaps in dirty index LEBs.
- * @c: UBIFS file-system description object
- * @lnum: LEB number that gap appears in
- * @gap_start: offset of start of gap
- * @gap_end: offset of end of gap
- * @dirt: adds dirty space to this
- *
- * This function returns the number of index nodes written into the gap.
- */
-static int fill_gap(struct ubifs_info *c, int lnum, int gap_start, int gap_end,
- int *dirt)
-{
- int len, gap_remains, gap_pos, written, pad_len;
-
- ubifs_assert((gap_start & 7) == 0);
- ubifs_assert((gap_end & 7) == 0);
- ubifs_assert(gap_end >= gap_start);
-
- gap_remains = gap_end - gap_start;
- if (!gap_remains)
- return 0;
- gap_pos = gap_start;
- written = 0;
- while (c->enext) {
- len = ubifs_idx_node_sz(c, c->enext->child_cnt);
- if (len < gap_remains) {
- struct ubifs_znode *znode = c->enext;
- const int alen = ALIGN(len, 8);
- int err;
-
- ubifs_assert(alen <= gap_remains);
- err = make_idx_node(c, c->ileb_buf + gap_pos, znode,
- lnum, gap_pos, len);
- if (err)
- return err;
- gap_remains -= alen;
- gap_pos += alen;
- c->enext = znode->cnext;
- if (c->enext == c->cnext)
- c->enext = NULL;
- written += 1;
- } else
- break;
- }
- if (gap_end == c->leb_size) {
- c->ileb_len = ALIGN(gap_pos, c->min_io_size);
- /* Pad to end of min_io_size */
- pad_len = c->ileb_len - gap_pos;
- } else
- /* Pad to end of gap */
- pad_len = gap_remains;
- dbg_gc("LEB %d:%d to %d len %d nodes written %d wasted bytes %d",
- lnum, gap_start, gap_end, gap_end - gap_start, written, pad_len);
- ubifs_pad(c, c->ileb_buf + gap_pos, pad_len);
- *dirt += pad_len;
- return written;
-}
-
-/**
- * find_old_idx - find an index node obsoleted since the last commit start.
- * @c: UBIFS file-system description object
- * @lnum: LEB number of obsoleted index node
- * @offs: offset of obsoleted index node
- *
- * Returns %1 if found and %0 otherwise.
- */
-static int find_old_idx(struct ubifs_info *c, int lnum, int offs)
-{
- struct ubifs_old_idx *o;
- struct rb_node *p;
-
- p = c->old_idx.rb_node;
- while (p) {
- o = rb_entry(p, struct ubifs_old_idx, rb);
- if (lnum < o->lnum)
- p = p->rb_left;
- else if (lnum > o->lnum)
- p = p->rb_right;
- else if (offs < o->offs)
- p = p->rb_left;
- else if (offs > o->offs)
- p = p->rb_right;
- else
- return 1;
- }
- return 0;
-}
-
-/**
- * is_idx_node_in_use - determine if an index node can be overwritten.
- * @c: UBIFS file-system description object
- * @key: key of index node
- * @level: index node level
- * @lnum: LEB number of index node
- * @offs: offset of index node
- *
- * If @key / @lnum / @offs identify an index node that was not part of the old
- * index, then this function returns %0 (obsolete). Else if the index node was
- * part of the old index but is now dirty %1 is returned, else if it is clean %2
- * is returned. A negative error code is returned on failure.
- */
-static int is_idx_node_in_use(struct ubifs_info *c, union ubifs_key *key,
- int level, int lnum, int offs)
-{
- int ret;
-
- ret = is_idx_node_in_tnc(c, key, level, lnum, offs);
- if (ret < 0)
- return ret; /* Error code */
- if (ret == 0)
- if (find_old_idx(c, lnum, offs))
- return 1;
- return ret;
-}
-
-/**
- * layout_leb_in_gaps - layout index nodes using in-the-gaps method.
- * @c: UBIFS file-system description object
- * @p: return LEB number here
- *
- * This function lays out new index nodes for dirty znodes using in-the-gaps
- * method of TNC commit.
- * This function merely puts the next znode into the next gap, making no attempt
- * to try to maximise the number of znodes that fit.
- * This function returns the number of index nodes written into the gaps, or a
- * negative error code on failure.
- */
-static int layout_leb_in_gaps(struct ubifs_info *c, int *p)
-{
- struct ubifs_scan_leb *sleb;
- struct ubifs_scan_node *snod;
- int lnum, dirt = 0, gap_start, gap_end, err, written, tot_written;
-
- tot_written = 0;
- /* Get an index LEB with lots of obsolete index nodes */
- lnum = ubifs_find_dirty_idx_leb(c);
- if (lnum < 0)
- /*
- * There also may be dirt in the index head that could be
- * filled, however we do not check there at present.
- */
- return lnum; /* Error code */
- *p = lnum;
- dbg_gc("LEB %d", lnum);
- /*
- * Scan the index LEB. We use the generic scan for this even though
- * it is more comprehensive and less efficient than is needed for this
- * purpose.
- */
- sleb = ubifs_scan(c, lnum, 0, c->ileb_buf);
- c->ileb_len = 0;
- if (IS_ERR(sleb))
- return PTR_ERR(sleb);
- gap_start = 0;
- list_for_each_entry(snod, &sleb->nodes, list) {
- struct ubifs_idx_node *idx;
- int in_use, level;
-
- ubifs_assert(snod->type == UBIFS_IDX_NODE);
- idx = snod->node;
- key_read(c, ubifs_idx_key(c, idx), &snod->key);
- level = le16_to_cpu(idx->level);
- /* Determine if the index node is in use (not obsolete) */
- in_use = is_idx_node_in_use(c, &snod->key, level, lnum,
- snod->offs);
- if (in_use < 0) {
- ubifs_scan_destroy(sleb);
- return in_use; /* Error code */
- }
- if (in_use) {
- if (in_use == 1)
- dirt += ALIGN(snod->len, 8);
- /*
- * The obsolete index nodes form gaps that can be
- * overwritten. This gap has ended because we have
- * found an index node that is still in use
- * i.e. not obsolete
- */
- gap_end = snod->offs;
- /* Try to fill gap */
- written = fill_gap(c, lnum, gap_start, gap_end, &dirt);
- if (written < 0) {
- ubifs_scan_destroy(sleb);
- return written; /* Error code */
- }
- tot_written += written;
- gap_start = ALIGN(snod->offs + snod->len, 8);
- }
- }
- ubifs_scan_destroy(sleb);
- c->ileb_len = c->leb_size;
- gap_end = c->leb_size;
- /* Try to fill gap */
- written = fill_gap(c, lnum, gap_start, gap_end, &dirt);
- if (written < 0)
- return written; /* Error code */
- tot_written += written;
- if (tot_written == 0) {
- struct ubifs_lprops lp;
-
- dbg_gc("LEB %d wrote %d index nodes", lnum, tot_written);
- err = ubifs_read_one_lp(c, lnum, &lp);
- if (err)
- return err;
- if (lp.free == c->leb_size) {
- /*
- * We must have snatched this LEB from the idx_gc list
- * so we need to correct the free and dirty space.
- */
- err = ubifs_change_one_lp(c, lnum,
- c->leb_size - c->ileb_len,
- dirt, 0, 0, 0);
- if (err)
- return err;
- }
- return 0;
- }
- err = ubifs_change_one_lp(c, lnum, c->leb_size - c->ileb_len, dirt,
- 0, 0, 0);
- if (err)
- return err;
- err = ubifs_leb_change(c, lnum, c->ileb_buf, c->ileb_len,
- UBI_SHORTTERM);
- if (err)
- return err;
- dbg_gc("LEB %d wrote %d index nodes", lnum, tot_written);
- return tot_written;
-}
-
-/**
- * get_leb_cnt - calculate the number of empty LEBs needed to commit.
- * @c: UBIFS file-system description object
- * @cnt: number of znodes to commit
- *
- * This function returns the number of empty LEBs needed to commit @cnt znodes
- * to the current index head. The number is not exact and may be more than
- * needed.
- */
-static int get_leb_cnt(struct ubifs_info *c, int cnt)
-{
- int d;
-
- /* Assume maximum index node size (i.e. overestimate space needed) */
- cnt -= (c->leb_size - c->ihead_offs) / c->max_idx_node_sz;
- if (cnt < 0)
- cnt = 0;
- d = c->leb_size / c->max_idx_node_sz;
- return DIV_ROUND_UP(cnt, d);
-}
-
-/**
- * layout_in_gaps - in-the-gaps method of committing TNC.
- * @c: UBIFS file-system description object
- * @cnt: number of dirty znodes to commit.
- *
- * This function lays out new index nodes for dirty znodes using in-the-gaps
- * method of TNC commit.
- *
- * This function returns %0 on success and a negative error code on failure.
- */
-static int layout_in_gaps(struct ubifs_info *c, int cnt)
-{
- int err, leb_needed_cnt, written, *p;
-
- dbg_gc("%d znodes to write", cnt);
-
- c->gap_lebs = kmalloc(sizeof(int) * (c->lst.idx_lebs + 1), GFP_NOFS);
- if (!c->gap_lebs)
- return -ENOMEM;
-
- p = c->gap_lebs;
- do {
- ubifs_assert(p < c->gap_lebs + sizeof(int) * c->lst.idx_lebs);
- written = layout_leb_in_gaps(c, p);
- if (written < 0) {
- err = written;
- if (err != -ENOSPC) {
- kfree(c->gap_lebs);
- c->gap_lebs = NULL;
- return err;
- }
- if (!dbg_force_in_the_gaps_enabled) {
- /*
- * Do not print scary warnings if the debugging
- * option which forces in-the-gaps is enabled.
- */
- ubifs_err("out of space");
- spin_lock(&c->space_lock);
- dbg_dump_budg(c);
- spin_unlock(&c->space_lock);
- dbg_dump_lprops(c);
- }
- /* Try to commit anyway */
- err = 0;
- break;
- }
- p++;
- cnt -= written;
- leb_needed_cnt = get_leb_cnt(c, cnt);
- dbg_gc("%d znodes remaining, need %d LEBs, have %d", cnt,
- leb_needed_cnt, c->ileb_cnt);
- } while (leb_needed_cnt > c->ileb_cnt);
-
- *p = -1;
- return 0;
-}
-
-/**
- * layout_in_empty_space - layout index nodes in empty space.
- * @c: UBIFS file-system description object
- *
- * This function lays out new index nodes for dirty znodes using empty LEBs.
- *
- * This function returns %0 on success and a negative error code on failure.
- */
-static int layout_in_empty_space(struct ubifs_info *c)
-{
- struct ubifs_znode *znode, *cnext, *zp;
- int lnum, offs, len, next_len, buf_len, buf_offs, used, avail;
- int wlen, blen, err;
-
- cnext = c->enext;
- if (!cnext)
- return 0;
-
- lnum = c->ihead_lnum;
- buf_offs = c->ihead_offs;
-
- buf_len = ubifs_idx_node_sz(c, c->fanout);
- buf_len = ALIGN(buf_len, c->min_io_size);
- used = 0;
- avail = buf_len;
-
- /* Ensure there is enough room for first write */
- next_len = ubifs_idx_node_sz(c, cnext->child_cnt);
- if (buf_offs + next_len > c->leb_size)
- lnum = -1;
-
- while (1) {
- znode = cnext;
-
- len = ubifs_idx_node_sz(c, znode->child_cnt);
-
- /* Determine the index node position */
- if (lnum == -1) {
- if (c->ileb_nxt >= c->ileb_cnt) {
- ubifs_err("out of space");
- return -ENOSPC;
- }
- lnum = c->ilebs[c->ileb_nxt++];
- buf_offs = 0;
- used = 0;
- avail = buf_len;
- }
-
- offs = buf_offs + used;
-
-#ifdef CONFIG_UBIFS_FS_DEBUG
- znode->lnum = lnum;
- znode->offs = offs;
- znode->len = len;
-#endif
-
- /* Update the parent */
- zp = znode->parent;
- if (zp) {
- struct ubifs_zbranch *zbr;
- int i;
-
- i = znode->iip;
- zbr = &zp->zbranch[i];
- zbr->lnum = lnum;
- zbr->offs = offs;
- zbr->len = len;
- } else {
- c->zroot.lnum = lnum;
- c->zroot.offs = offs;
- c->zroot.len = len;
- }
- c->calc_idx_sz += ALIGN(len, 8);
-
- /*
- * Once lprops is updated, we can decrease the dirty znode count
- * but it is easier to just do it here.
- */
- atomic_long_dec(&c->dirty_zn_cnt);
-
- /*
- * Calculate the next index node length to see if there is
- * enough room for it
- */
- cnext = znode->cnext;
- if (cnext == c->cnext)
- next_len = 0;
- else
- next_len = ubifs_idx_node_sz(c, cnext->child_cnt);
-
- if (c->min_io_size == 1) {
- buf_offs += ALIGN(len, 8);
- if (next_len) {
- if (buf_offs + next_len <= c->leb_size)
- continue;
- err = ubifs_update_one_lp(c, lnum, 0,
- c->leb_size - buf_offs, 0, 0);
- if (err)
- return err;
- lnum = -1;
- continue;
- }
- err = ubifs_update_one_lp(c, lnum,
- c->leb_size - buf_offs, 0, 0, 0);
- if (err)
- return err;
- break;
- }
-
- /* Update buffer positions */
- wlen = used + len;
- used += ALIGN(len, 8);
- avail -= ALIGN(len, 8);
-
- if (next_len != 0 &&
- buf_offs + used + next_len <= c->leb_size &&
- avail > 0)
- continue;
-
- if (avail <= 0 && next_len &&
- buf_offs + used + next_len <= c->leb_size)
- blen = buf_len;
- else
- blen = ALIGN(wlen, c->min_io_size);
-
- /* The buffer is full or there are no more znodes to do */
- buf_offs += blen;
- if (next_len) {
- if (buf_offs + next_len > c->leb_size) {
- err = ubifs_update_one_lp(c, lnum,
- c->leb_size - buf_offs, blen - used,
- 0, 0);
- if (err)
- return err;
- lnum = -1;
- }
- used -= blen;
- if (used < 0)
- used = 0;
- avail = buf_len - used;
- continue;
- }
- err = ubifs_update_one_lp(c, lnum, c->leb_size - buf_offs,
- blen - used, 0, 0);
- if (err)
- return err;
- break;
- }
-
-#ifdef CONFIG_UBIFS_FS_DEBUG
- c->new_ihead_lnum = lnum;
- c->new_ihead_offs = buf_offs;
-#endif
-
- return 0;
-}
-
-/**
- * layout_commit - determine positions of index nodes to commit.
- * @c: UBIFS file-system description object
- * @no_space: indicates that insufficient empty LEBs were allocated
- * @cnt: number of znodes to commit
- *
- * Calculate and update the positions of index nodes to commit. If there were
- * an insufficient number of empty LEBs allocated, then index nodes are placed
- * into the gaps created by obsolete index nodes in non-empty index LEBs. For
- * this purpose, an obsolete index node is one that was not in the index as at
- * the end of the last commit. To write "in-the-gaps" requires that those index
- * LEBs are updated atomically in-place.
- */
-static int layout_commit(struct ubifs_info *c, int no_space, int cnt)
-{
- int err;
-
- if (no_space) {
- err = layout_in_gaps(c, cnt);
- if (err)
- return err;
- }
- err = layout_in_empty_space(c);
- return err;
-}
-
-/**
- * find_first_dirty - find first dirty znode.
- * @znode: znode to begin searching from
- */
-static struct ubifs_znode *find_first_dirty(struct ubifs_znode *znode)
-{
- int i, cont;
-
- if (!znode)
- return NULL;
-
- while (1) {
- if (znode->level == 0) {
- if (ubifs_zn_dirty(znode))
- return znode;
- return NULL;
- }
- cont = 0;
- for (i = 0; i < znode->child_cnt; i++) {
- struct ubifs_zbranch *zbr = &znode->zbranch[i];
-
- if (zbr->znode && ubifs_zn_dirty(zbr->znode)) {
- znode = zbr->znode;
- cont = 1;
- break;
- }
- }
- if (!cont) {
- if (ubifs_zn_dirty(znode))
- return znode;
- return NULL;
- }
- }
-}
-
-/**
- * find_next_dirty - find next dirty znode.
- * @znode: znode to begin searching from
- */
-static struct ubifs_znode *find_next_dirty(struct ubifs_znode *znode)
-{
- int n = znode->iip + 1;
-
- znode = znode->parent;
- if (!znode)
- return NULL;
- for (; n < znode->child_cnt; n++) {
- struct ubifs_zbranch *zbr = &znode->zbranch[n];
-
- if (zbr->znode && ubifs_zn_dirty(zbr->znode))
- return find_first_dirty(zbr->znode);
- }
- return znode;
-}
-
-/**
- * get_znodes_to_commit - create list of dirty znodes to commit.
- * @c: UBIFS file-system description object
- *
- * This function returns the number of znodes to commit.
- */
-static int get_znodes_to_commit(struct ubifs_info *c)
-{
- struct ubifs_znode *znode, *cnext;
- int cnt = 0;
-
- c->cnext = find_first_dirty(c->zroot.znode);
- znode = c->enext = c->cnext;
- if (!znode) {
- dbg_cmt("no znodes to commit");
- return 0;
- }
- cnt += 1;
- while (1) {
- ubifs_assert(!test_bit(COW_ZNODE, &znode->flags));
- __set_bit(COW_ZNODE, &znode->flags);
- znode->alt = 0;
- cnext = find_next_dirty(znode);
- if (!cnext) {
- znode->cnext = c->cnext;
- break;
- }
- znode->cnext = cnext;
- znode = cnext;
- cnt += 1;
- }
- dbg_cmt("committing %d znodes", cnt);
- ubifs_assert(cnt == atomic_long_read(&c->dirty_zn_cnt));
- return cnt;
-}
-
-/**
- * alloc_idx_lebs - allocate empty LEBs to be used to commit.
- * @c: UBIFS file-system description object
- * @cnt: number of znodes to commit
- *
- * This function returns %-ENOSPC if it cannot allocate a sufficient number of
- * empty LEBs. %0 is returned on success, otherwise a negative error code
- * is returned.
- */
-static int alloc_idx_lebs(struct ubifs_info *c, int cnt)
-{
- int i, leb_cnt, lnum;
-
- c->ileb_cnt = 0;
- c->ileb_nxt = 0;
- leb_cnt = get_leb_cnt(c, cnt);
- dbg_cmt("need about %d empty LEBS for TNC commit", leb_cnt);
- if (!leb_cnt)
- return 0;
- c->ilebs = kmalloc(leb_cnt * sizeof(int), GFP_NOFS);
- if (!c->ilebs)
- return -ENOMEM;
- for (i = 0; i < leb_cnt; i++) {
- lnum = ubifs_find_free_leb_for_idx(c);
- if (lnum < 0)
- return lnum;
- c->ilebs[c->ileb_cnt++] = lnum;
- dbg_cmt("LEB %d", lnum);
- }
- if (dbg_force_in_the_gaps())
- return -ENOSPC;
- return 0;
-}
-
-/**
- * free_unused_idx_lebs - free unused LEBs that were allocated for the commit.
- * @c: UBIFS file-system description object
- *
- * It is possible that we allocate more empty LEBs for the commit than we need.
- * This functions frees the surplus.
- *
- * This function returns %0 on success and a negative error code on failure.
- */
-static int free_unused_idx_lebs(struct ubifs_info *c)
-{
- int i, err = 0, lnum, er;
-
- for (i = c->ileb_nxt; i < c->ileb_cnt; i++) {
- lnum = c->ilebs[i];
- dbg_cmt("LEB %d", lnum);
- er = ubifs_change_one_lp(c, lnum, LPROPS_NC, LPROPS_NC, 0,
- LPROPS_INDEX | LPROPS_TAKEN, 0);
- if (!err)
- err = er;
- }
- return err;
-}
-
-/**
- * free_idx_lebs - free unused LEBs after commit end.
- * @c: UBIFS file-system description object
- *
- * This function returns %0 on success and a negative error code on failure.
- */
-static int free_idx_lebs(struct ubifs_info *c)
-{
- int err;
-
- err = free_unused_idx_lebs(c);
- kfree(c->ilebs);
- c->ilebs = NULL;
- return err;
-}
-
-/**
- * ubifs_tnc_start_commit - start TNC commit.
- * @c: UBIFS file-system description object
- * @zroot: new index root position is returned here
- *
- * This function prepares the list of indexing nodes to commit and lays out
- * their positions on flash. If there is not enough free space it uses the
- * in-gap commit method. Returns zero in case of success and a negative error
- * code in case of failure.
- */
-int ubifs_tnc_start_commit(struct ubifs_info *c, struct ubifs_zbranch *zroot)
-{
- int err = 0, cnt;
-
- mutex_lock(&c->tnc_mutex);
- err = dbg_check_tnc(c, 1);
- if (err)
- goto out;
- cnt = get_znodes_to_commit(c);
- if (cnt != 0) {
- int no_space = 0;
-
- err = alloc_idx_lebs(c, cnt);
- if (err == -ENOSPC)
- no_space = 1;
- else if (err)
- goto out_free;
- err = layout_commit(c, no_space, cnt);
- if (err)
- goto out_free;
- ubifs_assert(atomic_long_read(&c->dirty_zn_cnt) == 0);
- err = free_unused_idx_lebs(c);
- if (err)
- goto out;
- }
- destroy_old_idx(c);
- memcpy(zroot, &c->zroot, sizeof(struct ubifs_zbranch));
-
- err = ubifs_save_dirty_idx_lnums(c);
- if (err)
- goto out;
-
- spin_lock(&c->space_lock);
- /*
- * Although we have not finished committing yet, update size of the
- * committed index ('c->old_idx_sz') and zero out the index growth
- * budget. It is OK to do this now, because we've reserved all the
- * space which is needed to commit the index, and it is save for the
- * budgeting subsystem to assume the index is already committed,
- * even though it is not.
- */
- c->old_idx_sz = c->calc_idx_sz;
- c->budg_uncommitted_idx = 0;
- spin_unlock(&c->space_lock);
- mutex_unlock(&c->tnc_mutex);
-
- dbg_cmt("number of index LEBs %d", c->lst.idx_lebs);
- dbg_cmt("size of index %llu", c->calc_idx_sz);
- return err;
-
-out_free:
- free_idx_lebs(c);
-out:
- mutex_unlock(&c->tnc_mutex);
- return err;
-}
-
-/**
- * write_index - write index nodes.
- * @c: UBIFS file-system description object
- *
- * This function writes the index nodes whose positions were laid out in the
- * layout_in_empty_space function.
- */
-static int write_index(struct ubifs_info *c)
-{
- struct ubifs_idx_node *idx;
- struct ubifs_znode *znode, *cnext;
- int i, lnum, offs, len, next_len, buf_len, buf_offs, used;
- int avail, wlen, err, lnum_pos = 0;
-
- cnext = c->enext;
- if (!cnext)
- return 0;
-
- /*
- * Always write index nodes to the index head so that index nodes and
- * other types of nodes are never mixed in the same erase block.
- */
- lnum = c->ihead_lnum;
- buf_offs = c->ihead_offs;
-
- /* Allocate commit buffer */
- buf_len = ALIGN(c->max_idx_node_sz, c->min_io_size);
- used = 0;
- avail = buf_len;
-
- /* Ensure there is enough room for first write */
- next_len = ubifs_idx_node_sz(c, cnext->child_cnt);
- if (buf_offs + next_len > c->leb_size) {
- err = ubifs_update_one_lp(c, lnum, LPROPS_NC, 0, 0,
- LPROPS_TAKEN);
- if (err)
- return err;
- lnum = -1;
- }
-
- while (1) {
- cond_resched();
-
- znode = cnext;
- idx = c->cbuf + used;
-
- /* Make index node */
- idx->ch.node_type = UBIFS_IDX_NODE;
- idx->child_cnt = cpu_to_le16(znode->child_cnt);
- idx->level = cpu_to_le16(znode->level);
- for (i = 0; i < znode->child_cnt; i++) {
- struct ubifs_branch *br = ubifs_idx_branch(c, idx, i);
- struct ubifs_zbranch *zbr = &znode->zbranch[i];
-
- key_write_idx(c, &zbr->key, &br->key);
- br->lnum = cpu_to_le32(zbr->lnum);
- br->offs = cpu_to_le32(zbr->offs);
- br->len = cpu_to_le32(zbr->len);
- if (!zbr->lnum || !zbr->len) {
- ubifs_err("bad ref in znode");
- dbg_dump_znode(c, znode);
- if (zbr->znode)
- dbg_dump_znode(c, zbr->znode);
- }
- }
- len = ubifs_idx_node_sz(c, znode->child_cnt);
- ubifs_prepare_node(c, idx, len, 0);
-
- /* Determine the index node position */
- if (lnum == -1) {
- lnum = c->ilebs[lnum_pos++];
- buf_offs = 0;
- used = 0;
- avail = buf_len;
- }
- offs = buf_offs + used;
-
-#ifdef CONFIG_UBIFS_FS_DEBUG
- if (lnum != znode->lnum || offs != znode->offs ||
- len != znode->len) {
- ubifs_err("inconsistent znode posn");
- return -EINVAL;
- }
-#endif
-
- /* Grab some stuff from znode while we still can */
- cnext = znode->cnext;
-
- ubifs_assert(ubifs_zn_dirty(znode));
- ubifs_assert(test_bit(COW_ZNODE, &znode->flags));
-
- /*
- * It is important that other threads should see %DIRTY_ZNODE
- * flag cleared before %COW_ZNODE. Specifically, it matters in
- * the 'dirty_cow_znode()' function. This is the reason for the
- * first barrier. Also, we want the bit changes to be seen to
- * other threads ASAP, to avoid unnecesarry copying, which is
- * the reason for the second barrier.
- */
- clear_bit(DIRTY_ZNODE, &znode->flags);
- smp_mb__before_clear_bit();
- clear_bit(COW_ZNODE, &znode->flags);
- smp_mb__after_clear_bit();
-
- /* Do not access znode from this point on */
-
- /* Update buffer positions */
- wlen = used + len;
- used += ALIGN(len, 8);
- avail -= ALIGN(len, 8);
-
- /*
- * Calculate the next index node length to see if there is
- * enough room for it
- */
- if (cnext == c->cnext)
- next_len = 0;
- else
- next_len = ubifs_idx_node_sz(c, cnext->child_cnt);
-
- if (c->min_io_size == 1) {
- /*
- * Write the prepared index node immediately if there is
- * no minimum IO size
- */
- err = ubifs_leb_write(c, lnum, c->cbuf, buf_offs,
- wlen, UBI_SHORTTERM);
- if (err)
- return err;
- buf_offs += ALIGN(wlen, 8);
- if (next_len) {
- used = 0;
- avail = buf_len;
- if (buf_offs + next_len > c->leb_size) {
- err = ubifs_update_one_lp(c, lnum,
- LPROPS_NC, 0, 0, LPROPS_TAKEN);
- if (err)
- return err;
- lnum = -1;
- }
- continue;
- }
- } else {
- int blen, nxt_offs = buf_offs + used + next_len;
-
- if (next_len && nxt_offs <= c->leb_size) {
- if (avail > 0)
- continue;
- else
- blen = buf_len;
- } else {
- wlen = ALIGN(wlen, 8);
- blen = ALIGN(wlen, c->min_io_size);
- ubifs_pad(c, c->cbuf + wlen, blen - wlen);
- }
- /*
- * The buffer is full or there are no more znodes
- * to do
- */
- err = ubifs_leb_write(c, lnum, c->cbuf, buf_offs,
- blen, UBI_SHORTTERM);
- if (err)
- return err;
- buf_offs += blen;
- if (next_len) {
- if (nxt_offs > c->leb_size) {
- err = ubifs_update_one_lp(c, lnum,
- LPROPS_NC, 0, 0, LPROPS_TAKEN);
- if (err)
- return err;
- lnum = -1;
- }
- used -= blen;
- if (used < 0)
- used = 0;
- avail = buf_len - used;
- memmove(c->cbuf, c->cbuf + blen, used);
- continue;
- }
- }
- break;
- }
-
-#ifdef CONFIG_UBIFS_FS_DEBUG
- if (lnum != c->new_ihead_lnum || buf_offs != c->new_ihead_offs) {
- ubifs_err("inconsistent ihead");
- return -EINVAL;
- }
-#endif
-
- c->ihead_lnum = lnum;
- c->ihead_offs = buf_offs;
-
- return 0;
-}
-
-/**
- * free_obsolete_znodes - free obsolete znodes.
- * @c: UBIFS file-system description object
- *
- * At the end of commit end, obsolete znodes are freed.
- */
-static void free_obsolete_znodes(struct ubifs_info *c)
-{
- struct ubifs_znode *znode, *cnext;
-
- cnext = c->cnext;
- do {
- znode = cnext;
- cnext = znode->cnext;
- if (test_bit(OBSOLETE_ZNODE, &znode->flags))
- kfree(znode);
- else {
- znode->cnext = NULL;
- atomic_long_inc(&c->clean_zn_cnt);
- atomic_long_inc(&ubifs_clean_zn_cnt);
- }
- } while (cnext != c->cnext);
-}
-
-/**
- * return_gap_lebs - return LEBs used by the in-gap commit method.
- * @c: UBIFS file-system description object
- *
- * This function clears the "taken" flag for the LEBs which were used by the
- * "commit in-the-gaps" method.
- */
-static int return_gap_lebs(struct ubifs_info *c)
-{
- int *p, err;
-
- if (!c->gap_lebs)
- return 0;
-
- dbg_cmt("");
- for (p = c->gap_lebs; *p != -1; p++) {
- err = ubifs_change_one_lp(c, *p, LPROPS_NC, LPROPS_NC, 0,
- LPROPS_TAKEN, 0);
- if (err)
- return err;
- }
-
- kfree(c->gap_lebs);
- c->gap_lebs = NULL;
- return 0;
-}
-
-/**
- * ubifs_tnc_end_commit - update the TNC for commit end.
- * @c: UBIFS file-system description object
- *
- * Write the dirty znodes.
- */
-int ubifs_tnc_end_commit(struct ubifs_info *c)
-{
- int err;
-
- if (!c->cnext)
- return 0;
-
- err = return_gap_lebs(c);
- if (err)
- return err;
-
- err = write_index(c);
- if (err)
- return err;
-
- mutex_lock(&c->tnc_mutex);
-
- dbg_cmt("TNC height is %d", c->zroot.znode->level + 1);
-
- free_obsolete_znodes(c);
-
- c->cnext = NULL;
- kfree(c->ilebs);
- c->ilebs = NULL;
-
- mutex_unlock(&c->tnc_mutex);
-
- return 0;
-}
--
1.6.2.3
2
1
From: Adrian Hunter <adrian.hunter(a)nokia.com>
UBIFS did not recovery in a situation in which it could
have. The relevant function assumed there could not be
more nodes in an eraseblock after a corrupted node, but
in fact the last (NAND) page written might contain anything.
The correct approach is to check for empty space (0xFF bytes)
from then on.
Signed-off-by: Adrian Hunter <adrian.hunter(a)nokia.com>
Signed-off-by: Stefan Roese <sr(a)denx.de>
---
fs/ubifs/recovery.c | 70 ++++++++++++++++----------------------------------
1 files changed, 23 insertions(+), 47 deletions(-)
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
index fe3b364..7444650 100644
--- a/fs/ubifs/recovery.c
+++ b/fs/ubifs/recovery.c
@@ -418,59 +418,35 @@ static void clean_buf(const struct ubifs_info *c, void **buf, int lnum,
* @lnum: LEB number of the LEB from which @buf was read
* @offs: offset from which @buf was read
*
- * This function scans @buf for more nodes and returns %0 is a node is found and
- * %1 if no more nodes are found.
+ * This function ensures that the corrupted node at @offs is the last thing
+ * written to a LEB. This function returns %1 if more data is not found and
+ * %0 if more data is found.
*/
static int no_more_nodes(const struct ubifs_info *c, void *buf, int len,
int lnum, int offs)
{
- int skip, next_offs = 0;
+ struct ubifs_ch *ch = buf;
+ int skip, dlen = le32_to_cpu(ch->len);
- if (len > UBIFS_DATA_NODE_SZ) {
- struct ubifs_ch *ch = buf;
- int dlen = le32_to_cpu(ch->len);
-
- if (ch->node_type == UBIFS_DATA_NODE && dlen >= UBIFS_CH_SZ &&
- dlen <= UBIFS_MAX_DATA_NODE_SZ)
- /* The corrupt node looks like a data node */
- next_offs = ALIGN(offs + dlen, 8);
- }
-
- if (c->min_io_size == 1)
- skip = 8;
- else
- skip = ALIGN(offs + 1, c->min_io_size) - offs;
-
- offs += skip;
- buf += skip;
- len -= skip;
- while (len > 8) {
- struct ubifs_ch *ch = buf;
- uint32_t magic = le32_to_cpu(ch->magic);
- int ret;
-
- if (magic == UBIFS_NODE_MAGIC) {
- ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1);
- if (ret == SCANNED_A_NODE || ret > 0) {
- /*
- * There is a small chance this is just data in
- * a data node, so check that possibility. e.g.
- * this is part of a file that itself contains
- * a UBIFS image.
- */
- if (next_offs && offs + le32_to_cpu(ch->len) <=
- next_offs)
- continue;
- dbg_rcvry("unexpected node at %d:%d", lnum,
- offs);
- return 0;
- }
- }
- offs += 8;
- buf += 8;
- len -= 8;
+ /* Check for empty space after the corrupt node's common header */
+ skip = ALIGN(offs + UBIFS_CH_SZ, c->min_io_size) - offs;
+ if (is_empty(buf + skip, len - skip))
+ return 1;
+ /*
+ * The area after the common header size is not empty, so the common
+ * header must be intact. Check it.
+ */
+ if (ubifs_check_node(c, buf, lnum, offs, 1, 0) != -EUCLEAN) {
+ dbg_rcvry("unexpected bad common header at %d:%d", lnum, offs);
+ return 0;
}
- return 1;
+ /* Now we know the corrupt node's length we can skip over it */
+ skip = ALIGN(offs + dlen, c->min_io_size) - offs;
+ /* After which there should be empty space */
+ if (is_empty(buf + skip, len - skip))
+ return 1;
+ dbg_rcvry("unexpected data at %d:%d", lnum, offs + skip);
+ return 0;
}
/**
--
1.6.2.3
2
1
From: Gao Guanhua <B22826(a)freescale.com>
The filelen should be signed type, not unsigned type.
otherwise, The condition as below never take.
if (filelen < 0)
Signed-off-by: Gao Guanhua <B22826(a)freescale.com>
Signed-off-by: Dave Liu <daveliu(a)freescale.com>
---
common/cmd_ext2.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c
index c2dcc64..8e316c7 100644
--- a/common/cmd_ext2.c
+++ b/common/cmd_ext2.c
@@ -129,7 +129,8 @@ int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
char *filename = NULL;
char *ep;
int dev, part = 1;
- ulong addr = 0, part_length, filelen;
+ ulong addr = 0, part_length;
+ int filelen;
disk_partition_t info;
block_dev_desc_t *dev_desc = NULL;
char buf [12];
--
1.5.4
2
1
From: David Brownell <dbrownell(a)users.sourceforge.net>
Chips without the EMAC controller won't need the utilities
it uses to read an Ethernet address from EEPROM; so don't
include them needlessly.
Use is_valid_ether() to validate the address from EEPROM.
All-zero addresses aren't the only invalid addresses.
A fully erased EEPROM returns all-ones, also invalid...
Switch those Ethernet utilities to use "%pM" for printing
MAC addresses; and not say ROM when they mean EEPROM.
Signed-off-by: David Brownell <dbrownell(a)users.sourceforge.net>
--- a/board/davinci/common/misc.c
+++ b/board/davinci/common/misc.c
@@ -25,6 +25,7 @@
#include <common.h>
#include <i2c.h>
+#include <net.h>
#include <asm/arch/hardware.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -49,6 +50,8 @@ void dv_display_clk_infos(void)
((REG(PLL2_DIV2) & 0x1f) + 1) / 2);
}
+#ifdef CONFIG_DRIVER_TI_EMAC
+
/* Read ethernet MAC address from EEPROM for DVEVM compatible boards.
* Returns 1 if found, 0 otherwise.
*/
@@ -60,8 +63,8 @@ int dvevm_read_mac_address(uint8_t *buf)
(uint8_t *) &buf[0], 6))
goto i2cerr;
- /* Check that MAC address is not null. */
- if (memcmp(buf, "\0\0\0\0\0\0", 6) == 0)
+ /* Check that MAC address is valid. */
+ if (!is_valid_ether_addr(buf))
goto err;
return 1; /* Found */
@@ -75,11 +78,11 @@ err:
}
/* If there is a MAC address in the environment, and if it is not identical to
- * the MAC address in the ROM, then a warning is printed and the MAC address
+ * the MAC address in the EEPROM, then a warning is printed and the MAC address
* from the environment is used.
*
* If there is no MAC address in the environment, then it will be initialized
- * (silently) from the value in the ROM.
+ * (silently) from the value in the EEPROM.
*/
void dv_configure_mac_address(uint8_t *rom_enetaddr)
{
@@ -96,31 +99,24 @@ void dv_configure_mac_address(uint8_t *r
tmp = (*end) ? end+1 : end;
}
- /* Check if ROM and U-Boot environment MAC addresses match. */
+ /* Check if EEPROM and U-Boot environment MAC addresses match. */
if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6) != 0 &&
memcmp(env_enetaddr, rom_enetaddr, 6) != 0) {
printf("Warning: MAC addresses don't match:\n");
- printf(" ROM MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n",
- rom_enetaddr[0], rom_enetaddr[1],
- rom_enetaddr[2], rom_enetaddr[3],
- rom_enetaddr[4], rom_enetaddr[5]);
- printf(" \"ethaddr\" value: %02X:%02X:%02X:%02X:%02X:%02X\n",
- env_enetaddr[0], env_enetaddr[1],
- env_enetaddr[2], env_enetaddr[3],
- env_enetaddr[4], env_enetaddr[5]) ;
+ printf(" EEPROM MAC address: %pM\n", rom_enetaddr);
+ printf(" \"ethaddr\" value: %pM\n", env_enetaddr) ;
debug("### Using MAC address from environment\n");
}
if (!tmp) {
char ethaddr[20];
/* There is no MAC address in the environment, so we initialize
- * it from the value in the ROM. */
- sprintf(ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X",
- rom_enetaddr[0], rom_enetaddr[1],
- rom_enetaddr[2], rom_enetaddr[3],
- rom_enetaddr[4], rom_enetaddr[5]) ;
- debug("### Setting environment from ROM MAC address = \"%s\"\n",
+ * it from the value in the EEPROM. */
+ sprintf(ethaddr, "%pM", rom_enetaddr) ;
+ debug("### Setting environment from EEPROM MAC address = \"%s\"\n",
ethaddr);
setenv("ethaddr", ethaddr);
}
}
+
+#endif /* DAVINCI_EMAC */
4
3
From: David Brownell <dbrownell(a)users.sourceforge.net>
Minor cleanup to clock-related defines for DaVinci DM6446 boards:
- CONFIG_SYS_CLK_FREQ is unused; remove it.
- CONFIG_SYS_NS16550_CLK must be the same as CONFIG_SYS_HZ_CLOCK
On DM6446 both of those peripheral clocks actually come from the
same source, the primary oscillator. Having them use the same
symbol avoids bugs in the clone'n'modify development cycle.
Signed-off-by: David Brownell <dbrownell(a)users.sourceforge.net>
---
include/configs/davinci_dvevm.h | 3 +--
include/configs/davinci_schmoogie.h | 3 +--
include/configs/davinci_sffsdr.h | 3 +--
include/configs/davinci_sonata.h | 3 +--
4 files changed, 4 insertions(+), 8 deletions(-)
--- a/include/configs/davinci_dvevm.h
+++ b/include/configs/davinci_dvevm.h
@@ -56,7 +56,6 @@
/* SoC Configuration */
/*===================*/
#define CONFIG_ARM926EJS /* arm926ejs CPU core */
-#define CONFIG_SYS_CLK_FREQ 297000000 /* Arm Clock frequency */
#define CONFIG_SYS_TIMERBASE 0x01c21400 /* use timer 0 */
#define CONFIG_SYS_HZ_CLOCK 27000000 /* Timer Input clock freq */
#define CONFIG_SYS_HZ 1000
@@ -87,7 +86,7 @@
#define CONFIG_SYS_NS16550_SERIAL
#define CONFIG_SYS_NS16550_REG_SIZE -4 /* NS16550 register size, byteorder */
#define CONFIG_SYS_NS16550_COM1 0x01c20000 /* Base address of UART0 */
-#define CONFIG_SYS_NS16550_CLK 27000000 /* Input clock to NS16550 */
+#define CONFIG_SYS_NS16550_CLK CONFIG_SYS_HZ_CLOCK /* Input clock to NS16550 */
#define CONFIG_CONS_INDEX 1 /* use UART0 for console */
#define CONFIG_BAUDRATE 115200 /* Default baud rate */
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
--- a/include/configs/davinci_schmoogie.h
+++ b/include/configs/davinci_schmoogie.h
@@ -31,7 +31,6 @@
/* SoC Configuration */
/*===================*/
#define CONFIG_ARM926EJS /* arm926ejs CPU core */
-#define CONFIG_SYS_CLK_FREQ 297000000 /* Arm Clock frequency */
#define CONFIG_SYS_TIMERBASE 0x01c21400 /* use timer 0 */
#define CONFIG_SYS_HZ_CLOCK 27000000 /* Timer Input clock freq */
#define CONFIG_SYS_HZ 1000
@@ -54,7 +53,7 @@
#define CONFIG_SYS_NS16550_SERIAL
#define CONFIG_SYS_NS16550_REG_SIZE -4 /* NS16550 register size, byteorder */
#define CONFIG_SYS_NS16550_COM1 0x01c20000 /* Base address of UART0 */
-#define CONFIG_SYS_NS16550_CLK 27000000 /* Input clock to NS16550 */
+#define CONFIG_SYS_NS16550_CLK CONFIG_SYS_HZ_CLOCK /* Input clock to NS16550 */
#define CONFIG_CONS_INDEX 1 /* use UART0 for console */
#define CONFIG_BAUDRATE 115200 /* Default baud rate */
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
--- a/include/configs/davinci_sffsdr.h
+++ b/include/configs/davinci_sffsdr.h
@@ -32,7 +32,6 @@
* powering ON the DSP. */
/* SoC Configuration */
#define CONFIG_ARM926EJS /* arm926ejs CPU core */
-#define CONFIG_SYS_CLK_FREQ 297000000 /* Arm Clock frequency */
#define CONFIG_SYS_TIMERBASE 0x01c21400 /* use timer 0 */
#define CONFIG_SYS_HZ_CLOCK 27000000 /* Timer Input clock freq */
#define CONFIG_SYS_HZ 1000
@@ -56,7 +55,7 @@
#define CONFIG_SYS_NS16550_SERIAL
#define CONFIG_SYS_NS16550_REG_SIZE -4 /* NS16550 register size, byteorder */
#define CONFIG_SYS_NS16550_COM1 0x01c20000 /* Base address of UART0 */
-#define CONFIG_SYS_NS16550_CLK 27000000 /* Input clock to NS16550 */
+#define CONFIG_SYS_NS16550_CLK CONFIG_SYS_HZ_CLOCK /* Input clock to NS16550 */
#define CONFIG_CONS_INDEX 1 /* use UART0 for console */
#define CONFIG_BAUDRATE 115200 /* Default baud rate */
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
--- a/include/configs/davinci_sonata.h
+++ b/include/configs/davinci_sonata.h
@@ -56,7 +56,6 @@
/* SoC Configuration */
/*===================*/
#define CONFIG_ARM926EJS /* arm926ejs CPU core */
-#define CONFIG_SYS_CLK_FREQ 297000000 /* Arm Clock frequency */
#define CONFIG_SYS_TIMERBASE 0x01c21400 /* use timer 0 */
#define CONFIG_SYS_HZ_CLOCK 27000000 /* Timer Input clock freq */
#define CONFIG_SYS_HZ 1000
@@ -87,7 +86,7 @@
#define CONFIG_SYS_NS16550_SERIAL
#define CONFIG_SYS_NS16550_REG_SIZE -4 /* NS16550 register size, byteorder */
#define CONFIG_SYS_NS16550_COM1 0x01c20000 /* Base address of UART0 */
-#define CONFIG_SYS_NS16550_CLK 27000000 /* Input clock to NS16550 */
+#define CONFIG_SYS_NS16550_CLK CONFIG_SYS_HZ_CLOCK /* Input clock to NS16550 */
#define CONFIG_CONS_INDEX 1 /* use UART0 for console */
#define CONFIG_BAUDRATE 115200 /* Default baud rate */
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
3
2
From: David Brownell <dbrownell(a)users.sourceforge.net>
Make the U-Boot dm9000 driver read addresses from EEPROM just
like Linux does ... read six bytes, instead of reading twelve
bytes then discarding every one.
Using the right Ethernet address is a big win.
Signed-off-by: David Brownell <dbrownell(a)users.sourceforge.net>
---
drivers/net/dm9000x.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -113,7 +113,7 @@ void eth_halt(void);
static int dm9000_probe(void);
static u16 phy_read(int);
static void phy_write(int, u16);
-u16 read_srom_word(int);
+static void read_srom_word(int, u8 *);
static u8 DM9000_ior(int);
static void DM9000_iow(int reg, u8 value);
@@ -348,8 +348,8 @@ eth_init(bd_t * bd)
/* Set Node address */
if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
#if !defined(CONFIG_AT91SAM9261EK)
- for (i = 0; i < 6; i++)
- enetaddr[i] = read_srom_word(i);
+ for (i = 0; i < 3; i++)
+ read_srom_word(i, enetaddr + 2 * i);
eth_setenv_enetaddr("ethaddr", enetaddr);
#endif
}
@@ -541,14 +541,14 @@ eth_rx(void)
/*
Read a word data from SROM
*/
-u16
-read_srom_word(int offset)
+static void read_srom_word(int offset, u8 *to)
{
DM9000_iow(DM9000_EPAR, offset);
DM9000_iow(DM9000_EPCR, 0x4);
udelay(8000);
DM9000_iow(DM9000_EPCR, 0x0);
- return (DM9000_ior(DM9000_EPDRL) + (DM9000_ior(DM9000_EPDRH) << 8));
+ to[0] = DM9000_ior(DM9000_EPDRL);
+ to[1] = DM9000_ior(DM9000_EPDRH);
}
void
4
7