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
November 2008
- 168 participants
- 480 discussions

06 Dec '08
Use the GNU 'date' command to auto-generate a new U-Boot
timestamp on every compile.
Signed-off-by: Peter Tyser <ptyser(a)xes-inc.com>
---
Changes since v1:
* Split up U_BOOT_DATE define (date and time) into
U_BOOT_DATE (day, month, year) and U_BOOT_TIME (time of day)
defines
* Updated all architetures/boards
Changes since v2:
* Placed U_BOOT_DATE and U_BOOT_TIME defines in
timestamp_autogenerated.h.
* Added include/timestamp.h
Changes since v3:
* rebased on TOT
* removed 2 whitespace violations
Changes since v4:
* Simplified timestamp_autogenerated.h creation
* Made timestamp.h and version.h dependent on VIDEO_INFO for
cpu/mpc8xx/video.c
Makefile | 17 +++++++++++------
board/bmw/bmw.c | 4 ++--
board/eXalion/eXalion.c | 3 ++-
board/lwmon/lwmon.c | 3 ++-
board/mousse/mousse.c | 3 ++-
board/netstar/eeprom.c | 3 ++-
board/sandburst/karef/karef.c | 6 ++++--
board/sandburst/metrobox/metrobox.c | 6 ++++--
board/tqc/tqm8xx/tqm8xx.c | 3 ++-
board/trab/trab_fkt.c | 3 ++-
board/voiceblue/eeprom.c | 3 ++-
cpu/74xx_7xx/start.S | 3 ++-
cpu/leon2/start.S | 3 ++-
cpu/leon3/start.S | 3 ++-
cpu/mcf5227x/start.S | 3 ++-
cpu/mcf523x/start.S | 3 ++-
cpu/mcf52x2/start.S | 3 ++-
cpu/mcf532x/start.S | 3 ++-
cpu/mcf5445x/start.S | 3 ++-
cpu/mcf547x_8x/start.S | 3 ++-
cpu/mpc512x/start.S | 3 ++-
cpu/mpc5xx/start.S | 3 ++-
cpu/mpc5xxx/start.S | 3 ++-
cpu/mpc8220/start.S | 3 ++-
cpu/mpc824x/start.S | 3 ++-
cpu/mpc8260/start.S | 3 ++-
cpu/mpc83xx/start.S | 3 ++-
cpu/mpc85xx/start.S | 3 ++-
cpu/mpc86xx/start.S | 3 ++-
cpu/mpc8xx/start.S | 3 ++-
cpu/mpc8xx/video.c | 6 +++++-
cpu/nios/start.S | 3 ++-
cpu/nios2/start.S | 3 ++-
cpu/ppc4xx/start.S | 3 ++-
include/.gitignore | 1 +
include/configs/NETPHONE.h | 2 +-
include/configs/NETTA.h | 2 +-
include/configs/NETTA2.h | 2 +-
include/timestamp.h | 30 ++++++++++++++++++++++++++++++
lib_arm/board.c | 3 ++-
lib_avr32/board.c | 3 ++-
lib_blackfin/board.c | 3 ++-
lib_i386/board.c | 3 ++-
lib_microblaze/board.c | 3 ++-
lib_mips/board.c | 3 ++-
lib_sh/board.c | 3 ++-
net/net.c | 3 +++
47 files changed, 135 insertions(+), 52 deletions(-)
create mode 100644 include/timestamp.h
diff --git a/Makefile b/Makefile
index d6abb4d..f999a21 100644
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,7 @@ U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
else
U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)
endif
+TIMESTAMP_FILE = $(obj)include/timestamp_autogenerated.h
VERSION_FILE = $(obj)include/version_autogenerated.h
HOSTARCH := $(shell uname -m | \
@@ -259,7 +260,7 @@ LIBS += api/libapi.a
LIBS += post/libpost.a
LIBS := $(addprefix $(obj),$(LIBS))
-.PHONY : $(LIBS) $(VERSION_FILE)
+.PHONY : $(LIBS) $(TIMESTAMP_FILE) $(VERSION_FILE)
LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).a
LIBBOARD := $(addprefix $(obj),$(LIBBOARD))
@@ -351,13 +352,13 @@ $(SUBDIRS): depend $(obj)include/autoconf.mk
$(LDSCRIPT): depend $(obj)include/autoconf.mk
$(MAKE) -C $(dir $@) $(notdir $@)
-$(NAND_SPL): $(VERSION_FILE) $(obj)include/autoconf.mk
+$(NAND_SPL): $(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk
$(MAKE) -C nand_spl/board/$(BOARDDIR) all
$(U_BOOT_NAND): $(NAND_SPL) $(obj)u-boot.bin $(obj)include/autoconf.mk
cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
-$(ONENAND_IPL): $(VERSION_FILE) $(obj)include/autoconf.mk
+$(ONENAND_IPL): $(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk
$(MAKE) -C onenand_ipl/board/$(BOARDDIR) all
$(U_BOOT_ONENAND): $(ONENAND_IPL) $(obj)u-boot.bin $(obj)include/autoconf.mk
@@ -370,6 +371,10 @@ $(VERSION_FILE):
) > $@.tmp
@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
+$(TIMESTAMP_FILE):
+ @date +'#define U_BOOT_DATE "%b %d %C%y"' > $@
+ @date +'#define U_BOOT_TIME "%T"' >> $@
+
gdbtools:
$(MAKE) -C tools/gdb all || exit 1
@@ -379,7 +384,7 @@ updater:
env:
$(MAKE) -C tools/env all MTD_VERSION=${MTD_VERSION} || exit 1
-depend dep: $(VERSION_FILE)
+depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE)
for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir _depend ; done
TAG_SUBDIRS += include
@@ -460,7 +465,7 @@ sinclude $(obj)include/autoconf.mk.dep
else # !config.mk
all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
-$(SUBDIRS) $(VERSION_FILE) gdbtools updater env depend \
+$(SUBDIRS) $(TIMESTAMP_FILE) $(VERSION_FILE) gdbtools updater env depend \
dep tags ctags etags cscope $(obj)System.map:
@echo "System not configured - see README" >&2
@ exit 1
@@ -3240,7 +3245,7 @@ clean:
@rm -f $(obj)include/bmp_logo.h
@rm -f $(obj)nand_spl/{u-boot-spl,u-boot-spl.map,System.map}
@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl-2k.bin,ipl-4k.bin,ipl.map}
- @rm -f $(obj)api_examples/demo $(VERSION_FILE)
+ @rm -f $(obj)api_examples/demo $(TIMESTAMP_FILE) $(VERSION_FILE)
@find $(OBJTREE) -type f \
\( -name 'core' -o -name '*.bak' -o -name '*~' \
-o -name '*.o' -o -name '*.a' \) -print \
diff --git a/board/bmw/bmw.c b/board/bmw/bmw.c
index b629c38..41ce14f 100644
--- a/board/bmw/bmw.c
+++ b/board/bmw/bmw.c
@@ -28,7 +28,7 @@
#include <malloc.h>
#include <devices.h>
#include <net.h>
-#include <version.h>
+#include <timestamp.h>
#include <dtt.h>
#include <mpc824x.h>
#include <asm/processor.h>
@@ -45,7 +45,7 @@ int checkboard(void)
char buf[32];
puts ("Board: BMW MPC8245/KAHLUA2 - CHRP (MAP B)\n");
- printf("Built: %s at %s\n", __DATE__ , __TIME__ );
+ printf("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
/* printf("MPLD: Revision %d\n", SYS_REVID_GET()); */
printf("Local Bus at %s MHz\n", strmhz(buf, busfreq));
return 0;
diff --git a/board/eXalion/eXalion.c b/board/eXalion/eXalion.c
index 34538c4..c17498f 100644
--- a/board/eXalion/eXalion.c
+++ b/board/eXalion/eXalion.c
@@ -31,6 +31,7 @@
#include <pci.h>
#include <ide.h>
#include <netdev.h>
+#include <timestamp.h>
#include "piix_pci.h"
#include "eXalion.h"
@@ -40,7 +41,7 @@ int checkboard (void)
char buf[32];
printf ("Board: eXalion MPC824x - CHRP (MAP B)\n");
- printf ("Built: %s at %s\n", __DATE__, __TIME__);
+ printf ("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
printf ("Local Bus: %s MHz\n", strmhz (buf, busfreq));
return 0;
diff --git a/board/lwmon/lwmon.c b/board/lwmon/lwmon.c
index 9e57246..b20ce7f 100644
--- a/board/lwmon/lwmon.c
+++ b/board/lwmon/lwmon.c
@@ -762,12 +762,13 @@ static uchar *key_match (uchar *kbd_data)
#ifdef CONFIG_LCD_INFO
#include <lcd.h>
#include <version.h>
+#include <timestamp.h>
void lcd_show_board_info(void)
{
char temp[32];
- lcd_printf ("%s (%s - %s)\n", U_BOOT_VERSION, __DATE__, __TIME__);
+ lcd_printf ("%s (%s - %s)\n", U_BOOT_VERSION, U_BOOT_DATE, U_BOOT_TIME);
lcd_printf ("(C) 2008 DENX Software Engineering GmbH\n");
lcd_printf (" Wolfgang DENK, wd(a)denx.de\n");
#ifdef CONFIG_LCD_INFO_BELOW_LOGO
diff --git a/board/mousse/mousse.c b/board/mousse/mousse.c
index 6a12b57..bd8d1c6 100644
--- a/board/mousse/mousse.c
+++ b/board/mousse/mousse.c
@@ -30,6 +30,7 @@
#include <mpc824x.h>
#include <netdev.h>
#include <asm/processor.h>
+#include <timestamp.h>
#include "mousse.h"
#include "m48t59y.h"
@@ -42,7 +43,7 @@ int checkboard (void)
char buf[32];
puts ("Board: MOUSSE MPC8240/KAHLUA - CHRP (MAP B)\n");
- printf ("Built: %s at %s\n", __DATE__, __TIME__);
+ printf ("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
printf ("MPLD: Revision %d\n", SYS_REVID_GET ());
printf ("Local Bus: %s MHz\n", strmhz (buf, busfreq));
diff --git a/board/netstar/eeprom.c b/board/netstar/eeprom.c
index 0de594b..5806128 100644
--- a/board/netstar/eeprom.c
+++ b/board/netstar/eeprom.c
@@ -26,6 +26,7 @@
#include <common.h>
#include <exports.h>
+#include <timestamp.h>
#include "../drivers/net/smc91111.h"
#define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE
@@ -173,7 +174,7 @@ int eeprom(int argc, char *argv[])
/* Print help message */
if (argv[1][1] == 'h') {
printf("VoiceBlue EEPROM writer\n");
- printf("Built: %s at %s\n", __DATE__ , __TIME__ );
+ printf("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
printf("Usage:\n\t<mac_address> [<element_1>] [<...>]\n");
return 0;
}
diff --git a/board/sandburst/karef/karef.c b/board/sandburst/karef/karef.c
index 7909d34..8d97a9c 100644
--- a/board/sandburst/karef/karef.c
+++ b/board/sandburst/karef/karef.c
@@ -26,6 +26,7 @@
#include <command.h>
#include "karef.h"
#include "karef_version.h"
+#include <timestamp.h>
#include <asm/processor.h>
#include <asm/io.h>
#include <spd_sdram.h>
@@ -299,7 +300,7 @@ int checkboard (void)
"Serial Number: %d\n", sernum);
printf ("%s\n", KAREF_U_BOOT_REL_STR);
- printf ("Built %s %s by %s\n", __DATE__, __TIME__, BUILDUSER);
+ printf ("Built %s %s by %s\n", U_BOOT_DATE, U_BOOT_TIME, BUILDUSER);
if (sbcommon_get_master()) {
printf("Slot 0 - Master\nSlave board");
if (sbcommon_secondary_present())
@@ -366,7 +367,8 @@ int misc_init_r (void)
setenv("ubrelver", KAREF_U_BOOT_REL_STR);
memset(envstr, 0, 255);
- sprintf (envstr, "Built %s %s by %s", __DATE__, __TIME__, BUILDUSER);
+ sprintf (envstr, "Built %s %s by %s",
+ U_BOOT_DATE, U_BOOT_TIME, BUILDUSER);
setenv("bldstr", envstr);
saveenv();
diff --git a/board/sandburst/metrobox/metrobox.c b/board/sandburst/metrobox/metrobox.c
index c3c4459..19302dc 100644
--- a/board/sandburst/metrobox/metrobox.c
+++ b/board/sandburst/metrobox/metrobox.c
@@ -25,6 +25,7 @@
#include <command.h>
#include "metrobox.h"
#include "metrobox_version.h"
+#include <timestamp.h>
#include <asm/processor.h>
#include <asm/io.h>
#include <spd_sdram.h>
@@ -270,7 +271,7 @@ int checkboard (void)
printf ("Board: Sandburst Corporation MetroBox Serial Number: %d\n", sernum);
printf ("%s\n", METROBOX_U_BOOT_REL_STR);
- printf ("Built %s %s by %s\n", __DATE__, __TIME__, BUILDUSER);
+ printf ("Built %s %s by %s\n", U_BOOT_DATE, U_BOOT_TIME, BUILDUSER);
if (sbcommon_get_master()) {
printf("Slot 0 - Master\nSlave board");
if (sbcommon_secondary_present())
@@ -335,7 +336,8 @@ int misc_init_r (void)
setenv("ubrelver", METROBOX_U_BOOT_REL_STR);
memset(envstr, 0, 255);
- sprintf (envstr, "Built %s %s by %s", __DATE__, __TIME__, BUILDUSER);
+ sprintf (envstr, "Built %s %s by %s",
+ U_BOOT_DATE, U_BOOT_TIME, BUILDUSER);
setenv("bldstr", envstr);
saveenv();
diff --git a/board/tqc/tqm8xx/tqm8xx.c b/board/tqc/tqm8xx/tqm8xx.c
index 928afed..8424804 100644
--- a/board/tqc/tqm8xx/tqm8xx.c
+++ b/board/tqc/tqm8xx/tqm8xx.c
@@ -570,10 +570,11 @@ void ide_led (uchar led, uchar status)
#ifdef CONFIG_LCD_INFO
#include <lcd.h>
+#include <timestamp.h>
void lcd_show_board_info(void)
{
- lcd_printf ("%s (%s - %s)\n", U_BOOT_VERSION, __DATE__, __TIME__);
+ lcd_printf ("%s (%s - %s)\n", U_BOOT_VERSION, U_BOOT_DATE, U_BOOT_TIME);
lcd_printf ("(C) 2008 DENX Software Engineering GmbH\n");
lcd_printf (" Wolfgang DENK, wd(a)denx.de\n");
#ifdef CONFIG_LCD_INFO_BELOW_LOGO
diff --git a/board/trab/trab_fkt.c b/board/trab/trab_fkt.c
index 7273ef9..93b9490 100644
--- a/board/trab/trab_fkt.c
+++ b/board/trab/trab_fkt.c
@@ -25,6 +25,7 @@
#include <common.h>
#include <exports.h>
+#include <timestamp.h>
#include <s3c2400.h>
#include "tsc2000.h"
#include "rs485.h"
@@ -296,7 +297,7 @@ int trab_fkt (int argc, char *argv[])
int do_info (void)
{
printf ("Stand-alone application for TRAB board function test\n");
- printf ("Built: %s at %s\n", __DATE__ , __TIME__ );
+ printf ("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
return 0;
}
diff --git a/board/voiceblue/eeprom.c b/board/voiceblue/eeprom.c
index d8ea6e5..f01597a 100644
--- a/board/voiceblue/eeprom.c
+++ b/board/voiceblue/eeprom.c
@@ -26,6 +26,7 @@
#include <common.h>
#include <exports.h>
+#include <timestamp.h>
#include "../drivers/net/smc91111.h"
#define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE
@@ -169,7 +170,7 @@ int eeprom(int argc, char *argv[])
/* Print help message */
if (argv[1][1] == 'h') {
printf("VoiceBlue EEPROM writer\n");
- printf("Built: %s at %s\n", __DATE__ , __TIME__ );
+ printf("Built: %s at %s\n", U_BOOT_DATE, U_BOOT_TIME);
printf("Usage:\n\t<mac_address> [<element_1>] [<...>]\n");
return 0;
}
diff --git a/cpu/74xx_7xx/start.S b/cpu/74xx_7xx/start.S
index b5484e3..792cd30 100644
--- a/cpu/74xx_7xx/start.S
+++ b/cpu/74xx_7xx/start.S
@@ -34,6 +34,7 @@
*/
#include <config.h>
#include <74xx_7xx.h>
+#include <timestamp.h>
#include <version.h>
#include <ppc_asm.tmpl>
@@ -87,7 +88,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
. = EXC_OFF_SYS_RESET
diff --git a/cpu/leon2/start.S b/cpu/leon2/start.S
index 9b5d83e..b1f1eb5 100644
--- a/cpu/leon2/start.S
+++ b/cpu/leon2/start.S
@@ -27,6 +27,7 @@
#include <asm/psr.h>
#include <asm/stack.h>
#include <asm/leon.h>
+#include <timestamp.h>
#include <version.h>
/* Entry for traps which jump to a programmer-specified trap handler. */
@@ -199,7 +200,7 @@ _trap_table:
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
.section ".text"
diff --git a/cpu/leon3/start.S b/cpu/leon3/start.S
index 7afe10e..bd634bd 100644
--- a/cpu/leon3/start.S
+++ b/cpu/leon3/start.S
@@ -27,6 +27,7 @@
#include <asm/psr.h>
#include <asm/stack.h>
#include <asm/leon.h>
+#include <timestamp.h>
#include <version.h>
/* Entry for traps which jump to a programmer-specified trap handler. */
@@ -200,7 +201,7 @@ _trap_table:
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
.section ".text"
diff --git a/cpu/mcf5227x/start.S b/cpu/mcf5227x/start.S
index becaab7..43e7006 100644
--- a/cpu/mcf5227x/start.S
+++ b/cpu/mcf5227x/start.S
@@ -22,6 +22,7 @@
*/
#include <config.h>
+#include <timestamp.h>
#include "version.h"
#ifndef CONFIG_IDENT_STRING
@@ -352,6 +353,6 @@ dcache_status:
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
.align 4
diff --git a/cpu/mcf523x/start.S b/cpu/mcf523x/start.S
index b70b83b..d44da37 100644
--- a/cpu/mcf523x/start.S
+++ b/cpu/mcf523x/start.S
@@ -22,6 +22,7 @@
*/
#include <config.h>
+#include <timestamp.h>
#include "version.h"
#ifndef CONFIG_IDENT_STRING
@@ -336,6 +337,6 @@ dcache_status:
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
.align 4
diff --git a/cpu/mcf52x2/start.S b/cpu/mcf52x2/start.S
index da45bcb..ba6b884 100644
--- a/cpu/mcf52x2/start.S
+++ b/cpu/mcf52x2/start.S
@@ -22,6 +22,7 @@
*/
#include <config.h>
+#include <timestamp.h>
#include "version.h"
#ifndef CONFIG_IDENT_STRING
@@ -474,6 +475,6 @@ dcache_status:
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
.align 4
diff --git a/cpu/mcf532x/start.S b/cpu/mcf532x/start.S
index 7a3eb5f..3f92912 100644
--- a/cpu/mcf532x/start.S
+++ b/cpu/mcf532x/start.S
@@ -22,6 +22,7 @@
*/
#include <config.h>
+#include <timestamp.h>
#include "version.h"
#ifndef CONFIG_IDENT_STRING
@@ -331,6 +332,6 @@ dcache_status:
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
.align 4
diff --git a/cpu/mcf5445x/start.S b/cpu/mcf5445x/start.S
index 61e43ff..d5a7f93 100644
--- a/cpu/mcf5445x/start.S
+++ b/cpu/mcf5445x/start.S
@@ -22,6 +22,7 @@
*/
#include <config.h>
+#include <timestamp.h>
#include "version.h"
#ifndef CONFIG_IDENT_STRING
@@ -627,6 +628,6 @@ dcache_status:
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
.align 4
diff --git a/cpu/mcf547x_8x/start.S b/cpu/mcf547x_8x/start.S
index 41fc694..94ef14b 100644
--- a/cpu/mcf547x_8x/start.S
+++ b/cpu/mcf547x_8x/start.S
@@ -22,6 +22,7 @@
*/
#include <config.h>
+#include <timestamp.h>
#include "version.h"
#ifndef CONFIG_IDENT_STRING
@@ -357,6 +358,6 @@ dcache_status:
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
.align 4
diff --git a/cpu/mpc512x/start.S b/cpu/mpc512x/start.S
index 26f3c52..360682d 100644
--- a/cpu/mpc512x/start.S
+++ b/cpu/mpc512x/start.S
@@ -31,6 +31,7 @@
#include <config.h>
#include <mpc512x.h>
+#include <timestamp.h>
#include <version.h>
#define CONFIG_521X 1 /* needed for Linux kernel header files*/
@@ -85,7 +86,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii " ", CONFIG_IDENT_STRING, "\0"
/*
diff --git a/cpu/mpc5xx/start.S b/cpu/mpc5xx/start.S
index f2ffe84..106935c 100644
--- a/cpu/mpc5xx/start.S
+++ b/cpu/mpc5xx/start.S
@@ -32,6 +32,7 @@
#include <config.h>
#include <mpc5xx.h>
+#include <timestamp.h>
#include <version.h>
#define CONFIG_5xx 1 /* needed for Linux kernel header files */
@@ -80,7 +81,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
. = EXC_OFF_SYS_RESET
diff --git a/cpu/mpc5xxx/start.S b/cpu/mpc5xxx/start.S
index defe77d..6b1162a 100644
--- a/cpu/mpc5xxx/start.S
+++ b/cpu/mpc5xxx/start.S
@@ -27,6 +27,7 @@
*/
#include <config.h>
#include <mpc5xxx.h>
+#include <timestamp.h>
#include <version.h>
#define CONFIG_MPC5xxx 1 /* needed for Linux kernel header files */
@@ -78,7 +79,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
/*
diff --git a/cpu/mpc8220/start.S b/cpu/mpc8220/start.S
index 373be2c..3abc619 100644
--- a/cpu/mpc8220/start.S
+++ b/cpu/mpc8220/start.S
@@ -27,6 +27,7 @@
*/
#include <config.h>
#include <mpc8220.h>
+#include <timestamp.h>
#include <version.h>
#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
@@ -77,7 +78,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
/*
diff --git a/cpu/mpc824x/start.S b/cpu/mpc824x/start.S
index b5d7eb1..39325cd 100644
--- a/cpu/mpc824x/start.S
+++ b/cpu/mpc824x/start.S
@@ -39,6 +39,7 @@
*/
#include <config.h>
#include <mpc824x.h>
+#include <timestamp.h>
#include <version.h>
#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
@@ -90,7 +91,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
. = EXC_OFF_SYS_RESET
diff --git a/cpu/mpc8260/start.S b/cpu/mpc8260/start.S
index da0c516..379f2fb 100644
--- a/cpu/mpc8260/start.S
+++ b/cpu/mpc8260/start.S
@@ -27,6 +27,7 @@
*/
#include <config.h>
#include <mpc8260.h>
+#include <timestamp.h>
#include <version.h>
#define CONFIG_8260 1 /* needed for Linux kernel header files */
@@ -85,7 +86,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
/*
diff --git a/cpu/mpc83xx/start.S b/cpu/mpc83xx/start.S
index cd566b2..792b2c8 100644
--- a/cpu/mpc83xx/start.S
+++ b/cpu/mpc83xx/start.S
@@ -29,6 +29,7 @@
#include <config.h>
#include <mpc83xx.h>
+#include <timestamp.h>
#include <version.h>
#define CONFIG_83XX 1 /* needed for Linux kernel header files*/
@@ -105,7 +106,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii " ", CONFIG_IDENT_STRING, "\0"
diff --git a/cpu/mpc85xx/start.S b/cpu/mpc85xx/start.S
index 651ff1c..8fa0ff7 100644
--- a/cpu/mpc85xx/start.S
+++ b/cpu/mpc85xx/start.S
@@ -30,6 +30,7 @@
#include <config.h>
#include <mpc85xx.h>
+#include <timestamp.h>
#include <version.h>
#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
@@ -274,7 +275,7 @@ _start:
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
.align 4
diff --git a/cpu/mpc86xx/start.S b/cpu/mpc86xx/start.S
index 75e4317..1b3d740 100644
--- a/cpu/mpc86xx/start.S
+++ b/cpu/mpc86xx/start.S
@@ -32,6 +32,7 @@
*/
#include <config.h>
#include <mpc86xx.h>
+#include <timestamp.h>
#include <version.h>
#include <ppc_asm.tmpl>
@@ -76,7 +77,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
. = EXC_OFF_SYS_RESET
diff --git a/cpu/mpc8xx/start.S b/cpu/mpc8xx/start.S
index 7b75660..45c902e 100644
--- a/cpu/mpc8xx/start.S
+++ b/cpu/mpc8xx/start.S
@@ -39,6 +39,7 @@
*/
#include <config.h>
#include <mpc8xx.h>
+#include <timestamp.h>
#include <version.h>
#define CONFIG_8xx 1 /* needed for Linux kernel header files */
@@ -87,7 +88,7 @@
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
. = EXC_OFF_SYS_RESET
diff --git a/cpu/mpc8xx/video.c b/cpu/mpc8xx/video.c
index 2e6a22a..5479644 100644
--- a/cpu/mpc8xx/video.c
+++ b/cpu/mpc8xx/video.c
@@ -32,7 +32,10 @@
#include <stdarg.h>
#include <common.h>
#include <config.h>
+#ifdef VIDEO_INFO
#include <version.h>
+#include <timestamp.h>
+#endif
#include <i2c.h>
#include <linux/types.h>
#include <devices.h>
@@ -1174,7 +1177,8 @@ static void *video_logo (void)
easylogo_plot (VIDEO_LOGO_ADDR, screen, width, 0, 0);
#ifdef VIDEO_INFO
- sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__);
+ sprintf (info, "%s (%s - %s) ",
+ U_BOOT_VERSION, U_BOOT_DATE, U_BOOT_TIME);
video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, info);
sprintf (info, "(C) 2002 DENX Software Engineering");
diff --git a/cpu/nios/start.S b/cpu/nios/start.S
index 5d15e8d..3578a04 100644
--- a/cpu/nios/start.S
+++ b/cpu/nios/start.S
@@ -23,6 +23,7 @@
#include <config.h>
+#include <timestamp.h>
#include <version.h>
#if !defined(CONFIG_IDENT_STRING)
@@ -233,5 +234,5 @@ dly_clks:
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
diff --git a/cpu/nios2/start.S b/cpu/nios2/start.S
index ea41435..31cd5b0 100644
--- a/cpu/nios2/start.S
+++ b/cpu/nios2/start.S
@@ -23,6 +23,7 @@
#include <config.h>
+#include <timestamp.h>
#include <version.h>
/*************************************************************************
@@ -212,5 +213,5 @@ dly_clks:
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
diff --git a/cpu/ppc4xx/start.S b/cpu/ppc4xx/start.S
index 882ef21..2fb4d8b 100644
--- a/cpu/ppc4xx/start.S
+++ b/cpu/ppc4xx/start.S
@@ -63,6 +63,7 @@
*/
#include <config.h>
#include <ppc4xx.h>
+#include <timestamp.h>
#include <version.h>
#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
@@ -509,7 +510,7 @@ rsttlb: tlbwe r0,r1,0x0000 /* Invalidate all entries (V=0)*/
.globl version_string
version_string:
.ascii U_BOOT_VERSION
- .ascii " (", __DATE__, " - ", __TIME__, ")"
+ .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
.ascii CONFIG_IDENT_STRING, "\0"
. = EXC_OFF_SYS_RESET
diff --git a/include/.gitignore b/include/.gitignore
index ef7dd5f..4481412 100644
--- a/include/.gitignore
+++ b/include/.gitignore
@@ -5,4 +5,5 @@
/bmp_logo.h
/config.h
/config.mk
+/timestamp_autogenerated.h
/version_autogenerated.h
diff --git a/include/configs/NETPHONE.h b/include/configs/NETPHONE.h
index a147aff..34de947 100644
--- a/include/configs/NETPHONE.h
+++ b/include/configs/NETPHONE.h
@@ -799,7 +799,7 @@ typedef unsigned int led_id_t;
#define CONFIG_CDP_DEVICE_ID_PREFIX "NP" /* netphone */
#define CONFIG_CDP_PORT_ID "eth%d"
#define CONFIG_CDP_CAPABILITIES 0x00000010
-#define CONFIG_CDP_VERSION "u-boot" " " __DATE__ " " __TIME__
+#define CONFIG_CDP_VERSION "u-boot" " " U_BOOT_DATE " " U_BOOT_TIME
#define CONFIG_CDP_PLATFORM "Intracom NetPhone"
#define CONFIG_CDP_TRIGGER 0x20020001
#define CONFIG_CDP_POWER_CONSUMPTION 4300 /* 90 mA @ 48V */
diff --git a/include/configs/NETTA.h b/include/configs/NETTA.h
index 63810b3..004b3c8 100644
--- a/include/configs/NETTA.h
+++ b/include/configs/NETTA.h
@@ -775,7 +775,7 @@
#define CONFIG_CDP_DEVICE_ID_PREFIX "NT" /* netta */
#define CONFIG_CDP_PORT_ID "eth%d"
#define CONFIG_CDP_CAPABILITIES 0x00000010
-#define CONFIG_CDP_VERSION "u-boot 1.0" " " __DATE__ " " __TIME__
+#define CONFIG_CDP_VERSION "u-boot 1.0" " " U_BOOT_DATE " " U_BOOT_TIME
#define CONFIG_CDP_PLATFORM "Intracom NetTA"
#define CONFIG_CDP_TRIGGER 0x20020001
#define CONFIG_CDP_POWER_CONSUMPTION 4300 /* 90 mA @ 48V */
diff --git a/include/configs/NETTA2.h b/include/configs/NETTA2.h
index 61c5547..70995fa 100644
--- a/include/configs/NETTA2.h
+++ b/include/configs/NETTA2.h
@@ -750,7 +750,7 @@ typedef unsigned int led_id_t;
#define CONFIG_CDP_DEVICE_ID_PREFIX "NT" /* netta2 */
#define CONFIG_CDP_PORT_ID "eth%d"
#define CONFIG_CDP_CAPABILITIES 0x00000010
-#define CONFIG_CDP_VERSION "u-boot" " " __DATE__ " " __TIME__
+#define CONFIG_CDP_VERSION "u-boot" " " U_BOOT_DATE " " U_BOOT_TIME
#define CONFIG_CDP_PLATFORM "Intracom NetTA2"
#define CONFIG_CDP_TRIGGER 0x20020001
#define CONFIG_CDP_POWER_CONSUMPTION 4300 /* 90 mA @ 48V */
diff --git a/include/timestamp.h b/include/timestamp.h
new file mode 100644
index 0000000..b2f4cf4
--- /dev/null
+++ b/include/timestamp.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2008 Extreme Engineering Solutions, Inc.
+ *
+ * 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 __TIMESTAMP_H__
+#define __TIMESTAMP_H__
+
+#ifndef DO_DEPS_ONLY
+#include "timestamp_autogenerated.h"
+#endif
+
+#endif /* __TIMESTAMP_H__ */
diff --git a/lib_arm/board.c b/lib_arm/board.c
index 4ba1f5e..2358beb 100644
--- a/lib_arm/board.c
+++ b/lib_arm/board.c
@@ -42,6 +42,7 @@
#include <command.h>
#include <malloc.h>
#include <devices.h>
+#include <timestamp.h>
#include <version.h>
#include <net.h>
#include <serial.h>
@@ -69,7 +70,7 @@ extern void dataflash_print_info(void);
#endif
const char version_string[] =
- U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")"CONFIG_IDENT_STRING;
+ U_BOOT_VERSION" (" U_BOOT_DATE " - " U_BOOT_TIME ")"CONFIG_IDENT_STRING;
#ifdef CONFIG_DRIVER_CS8900
extern void cs8900_get_enetaddr (uchar * addr);
diff --git a/lib_avr32/board.c b/lib_avr32/board.c
index 8771de9..2a98bd4 100644
--- a/lib_avr32/board.c
+++ b/lib_avr32/board.c
@@ -23,6 +23,7 @@
#include <command.h>
#include <malloc.h>
#include <devices.h>
+#include <timestamp.h>
#include <version.h>
#include <net.h>
@@ -36,7 +37,7 @@
DECLARE_GLOBAL_DATA_PTR;
const char version_string[] =
- U_BOOT_VERSION " (" __DATE__ " - " __TIME__ ") " CONFIG_IDENT_STRING;
+ U_BOOT_VERSION " ("U_BOOT_DATE" - "U_BOOT_TIME") " CONFIG_IDENT_STRING;
unsigned long monitor_flash_len;
diff --git a/lib_blackfin/board.c b/lib_blackfin/board.c
index ba57392..5f7d50d 100644
--- a/lib_blackfin/board.c
+++ b/lib_blackfin/board.c
@@ -16,6 +16,7 @@
#include <i2c.h>
#include <malloc.h>
#include <net.h>
+#include <timestamp.h>
#include <version.h>
#include <asm/cplb.h>
@@ -32,7 +33,7 @@ int post_flag;
DECLARE_GLOBAL_DATA_PTR;
-const char version_string[] = U_BOOT_VERSION " (" __DATE__ " - " __TIME__ ")";
+const char version_string[] = U_BOOT_VERSION " ("U_BOOT_DATE" - "U_BOOT_TIME")";
__attribute__((always_inline))
static inline void serial_early_puts(const char *s)
diff --git a/lib_i386/board.c b/lib_i386/board.c
index 659f9a2..1734f86 100644
--- a/lib_i386/board.c
+++ b/lib_i386/board.c
@@ -32,6 +32,7 @@
#include <watchdog.h>
#include <command.h>
#include <devices.h>
+#include <timestamp.h>
#include <version.h>
#include <malloc.h>
#include <net.h>
@@ -70,7 +71,7 @@ ulong i386boot_bios_size = (ulong)&_i386boot_bios_size; /* size of BIOS
const char version_string[] =
- U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
+ U_BOOT_VERSION" (" U_BOOT_DATE " - " U_BOOT_TIME ")";
/*
diff --git a/lib_microblaze/board.c b/lib_microblaze/board.c
index cd61918..250972c 100644
--- a/lib_microblaze/board.c
+++ b/lib_microblaze/board.c
@@ -27,12 +27,13 @@
#include <common.h>
#include <command.h>
#include <malloc.h>
+#include <timestamp.h>
#include <version.h>
#include <watchdog.h>
DECLARE_GLOBAL_DATA_PTR;
-const char version_string[] = U_BOOT_VERSION " (" __DATE__ " - " __TIME__ ")";
+const char version_string[] = U_BOOT_VERSION " ("U_BOOT_DATE" - "U_BOOT_TIME")";
#ifdef CONFIG_SYS_GPIO_0
extern int gpio_init (void);
diff --git a/lib_mips/board.c b/lib_mips/board.c
index 77e1cc8..9c997f1 100644
--- a/lib_mips/board.c
+++ b/lib_mips/board.c
@@ -25,6 +25,7 @@
#include <command.h>
#include <malloc.h>
#include <devices.h>
+#include <timestamp.h>
#include <version.h>
#include <net.h>
#include <environment.h>
@@ -53,7 +54,7 @@ extern ulong uboot_end;
ulong monitor_flash_len;
const char version_string[] =
- U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
+ U_BOOT_VERSION" (" U_BOOT_DATE " - " U_BOOT_TIME ")";
static char *failed = "*** failed ***\n";
diff --git a/lib_sh/board.c b/lib_sh/board.c
index b6be22e..d4cc85c 100644
--- a/lib_sh/board.c
+++ b/lib_sh/board.c
@@ -22,6 +22,7 @@
#include <command.h>
#include <malloc.h>
#include <devices.h>
+#include <timestamp.h>
#include <version.h>
#include <watchdog.h>
#include <net.h>
@@ -33,7 +34,7 @@ extern int board_init(void);
extern int dram_init(void);
extern int timer_init(void);
-const char version_string[] = U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
+const char version_string[] = U_BOOT_VERSION" ("U_BOOT_DATE" - "U_BOOT_TIME")";
unsigned long monitor_flash_len = CONFIG_SYS_MONITOR_LEN;
diff --git a/net/net.c b/net/net.c
index 77e83b5..e9754e4 100644
--- a/net/net.c
+++ b/net/net.c
@@ -89,6 +89,9 @@
#if defined(CONFIG_CMD_SNTP)
#include "sntp.h"
#endif
+#if defined(CONFIG_CDP_VERSION)
+#include <timestamp.h>
+#endif
#if defined(CONFIG_CMD_NET)
--
1.6.0.2.GIT
2
2

[U-Boot] [PATCH-OMAP3 0/2] OMAP3: Add support for OMAP3 based Pandora board
by Grazvydas Ignotas 06 Dec '08
by Grazvydas Ignotas 06 Dec '08
06 Dec '08
Pandora is open handheld gaming console, which uses Texas
Instruments OMAP 3530 SoC. More information can be found
at http://openpandora.org/.
The following two patches are to be applied on
u-boot-arm/omap3 branch, and should match style currently
used there.
3
5
Hi,
this patch adds support for Toradex' "Colibri PXA300" module. I had to
modify the AX88796 driver a bit to make it work, but that goes in a
different patch.
Also, the board code does not support NAND yet. I'll implement the code
from Oliver Ford soon.
Signed-off-by: Daniel Mack <daniel(a)caiaq.de>
diff --git a/MAKEALL b/MAKEALL
index dbed268..868205f 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -554,6 +554,7 @@ LIST_at91=" \
LIST_pxa=" \
cerf250 \
+ colibri_pxa300 \
cradle \
csb226 \
delta \
diff --git a/Makefile b/Makefile
index befb608..ee94d17 100644
--- a/Makefile
+++ b/Makefile
@@ -2804,6 +2804,9 @@ actux4_config : unconfig
cerf250_config : unconfig
@$(MKCONFIG) $(@:_config=) arm pxa cerf250
+colibri_pxa300_config: unconfig
+ @$(MKCONFIG) $(@:_config=) arm pxa colibri_pxa300
+
cradle_config : unconfig
@$(MKCONFIG) $(@:_config=) arm pxa cradle
diff --git a/board/colibri_pxa300/Makefile b/board/colibri_pxa300/Makefile
new file mode 100644
index 0000000..2fa3fb9
--- /dev/null
+++ b/board/colibri_pxa300/Makefile
@@ -0,0 +1,51 @@
+#
+# (C) Copyright 2000-2006
+# 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 $(TOPDIR)/config.mk
+
+LIB = $(obj)lib$(BOARD).a
+
+COBJS := colibri_pxa300.o
+SOBJS := lowlevel_init.o
+
+SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS))
+SOBJS := $(addprefix $(obj),$(SOBJS))
+
+$(LIB): $(obj).depend $(OBJS) $(SOBJS)
+ $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
+
+clean:
+ rm -f $(SOBJS) $(OBJS)
+
+distclean: clean
+ rm -f $(LIB) core *.bak $(obj).depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/colibri_pxa300/colibri_pxa300.c b/board/colibri_pxa300/colibri_pxa300.c
new file mode 100644
index 0000000..2c2b0d7
--- /dev/null
+++ b/board/colibri_pxa300/colibri_pxa300.c
@@ -0,0 +1,61 @@
+/*
+ * (C) Copyright 2008
+ * Daniel Mack, caiaq GbR <daniel(a)caiaq.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>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * Miscelaneous platform dependent initialisations
+ */
+
+int board_init (void)
+{
+ /* arch number for linux kernel */
+ gd->bd->bi_arch_number = MACH_TYPE_COLIBRI300;
+
+ /* adress of boot parameters */
+ gd->bd->bi_boot_params = 0xa0000100;
+
+ return 0;
+}
+
+int board_late_init(void)
+{
+ setenv("stdout", "serial");
+ setenv("stderr", "serial");
+ return 0;
+}
+
+int dram_init (void)
+{
+ gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+ gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+ gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
+ gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
+ gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
+ gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;
+ gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
+ gd->bd->bi_dram[3].size = PHYS_SDRAM_4_SIZE;
+ return 0;
+}
diff --git a/board/colibri_pxa300/config.mk b/board/colibri_pxa300/config.mk
new file mode 100644
index 0000000..350ff3d
--- /dev/null
+++ b/board/colibri_pxa300/config.mk
@@ -0,0 +1,2 @@
+TEXT_BASE = 0x81000000
+
diff --git a/board/colibri_pxa300/lowlevel_init.S b/board/colibri_pxa300/lowlevel_init.S
new file mode 100644
index 0000000..23155ab
--- /dev/null
+++ b/board/colibri_pxa300/lowlevel_init.S
@@ -0,0 +1,97 @@
+/*
+ * 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 <config.h>
+#include <version.h>
+#include <asm/arch/pxa-regs.h>
+
+/* There is no memory init here since U-Boot was booted from DRAM
+ already. You need to implement a first-stage bootloader to setup
+ the RAM controller and load contents from NAND if needed. */
+
+.globl lowlevel_init
+lowlevel_init:
+
+ /* Configure GPIO pins for UART1 / altFn 1 */
+ ldr r0, =0x40E10600 @ GPIO99 FFRXD
+ ldr r1, =0x801
+ str r1, [r0]
+
+ ldr r0, =0x40E10604 @ GPIO100 FFTXD
+ ldr r1, =0x801
+ str r1, [r0]
+
+ ldr r0, =0x40E10608 @ GPIO101 FFCTS
+ ldr r1, =0x801
+ str r1, [r0]
+
+ ldr r0, =0x40E10630 @ GPIO111 FFRTS
+ ldr r1, =0x801
+ str r1, [r0]
+
+ ldr r0, =0x40E10610 @ GPIO103 FFDTR
+ ldr r1, =0x801
+ str r1, [r0]
+
+ ldr r0, =0x40E10618 @ GPIO105 FFDSR
+ ldr r1, =0x801
+ str r1, [r0]
+
+ ldr r0, =0x40E1060c @ GPIO102 FFDCD
+ ldr r1, =0x801
+ str r1, [r0]
+
+ ldr r0, =0x40E10614 @ GPIO104 FFRI
+ ldr r1, =0x801
+ str r1, [r0]
+
+ /* CS2 @GPIO1 */
+ ldr r0, =0x40E100b8
+ ldr r1, =0x1
+ str r1, [r0]
+
+ /* configure SRAM controller for ethernet chip */
+
+ /* MSC1: SRAM, 16bit */
+ ldr r0, =MSC1
+ ldr r1, =0x00000779
+ str r1, [r0]
+
+ /* SXCNFG: enable CS2 for static memory */
+ ldr r0, =SXCNFG
+ ldr r1, =0x00880008
+ str r1, [r0]
+
+ /* MEMCLKCFG: set clock speed for SRAM */
+ ldr r0, =MEMCLKCFG
+ ldr r1, =0x00030003
+ str r1, [r0]
+
+ /* CSADRCFG2: interface type 'SRAM / async flash',
+ byte address split 16 */
+ ldr r0, =CSADRCFG2
+ ldr r1, =0x0032C809
+ str r1, [r0]
+
+ /* enable clocks for NAND and static memory */
+ ldr r0, =CKENA
+ ldr r1, [r0]
+ orr r1, r1, #(CKENA_4_NAND | CKENA_9_SMC)
+ str r1, [r0]
+
+ mov pc, lr
+
diff --git a/board/colibri_pxa300/u-boot.lds b/board/colibri_pxa300/u-boot.lds
new file mode 100644
index 0000000..7cf9fdf
--- /dev/null
+++ b/board/colibri_pxa300/u-boot.lds
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2000
+ * 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
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x00000000;
+
+ . = ALIGN(4);
+ .text :
+ {
+ cpu/pxa/start.o (.text)
+ *(.text)
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(.rodata) }
+
+ . = ALIGN(4);
+ .data : { *(.data) }
+
+ . = ALIGN(4);
+ .got : { *(.got) }
+
+ . = .;
+ __u_boot_cmd_start = .;
+ .u_boot_cmd : { *(.u_boot_cmd) }
+ __u_boot_cmd_end = .;
+
+ . = ALIGN(4);
+ __bss_start = .;
+ .bss (NOLOAD) : { *(.bss) . = ALIGN(4); }
+ _end = .;
+}
diff --git a/include/configs/colibri_pxa300.h b/include/configs/colibri_pxa300.h
new file mode 100644
index 0000000..f589337
--- /dev/null
+++ b/include/configs/colibri_pxa300.h
@@ -0,0 +1,173 @@
+/*
+ * (C) Copyright 2008
+ * Daniel Mack <daniel(a)caiaq.de>
+ *
+ * Based on configuation settings for the Zylonite board.
+ *
+ * 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 __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ * (easy to change)
+ */
+#define CONFIG_CPU_MONAHANS 1 /* Intel Monahans CPU */
+#define CONFIG_COLIBRI_PXA300 1 /* Colibri PXA300 board */
+
+#undef BOARD_LATE_INIT
+#undef CONFIG_SKIP_RELOCATE_UBOOT
+#undef CONFIG_USE_IRQ /* we don't need IRQ/FIQ stuff */
+#undef CONFIG_SKIP_LOWLEVEL_INIT
+#define CONFIG_SYS_SKIP_DRAM_SCRUB
+
+/*
+ * Environment settings
+ */
+#define CONFIG_ENV_IS_NOWHERE 1
+#define CONFIG_ENV_OFFSET 0x40000
+#define CONFIG_ENV_OFFSET_REDUND 0x44000
+#define CONFIG_ENV_SIZE 0x4000
+
+#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024)
+#define CONFIG_SYS_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */
+
+/*
+ * select serial console configuration
+ */
+#define CONFIG_FFUART 1
+
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_BAUDRATE 115200
+
+/*
+ * BOOTP options
+ */
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_BOOTPATH
+#define CONFIG_BOOTP_GATEWAY
+#define CONFIG_BOOTP_HOSTNAME
+
+/*
+ * Command line configuration.
+ */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_ENV
+#undef CONFIG_CMD_IMLS
+
+#define CONFIG_BOOTDELAY -1
+#define CONFIG_NETMASK 255.255.255.0
+#define CONFIG_IPADDR 192.168.1.52
+#define CONFIG_SERVERIP 192.168.1.51
+#define CONFIG_BOOTCOMMAND "bootm 80000"
+#define CONFIG_BOOTARGS "console=ttyS0,115200"
+#define CONFIG_TIMESTAMP
+#define CONFIG_EXTRA_ENV_SETTINGS "ethaddr=08:00:3e:26:0a:5b"
+
+/*
+ * Kernel boot tags
+ */
+#define CONFIG_CMDLINE_TAG
+#define CONFIG_SETUP_MEMORY_TAGS
+
+#if defined(CONFIG_CMD_KGDB)
+#define CONFIG_KGDB_BAUDRATE 230400 /* speed to run kgdb serial port */
+#define CONFIG_KGDB_SER_INDEX 2 /* which serial port to use */
+#endif
+
+/*
+ * Hardware drivers
+ */
+#if defined(CONFIG_CMD_NET)
+/* AX88696L Support(NE2000 base chip) */
+#define CONFIG_DRIVER_AX88796L
+#define CONFIG_DRIVER_NE2000_BASE 0x10000000
+#define CONFIG_NE2000_NOPROM
+#endif
+
+/*
+ * Miscellaneous configurable options
+ */
+#define CONFIG_SYS_HUSH_PARSER 1
+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+
+#define CONFIG_SYS_LONGHELP /* undef to save memory */
+#ifdef CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT "$ " /* Monitor Command Prompt */
+#else
+#define CONFIG_SYS_PROMPT "=> " /* Monitor Command Prompt */
+#endif
+#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */
+#define CONFIG_SYS_MAXARGS 16 /* max number of command args */
+#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */
+#define CONFIG_SYS_DEVICE_NULLDEV 1
+
+#define CONFIG_SYS_MEMTEST_START 0x80200000 /* memtest works on */
+#define CONFIG_SYS_MEMTEST_END 0x80400000 /* 4 ... 8 MB in DRAM */
+
+#undef CONFIG_SYS_CLKS_IN_HZ /* everything, incl board info, in Hz */
+
+#define CONFIG_SYS_HZ 3250000 /* incrementer freq: 3.25 MHz */
+
+/* Monahans Core Frequency */
+#define CONFIG_SYS_MONAHANS_RUN_MODE_OSC_RATIO 8 /* valid values: 8, 16, 24, 31 */
+#define CONFIG_SYS_MONAHANS_TURBO_RUN_MODE_RATIO 1 /* valid values: 1, 2 */
+
+ /* valid baudrates */
+#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
+
+/*
+ * Stack sizes
+ *
+ * The stack sizes are set up in start.S using the settings below
+ */
+#define CONFIG_STACKSIZE (128*1024) /* regular stack */
+#ifdef CONFIG_USE_IRQ
+#define CONFIG_STACKSIZE_IRQ (4*1024) /* IRQ stack */
+#define CONFIG_STACKSIZE_FIQ (4*1024) /* FIQ stack */
+#endif
+
+/*
+ * Physical Memory Map
+ */
+#define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */
+#define PHYS_SDRAM_1 0xa0000000 /* SDRAM Bank #1 */
+#define PHYS_SDRAM_1_SIZE 0x04000000 /* 64 MB */
+#define PHYS_SDRAM_2 0xa4000000 /* SDRAM Bank #2 */
+#define PHYS_SDRAM_2_SIZE 0x00000000 /* 0 MB */
+#define PHYS_SDRAM_3 0xa8000000 /* SDRAM Bank #3 */
+#define PHYS_SDRAM_3_SIZE 0x00000000 /* 0 MB */
+#define PHYS_SDRAM_4 0xac000000 /* SDRAM Bank #4 */
+#define PHYS_SDRAM_4_SIZE 0x00000000 /* 0 MB */
+
+#define CONFIG_SYS_DRAM_BASE 0xa0200000 /* at CS0 */
+#define CONFIG_SYS_DRAM_SIZE 0x04000000 /* 64 MB Ram */
+
+#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_DRAM_BASE + 0x8000) /* default load address */
+#define CONFIG_SYS_NO_FLASH 1
+
+#endif /* __CONFIG_H */
+
2
2

[U-Boot] [PATCH-OMAP3 2/2] OMAP3: Convert register access to structure style, part #2
by Dirk Behme 06 Dec '08
by Dirk Behme 06 Dec '08
06 Dec '08
Convert register access to structure style, part #2.
No functional change.
Signed-off-by: Jason Kridner <jkridner(a)gmail.com>
Signed-off-by: Dirk Behme <dirk.behme(a)googlemail.com>
---
board/omap3/beagle/beagle.c | 16 +----
board/omap3/evm/evm.c | 39 +++++-------
board/omap3/overo/overo.c | 16 +----
board/omap3/pandora/pandora.c | 21 +++---
cpu/arm_cortexa8/omap3/interrupts.c | 10 +--
cpu/arm_cortexa8/omap3/mem.c | 105 +++++++++++++++++----------------
cpu/arm_cortexa8/omap3/sys_info.c | 22 +++---
cpu/arm_cortexa8/omap3/syslib.c | 11 +--
drivers/mtd/nand/omap_gpmc.c | 47 +++++++-------
include/asm-arm/arch-omap3/mem.h | 9 +-
include/asm-arm/arch-omap3/omap3.h | 22 +++++-
include/asm-arm/arch-omap3/sys_proto.h | 4 -
include/configs/omap3_beagle.h | 17 +++--
include/configs/omap3_evm.h | 18 +++--
include/configs/omap3_overo.h | 17 +++--
include/configs/omap3_pandora.h | 17 +++--
16 files changed, 204 insertions(+), 187 deletions(-)
Index: u-boot-arm/cpu/arm_cortexa8/omap3/interrupts.c
===================================================================
--- u-boot-arm.orig/cpu/arm_cortexa8/omap3/interrupts.c
+++ u-boot-arm/cpu/arm_cortexa8/omap3/interrupts.c
@@ -167,16 +167,16 @@ void do_irq(struct pt_regs *pt_regs)
static ulong timestamp;
static ulong lastinc;
-static u32 *timer_base = (u32 *)CONFIG_SYS_TIMERBASE;
+static gptimer_t *timer_base = (gptimer_t *)CONFIG_SYS_TIMERBASE;
/* nothing really to do with interrupts, just starts up a counter. */
int interrupt_init(void)
{
/* start the counter ticking up, reload value on overflow */
- writel(TIMER_LOAD_VAL, timer_base + OFFS(TLDR));
+ writel(TIMER_LOAD_VAL, &timer_base->tldr);
/* enable timer */
writel((CONFIG_SYS_PVT << 2) | TCLR_PRE | TCLR_AR | TCLR_ST,
- timer_base + OFFS(TCLR));
+ &timer_base->tclr);
reset_timer_masked(); /* init the timestamp and lastinc value */
@@ -232,13 +232,13 @@ void udelay(unsigned long usec)
void reset_timer_masked(void)
{
/* reset time, capture current incrementer value time */
- lastinc = readl(timer_base + OFFS(TCRR));
+ lastinc = readl(&timer_base->tcrr);
timestamp = 0; /* start "advancing" time stamp from 0 */
}
ulong get_timer_masked(void)
{
- ulong now = readl(timer_base + OFFS(TCRR)); /* current tick value */
+ ulong now = readl(&timer_base->tcrr); /* current tick value */
if (now >= lastinc) /* normal mode (non roll) */
/* move stamp fordward with absoulte diff ticks */
Index: u-boot-arm/drivers/mtd/nand/omap_gpmc.c
===================================================================
--- u-boot-arm.orig/drivers/mtd/nand/omap_gpmc.c
+++ u-boot-arm/drivers/mtd/nand/omap_gpmc.c
@@ -30,8 +30,8 @@
#include <nand.h>
static uint8_t cs;
-static uint32_t *gpmc_base = (uint32_t *)GPMC_BASE;
-static uint32_t *gpmc_cs_base;
+static gpmc_t *gpmc_base = (gpmc_t *)GPMC_BASE;
+static gpmc_csx_t *gpmc_cs_base;
static struct nand_ecclayout hw_nand_oob = GPMC_NAND_HW_ECC_LAYOUT;
/*
@@ -49,13 +49,13 @@ static void omap_nand_hwcontrol(struct m
*/
switch (ctrl) {
case NAND_CTRL_CHANGE | NAND_CTRL_CLE:
- this->IO_ADDR_W = gpmc_cs_base + OFFS(GPMC_NAND_CMD);
+ this->IO_ADDR_W = (void __iomem *)&gpmc_cs_base->nand_cmd;
break;
case NAND_CTRL_CHANGE | NAND_CTRL_ALE:
- this->IO_ADDR_W = gpmc_cs_base + OFFS(GPMC_NAND_ADR);
+ this->IO_ADDR_W = (void __iomem *)&gpmc_cs_base->nand_adr;
break;
case NAND_CTRL_CHANGE | NAND_NCE:
- this->IO_ADDR_W = gpmc_cs_base + OFFS(GPMC_NAND_DAT);
+ this->IO_ADDR_W = (void __iomem *)&gpmc_cs_base->nand_dat;
break;
}
@@ -75,9 +75,8 @@ static void omap_hwecc_init(struct nand_
* Init ECC Control Register
* Clear all ECC | Enable Reg1
*/
- writel(ECCCLEAR | ECCRESULTREG1, gpmc_base + OFFS(GPMC_ECC_CONTROL));
- writel(ECCSIZE1 | ECCSIZE0 | ECCSIZE0SEL,
- gpmc_base + OFFS(GPMC_ECC_SIZE_CONFIG));
+ writel(ECCCLEAR | ECCRESULTREG1, &gpmc_base->ecc_control);
+ writel(ECCSIZE1 | ECCSIZE0 | ECCSIZE0SEL, &gpmc_base->ecc_size_config);
}
/*
@@ -109,7 +108,7 @@ static uint32_t gen_true_ecc(uint8_t *ec
* @return 0 if data is OK or corrected, else returns -1
*/
static int omap_correct_data(struct mtd_info *mtd, uint8_t *dat,
- uint8_t *read_ecc, uint8_t *calc_ecc)
+ uint8_t *read_ecc, uint8_t *calc_ecc)
{
uint32_t orig_ecc, new_ecc, res, hm;
uint16_t parity_bits, byte;
@@ -175,12 +174,12 @@ static int omap_correct_data(struct mtd_
* @ecc_code: ecc_code buffer
*/
static int omap_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat,
- uint8_t *ecc_code)
+ uint8_t *ecc_code)
{
u_int32_t val;
/* Start Reading from HW ECC1_Result = 0x200 */
- val = readl(gpmc_base + OFFS(GPMC_ECC1_RESULT));
+ val = readl(&gpmc_base->ecc1_result);
ecc_code[0] = val & 0xFF;
ecc_code[1] = (val >> 16) & 0xFF;
@@ -190,7 +189,7 @@ static int omap_calculate_ecc(struct mtd
* Stop reading anymore ECC vals and clear old results
* enable will be called if more reads are required
*/
- writel(0x000, gpmc_base + OFFS(GPMC_ECC_CONFIG));
+ writel(0x000, &gpmc_base->ecc_config);
return 0;
}
@@ -209,17 +208,17 @@ static void omap_enable_hwecc(struct mtd
case NAND_ECC_READ:
case NAND_ECC_WRITE:
/* Clear the ecc result registers, select ecc reg as 1 */
- writel(ECCCLEAR | ECCRESULTREG1,
- gpmc_base + OFFS(GPMC_ECC_CONTROL));
+ writel(ECCCLEAR | ECCRESULTREG1, &gpmc_base->ecc_control);
+
/*
* Size 0 = 0xFF, Size1 is 0xFF - both are 512 bytes
* tell all regs to generate size0 sized regs
* we just have a single ECC engine for all CS
*/
writel(ECCSIZE1 | ECCSIZE0 | ECCSIZE0SEL,
- gpmc_base + OFFS(GPMC_ECC_SIZE_CONFIG));
+ &gpmc_base->ecc_size_config);
val = (dev_width << 7) | (cs << 1) | (0x1);
- writel(val, gpmc_base + OFFS(GPMC_ECC_CONFIG));
+ writel(val, &gpmc_base->ecc_config);
break;
default:
printf("Error: Unrecognized Mode[%d]!\n", mode);
@@ -318,10 +317,10 @@ int board_nand_init(struct nand_chip *na
* Each GPMC set for a single CS is at offset 0x30
* - already remapped for us
*/
- gpmc_cs_base = (void __iomem *)(GPMC_CONFIG_CS0_BASE +
- (cs * GPMC_CONFIG_WIDTH));
+ gpmc_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
+ (cs * GPMC_CONFIG_WIDTH));
/* Check if NAND type is set */
- if ((readl(gpmc_cs_base + OFFS(GPMC_CONFIG1)) & 0xC00) ==
+ if ((readl(&gpmc_cs_base->config1) & 0xC00) ==
0x800) {
/* Found it!! */
break;
@@ -330,17 +329,17 @@ int board_nand_init(struct nand_chip *na
}
if (cs >= GPMC_MAX_CS) {
printf("NAND: Unable to find NAND settings in "
- "GPMC Configuration - quitting\n");
+ "GPMC Configuration - quitting\n");
return -ENODEV;
}
- gpmc_config = readl(gpmc_base + OFFS(GPMC_CONFIG));
+ gpmc_config = readl(&gpmc_base->config);
/* Disable Write protect */
gpmc_config |= 0x10;
- writel(gpmc_config, gpmc_base + OFFS(GPMC_CONFIG));
+ writel(gpmc_config, &gpmc_base->config);
- nand->IO_ADDR_R = gpmc_cs_base + OFFS(GPMC_NAND_DAT);
- nand->IO_ADDR_W = gpmc_cs_base + OFFS(GPMC_NAND_CMD);
+ nand->IO_ADDR_R = (void __iomem *)&gpmc_cs_base->nand_dat;
+ nand->IO_ADDR_W = (void __iomem *)&gpmc_cs_base->nand_cmd;
nand->cmd_ctrl = omap_nand_hwcontrol;
nand->options = NAND_NO_PADDING | NAND_CACHEPRG | NAND_NO_AUTOINCR |
Index: u-boot-arm/cpu/arm_cortexa8/omap3/sys_info.c
===================================================================
--- u-boot-arm.orig/cpu/arm_cortexa8/omap3/sys_info.c
+++ u-boot-arm/cpu/arm_cortexa8/omap3/sys_info.c
@@ -32,9 +32,9 @@
#include <i2c.h>
extern omap3_sysinfo sysinfo;
-static u32 *gpmc_base = (u32 *)GPMC_BASE;
-static u32 *sdrc_base = (u32 *)OMAP34XX_SDRC_BASE;
-static u32 *ctrl_base = (u32 *)OMAP34XX_CTRL_BASE;
+static gpmc_csx_t *gpmc_cs_base = (gpmc_csx_t *)GPMC_CONFIG_CS0_BASE;
+static sdrc_t *sdrc_base = (sdrc_t *)OMAP34XX_SDRC_BASE;
+static ctrl_t *ctrl_base = (ctrl_t *)OMAP34XX_CTRL_BASE;
/******************************************
* get_cpu_rev(void) - extract version info
@@ -61,8 +61,7 @@ u32 get_cpu_rev(void)
****************************************************/
u32 is_mem_sdr(void)
{
- if (readl(sdrc_base + OFFS(SDRC_MR_0 + SDRC_CS0_OSET)) ==
- SDP_SDRC_MR_0_SDR)
+ if (readl(&sdrc_base->cs[CS0].mr) == SDP_SDRC_MR_0_SDR)
return 1;
return 0;
}
@@ -70,12 +69,12 @@ u32 is_mem_sdr(void)
/***********************************************************************
* get_cs0_size() - get size of chip select 0/1
************************************************************************/
-u32 get_sdr_cs_size(u32 offset)
+u32 get_sdr_cs_size(u32 cs)
{
u32 size;
/* get ram size field */
- size = readl(sdrc_base + OFFS(SDRC_MCFG_0 + offset)) >> 8;
+ size = readl(&sdrc_base->cs[cs].mcfg) >> 8;
size &= 0x3FF; /* remove unwanted bits */
size *= SZ_2M; /* find size in MB */
return size;
@@ -91,7 +90,7 @@ u32 get_sdr_cs_offset(u32 cs)
if (!cs)
return 0;
- offset = readl(sdrc_base + OFFS(SDRC_CS_CFG));
+ offset = readl(&sdrc_base->cs_cfg);
offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
return offset;
@@ -129,7 +128,7 @@ u32 get_gpmc0_base(void)
{
u32 b;
- b = readl(gpmc_base + OFFS(GPMC_CONFIG7));
+ b = readl(&gpmc_cs_base->config7);
b &= 0x1F; /* keep base [5:0] */
b = b << 24; /* ret 0x0b000000 */
return b;
@@ -243,7 +242,7 @@ u32 is_running_in_sdram(void)
***************************************************************/
u32 get_boot_type(void)
{
- return (readl(ctrl_base + OFFS(CONTROL_STATUS)) & SYSBOOT_MASK);
+ return (readl(&ctrl_base->status) & SYSBOOT_MASK);
}
/*************************************************************
@@ -251,6 +250,5 @@ u32 get_boot_type(void)
*************************************************************/
u32 get_device_type(void)
{
- return ((readl(ctrl_base + OFFS(CONTROL_STATUS)) &
- (DEVICE_MASK)) >> 8);
+ return ((readl(&ctrl_base->status) & (DEVICE_MASK)) >> 8);
}
Index: u-boot-arm/cpu/arm_cortexa8/omap3/mem.c
===================================================================
--- u-boot-arm.orig/cpu/arm_cortexa8/omap3/mem.c
+++ u-boot-arm/cpu/arm_cortexa8/omap3/mem.c
@@ -76,7 +76,8 @@ static u32 gpmc_m_nand[GPMC_MAX_REG] = {
M_NAND_GPMC_CONFIG6, 0
};
-u32 *nand_cs_base;
+gpmc_csx_t *nand_cs_base;
+gpmc_t *gpmc_cfg_base;
#if defined(CONFIG_ENV_IS_IN_NAND)
#define GPMC_CS 0
@@ -96,7 +97,7 @@ static u32 gpmc_onenand[GPMC_MAX_REG] =
ONENAND_GPMC_CONFIG6, 0
};
-u32 *onenand_cs_base;
+gpmc_csx_t *onenand_cs_base;
#if defined(CONFIG_ENV_IS_IN_ONENAND)
#define GPMC_CS 0
@@ -106,7 +107,7 @@ u32 *onenand_cs_base;
#endif
-static u32 *sdrc_base = (u32 *)OMAP34XX_SDRC_BASE;
+static sdrc_t *sdrc_base = (sdrc_t *)OMAP34XX_SDRC_BASE;
/**************************************************************************
* make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
@@ -118,11 +119,11 @@ void make_cs1_contiguous(void)
{
u32 size, a_add_low, a_add_high;
- size = get_sdr_cs_size(SDRC_CS0_OSET);
+ size = get_sdr_cs_size(CS0);
size /= SZ_32M; /* find size to offset CS1 */
a_add_high = (size & 3) << 8; /* set up low field */
a_add_low = (size & 0x3C) >> 2; /* set up high field */
- writel((a_add_high | a_add_low), sdrc_base + OFFS(SDRC_CS_CFG));
+ writel((a_add_high | a_add_low), &sdrc_base->cs_cfg);
}
@@ -158,7 +159,7 @@ u32 mem_ok(u32 cs)
void sdrc_init(void)
{
/* only init up first bank here */
- do_sdrc_init(SDRC_CS0_OSET, EARLY_INIT);
+ do_sdrc_init(CS0, EARLY_INIT);
}
/*************************************************************************
@@ -167,70 +168,73 @@ void sdrc_init(void)
* -optimal settings can be placed here, or redone after i2c
* inspection of board info
*
- * - code called ones in C-Stack only context for CS0 and a possible 2nd
+ * - code called once in C-Stack only context for CS0 and a possible 2nd
* time depending on memory configuration from stack+global context
**************************************************************************/
-void do_sdrc_init(u32 offset, u32 early)
+void do_sdrc_init(u32 cs, u32 early)
{
- u32 actim_offs = offset? 0x28: 0;
+ sdrc_actim_t *sdrc_actim_base;
+
+ if(cs)
+ sdrc_actim_base = (sdrc_actim_t *)SDRC_ACTIM_CTRL1_BASE;
+ else
+ sdrc_actim_base = (sdrc_actim_t *)SDRC_ACTIM_CTRL0_BASE;
if (early) {
/* reset sdrc controller */
- writel(SOFTRESET, sdrc_base + OFFS(SDRC_SYSCONFIG));
- wait_on_value(RESETDONE, RESETDONE, SDRC_STATUS_REG, 12000000);
- writel(0, sdrc_base + OFFS(SDRC_SYSCONFIG));
+ writel(SOFTRESET, &sdrc_base->sysconfig);
+ wait_on_value(RESETDONE, RESETDONE, &sdrc_base->status,
+ 12000000);
+ writel(0, &sdrc_base->sysconfig);
/* setup sdrc to ball mux */
- writel(SDP_SDRC_SHARING, sdrc_base + OFFS(SDRC_SHARING));
+ writel(SDP_SDRC_SHARING, &sdrc_base->sharing);
/* Disable Power Down of CKE cuz of 1 CKE on combo part */
- writel(SRFRONRESET | PAGEPOLICY_HIGH,
- sdrc_base + OFFS(SDRC_POWER));
+ writel(SRFRONRESET | PAGEPOLICY_HIGH, &sdrc_base->power);
- writel(ENADLL | DLLPHASE_90, sdrc_base + OFFS(SDRC_DLLA_CTRL));
+ writel(ENADLL | DLLPHASE_90, &sdrc_base->dlla_ctrl);
sdelay(0x20000);
}
writel(RASWIDTH_13BITS | CASWIDTH_10BITS | ADDRMUXLEGACY |
RAMSIZE_128 | BANKALLOCATION | B32NOT16 | B32NOT16 |
- DEEPPD | DDR_SDRAM, sdrc_base + OFFS(SDRC_MCFG_0 + offset));
- writel(ARCV | ARE_ARCV_1, sdrc_base + OFFS(SDRC_RFR_CTRL + offset));
- writel(V_ACTIMA_165, sdrc_base +
- OFFS(SDRC_ACTIM_CTRLA_0 + actim_offs));
- writel(V_ACTIMB_165, sdrc_base +
- OFFS(SDRC_ACTIM_CTRLB_0 + actim_offs));
-
- writel(CMD_NOP, sdrc_base + OFFS(SDRC_MANUAL_0 + offset));
- writel(CMD_PRECHARGE, sdrc_base + OFFS(SDRC_MANUAL_0 + offset));
- writel(CMD_AUTOREFRESH, sdrc_base + OFFS(SDRC_MANUAL_0 + offset));
- writel(CMD_AUTOREFRESH, sdrc_base + OFFS(SDRC_MANUAL_0 + offset));
+ DEEPPD | DDR_SDRAM, &sdrc_base->cs[cs].mcfg);
+ writel(ARCV | ARE_ARCV_1, &sdrc_base->cs[cs].rfr_ctrl);
+ writel(V_ACTIMA_165, &sdrc_actim_base->ctrla);
+ writel(V_ACTIMB_165, &sdrc_actim_base->ctrlb);
+
+ writel(CMD_NOP, &sdrc_base ->cs[cs].manual);
+ writel(CMD_PRECHARGE, &sdrc_base->cs[cs].manual);
+ writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
+ writel(CMD_AUTOREFRESH, &sdrc_base->cs[cs].manual);
/*
* CAS latency 3, Write Burst = Read Burst, Serial Mode,
* Burst length = 4
*/
- writel(CASL3 | BURSTLENGTH4, sdrc_base + OFFS(SDRC_MR_0 + offset));
+ writel(CASL3 | BURSTLENGTH4, &sdrc_base->cs[cs].mr);
- if (!mem_ok(offset))
- writel(0, sdrc_base + OFFS(SDRC_MCFG_0 + offset));
+ if (!mem_ok(cs))
+ writel(0, &sdrc_base->cs[cs].mcfg);
}
-void enable_gpmc_config(u32 *gpmc_config, u32 *gpmc_cs_base, u32 base,
+void enable_gpmc_config(u32 *gpmc_config, gpmc_csx_t *gpmc_cs_base, u32 base,
u32 size)
{
- writel(0, gpmc_cs_base + OFFS(GPMC_CONFIG7));
+ writel(0, &gpmc_cs_base->config7);
sdelay(1000);
/* Delay for settling */
- writel(gpmc_config[0], gpmc_cs_base + OFFS(GPMC_CONFIG1));
- writel(gpmc_config[1], gpmc_cs_base + OFFS(GPMC_CONFIG2));
- writel(gpmc_config[2], gpmc_cs_base + OFFS(GPMC_CONFIG3));
- writel(gpmc_config[3], gpmc_cs_base + OFFS(GPMC_CONFIG4));
- writel(gpmc_config[4], gpmc_cs_base + OFFS(GPMC_CONFIG5));
- writel(gpmc_config[5], gpmc_cs_base + OFFS(GPMC_CONFIG6));
+ writel(gpmc_config[0], &gpmc_cs_base->config1);
+ writel(gpmc_config[1], &gpmc_cs_base->config2);
+ writel(gpmc_config[2], &gpmc_cs_base->config3);
+ writel(gpmc_config[3], &gpmc_cs_base->config4);
+ writel(gpmc_config[4], &gpmc_cs_base->config5);
+ writel(gpmc_config[5], &gpmc_cs_base->config6);
/* Enable the config */
writel((((size & 0xF) << 8) | ((base >> 24) & 0x3F) |
- (1 << 6)), gpmc_cs_base + OFFS(GPMC_CONFIG7));
+ (1 << 6)), &gpmc_cs_base->config7);
sdelay(2000);
}
@@ -243,8 +247,8 @@ void gpmc_init(void)
{
/* putting a blanket check on GPMC based on ZeBu for now */
u32 *gpmc_config = NULL;
- u32 *gpmc_base = (u32 *)GPMC_BASE;
- u32 *gpmc_cs_base = (u32 *)GPMC_CONFIG_CS0_BASE;
+ gpmc_t *gpmc_base = (gpmc_t *)GPMC_BASE;
+ gpmc_csx_t *gpmc_cs_base = (gpmc_csx_t *)GPMC_CONFIG_CS0_BASE;
u32 base = 0;
u32 size = 0;
u32 f_off = CONFIG_SYS_MONITOR_LEN;
@@ -252,24 +256,25 @@ void gpmc_init(void)
u32 config = 0;
/* global settings */
- writel(0, gpmc_base + OFFS(GPMC_IRQENABLE)); /* isr's sources masked */
- writel(0, gpmc_base + OFFS(GPMC_TIMEOUT_CONTROL));/* timeout disable */
+ writel(0, &gpmc_base->irqenable); /* isr's sources masked */
+ writel(0, &gpmc_base->timeout_control);/* timeout disable */
- config = readl(gpmc_base + OFFS(GPMC_CONFIG));
+ config = readl(&gpmc_base->config);
config &= (~0xf00);
- writel(config, gpmc_base + OFFS(GPMC_CONFIG));
+ writel(config, &gpmc_base->config);
/*
* Disable the GPMC0 config set by ROM code
* It conflicts with our MPDB (both at 0x08000000)
*/
- writel(0, gpmc_cs_base + OFFS(GPMC_CONFIG7));
+ writel(0, &gpmc_cs_base->config7);
sdelay(1000);
#if defined(CONFIG_CMD_NAND) /* CS 0 */
gpmc_config = gpmc_m_nand;
- nand_cs_base = (u32 *)(GPMC_CONFIG_CS0_BASE +
- (GPMC_CS * GPMC_CONFIG_WIDTH));
+ gpmc_cfg_base = gpmc_base;
+ nand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
+ (GPMC_CS * GPMC_CONFIG_WIDTH));
base = PISMO1_NAND_BASE;
size = PISMO1_NAND_SIZE;
enable_gpmc_config(gpmc_config, nand_cs_base, base, size);
@@ -287,8 +292,8 @@ void gpmc_init(void)
#if defined(CONFIG_CMD_ONENAND)
gpmc_config = gpmc_onenand;
- onenand_cs_base = (u32 *)(GPMC_CONFIG_CS0_BASE +
- (GPMC_CS * GPMC_CONFIG_WIDTH));
+ onenand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
+ (GPMC_CS * GPMC_CONFIG_WIDTH));
base = PISMO1_ONEN_BASE;
size = PISMO1_ONEN_SIZE;
enable_gpmc_config(gpmc_config, onenand_cs_base, base, size);
Index: u-boot-arm/board/omap3/evm/evm.c
===================================================================
--- u-boot-arm.orig/board/omap3/evm/evm.c
+++ u-boot-arm/board/omap3/evm/evm.c
@@ -89,38 +89,35 @@ void set_muxconf_regs(void)
*****************************************************************************/
static void setup_net_chip(void)
{
- unsigned int *gpio3_base = (unsigned int *)OMAP34XX_GPIO3_BASE;
- unsigned int *gpmc_cs6_base = (unsigned int *)GPMC_CONFIG_CS6_BASE;
- unsigned short *ctrl_base = (unsigned short *)OMAP34XX_CTRL_BASE;
+ gpio_t *gpio3_base = (gpio_t *)OMAP34XX_GPIO3_BASE;
+ gpmc_csx_t *gpmc_cs6_base = (gpmc_csx_t *)GPMC_CONFIG_CS6_BASE;
+ ctrl_t *ctrl_base = (ctrl_t *)OMAP34XX_CTRL_BASE;
/* Configure GPMC registers */
- writel(NET_GPMC_CONFIG1, gpmc_cs6_base + OFFS(GPMC_CONFIG1));
- writel(NET_GPMC_CONFIG2, gpmc_cs6_base + OFFS(GPMC_CONFIG2));
- writel(NET_GPMC_CONFIG3, gpmc_cs6_base + OFFS(GPMC_CONFIG3));
- writel(NET_GPMC_CONFIG4, gpmc_cs6_base + OFFS(GPMC_CONFIG4));
- writel(NET_GPMC_CONFIG5, gpmc_cs6_base + OFFS(GPMC_CONFIG5));
- writel(NET_GPMC_CONFIG6, gpmc_cs6_base + OFFS(GPMC_CONFIG6));
- writel(NET_GPMC_CONFIG7, gpmc_cs6_base + OFFS(GPMC_CONFIG7));
+ writel(NET_GPMC_CONFIG1, &gpmc_cs6_base->config1);
+ writel(NET_GPMC_CONFIG2, &gpmc_cs6_base->config2);
+ writel(NET_GPMC_CONFIG3, &gpmc_cs6_base->config3);
+ writel(NET_GPMC_CONFIG4, &gpmc_cs6_base->config4);
+ writel(NET_GPMC_CONFIG5, &gpmc_cs6_base->config5);
+ writel(NET_GPMC_CONFIG6, &gpmc_cs6_base->config6);
+ writel(NET_GPMC_CONFIG7, &gpmc_cs6_base->config7);
/* Enable off mode for NWE in PADCONF_GPMC_NWE register */
- writew(readw(ctrl_base + (CONTROL_PADCONF_GPMC_NWE >> 1)) | 0x0E00,
- ctrl_base + (CONTROL_PADCONF_GPMC_NWE >> 1));
+ writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
/* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
- writew(readw(ctrl_base + (CONTROL_PADCONF_GPMC_NOE >> 1)) | 0x0E00,
- ctrl_base + (CONTROL_PADCONF_GPMC_NOE >> 1));
+ writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
/* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
- writew(readw(ctrl_base + (CONTROL_PADCONF_GPMC_NADV_ALE >> 1)) | 0x0E00,
- ctrl_base + (CONTROL_PADCONF_GPMC_NADV_ALE >> 1));
+ writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
+ &ctrl_base->gpmc_nadv_ale);
/* Make GPIO 64 as output pin */
- writel(readl(gpio3_base + OFFS(GPIO_OE)) & ~(GPIO0),
- gpio3_base + OFFS(GPIO_OE));
+ writel(readl(&gpio3_base->oe) & ~(GPIO0), &gpio3_base->oe);
/* Now send a pulse on the GPIO pin */
- writel(GPIO0, gpio3_base + OFFS(GPIO_SETDATAOUT));
+ writel(GPIO0, &gpio3_base->setdataout);
udelay(1);
- writel(GPIO0, gpio3_base + OFFS(GPIO_CLEARDATAOUT));
+ writel(GPIO0, &gpio3_base->cleardataout);
udelay(1);
- writel(GPIO0, gpio3_base + OFFS(GPIO_SETDATAOUT));
+ writel(GPIO0, &gpio3_base->setdataout);
}
Index: u-boot-arm/include/configs/omap3_beagle.h
===================================================================
--- u-boot-arm.orig/include/configs/omap3_beagle.h
+++ u-boot-arm/include/configs/omap3_beagle.h
@@ -285,7 +285,8 @@
#define ENV_IS_VARIABLE 1
#ifndef __ASSEMBLY__
-extern unsigned int *nand_cs_base;
+extern gpmc_csx_t *nand_cs_base;
+extern gpmc_t *gpmc_cfg_base;
extern unsigned int boot_flash_base;
extern volatile unsigned int boot_flash_env_addr;
extern unsigned int boot_flash_off;
@@ -295,15 +296,17 @@ extern unsigned int boot_flash_type;
#define WRITE_NAND_COMMAND(d, adr)\
- writel(d, (nand_cs_base + OFFS(GPMC_NAND_CMD)))
+ writel(d, &nand_cs_base->nand_cmd)
#define WRITE_NAND_ADDRESS(d, adr)\
- writel(d, (nand_cs_base + OFFS(GPMC_NAND_ADR)))
-#define WRITE_NAND(d, adr) writew(d, (nand_cs_base + OFFS(GPMC_NAND_DAT)))
-#define READ_NAND(adr) readl((nand_cs_base + OFFS(GPMC_NAND_DAT)))
+ writel(d, &nand_cs_base->nand_adr)
+#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
+#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
/* Other NAND Access APIs */
-#define NAND_WP_OFF() do {readl(GPMC_CONFIG_REG) |= GPMC_CONFIG_WP; } while (0)
-#define NAND_WP_ON() do {readl(GPMC_CONFIG_REG) &= ~GPMC_CONFIG_WP; } while (0)
+#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |= GPMC_CONFIG_WP; } \
+ while (0)
+#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &= ~GPMC_CONFIG_WP; } \
+ while (0)
#define NAND_DISABLE_CE(nand)
#define NAND_ENABLE_CE(nand)
#define NAND_WAIT_READY(nand) udelay(10)
Index: u-boot-arm/include/configs/omap3_evm.h
===================================================================
--- u-boot-arm.orig/include/configs/omap3_evm.h
+++ u-boot-arm/include/configs/omap3_evm.h
@@ -290,7 +290,8 @@
#define ENV_IS_VARIABLE 1
#ifndef __ASSEMBLY__
-extern unsigned int *nand_cs_base;
+extern gpmc_csx_t *nand_cs_base;
+extern gpmc_t *gpmc_cfg_base;
extern unsigned int boot_flash_base;
extern volatile unsigned int boot_flash_env_addr;
extern unsigned int boot_flash_off;
@@ -300,20 +301,21 @@ extern unsigned int boot_flash_type;
#define WRITE_NAND_COMMAND(d, adr)\
- writel(d, (nand_cs_base + OFFS(GPMC_NAND_CMD)))
+ writel(d, &nand_cs_base->nand_cmd)
#define WRITE_NAND_ADDRESS(d, adr)\
- writel(d, (nand_cs_base + OFFS(GPMC_NAND_ADR)))
-#define WRITE_NAND(d, adr) writel(d, (nand_cs_base + OFFS(GPMC_NAND_DAT)))
-#define READ_NAND(adr) readl((nand_cs_base + OFFS(GPMC_NAND_DAT)))
+ writel(d, &nand_cs_base->nand_adr)
+#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
+#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
/* Other NAND Access APIs */
-#define NAND_WP_OFF() do {readl(GPMC_CONFIG_REG) |= GPMC_CONFIG_WP; } while (0)
-#define NAND_WP_ON() do {readl(GPMC_CONFIG_REG) &= ~GPMC_CONFIG_WP; } while (0)
+#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |= GPMC_CONFIG_WP; } \
+ while (0)
+#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &= ~GPMC_CONFIG_WP; } \
+ while (0)
#define NAND_DISABLE_CE(nand)
#define NAND_ENABLE_CE(nand)
#define NAND_WAIT_READY(nand) udelay(10)
-
/*----------------------------------------------------------------------------
* SMSC9115 Ethernet from SMSC9118 family
*----------------------------------------------------------------------------
Index: u-boot-arm/include/configs/omap3_overo.h
===================================================================
--- u-boot-arm.orig/include/configs/omap3_overo.h
+++ u-boot-arm/include/configs/omap3_overo.h
@@ -277,7 +277,8 @@
#define ENV_IS_VARIABLE 1
#ifndef __ASSEMBLY__
-extern unsigned int *nand_cs_base;
+extern gpmc_csx_t *nand_cs_base;
+extern gpmc_t *gpmc_cfg_base;
extern unsigned int boot_flash_base;
extern volatile unsigned int boot_flash_env_addr;
extern unsigned int boot_flash_off;
@@ -287,15 +288,17 @@ extern unsigned int boot_flash_type;
#define WRITE_NAND_COMMAND(d, adr)\
- writel(d, (nand_cs_base + OFFS(GPMC_NAND_CMD)))
+ writel(d, &nand_cs_base->nand_cmd)
#define WRITE_NAND_ADDRESS(d, adr)\
- writel(d, (nand_cs_base + OFFS(GPMC_NAND_ADR)))
-#define WRITE_NAND(d, adr) writel(d, (nand_cs_base + OFFS(GPMC_NAND_DAT)))
-#define READ_NAND(adr) readl((nand_cs_base + OFFS(GPMC_NAND_DAT)))
+ writel(d, &nand_cs_base->nand_adr)
+#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
+#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
/* Other NAND Access APIs */
-#define NAND_WP_OFF() do {readl(GPMC_CONFIG_REG) |= GPMC_CONFIG_WP; } while (0)
-#define NAND_WP_ON() do {readl(GPMC_CONFIG_REG) &= ~GPMC_CONFIG_WP; } while (0)
+#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |= GPMC_CONFIG_WP; } \
+ while (0)
+#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &= ~GPMC_CONFIG_WP; } \
+ while (0)
#define NAND_DISABLE_CE(nand)
#define NAND_ENABLE_CE(nand)
#define NAND_WAIT_READY(nand) udelay(10)
Index: u-boot-arm/include/configs/omap3_pandora.h
===================================================================
--- u-boot-arm.orig/include/configs/omap3_pandora.h
+++ u-boot-arm/include/configs/omap3_pandora.h
@@ -276,7 +276,8 @@
#define ENV_IS_VARIABLE 1
#ifndef __ASSEMBLY__
-extern unsigned int *nand_cs_base;
+extern gpmc_csx_t *nand_cs_base;
+extern gpmc_t *gpmc_cfg_base;
extern unsigned int boot_flash_base;
extern volatile unsigned int boot_flash_env_addr;
extern unsigned int boot_flash_off;
@@ -286,15 +287,17 @@ extern unsigned int boot_flash_type;
#define WRITE_NAND_COMMAND(d, adr)\
- writel(d, (nand_cs_base + OFFS(GPMC_NAND_CMD)))
+ writel(d, &nand_cs_base->nand_cmd)
#define WRITE_NAND_ADDRESS(d, adr)\
- writel(d, (nand_cs_base + OFFS(GPMC_NAND_ADR)))
-#define WRITE_NAND(d, adr) writew(d, (nand_cs_base + OFFS(GPMC_NAND_DAT)))
-#define READ_NAND(adr) readl((nand_cs_base + OFFS(GPMC_NAND_DAT)))
+ writel(d, &nand_cs_base->nand_adr)
+#define WRITE_NAND(d, adr) writew(d, &nand_cs_base->nand_dat)
+#define READ_NAND(adr) readl(&nand_cs_base->nand_dat)
/* Other NAND Access APIs */
-#define NAND_WP_OFF() do {readl(GPMC_CONFIG_REG) |= GPMC_CONFIG_WP; } while (0)
-#define NAND_WP_ON() do {readl(GPMC_CONFIG_REG) &= ~GPMC_CONFIG_WP; } while (0)
+#define NAND_WP_OFF() do {readl(&gpmc_cfg_base->config) |= GPMC_CONFIG_WP; } \
+ while (0)
+#define NAND_WP_ON() do {readl(&gpmc_cfg_base->config) &= ~GPMC_CONFIG_WP; } \
+ while (0)
#define NAND_DISABLE_CE(nand)
#define NAND_ENABLE_CE(nand)
#define NAND_WAIT_READY(nand) udelay(10)
Index: u-boot-arm/include/asm-arm/arch-omap3/omap3.h
===================================================================
--- u-boot-arm.orig/include/asm-arm/arch-omap3/omap3.h
+++ u-boot-arm/include/asm-arm/arch-omap3/omap3.h
@@ -75,7 +75,15 @@
/* 32KTIMER */
#define SYNC_32KTIMER_BASE 0x48320000
-#define S32K_CR 0x10
+
+#ifndef __ASSEMBLY__
+
+typedef struct s32ktimer {
+ unsigned char res[0x10];
+ unsigned int s32k_cr; /* 0x10 */
+} s32ktimer_t;
+
+#endif /* __ASSEMBLY__ */
/* OMAP3 GPIO registers */
#define OMAP34XX_GPIO1_BASE 0x48310000
@@ -85,9 +93,15 @@
#define OMAP34XX_GPIO5_BASE 0x49056000
#define OMAP34XX_GPIO6_BASE 0x49058000
-#define GPIO_OE 0x34
-#define GPIO_CLEARDATAOUT 0x90
-#define GPIO_SETDATAOUT 0x94
+#ifndef __ASSEMBLY__
+typedef struct gpio {
+ unsigned char res1[0x34];
+ unsigned int oe; /* 0x34 */
+ unsigned char res2[0x58];
+ unsigned int cleardataout; /* 0x90 */
+ unsigned int setdataout; /* 0x94 */
+} gpio_t;
+#endif /* __ASSEMBLY__ */
#define GPIO0 (0x1 << 0)
#define GPIO1 (0x1 << 1)
Index: u-boot-arm/include/asm-arm/arch-omap3/mem.h
===================================================================
--- u-boot-arm.orig/include/asm-arm/arch-omap3/mem.h
+++ u-boot-arm/include/asm-arm/arch-omap3/mem.h
@@ -25,18 +25,19 @@
#ifndef _MEM_H_
#define _MEM_H_
-#define SDRC_CS0_OSET 0x0
-#define SDRC_CS1_OSET 0x30 /* mirror CS1 regs appear offset 0x30 from CS0 */
+//#define SDRC_CS0_OSET 0x0
+//#define SDRC_CS1_OSET 0x30 /* mirror CS1 regs appear offset 0x30 from CS0 */
-#ifndef __ASSEMBLY__
+#define CS0 0x0
+#define CS1 0x1 /* mirror CS1 regs appear offset 0x30 from CS0 */
+#ifndef __ASSEMBLY__
typedef enum {
STACKED = 0,
IP_DDR = 1,
COMBO_DDR = 2,
IP_SDR = 3,
} mem_t;
-
#endif /* __ASSEMBLY__ */
#define EARLY_INIT 1
Index: u-boot-arm/board/omap3/beagle/beagle.c
===================================================================
--- u-boot-arm.orig/board/omap3/beagle/beagle.c
+++ u-boot-arm/board/omap3/beagle/beagle.c
@@ -62,8 +62,8 @@ int misc_init_r(void)
{
unsigned char byte;
- unsigned int *gpio5_base = (unsigned int *)OMAP34XX_GPIO5_BASE;
- unsigned int *gpio6_base = (unsigned int *)OMAP34XX_GPIO6_BASE;
+ gpio_t *gpio5_base = (gpio_t *)OMAP34XX_GPIO5_BASE;
+ gpio_t *gpio6_base = (gpio_t *)OMAP34XX_GPIO6_BASE;
#ifdef CONFIG_DRIVER_OMAP34XX_I2C
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
@@ -97,18 +97,14 @@ int misc_init_r(void)
i2c_write(PWRMGT_ADDR_ID3, LEDEN, 1, &byte, 1);
/* Configure GPIOs to output */
- writel(~((GPIO10) | GPIO9 | GPIO3 | GPIO2),
- gpio6_base + OFFS(GPIO_OE));
+ writel(~((GPIO10) | GPIO9 | GPIO3 | GPIO2), &gpio6_base->oe);
writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
- GPIO15 | GPIO14 | GPIO13 | GPIO12),
- gpio5_base + OFFS(GPIO_OE));
+ GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
/* Set GPIOs */
- writel(GPIO10 | GPIO9 | GPIO3 | GPIO2,
- gpio6_base + OFFS(GPIO_SETDATAOUT));
+ writel(GPIO10 | GPIO9 | GPIO3 | GPIO2, &gpio6_base->setdataout);
writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
- GPIO15 | GPIO14 | GPIO13 | GPIO12,
- gpio5_base + OFFS(GPIO_SETDATAOUT));
+ GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
return 0;
}
Index: u-boot-arm/board/omap3/overo/overo.c
===================================================================
--- u-boot-arm.orig/board/omap3/overo/overo.c
+++ u-boot-arm/board/omap3/overo/overo.c
@@ -61,8 +61,8 @@ int misc_init_r(void)
{
unsigned char byte;
- unsigned int *gpio5_base = (unsigned int *)OMAP34XX_GPIO5_BASE;
- unsigned int *gpio6_base = (unsigned int *)OMAP34XX_GPIO6_BASE;
+ gpio_t *gpio5_base = (gpio_t *)OMAP34XX_GPIO5_BASE;
+ gpio_t *gpio6_base = (gpio_t *)OMAP34XX_GPIO6_BASE;
#ifdef CONFIG_DRIVER_OMAP34XX_I2C
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
@@ -102,18 +102,14 @@ int misc_init_r(void)
i2c_write(PWRMGT_ADDR_ID3, LEDEN, 1, &byte, 1);
/* Configure GPIOs to output */
- writel(~((GPIO10) | GPIO9 | GPIO3 | GPIO2),
- gpio6_base + OFFS(GPIO_OE));
+ writel(~((GPIO10) | GPIO9 | GPIO3 | GPIO2), &gpio6_base->oe);
writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
- GPIO15 | GPIO14 | GPIO13 | GPIO12),
- gpio5_base + OFFS(GPIO_OE));
+ GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
/* Set GPIOs */
- writel(GPIO10 | GPIO9 | GPIO3 | GPIO2,
- gpio6_base + OFFS(GPIO_SETDATAOUT));
+ writel(GPIO10 | GPIO9 | GPIO3 | GPIO2, &gpio6_base->setdataout);
writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
- GPIO15 | GPIO14 | GPIO13 | GPIO12,
- gpio5_base + OFFS(GPIO_SETDATAOUT));
+ GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
return 0;
}
Index: u-boot-arm/board/omap3/pandora/pandora.c
===================================================================
--- u-boot-arm.orig/board/omap3/pandora/pandora.c
+++ u-boot-arm/board/omap3/pandora/pandora.c
@@ -61,10 +61,10 @@ int misc_init_r(void)
{
unsigned char byte;
- unsigned int *gpio1_base = (unsigned int *)OMAP34XX_GPIO1_BASE;
- unsigned int *gpio4_base = (unsigned int *)OMAP34XX_GPIO4_BASE;
- unsigned int *gpio5_base = (unsigned int *)OMAP34XX_GPIO5_BASE;
- unsigned int *gpio6_base = (unsigned int *)OMAP34XX_GPIO6_BASE;
+ gpio_t *gpio1_base = (gpio_t *)OMAP34XX_GPIO1_BASE;
+ gpio_t *gpio4_base = (gpio_t *)OMAP34XX_GPIO4_BASE;
+ gpio_t *gpio5_base = (gpio_t *)OMAP34XX_GPIO5_BASE;
+ gpio_t *gpio6_base = (gpio_t *)OMAP34XX_GPIO6_BASE;
#ifdef CONFIG_DRIVER_OMAP34XX_I2C
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
@@ -98,16 +98,15 @@ int misc_init_r(void)
i2c_write(PWRMGT_ADDR_ID3, LEDEN, 1, &byte, 1);
/* Configure GPIOs to output */
- writel(~(GPIO14 | GPIO15 | GPIO16 | GPIO23),
- gpio1_base + OFFS(GPIO_OE));
- writel(~GPIO22, gpio4_base + OFFS(GPIO_OE)); /* 118 */
+ writel(~(GPIO14 | GPIO15 | GPIO16 | GPIO23), &gpio1_base->oe);
+ writel(~GPIO22, &gpio4_base->oe); /* 118 */
writel(~(GPIO0 | GPIO1 | GPIO28 | GPIO29 | GPIO30 | GPIO31),
- gpio5_base + OFFS(GPIO_OE)); /* 128, 129, 156-159 */
- writel(~GPIO4, gpio6_base + OFFS(GPIO_OE)); /* 164 */
+ &gpio5_base->oe); /* 128, 129, 156-159 */
+ writel(~GPIO4, &gpio6_base->oe); /* 164 */
/* Set GPIOs */
- writel(GPIO28, gpio5_base + OFFS(GPIO_SETDATAOUT));
- writel(GPIO4, gpio6_base + OFFS(GPIO_SETDATAOUT));
+ writel(GPIO28, &gpio5_base->setdataout);
+ writel(GPIO4, &gpio6_base->setdataout);
return 0;
}
Index: u-boot-arm/cpu/arm_cortexa8/omap3/syslib.c
===================================================================
--- u-boot-arm.orig/cpu/arm_cortexa8/omap3/syslib.c
+++ u-boot-arm/cpu/arm_cortexa8/omap3/syslib.c
@@ -43,26 +43,27 @@ void sdelay(unsigned long loops)
/*****************************************************************
* sr32 - clear & set a value in a bit range for a 32 bit address
*****************************************************************/
-void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
+void sr32(void *addr, u32 start_bit, u32 num_bits, u32 value)
{
u32 tmp, msk = 0;
msk = 1 << num_bits;
--msk;
- tmp = readl(addr) & ~(msk << start_bit);
+ tmp = readl((u32)addr) & ~(msk << start_bit);
tmp |= value << start_bit;
- writel(tmp, addr);
+ writel(tmp, (u32)addr);
}
/*********************************************************************
* wait_on_value() - common routine to allow waiting for changes in
* volatile regs.
*********************************************************************/
-u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
+u32 wait_on_value(u32 read_bit_mask, u32 match_value, void *read_addr,
+ u32 bound)
{
u32 i = 0, val;
do {
++i;
- val = readl(read_addr) & read_bit_mask;
+ val = readl((u32)read_addr) & read_bit_mask;
if (val == match_value)
return 1;
if (i == bound)
Index: u-boot-arm/include/asm-arm/arch-omap3/sys_proto.h
===================================================================
--- u-boot-arm.orig/include/asm-arm/arch-omap3/sys_proto.h
+++ u-boot-arm/include/asm-arm/arch-omap3/sys_proto.h
@@ -61,8 +61,8 @@ void setup_auxcr(void);
void try_unlock_memory(void);
u32 get_boot_type(void);
void v7_flush_dcache_all(u32);
-void sr32(u32, u32, u32, u32);
-u32 wait_on_value(u32, u32, u32, u32);
+void sr32(void *, u32, u32, u32);
+u32 wait_on_value(u32, u32, void *, u32);
void sdelay(unsigned long);
void make_cs1_contiguous(void);
void omap_nand_switch_ecc(int);
2
1
Hi,
the net/net.c implemenation of timeouts assumes that get_timer() returns
values in milliseconds. As this is true for most platforms, it does not
apply to PXA3x where the OSCR register increments with more than 3MHz.
The following patch fixes the problem by calculation with the
CONFIG_SYS_HZ variable.
Best regards,
Daniel
diff --git a/net/net.c b/net/net.c
index 77e83b5..b9326de 100644
--- a/net/net.c
+++ b/net/net.c
@@ -206,6 +206,11 @@ uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
ulong NetArpWaitTimerStart;
int NetArpWaitTry;
+static long net_get_timer(long base)
+{
+ return get_timer(base) / (CONFIG_SYS_HZ / 1000);
+}
+
void ArpRequest (void)
{
int i;
@@ -256,7 +261,7 @@ void ArpTimeoutCheck(void)
if (!NetArpWaitPacketIP)
return;
- t = get_timer(0);
+ t = net_get_timer(0);
/* check for arp timeout */
if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT) {
@@ -517,7 +522,7 @@ restart:
* Check for a timeout, and run the timeout handler
* if we have one.
*/
- if (timeHandler && ((get_timer(0) - timeStart) > timeDelta)) {
+ if (timeHandler && ((net_get_timer(0) - timeStart) > timeDelta)) {
thand_f *x;
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
@@ -639,7 +644,7 @@ NetSetTimeout(ulong iv, thand_f * f)
timeHandler = (thand_f *)0;
} else {
timeHandler = f;
- timeStart = get_timer(0);
+ timeStart = net_get_timer(0);
timeDelta = iv;
}
}
@@ -684,7 +689,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
/* and do the ARP request */
NetArpWaitTry = 1;
- NetArpWaitTimerStart = get_timer(0);
+ NetArpWaitTimerStart = net_get_timer(0);
ArpRequest();
return 1; /* waiting */
}
@@ -755,7 +760,7 @@ int PingSend(void)
/* and do the ARP request */
NetArpWaitTry = 1;
- NetArpWaitTimerStart = get_timer(0);
+ NetArpWaitTimerStart = net_get_timer(0);
ArpRequest();
return 1; /* waiting */
}
3
15
Commit 6b59e03e0237a40a2305ea385defdfd92000978b
lcd: Let the board code show board-specific info
introduced some bugs which prevent U-Boot building
for lwmon board if CONFIG_LCD_INFO_BELOW_LOGO will
be defined in the board configuration.
Also "LCD enabled" building for TQM823L doesn't work
since this commit.
This patch fixes above-mentioned issues.
Signed-off-by: Anatolij Gustschin <agust(a)denx.de>
---
board/lwmon/lwmon.c | 2 --
board/tqc/tqm8xx/tqm8xx.c | 5 +++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/board/lwmon/lwmon.c b/board/lwmon/lwmon.c
index 9e57246..d062466 100644
--- a/board/lwmon/lwmon.c
+++ b/board/lwmon/lwmon.c
@@ -773,8 +773,6 @@ void lcd_show_board_info(void)
#ifdef CONFIG_LCD_INFO_BELOW_LOGO
lcd_printf ("MPC823 CPU at %s MHz\n",
strmhz(temp, gd->cpu_clk));
- lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3,
- info, strlen(info));
lcd_printf (" %ld MB RAM, %ld MB Flash\n",
gd->ram_size >> 20,
gd->bd->bi_flashsize >> 20 );
diff --git a/board/tqc/tqm8xx/tqm8xx.c b/board/tqc/tqm8xx/tqm8xx.c
index 928afed..d8a19a4 100644
--- a/board/tqc/tqm8xx/tqm8xx.c
+++ b/board/tqc/tqm8xx/tqm8xx.c
@@ -570,17 +570,18 @@ void ide_led (uchar led, uchar status)
#ifdef CONFIG_LCD_INFO
#include <lcd.h>
+#include <version.h>
void lcd_show_board_info(void)
{
+ char temp[32];
+
lcd_printf ("%s (%s - %s)\n", U_BOOT_VERSION, __DATE__, __TIME__);
lcd_printf ("(C) 2008 DENX Software Engineering GmbH\n");
lcd_printf (" Wolfgang DENK, wd(a)denx.de\n");
#ifdef CONFIG_LCD_INFO_BELOW_LOGO
lcd_printf ("MPC823 CPU at %s MHz\n",
strmhz(temp, gd->cpu_clk));
- lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3,
- info, strlen(info));
lcd_printf (" %ld MB RAM, %ld MB Flash\n",
gd->ram_size >> 20,
gd->bd->bi_flashsize >> 20 );
--
1.5.3.3
2
1
Hi!
The patch attached implements the FFS/UFS FreeBSD filesystem
support for u-boot. Hopefully, it will be useful for
someone.
diff -r 5221092ac503 -r e78f761f0c62 Makefile
--- a/Makefile Fri Oct 31 01:46:20 2008 +0300
+++ b/Makefile Fri Oct 31 02:00:44 2008 +0300
@@ -210,7 +210,7 @@
endif
LIBS += lib_$(ARCH)/lib$(ARCH).a
LIBS += fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a \
- fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a
+ fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a fs/ffs/libffs.a
LIBS += net/libnet.a
LIBS += disk/libdisk.a
LIBS += drivers/bios_emulator/libatibiosemu.a
diff -r 5221092ac503 -r e78f761f0c62 common/Makefile
--- a/common/Makefile Fri Oct 31 01:46:20 2008 +0300
+++ b/common/Makefile Fri Oct 31 02:00:44 2008 +0300
@@ -62,6 +62,7 @@
COBJS-y += cmd_fdc.o
COBJS-$(CONFIG_OF_LIBFDT) += cmd_fdt.o fdt_support.o
COBJS-$(CONFIG_CMD_FDOS) += cmd_fdos.o
+COBJS-$(CONFIG_CMD_FFS) += cmd_ffs.o
COBJS-$(CONFIG_CMD_FLASH) += cmd_flash.o
ifdef CONFIG_FPGA
COBJS-$(CONFIG_CMD_FPGA) += cmd_fpga.o
diff -r 5221092ac503 -r e78f761f0c62 common/cmd_ffs.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/cmd_ffs.c Fri Oct 31 02:00:44 2008 +0300
@@ -0,0 +1,208 @@
+/*-
+ * Copyright (c) 2008 Stanislav Sedov <stas(a)FreeBSD.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * FFSv2 filesystem driver.
+ */
+
+#include <common.h>
+#include <config.h>
+#include <command.h>
+#include <image.h>
+#include <asm/byteorder.h>
+#include <ffs.h>
+#include <part.h>
+
+int
+ffs_parse_device_spec(char *iface, const char *str,
+ block_dev_desc_t **desc, long *dev, long *part)
+{
+ char *ep, *p;
+
+ *dev = simple_strtoul(str, &ep, 16);
+ if ((*ep != '\0' && *ep != ':') || *str == '\0') {
+ printf("Error: invalid device number: %s\n", str);
+ return (1);
+ }
+
+ *desc = get_dev(iface, *dev);
+ if (*desc == NULL) {
+ printf("Error: block device %ld on %s is not supported\n",
+ *dev, iface);
+ return (1);
+ }
+
+ if (*ep) {
+ p = ++ep;
+ *part = simple_strtoul(p, &ep, 16);
+ if (p == '\0' || *ep != '\0') {
+ printf("Error: invalid partition number %s\n", p);
+ return (1);
+ }
+ } else {
+ *part = 0; /* Whole disk. */
+ }
+ return (0);
+}
+
+int
+do_ffs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ char *filename;
+ long dev, part;
+ block_dev_desc_t *dev_desc;
+ int error;
+
+ if (argc < 3) {
+ printf("Usage:\n%s\n", cmdtp->usage);
+ return (1);
+ }
+
+ error = ffs_parse_device_spec(argv[1], argv[2], &dev_desc, &dev, &part);
+ if (error != 0)
+ return (error);
+
+ filename = argc == 4 ? argv[3] : "/";
+ error = ffs_probe(dev_desc, part);
+ if (error != 0) {
+ printf("Error: could not mount %ld dev %ld part on %s: %d\n",
+ dev, part, argv[1], error);
+ return (1);
+ }
+
+ error = ffs_ls(dev_desc, part, filename);
+ if (error != 0) {
+ printf("Error: ffs_ls: %d\n", error);
+ return (1);
+ }
+ return (0);
+}
+
+int
+do_ffs_load(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ char *filename;
+ long dev, part;
+ unsigned long addr, length;
+ block_dev_desc_t *dev_desc;
+ char buf[12];
+ unsigned long count;
+ char *str, *ep;
+ int error;
+
+ if (argc >= 4) { /* loadaddr is given. */
+ addr = simple_strtoul(argv[3], &ep, 16);
+ if (*ep != '\0' || *argv[3] == '\0') {
+ printf("Error: invalid load address: %s\n", argv[3]);
+ return (1);
+ }
+ } else {
+ str = getenv("loadaddr");
+ if (str != NULL) {
+ addr = simple_strtoul(str, &ep, 16);
+ if (*ep != '\0' || *argv[3] == '\0') {
+ printf("Error: invalid load address: %s\n",
+ argv[3]);
+ return (1);
+ }
+ } else {
+ addr = CFG_LOAD_ADDR;
+ }
+ }
+
+ if (argc >= 5) /* filename is given. */
+ filename = argv[4];
+ else
+ filename = getenv("bootfile");
+ if (filename == NULL || filename == '\0') {
+ printf("Error: no filename to load\n");
+ return (1);
+ }
+
+ if (argc == 6) { /* count is given. */
+ count = simple_strtoul(argv[5], &ep, 16);
+ if (*ep != '\0' || *argv[5] == '\0') {
+ printf("Error: invalid count specification: %s\n",
+ argv[5]);
+ return (1);
+ }
+ } else {
+ count = 0;
+ }
+
+ if (argc < 3 || argc > 6) { /* Catch up on errors. */
+ printf("Usage:\n%s\n", cmdtp->usage);
+ return (1);
+ }
+
+ error = ffs_parse_device_spec(argv[1], argv[2], &dev_desc, &dev, &part);
+ if (error != 0)
+ return (error);
+
+ error = ffs_probe(dev_desc, part);
+ if (error != 0) {
+ printf("Error: could not mount %ld dev %ld part on %s: %d\n",
+ dev, part, argv[1], error);
+ return (1);
+ }
+
+ error = ffs_getfilelength(dev_desc, part, filename, &length);
+ if (error != 0) {
+ printf("Error: file not found: %s\n", filename);
+ return (1);
+ }
+ if ((count < length) && (count != 0)) {
+ length = count;
+ }
+
+ error = ffs_read(dev_desc, part, filename, (char *)addr, length);
+ if (error != 0) {
+ printf("Error reading %ld bytes from %s", length, filename);
+ return (1);
+ }
+
+ load_addr = addr; /* Update load address. */
+ sprintf(buf, "%lX", length);
+ setenv("filesize", buf); /* Update filesize. */
+
+ return (length);
+}
+
+/*
+ * U-boot drop-in's.
+ */
+
+U_BOOT_CMD(
+ ffsls, 4, 1, do_ffs_ls,
+ "ffsls - list files in a directory (default /)\n",
+ "<interface> <dev[:part]> [directory]\n"
+ " - list directory of device 'dev' partition 'part' at 'interface'\n"
+);
+
+U_BOOT_CMD(
+ ffsload, 6, 0, do_ffs_load,
+ "ffsload - load binary file from a FFS filesystem\n",
+ "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
+ " - load binary file from device 'dev' partition 'part'\n"
+ " at 'interface' to address 'addr'\n"
+);
diff -r 5221092ac503 -r e78f761f0c62 fs/Makefile
--- a/fs/Makefile Fri Oct 31 01:46:20 2008 +0300
+++ b/fs/Makefile Fri Oct 31 02:00:44 2008 +0300
@@ -22,7 +22,7 @@
#
#
-SUBDIRS := jffs2 cramfs fdos fat reiserfs ext2
+SUBDIRS := jffs2 cramfs fdos fat reiserfs ext2 ffs
$(obj).depend all:
@for dir in $(SUBDIRS) ; do \
diff -r 5221092ac503 -r e78f761f0c62 fs/ffs/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fs/ffs/Makefile Fri Oct 31 02:00:44 2008 +0300
@@ -0,0 +1,52 @@
+#
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+#
+# (C) Copyright 2003
+# Pavel Bartusek, Sysgo Real-Time Solutions AG, pba(a)sysgo.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 $(TOPDIR)/config.mk
+
+LIB = $(obj)libffs.a
+
+AOBJS =
+COBJS = ffs.o
+
+SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
+
+#CPPFLAGS +=
+
+all: $(LIB) $(AOBJS)
+
+$(LIB): $(obj).depend $(OBJS)
+ $(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff -r 5221092ac503 -r e78f761f0c62 fs/ffs/ffs.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fs/ffs/ffs.c Fri Oct 31 02:00:44 2008 +0300
@@ -0,0 +1,668 @@
+/*-
+ * Copyright (c) 2008 Stanislav Sedov <stas(a)FreeBSD.org>.
+ * All rights reserved.
+ * Copyright (c) 2002 McAfee, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Marshall
+ * Kirk McKusick and McAfee Research,, the Security Research Division of
+ * McAfee, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as
+ * part of the DARPA CHATS research program
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Copyright (c) 1998 Robert Nordier
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are freely
+ * permitted provided that the above copyright notice and this
+ * paragraph and the following disclaimer are duplicated in all
+ * such forms.
+ *
+ * This software is provided "AS IS" and without any express or
+ * implied warranties, including, without limitation, the implied
+ * warranties of merchantability and fitness for a particular
+ * purpose.
+ */
+
+#include <common.h>
+
+#if defined(CONFIG_CMD_FFS)
+#include <ffs_dinode.h>
+#include <ffs_fs.h>
+#include <ffs.h>
+#include <malloc.h>
+
+/*
+ * We use 4k `virtual' blocks for filesystem data, whatever the actual
+ * filesystem block size. FFS blocks are always a multiple of 4k.
+ */
+#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
+#define DEV_BSIZE (1<<DEV_BSHIFT)
+#define VBLKSHIFT 12
+#define VBLKSIZE (1 << VBLKSHIFT)
+#define VBLKMASK (VBLKSIZE - 1)
+#define DBPERVBLK (VBLKSIZE / DEV_BSIZE)
+#define INDIRPERVBLK(fs) (NINDIR(fs) / ((fs)->fs_bsize >> VBLKSHIFT))
+#define IPERVBLK(fs) (INOPB(fs) / ((fs)->fs_bsize >> VBLKSHIFT))
+#define INO_TO_VBA(fs, ipervblk, x) \
+ (fsbtodb(fs, cgimin(fs, ino_to_cg(fs, x))) + \
+ (((x) % (fs)->fs_ipg) / (ipervblk) * DBPERVBLK))
+#define INO_TO_VBO(ipervblk, x) ((x) % ipervblk)
+#define FS_TO_VBA(fs, fsb, off) (fsbtodb(fs, fsb) + \
+ ((off) / VBLKSIZE) * DBPERVBLK)
+#define FS_TO_VBO(fs, fsb, off) ((off) & VBLKMASK)
+#define DIP(node, field) ((node)->ver == 1 ? (node)->inode1.field : \
+ (node)->inode2.field)
+
+
+/*
+ * File types
+ */
+#define DT_UNKNOWN 0
+#define DT_FIFO 1
+#define DT_CHR 2
+#define DT_DIR 4
+#define DT_BLK 6
+#define DT_REG 8
+#define DT_LNK 10
+#define DT_SOCK 12
+#define DT_WHT 14
+
+#define MAXBSIZE 65536
+
+struct dirent {
+ uint32_t d_fileno; /* file number of entry */
+ uint16_t d_reclen; /* length of this record */
+ uint8_t d_type; /* file type, see below */
+ uint8_t d_namlen; /* length of string in d_name */
+#define MAXNAMLEN 255
+ char d_name[MAXNAMLEN + 1]; /* name must be no longer */
+};
+typedef struct {
+ struct fs fs;
+ block_dev_desc_t *dev;
+ long part;
+ uint8_t ver;
+} ffs_mount_t;
+typedef struct {
+ union {
+ struct ufs1_dinode inode1;
+ struct ufs2_dinode inode2;
+ };
+ ffs_mount_t *mount;
+ uint8_t ver;
+} ffs_node_t;
+
+/*
+ * Convert between stat structure types and directory types.
+ */
+#define IFTODT(mode) (((mode) & 0170000) >> 12)
+#define DTTOIF(dirtype) ((dirtype) << 12)
+
+static ino_t lookup(ffs_mount_t *mount, const char *path);
+static ssize_t fsread(ffs_mount_t *mount, ffs_node_t *node, void *buf,
+ size_t len, uint32_t off);
+static int ffs_open(ffs_mount_t *mount, ino_t ino, ffs_node_t *node);
+
+static int
+dskread(block_dev_desc_t *desc, long part, void *buf, unsigned lba,
+ unsigned int nblk)
+{
+ disk_partition_t pinfo;
+ int error;
+
+ if (part == 0) {
+ pinfo.start = 0;
+ pinfo.size = desc->lba;
+ pinfo.blksz = desc->blksz;
+ } else {
+ error = get_partition_info(desc, part, &pinfo);
+ if (error != 0)
+ return (error);
+ }
+ if (lba >= pinfo.size) {
+ printf("Error: reading outside the partition size\n");
+ return (1);
+ }
+ error = desc->block_read(desc->dev, pinfo.start + lba, nblk, buf);
+ if (error != nblk) {
+ printf("Error: not all blocks read: wanted %d got %d\n", nblk,
+ error);
+ return (1);
+ }
+ return (0);
+}
+
+static int
+fsfind(ffs_mount_t *mount, const char *name, ino_t * ino)
+{
+ char buf[DEV_BSIZE];
+ struct dirent *d;
+ char *s;
+ ssize_t n;
+ uint32_t off;
+ ffs_node_t *node = NULL;
+ int error;
+
+ node = (ffs_node_t *)malloc(sizeof(*node));
+ if (node == NULL) {
+ printf("Error: allocating %ld bytes failed.\n", sizeof(*node));
+ return (0);
+ }
+ error = ffs_open(mount, *ino, node);
+ if (error != 0) {
+ printf("Error: could not read inode.\n");
+ free(node);
+ return (0);
+ }
+ off = 0;
+ while ((n = fsread(mount, node, buf, DEV_BSIZE, off)) > 0) {
+ for (s = buf; s < buf + DEV_BSIZE;) {
+ d = (void *)s;
+ if (!strcmp(name, d->d_name)) {
+ *ino = d->d_fileno;
+ free(node);
+ return (d->d_type);
+ }
+ s += d->d_reclen;
+ }
+ off += n;
+ }
+ free(node);
+ return (0);
+}
+
+static ino_t
+lookup(ffs_mount_t *mount, const char *path)
+{
+ char name[MAXNAMLEN + 1];
+ const char *s;
+ ino_t ino;
+ ssize_t n;
+ int dt;
+
+ ino = ROOTINO;
+ dt = DT_DIR;
+ name[0] = '/';
+ name[1] = '\0';
+ for (;;) {
+ if (*path == '/')
+ path++;
+ if (!*path)
+ break;
+ for (s = path; *s && *s != '/'; s++);
+ if ((n = s - path) > MAXNAMLEN)
+ return (0);
+ memcpy(name, path, n);
+ name[n] = 0;
+ if (dt != DT_DIR) {
+ printf("%s: not a directory.\n", name);
+ return (0);
+ }
+ if ((dt = fsfind(mount, name, &ino)) <= 0)
+ break;
+ path = s;
+ }
+ return (ino);
+}
+
+/*
+ * Possible superblock locations ordered from most to least likely.
+ */
+static int sblocksearch[] = SBLOCKSEARCH;
+
+static int
+ffs_mount(block_dev_desc_t *desc, long part, ffs_mount_t *mount)
+{
+ int i;
+ struct fs *buf;
+ int error;
+
+ assert(mount != NULL);
+ buf = (struct fs *)malloc(SBLOCKSIZE);
+ if (buf == NULL) {
+ printf("Error: allocating buffer of size %d failed.\n",
+ SBLOCKSIZE);
+ return (-1);
+ }
+
+ /*
+ * Try to read the superblock.
+ */
+ for (i = 0; sblocksearch[i] != -1; i++) {
+ error = dskread(desc, part, buf, sblocksearch[i] / DEV_BSIZE,
+ SBLOCKSIZE / DEV_BSIZE);
+ if (error != 0) {
+ printf("Error reading superblock.\n");
+ free(buf);
+ return (-1);
+ }
+ /* Check for correct block size. */
+ if (buf->fs_bsize > MAXBSIZE ||
+ buf->fs_bsize < sizeof(struct fs))
+ continue;
+ /* Check for magic. */
+ if (buf->fs_magic == FS_UFS1_MAGIC) {
+ mount->ver = 1;
+ break;
+ }
+ if (buf->fs_magic == FS_UFS2_MAGIC &&
+ buf->fs_sblockloc == sblocksearch[i]) {
+ mount->ver = 2;
+ break;
+ }
+ }
+ if (sblocksearch[i] == -1) {
+ printf("UFS superblock was not found.\n");
+ free(buf);
+ return(-1);
+ }
+ mount->dev = desc;
+ mount->part = part;
+ memcpy(&mount->fs, buf, sizeof(struct fs));
+ free(buf);
+ return (0);
+}
+
+static int
+ffs_open(ffs_mount_t *mount, ino_t ino, ffs_node_t *node)
+{
+ size_t ipervblk, i_off, len;
+ struct fs *fs;
+ char *blkbuf;
+ int error;
+
+ assert(node != NULL);
+ assert(ino != 0);
+ fs = &mount->fs;
+
+ blkbuf = (char *)malloc(VBLKSIZE);
+ if (blkbuf == NULL) {
+ printf("Error: allocating buffer of size %d failed.\n",
+ VBLKSIZE);
+ return (-1);
+ }
+
+ /*
+ * Read the inode requested.
+ */
+ ipervblk = IPERVBLK(fs);
+ error = dskread(mount->dev, mount->part, blkbuf,
+ INO_TO_VBA(fs, ipervblk, ino), DBPERVBLK);
+ if (error != 0) {
+ printf("Error reading inode.\n");
+ free(blkbuf);
+ return (-1);
+ }
+ node->mount = mount;
+ node->ver = mount->ver;
+ i_off = INO_TO_VBO(ipervblk, ino);
+ if (mount->ver == 1) {
+ len = sizeof(struct ufs1_dinode);
+ memcpy(&node->inode1, blkbuf + i_off * len, len);
+ } else {
+ len = sizeof(struct ufs2_dinode);
+ memcpy(&node->inode2, blkbuf + i_off * len, len);
+ }
+ free(blkbuf);
+ return (0);
+}
+
+static ssize_t
+fsread(ffs_mount_t *mount, ffs_node_t *node, void *buf, size_t len,
+ uint32_t off)
+{
+ char *blkbuf = NULL;
+ void *indbuf = NULL;
+ size_t left, size, f_off, vboff;
+ ufs_lbn_t f_lbn;
+ ufs2_daddr_t addr, vbaddr;
+ int i, n;
+ int error;
+ int indirpervblk;
+ struct fs *fs;
+
+ assert(mount != NULL);
+ assert(node != NULL);
+
+ /*
+ * Allocate work memory.
+ */
+ blkbuf = (char *)malloc(VBLKSIZE);
+ indbuf = malloc(VBLKSIZE);
+ if (blkbuf == NULL || indbuf == NULL) {
+ printf("Error: allocating buffers of size %d failed.\n",
+ VBLKSIZE);
+ error = -1;
+ goto fail;
+ }
+
+ fs = &mount->fs;
+ size = DIP(node, di_size);
+ n = size - off;
+ if (len > n)
+ len = n;
+ left = len;
+ while (left > 0) {
+ f_lbn = lblkno(fs, off); /* Block number of the file. */
+ f_off = blkoff(fs, off); /* Offset in the file block. */
+
+ /*
+ * Get the address of the block requested.
+ */
+ if (f_lbn < NDADDR) {
+ addr = DIP(node, di_db[f_lbn]);
+ } else if (f_lbn < NDADDR + NINDIR(fs)) {
+ /*
+ * Try to read the block map table.
+ */
+ indirpervblk = INDIRPERVBLK(fs);
+ addr = DIP(node, di_ib[0]);
+ vbaddr = fsbtodb(fs, addr) + /* Block map address. */
+ (f_lbn - NDADDR) / (indirpervblk * DBPERVBLK);
+ error = dskread(mount->dev, mount->part, indbuf,
+ vbaddr, DBPERVBLK);
+ if (error != 0) {
+ printf("Error reading indirect block map.\n");
+ error = -1;
+ goto fail;
+ }
+ /* Offset in the table. */
+ i = (f_lbn - NDADDR) & (indirpervblk - 1);
+ if (fs->fs_magic == FS_UFS1_MAGIC)
+ addr = ((ufs1_daddr_t *)indbuf)[i];
+ else
+ addr = ((ufs2_daddr_t *)indbuf)[i];
+ } else {
+ printf("Error: double-indirect blocks are not"
+ " supported (yet).");
+ goto fail;
+ }
+
+ /*
+ * Read the block itself.
+ */
+ vbaddr = fsbtodb(fs, addr) + (f_off >> VBLKSHIFT) * DBPERVBLK;
+ vboff = f_off & VBLKMASK;
+ i = sblksize(fs, size, f_lbn) - (f_off & ~VBLKMASK);
+ if (i > VBLKSIZE)
+ i = VBLKSIZE;
+ error = dskread(mount->dev, mount->part, blkbuf, vbaddr,
+ i >> DEV_BSHIFT);
+ if (error != 0) {
+ printf("Error reading data block.\n");
+ error = -1;
+ goto fail;
+ }
+ i -= vboff;
+ if (i > left)
+ i = left;
+ memcpy(buf, blkbuf + vboff, i);
+ buf += i;
+ off += i;
+ left -= i;
+ }
+ error = len;
+
+fail:
+ if (blkbuf != NULL)
+ free(blkbuf);
+ if (indbuf != NULL)
+ free(indbuf);
+ return (error);
+}
+
+int
+ffs_probe(block_dev_desc_t *desc, long part)
+{
+ ffs_mount_t *mount = NULL;
+ int error;
+
+ mount = (ffs_mount_t *)malloc(sizeof(*mount));
+ if (mount == NULL) {
+ printf("Error: allocating %ld bytes failed.\n", sizeof(*mount));
+ return (1);
+ }
+
+ /*
+ * Try to mount the fs.
+ */
+ error = ffs_mount(desc, part, mount);
+ free(mount);
+ return (error);
+}
+
+int
+ffs_getfilelength(block_dev_desc_t *desc, long part, const char *filename,
+ unsigned long *len)
+{
+ ffs_mount_t *mount = NULL;
+ ffs_node_t *node = NULL;
+ ino_t ino;
+ int error;
+
+ mount = (ffs_mount_t *)malloc(sizeof(*mount));
+ if (mount == NULL) {
+ printf("Error: allocating %ld bytes failed.\n", sizeof(*mount));
+ return (1);
+ }
+
+ /*
+ * Try to mount the fs.
+ */
+ error = ffs_mount(desc, part, mount);
+ if (error != 0) {
+ printf("Error: could not mount the filesystem.\n");
+ goto fail;
+ }
+
+ ino = lookup(mount, filename);
+ if (ino == 0) {
+ error = 1;
+ goto fail;
+ }
+
+ /*
+ * Open the file.
+ */
+ node = (ffs_node_t *)malloc(sizeof(*node));
+ if (node == NULL) {
+ printf("Error: allocating %ld bytes failed.\n", sizeof(*node));
+ error = 1;
+ goto fail;
+ }
+ error = ffs_open(mount, ino, node);
+ if (error != 0)
+ printf("Error: could not read inode.\n");
+ else
+ *len = DIP(node, di_size);
+fail:
+ if (mount != NULL)
+ free(mount);
+ return (error);
+}
+
+int
+ffs_ls(block_dev_desc_t *desc, long part, const char *filename)
+{
+ char buf[DEV_BSIZE];
+ struct dirent *d;
+ char *s;
+ ssize_t n;
+ ino_t ino;
+ uint32_t off;
+ ffs_mount_t *mount = NULL;
+ ffs_node_t *node = NULL, *fnode = NULL;
+ int error;
+
+ if (*filename == '\0') {
+ printf("Error: empty filename\n");
+ return (1);
+ }
+
+ mount = (ffs_mount_t *)malloc(sizeof(*mount));
+ if (mount == NULL) {
+ printf("Error: allocating %ld bytes failed.\n", sizeof(*mount));
+ return (1);
+ }
+
+ /*
+ * Try to mount the fs.
+ */
+ error = ffs_mount(desc, part, mount);
+ if (error != 0) {
+ printf("Error: could not mount the filesystem.\n");
+ error = 1;
+ goto fail;
+ }
+
+ /*
+ * Try to locate the file.
+ */
+ ino = lookup(mount, filename);
+ if (ino == 0) {
+ printf("Error: not found\n");
+ error = 1;
+ goto fail;
+ }
+
+ /*
+ * Open the directory file and read it.
+ */
+ node = (ffs_node_t *)malloc(sizeof(*node));
+ fnode = (ffs_node_t *)malloc(sizeof(*fnode));
+ if (node == NULL || fnode == NULL) {
+ printf("Error: allocating %ld bytes failed.\n",
+ 2 * sizeof(*node));
+ error = 1;
+ goto fail;
+ }
+ error = ffs_open(mount, ino, node);
+ if (error != 0) {
+ printf("Error: could not read inode.\n");
+ error = 1;
+ goto fail;
+ }
+
+ off = 0;
+ printf("%-8s%-15s%s\n", "INODE", "SIZE", "NAME");
+ while ((n = fsread(mount, node, buf, DEV_BSIZE, off)) > 0) {
+ for (s = buf; s < buf + DEV_BSIZE;) {
+ d = (void *)s;
+ s += d->d_reclen;
+ error = ffs_open(mount, d->d_fileno, fnode);
+ if (error != 0) {
+ printf("Error: could not open file %s\n",
+ d->d_name);
+ continue;
+ }
+ printf("%-8d%-15d%s", d->d_fileno,
+ (int)DIP(fnode, di_size), d->d_name);
+ if (d->d_type == DT_DIR)
+ printf("/");
+ printf("\n");
+ }
+ off += n;
+ }
+ printf("\n");
+ error = 0;
+fail:
+ if (node != NULL)
+ free(node);
+ if (fnode != NULL)
+ free(fnode);
+ if (mount != NULL)
+ free(mount);
+ return (error);
+}
+
+int
+ffs_read(block_dev_desc_t *desc, long part, const char *filename, char *addr,
+ unsigned long len)
+{
+ ino_t ino;
+ int error;
+ ffs_mount_t *mount = NULL;
+ ffs_node_t *node = NULL;
+
+ if (*filename == '\0') {
+ printf("Error: empty filename\n");
+ return (1);
+ }
+
+ mount = (ffs_mount_t *)malloc(sizeof(*mount));
+ if (mount == NULL) {
+ printf("Error: allocating %ld bytes failed.\n", sizeof(*mount));
+ return (1);
+ }
+
+ /*
+ * Try to mount the fs.
+ */
+ error = ffs_mount(desc, part, mount);
+ if (error != 0) {
+ printf("Error: could not mount the filesystem.\n");
+ error = 1;
+ goto fail;
+ }
+
+ /*
+ * Try to locate the file.
+ */
+ ino = lookup(mount, filename);
+ if (ino == 0) {
+ printf("Error: not found\n");
+ error = 1;
+ goto fail;
+ }
+
+ /*
+ * Open the file and read it.
+ */
+ node = (ffs_node_t *)malloc(sizeof(*node));
+ if (node == NULL) {
+ printf("Error: allocating %ld bytes failed.\n", sizeof(*node));
+ error = 1;
+ goto fail;
+ }
+ error = ffs_open(mount, ino, node);
+ if (error != 0) {
+ printf("Error: could not read inode.\n");
+ error = 1;
+ goto fail;
+ }
+ error = fsread(mount, node, addr, len, 0);
+ if (error != len) {
+ printf("Error: not all data read: wanted %ld got %d\n", len,
+ error);
+ error = 1;
+ } else
+ error = 0;
+fail:
+ if (node != NULL)
+ free(node);
+ if (mount != NULL)
+ free(mount);
+ return (error);
+}
+#endif
diff -r 5221092ac503 -r e78f761f0c62 include/ffs.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/ffs.h Fri Oct 31 02:00:44 2008 +0300
@@ -0,0 +1,33 @@
+/*-
+ * Copyright (c) 2008 Stanislav Sedov <stas(a)FreeBSD.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _FFS_H_
+#define _FFS_H_
+int ffs_probe(block_dev_desc_t *desc, long part);
+int ffs_ls(block_dev_desc_t *desc, long part, const char *filename);
+int ffs_read(block_dev_desc_t *desc, long part, const char *filename,
+ char *addr, unsigned long len);
+int ffs_getfilelength(block_dev_desc_t *desc, long part,
+ const char *filename, unsigned long *len);
+#endif /* !_FFS_H_ */
diff -r 5221092ac503 -r e78f761f0c62 include/ffs_dinode.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/ffs_dinode.h Fri Oct 31 02:00:44 2008 +0300
@@ -0,0 +1,191 @@
+/*-
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by Marshall
+ * Kirk McKusick and Network Associates Laboratories, the Security
+ * Research Division of Network Associates, Inc. under DARPA/SPAWAR
+ * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
+ * research program
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Copyright (c) 1982, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)dinode.h 8.3 (Berkeley) 1/21/94
+ * $FreeBSD: src/sys/ufs/ufs/dinode.h,v 1.17 2006/05/21 21:55:29 maxim Exp $
+ */
+
+#ifndef _UFS_UFS_DINODE_H_
+#define _UFS_UFS_DINODE_H_
+
+/*
+ * The root inode is the root of the filesystem. Inode 0 can't be used for
+ * normal purposes and historically bad blocks were linked to inode 1, thus
+ * the root inode is 2. (Inode 1 is no longer used for this purpose, however
+ * numerous dump tapes make this assumption, so we are stuck with it).
+ */
+#define ROOTINO ((ino_t)2)
+
+/*
+ * The Whiteout inode# is a dummy non-zero inode number which will
+ * never be allocated to a real file. It is used as a place holder
+ * in the directory entry which has been tagged as a DT_WHT entry.
+ * See the comments about ROOTINO above.
+ */
+#define WINO ((ino_t)1)
+
+/*
+ * The size of physical and logical block numbers and time fields in UFS.
+ */
+typedef int32_t ufs1_daddr_t;
+typedef int64_t ufs2_daddr_t;
+typedef int64_t ufs_lbn_t;
+typedef int64_t ufs_time_t;
+
+/* File permissions. */
+#define IEXEC 0000100 /* Executable. */
+#define IWRITE 0000200 /* Writeable. */
+#define IREAD 0000400 /* Readable. */
+#define ISVTX 0001000 /* Sticky bit. */
+#define ISGID 0002000 /* Set-gid. */
+#define ISUID 0004000 /* Set-uid. */
+
+/* File types. */
+#define IFMT 0170000 /* Mask of file type. */
+#define IFIFO 0010000 /* Named pipe (fifo). */
+#define IFCHR 0020000 /* Character device. */
+#define IFDIR 0040000 /* Directory file. */
+#define IFBLK 0060000 /* Block device. */
+#define IFREG 0100000 /* Regular file. */
+#define IFLNK 0120000 /* Symbolic link. */
+#define IFSOCK 0140000 /* UNIX domain socket. */
+#define IFWHT 0160000 /* Whiteout. */
+
+/*
+ * A dinode contains all the meta-data associated with a UFS2 file.
+ * This structure defines the on-disk format of a dinode. Since
+ * this structure describes an on-disk structure, all its fields
+ * are defined by types with precise widths.
+ */
+
+#define NXADDR 2 /* External addresses in inode. */
+#define NDADDR 12 /* Direct addresses in inode. */
+#define NIADDR 3 /* Indirect addresses in inode. */
+
+struct ufs2_dinode {
+ u_int16_t di_mode; /* 0: IFMT, permissions; see below. */
+ int16_t di_nlink; /* 2: File link count. */
+ u_int32_t di_uid; /* 4: File owner. */
+ u_int32_t di_gid; /* 8: File group. */
+ u_int32_t di_blksize; /* 12: Inode blocksize. */
+ u_int64_t di_size; /* 16: File byte count. */
+ u_int64_t di_blocks; /* 24: Blocks actually held. */
+ ufs_time_t di_atime; /* 32: Last access time. */
+ ufs_time_t di_mtime; /* 40: Last modified time. */
+ ufs_time_t di_ctime; /* 48: Last inode change time. */
+ ufs_time_t di_birthtime; /* 56: Inode creation time. */
+ int32_t di_mtimensec; /* 64: Last modified time. */
+ int32_t di_atimensec; /* 68: Last access time. */
+ int32_t di_ctimensec; /* 72: Last inode change time. */
+ int32_t di_birthnsec; /* 76: Inode creation time. */
+ int32_t di_gen; /* 80: Generation number. */
+ u_int32_t di_kernflags; /* 84: Kernel flags. */
+ u_int32_t di_flags; /* 88: Status flags (chflags). */
+ int32_t di_extsize; /* 92: External attributes block. */
+ ufs2_daddr_t di_extb[NXADDR];/* 96: External attributes block. */
+ ufs2_daddr_t di_db[NDADDR]; /* 112: Direct disk blocks. */
+ ufs2_daddr_t di_ib[NIADDR]; /* 208: Indirect disk blocks. */
+ int64_t di_spare[3]; /* 232: Reserved; currently unused */
+};
+
+/*
+ * The di_db fields may be overlaid with other information for
+ * file types that do not have associated disk storage. Block
+ * and character devices overlay the first data block with their
+ * dev_t value. Short symbolic links place their path in the
+ * di_db area.
+ */
+#define di_rdev di_db[0]
+
+/*
+ * A UFS1 dinode contains all the meta-data associated with a UFS1 file.
+ * This structure defines the on-disk format of a UFS1 dinode. Since
+ * this structure describes an on-disk structure, all its fields
+ * are defined by types with precise widths.
+ */
+struct ufs1_dinode {
+ u_int16_t di_mode; /* 0: IFMT, permissions; see below. */
+ int16_t di_nlink; /* 2: File link count. */
+ union {
+ u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */
+ } di_u;
+ u_int64_t di_size; /* 8: File byte count. */
+ int32_t di_atime; /* 16: Last access time. */
+ int32_t di_atimensec; /* 20: Last access time. */
+ int32_t di_mtime; /* 24: Last modified time. */
+ int32_t di_mtimensec; /* 28: Last modified time. */
+ int32_t di_ctime; /* 32: Last inode change time. */
+ int32_t di_ctimensec; /* 36: Last inode change time. */
+ ufs1_daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */
+ ufs1_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */
+ u_int32_t di_flags; /* 100: Status flags (chflags). */
+ int32_t di_blocks; /* 104: Blocks actually held. */
+ int32_t di_gen; /* 108: Generation number. */
+ u_int32_t di_uid; /* 112: File owner. */
+ u_int32_t di_gid; /* 116: File group. */
+ int32_t di_spare[2]; /* 120: Reserved; currently unused */
+};
+#define di_ogid di_u.oldids[1]
+#define di_ouid di_u.oldids[0]
+
+#endif /* _UFS_UFS_DINODE_H_ */
diff -r 5221092ac503 -r e78f761f0c62 include/ffs_fs.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/ffs_fs.h Fri Oct 31 02:00:44 2008 +0300
@@ -0,0 +1,616 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)fs.h 8.13 (Berkeley) 3/21/95
+ * $FreeBSD: src/sys/ufs/ffs/fs.h,v 1.49 2006/10/31 21:48:53 pjd Exp $
+ */
+
+#ifndef _UFS_FFS_FS_H_
+#define _UFS_FFS_FS_H_
+
+/*
+ * Each disk drive contains some number of filesystems.
+ * A filesystem consists of a number of cylinder groups.
+ * Each cylinder group has inodes and data.
+ *
+ * A filesystem is described by its super-block, which in turn
+ * describes the cylinder groups. The super-block is critical
+ * data and is replicated in each cylinder group to protect against
+ * catastrophic loss. This is done at `newfs' time and the critical
+ * super-block data does not change, so the copies need not be
+ * referenced further unless disaster strikes.
+ *
+ * For filesystem fs, the offsets of the various blocks of interest
+ * are given in the super block as:
+ * [fs->fs_sblkno] Super-block
+ * [fs->fs_cblkno] Cylinder group block
+ * [fs->fs_iblkno] Inode blocks
+ * [fs->fs_dblkno] Data blocks
+ * The beginning of cylinder group cg in fs, is given by
+ * the ``cgbase(fs, cg)'' macro.
+ *
+ * Depending on the architecture and the media, the superblock may
+ * reside in any one of four places. For tiny media where every block
+ * counts, it is placed at the very front of the partition. Historically,
+ * UFS1 placed it 8K from the front to leave room for the disk label and
+ * a small bootstrap. For UFS2 it got moved to 64K from the front to leave
+ * room for the disk label and a bigger bootstrap, and for really piggy
+ * systems we check at 256K from the front if the first three fail. In
+ * all cases the size of the superblock will be SBLOCKSIZE. All values are
+ * given in byte-offset form, so they do not imply a sector size. The
+ * SBLOCKSEARCH specifies the order in which the locations should be searched.
+ */
+#define SBLOCK_FLOPPY 0
+#define SBLOCK_UFS1 8192
+#define SBLOCK_UFS2 65536
+#define SBLOCK_PIGGY 262144
+#define SBLOCKSIZE 8192
+#define SBLOCKSEARCH \
+ { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 }
+
+/*
+ * Max number of fragments per block. This value is NOT tweakable.
+ */
+#define MAXFRAG 8
+
+/*
+ * Addresses stored in inodes are capable of addressing fragments
+ * of `blocks'. File system blocks of at most size MAXBSIZE can
+ * be optionally broken into 2, 4, or 8 pieces, each of which is
+ * addressable; these pieces may be DEV_BSIZE, or some multiple of
+ * a DEV_BSIZE unit.
+ *
+ * Large files consist of exclusively large data blocks. To avoid
+ * undue wasted disk space, the last data block of a small file may be
+ * allocated as only as many fragments of a large block as are
+ * necessary. The filesystem format retains only a single pointer
+ * to such a fragment, which is a piece of a single large block that
+ * has been divided. The size of such a fragment is determinable from
+ * information in the inode, using the ``blksize(fs, ip, lbn)'' macro.
+ *
+ * The filesystem records space availability at the fragment level;
+ * to determine block availability, aligned fragments are examined.
+ */
+
+/*
+ * MINBSIZE is the smallest allowable block size.
+ * In order to insure that it is possible to create files of size
+ * 2^32 with only two levels of indirection, MINBSIZE is set to 4096.
+ * MINBSIZE must be big enough to hold a cylinder group block,
+ * thus changes to (struct cg) must keep its size within MINBSIZE.
+ * Note that super blocks are always of size SBSIZE,
+ * and that both SBSIZE and MAXBSIZE must be >= MINBSIZE.
+ */
+#define MINBSIZE 4096
+
+/*
+ * The path name on which the filesystem is mounted is maintained
+ * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
+ * the super block for this name.
+ */
+#define MAXMNTLEN 468
+
+/*
+ * The volume name for this filesystem is maintained in fs_volname.
+ * MAXVOLLEN defines the length of the buffer allocated.
+ */
+#define MAXVOLLEN 32
+
+/*
+ * There is a 128-byte region in the superblock reserved for in-core
+ * pointers to summary information. Originally this included an array
+ * of pointers to blocks of struct csum; now there are just a few
+ * pointers and the remaining space is padded with fs_ocsp[].
+ *
+ * NOCSPTRS determines the size of this padding. One pointer (fs_csp)
+ * is taken away to point to a contiguous array of struct csum for
+ * all cylinder groups; a second (fs_maxcluster) points to an array
+ * of cluster sizes that is computed as cylinder groups are inspected,
+ * and the third points to an array that tracks the creation of new
+ * directories. A fourth pointer, fs_active, is used when creating
+ * snapshots; it points to a bitmap of cylinder groups for which the
+ * free-block bitmap has changed since the snapshot operation began.
+ */
+#define NOCSPTRS ((128 / sizeof(void *)) - 4)
+
+/*
+ * A summary of contiguous blocks of various sizes is maintained
+ * in each cylinder group. Normally this is set by the initial
+ * value of fs_maxcontig. To conserve space, a maximum summary size
+ * is set by FS_MAXCONTIG.
+ */
+#define FS_MAXCONTIG 16
+
+/*
+ * MINFREE gives the minimum acceptable percentage of filesystem
+ * blocks which may be free. If the freelist drops below this level
+ * only the superuser may continue to allocate blocks. This may
+ * be set to 0 if no reserve of free blocks is deemed necessary,
+ * however throughput drops by fifty percent if the filesystem
+ * is run at between 95% and 100% full; thus the minimum default
+ * value of fs_minfree is 5%. However, to get good clustering
+ * performance, 10% is a better choice. hence we use 10% as our
+ * default value. With 10% free space, fragmentation is not a
+ * problem, so we choose to optimize for time.
+ */
+#define MINFREE 8
+#define DEFAULTOPT FS_OPTTIME
+
+/*
+ * Grigoriy Orlov <gluk(a)ptci.ru> has done some extensive work to fine
+ * tune the layout preferences for directories within a filesystem.
+ * His algorithm can be tuned by adjusting the following parameters
+ * which tell the system the average file size and the average number
+ * of files per directory. These defaults are well selected for typical
+ * filesystems, but may need to be tuned for odd cases like filesystems
+ * being used for squid caches or news spools.
+ */
+#define AVFILESIZ 16384 /* expected average file size */
+#define AFPDIR 64 /* expected number of files per directory */
+
+/*
+ * The maximum number of snapshot nodes that can be associated
+ * with each filesystem. This limit affects only the number of
+ * snapshot files that can be recorded within the superblock so
+ * that they can be found when the filesystem is mounted. However,
+ * maintaining too many will slow the filesystem performance, so
+ * having this limit is a good idea.
+ */
+#define FSMAXSNAP 20
+
+/*
+ * Used to identify special blocks in snapshots:
+ *
+ * BLK_NOCOPY - A block that was unallocated at the time the snapshot
+ * was taken, hence does not need to be copied when written.
+ * BLK_SNAP - A block held by another snapshot that is not needed by this
+ * snapshot. When the other snapshot is freed, the BLK_SNAP entries
+ * are converted to BLK_NOCOPY. These are needed to allow fsck to
+ * identify blocks that are in use by other snapshots (which are
+ * expunged from this snapshot).
+ */
+#define BLK_NOCOPY ((ufs2_daddr_t)(1))
+#define BLK_SNAP ((ufs2_daddr_t)(2))
+
+/*
+ * Sysctl values for the fast filesystem.
+ */
+#define FFS_ADJ_REFCNT 1 /* adjust inode reference count */
+#define FFS_ADJ_BLKCNT 2 /* adjust inode used block count */
+#define FFS_BLK_FREE 3 /* free range of blocks in map */
+#define FFS_DIR_FREE 4 /* free specified dir inodes in map */
+#define FFS_FILE_FREE 5 /* free specified file inodes in map */
+#define FFS_SET_FLAGS 6 /* set filesystem flags */
+#define FFS_ADJ_NDIR 7 /* adjust number of directories */
+#define FFS_ADJ_NBFREE 8 /* adjust number of free blocks */
+#define FFS_ADJ_NIFREE 9 /* adjust number of free inodes */
+#define FFS_ADJ_NFFREE 10 /* adjust number of free frags */
+#define FFS_ADJ_NUMCLUSTERS 11 /* adjust number of free clusters */
+#define FFS_MAXID 12 /* number of valid ffs ids */
+
+/*
+ * Command structure passed in to the filesystem to adjust filesystem values.
+ */
+#define FFS_CMD_VERSION 0x19790518 /* version ID */
+struct fsck_cmd {
+ int32_t version; /* version of command structure */
+ int32_t handle; /* reference to filesystem to be changed */
+ int64_t value; /* inode or block number to be affected */
+ int64_t size; /* amount or range to be adjusted */
+ int64_t spare; /* reserved for future use */
+};
+
+/*
+ * Per cylinder group information; summarized in blocks allocated
+ * from first cylinder group data blocks. These blocks have to be
+ * read in from fs_csaddr (size fs_cssize) in addition to the
+ * super block.
+ */
+struct csum {
+ int32_t cs_ndir; /* number of directories */
+ int32_t cs_nbfree; /* number of free blocks */
+ int32_t cs_nifree; /* number of free inodes */
+ int32_t cs_nffree; /* number of free frags */
+};
+struct csum_total {
+ int64_t cs_ndir; /* number of directories */
+ int64_t cs_nbfree; /* number of free blocks */
+ int64_t cs_nifree; /* number of free inodes */
+ int64_t cs_nffree; /* number of free frags */
+ int64_t cs_numclusters; /* number of free clusters */
+ int64_t cs_spare[3]; /* future expansion */
+};
+
+/*
+ * Super block for an FFS filesystem.
+ */
+struct fs {
+ int32_t fs_firstfield; /* historic filesystem linked list, */
+ int32_t fs_unused_1; /* used for incore super blocks */
+ int32_t fs_sblkno; /* offset of super-block in filesys */
+ int32_t fs_cblkno; /* offset of cyl-block in filesys */
+ int32_t fs_iblkno; /* offset of inode-blocks in filesys */
+ int32_t fs_dblkno; /* offset of first data after cg */
+ int32_t fs_old_cgoffset; /* cylinder group offset in cylinder */
+ int32_t fs_old_cgmask; /* used to calc mod fs_ntrak */
+ int32_t fs_old_time; /* last time written */
+ int32_t fs_old_size; /* number of blocks in fs */
+ int32_t fs_old_dsize; /* number of data blocks in fs */
+ int32_t fs_ncg; /* number of cylinder groups */
+ int32_t fs_bsize; /* size of basic blocks in fs */
+ int32_t fs_fsize; /* size of frag blocks in fs */
+ int32_t fs_frag; /* number of frags in a block in fs */
+/* these are configuration parameters */
+ int32_t fs_minfree; /* minimum percentage of free blocks */
+ int32_t fs_old_rotdelay; /* num of ms for optimal next block */
+ int32_t fs_old_rps; /* disk revolutions per second */
+/* these fields can be computed from the others */
+ int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */
+ int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */
+ int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */
+ int32_t fs_fshift; /* ``numfrags'' calc number of frags */
+/* these are configuration parameters */
+ int32_t fs_maxcontig; /* max number of contiguous blks */
+ int32_t fs_maxbpg; /* max number of blks per cyl group */
+/* these fields can be computed from the others */
+ int32_t fs_fragshift; /* block to frag shift */
+ int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
+ int32_t fs_sbsize; /* actual size of super block */
+ int32_t fs_spare1[2]; /* old fs_csmask */
+ /* old fs_csshift */
+ int32_t fs_nindir; /* value of NINDIR */
+ int32_t fs_inopb; /* value of INOPB */
+ int32_t fs_old_nspf; /* value of NSPF */
+/* yet another configuration parameter */
+ int32_t fs_optim; /* optimization preference, see below */
+ int32_t fs_old_npsect; /* # sectors/track including spares */
+ int32_t fs_old_interleave; /* hardware sector interleave */
+ int32_t fs_old_trackskew; /* sector 0 skew, per track */
+ int32_t fs_id[2]; /* unique filesystem id */
+/* sizes determined by number of cylinder groups and their sizes */
+ int32_t fs_old_csaddr; /* blk addr of cyl grp summary area */
+ int32_t fs_cssize; /* size of cyl grp summary area */
+ int32_t fs_cgsize; /* cylinder group size */
+ int32_t fs_spare2; /* old fs_ntrak */
+ int32_t fs_old_nsect; /* sectors per track */
+ int32_t fs_old_spc; /* sectors per cylinder */
+ int32_t fs_old_ncyl; /* cylinders in filesystem */
+ int32_t fs_old_cpg; /* cylinders per group */
+ int32_t fs_ipg; /* inodes per group */
+ int32_t fs_fpg; /* blocks per group * fs_frag */
+/* this data must be re-computed after crashes */
+ struct csum fs_old_cstotal; /* cylinder summary information */
+/* these fields are cleared at mount time */
+ int8_t fs_fmod; /* super block modified flag */
+ int8_t fs_clean; /* filesystem is clean flag */
+ int8_t fs_ronly; /* mounted read-only flag */
+ int8_t fs_old_flags; /* old FS_ flags */
+ u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
+ u_char fs_volname[MAXVOLLEN]; /* volume name */
+ u_int64_t fs_swuid; /* system-wide uid */
+ int32_t fs_pad; /* due to alignment of fs_swuid */
+/* these fields retain the current block allocation info */
+ int32_t fs_cgrotor; /* last cg searched */
+ void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */
+ u_int8_t *fs_contigdirs; /* (u) # of contig. allocated dirs */
+ struct csum *fs_csp; /* (u) cg summary info buffer */
+ int32_t *fs_maxcluster; /* (u) max cluster in each cyl group */
+ u_int *fs_active; /* (u) used by snapshots to track fs */
+ int32_t fs_old_cpc; /* cyl per cycle in postbl */
+ int32_t fs_maxbsize; /* maximum blocking factor permitted */
+ int64_t fs_unrefs; /* number of unreferenced inodes */
+ int64_t fs_sparecon64[16]; /* old rotation block list head */
+ int64_t fs_sblockloc; /* byte offset of standard superblock */
+ struct csum_total fs_cstotal; /* (u) cylinder summary information */
+ ufs_time_t fs_time; /* last time written */
+ int64_t fs_size; /* number of blocks in fs */
+ int64_t fs_dsize; /* number of data blocks in fs */
+ ufs2_daddr_t fs_csaddr; /* blk addr of cyl grp summary area */
+ int64_t fs_pendingblocks; /* (u) blocks being freed */
+ int32_t fs_pendinginodes; /* (u) inodes being freed */
+ int32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
+ int32_t fs_avgfilesize; /* expected average file size */
+ int32_t fs_avgfpdir; /* expected # of files per directory */
+ int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */
+ int32_t fs_sparecon32[26]; /* reserved for future constants */
+ int32_t fs_flags; /* see FS_ flags below */
+ int32_t fs_contigsumsize; /* size of cluster summary array */
+ int32_t fs_maxsymlinklen; /* max length of an internal symlink */
+ int32_t fs_old_inodefmt; /* format of on-disk inodes */
+ u_int64_t fs_maxfilesize; /* maximum representable file size */
+ int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */
+ int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */
+ int32_t fs_state; /* validate fs_clean field */
+ int32_t fs_old_postblformat; /* format of positional layout tables */
+ int32_t fs_old_nrpos; /* number of rotational positions */
+ int32_t fs_spare5[2]; /* old fs_postbloff */
+ /* old fs_rotbloff */
+ int32_t fs_magic; /* magic number */
+};
+
+/* Sanity checking. */
+#ifdef CTASSERT
+CTASSERT(sizeof(struct fs) == 1376);
+#endif
+
+/*
+ * Filesystem identification
+ */
+#define FS_UFS1_MAGIC 0x011954 /* UFS1 fast filesystem magic number */
+#define FS_UFS2_MAGIC 0x19540119 /* UFS2 fast filesystem magic number */
+#define FS_BAD_MAGIC 0x19960408 /* UFS incomplete newfs magic number */
+#define FS_OKAY 0x7c269d38 /* superblock checksum */
+#define FS_42INODEFMT -1 /* 4.2BSD inode format */
+#define FS_44INODEFMT 2 /* 4.4BSD inode format */
+
+/*
+ * Preference for optimization.
+ */
+#define FS_OPTTIME 0 /* minimize allocation time */
+#define FS_OPTSPACE 1 /* minimize disk fragmentation */
+
+/*
+ * Filesystem flags.
+ *
+ * The FS_UNCLEAN flag is set by the kernel when the filesystem was
+ * mounted with fs_clean set to zero. The FS_DOSOFTDEP flag indicates
+ * that the filesystem should be managed by the soft updates code.
+ * Note that the FS_NEEDSFSCK flag is set and cleared only by the
+ * fsck utility. It is set when background fsck finds an unexpected
+ * inconsistency which requires a traditional foreground fsck to be
+ * run. Such inconsistencies should only be found after an uncorrectable
+ * disk error. A foreground fsck will clear the FS_NEEDSFSCK flag when
+ * it has successfully cleaned up the filesystem. The kernel uses this
+ * flag to enforce that inconsistent filesystems be mounted read-only.
+ * The FS_INDEXDIRS flag when set indicates that the kernel maintains
+ * on-disk auxiliary indexes (such as B-trees) for speeding directory
+ * accesses. Kernels that do not support auxiliary indicies clear the
+ * flag to indicate that the indicies need to be rebuilt (by fsck) before
+ * they can be used.
+ *
+ * FS_ACLS indicates that ACLs are administratively enabled for the
+ * file system, so they should be loaded from extended attributes,
+ * observed for access control purposes, and be administered by object
+ * owners. FS_MULTILABEL indicates that the TrustedBSD MAC Framework
+ * should attempt to back MAC labels into extended attributes on the
+ * file system rather than maintain a single mount label for all
+ * objects.
+ */
+#define FS_UNCLEAN 0x01 /* filesystem not clean at mount */
+#define FS_DOSOFTDEP 0x02 /* filesystem using soft dependencies */
+#define FS_NEEDSFSCK 0x04 /* filesystem needs sync fsck before mount */
+#define FS_INDEXDIRS 0x08 /* kernel supports indexed directories */
+#define FS_ACLS 0x10 /* file system has ACLs enabled */
+#define FS_MULTILABEL 0x20 /* file system is MAC multi-label */
+#define FS_GJOURNAL 0x40 /* gjournaled file system */
+#define FS_FLAGS_UPDATED 0x80 /* flags have been moved to new location */
+
+/*
+ * Macros to access bits in the fs_active array.
+ */
+#define ACTIVECGNUM(fs, cg) ((fs)->fs_active[(cg) / (NBBY * sizeof(int))])
+#define ACTIVECGOFF(cg) (1 << ((cg) % (NBBY * sizeof(int))))
+#define ACTIVESET(fs, cg) do { \
+ if ((fs)->fs_active) \
+ ACTIVECGNUM((fs), (cg)) |= ACTIVECGOFF((cg)); \
+} while (0)
+#define ACTIVECLEAR(fs, cg) do { \
+ if ((fs)->fs_active) \
+ ACTIVECGNUM((fs), (cg)) &= ~ACTIVECGOFF((cg)); \
+} while (0)
+
+/*
+ * The size of a cylinder group is calculated by CGSIZE. The maximum size
+ * is limited by the fact that cylinder groups are at most one block.
+ * Its size is derived from the size of the maps maintained in the
+ * cylinder group and the (struct cg) size.
+ */
+#define CGSIZE(fs) \
+ /* base cg */ (sizeof(struct cg) + sizeof(int32_t) + \
+ /* old btotoff */ (fs)->fs_old_cpg * sizeof(int32_t) + \
+ /* old boff */ (fs)->fs_old_cpg * sizeof(u_int16_t) + \
+ /* inode map */ howmany((fs)->fs_ipg, NBBY) + \
+ /* block map */ howmany((fs)->fs_fpg, NBBY) +\
+ /* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \
+ /* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \
+ /* cluster map */ howmany(fragstoblks(fs, (fs)->fs_fpg), NBBY)))
+
+/*
+ * The minimal number of cylinder groups that should be created.
+ */
+#define MINCYLGRPS 4
+
+/*
+ * Convert cylinder group to base address of its global summary info.
+ */
+#define fs_cs(fs, indx) fs_csp[indx]
+
+/*
+ * Cylinder group block for a filesystem.
+ */
+#define CG_MAGIC 0x090255
+struct cg {
+ int32_t cg_firstfield; /* historic cyl groups linked list */
+ int32_t cg_magic; /* magic number */
+ int32_t cg_old_time; /* time last written */
+ int32_t cg_cgx; /* we are the cgx'th cylinder group */
+ int16_t cg_old_ncyl; /* number of cyl's this cg */
+ int16_t cg_old_niblk; /* number of inode blocks this cg */
+ int32_t cg_ndblk; /* number of data blocks this cg */
+ struct csum cg_cs; /* cylinder summary information */
+ int32_t cg_rotor; /* position of last used block */
+ int32_t cg_frotor; /* position of last used frag */
+ int32_t cg_irotor; /* position of last used inode */
+ int32_t cg_frsum[MAXFRAG]; /* counts of available frags */
+ int32_t cg_old_btotoff; /* (int32) block totals per cylinder */
+ int32_t cg_old_boff; /* (u_int16) free block positions */
+ int32_t cg_iusedoff; /* (u_int8) used inode map */
+ int32_t cg_freeoff; /* (u_int8) free block map */
+ int32_t cg_nextfreeoff; /* (u_int8) next available space */
+ int32_t cg_clustersumoff; /* (u_int32) counts of avail clusters */
+ int32_t cg_clusteroff; /* (u_int8) free cluster map */
+ int32_t cg_nclusterblks; /* number of clusters this cg */
+ int32_t cg_niblk; /* number of inode blocks this cg */
+ int32_t cg_initediblk; /* last initialized inode */
+ int32_t cg_unrefs; /* number of unreferenced inodes */
+ int32_t cg_sparecon32[2]; /* reserved for future use */
+ ufs_time_t cg_time; /* time last written */
+ int64_t cg_sparecon64[3]; /* reserved for future use */
+ u_int8_t cg_space[1]; /* space for cylinder group maps */
+/* actually longer */
+};
+
+/*
+ * Macros for access to cylinder group array structures
+ */
+#define cg_chkmagic(cgp) ((cgp)->cg_magic == CG_MAGIC)
+#define cg_inosused(cgp) \
+ ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_iusedoff))
+#define cg_blksfree(cgp) \
+ ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_freeoff))
+#define cg_clustersfree(cgp) \
+ ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_clusteroff))
+#define cg_clustersum(cgp) \
+ ((int32_t *)((uintptr_t)(cgp) + (cgp)->cg_clustersumoff))
+
+/*
+ * Turn filesystem block numbers into disk block addresses.
+ * This maps filesystem blocks to device size blocks.
+ */
+#define fsbtodb(fs, b) ((daddr_t)(b) << (fs)->fs_fsbtodb)
+#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb)
+
+/*
+ * Cylinder group macros to locate things in cylinder groups.
+ * They calc filesystem addresses of cylinder group data structures.
+ */
+#define cgbase(fs, c) (((ufs2_daddr_t)(fs)->fs_fpg) * (c))
+#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */
+#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */
+#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */
+#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */
+#define cgstart(fs, c) \
+ ((fs)->fs_magic == FS_UFS2_MAGIC ? cgbase(fs, c) : \
+ (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask))))
+
+/*
+ * Macros for handling inode numbers:
+ * inode number to filesystem block offset.
+ * inode number to cylinder group number.
+ * inode number to filesystem block address.
+ */
+#define ino_to_cg(fs, x) ((x) / (fs)->fs_ipg)
+#define ino_to_fsba(fs, x) \
+ ((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + \
+ (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
+#define ino_to_fsbo(fs, x) ((x) % INOPB(fs))
+
+/*
+ * Give cylinder group number for a filesystem block.
+ * Give cylinder group block number for a filesystem block.
+ */
+#define dtog(fs, d) ((d) / (fs)->fs_fpg)
+#define dtogd(fs, d) ((d) % (fs)->fs_fpg)
+
+/*
+ * Extract the bits for a block from a map.
+ * Compute the cylinder and rotational position of a cyl block addr.
+ */
+#define blkmap(fs, map, loc) \
+ (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag)))
+
+/*
+ * The following macros optimize certain frequently calculated
+ * quantities by using shifts and masks in place of divisions
+ * modulos and multiplications.
+ */
+#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \
+ ((loc) & (fs)->fs_qbmask)
+#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \
+ ((loc) & (fs)->fs_qfmask)
+#define lfragtosize(fs, frag) /* calculates ((off_t)frag * fs->fs_fsize) */ \
+ (((off_t)(frag)) << (fs)->fs_fshift)
+#define lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \
+ (((off_t)(blk)) << (fs)->fs_bshift)
+/* Use this only when `blk' is known to be small, e.g., < NDADDR. */
+#define smalllblktosize(fs, blk) /* calculates (blk * fs->fs_bsize) */ \
+ ((blk) << (fs)->fs_bshift)
+#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \
+ ((loc) >> (fs)->fs_bshift)
+#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \
+ ((loc) >> (fs)->fs_fshift)
+#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \
+ (((size) + (fs)->fs_qbmask) & (fs)->fs_bmask)
+#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \
+ (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask)
+#define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \
+ ((frags) >> (fs)->fs_fragshift)
+#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \
+ ((blks) << (fs)->fs_fragshift)
+#define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \
+ ((fsb) & ((fs)->fs_frag - 1))
+#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \
+ ((fsb) &~ ((fs)->fs_frag - 1))
+
+/*
+ * Determine the number of available frags given a
+ * percentage to hold in reserve.
+ */
+#define freespace(fs, percentreserved) \
+ (blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \
+ (fs)->fs_cstotal.cs_nffree - \
+ (((off_t)((fs)->fs_dsize)) * (percentreserved) / 100))
+
+/*
+ * Determining the size of a file block in the filesystem.
+ */
+#define blksize(fs, ip, lbn) \
+ (((lbn) >= NDADDR || (ip)->i_size >= smalllblktosize(fs, (lbn) + 1)) \
+ ? (fs)->fs_bsize \
+ : (fragroundup(fs, blkoff(fs, (ip)->i_size))))
+#define sblksize(fs, size, lbn) \
+ (((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \
+ ? (fs)->fs_bsize \
+ : (fragroundup(fs, blkoff(fs, (size)))))
+
+
+/*
+ * Number of inodes in a secondary storage block/fragment.
+ */
+#define INOPB(fs) ((fs)->fs_inopb)
+#define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift)
+
+/*
+ * Number of indirects in a filesystem block.
+ */
+#define NINDIR(fs) ((fs)->fs_nindir)
+
+extern int inside[], around[];
+extern u_char *fragtbl[];
+
+#endif
--
Stanislav Sedov
ST4096-RIPE
2
3
When using gdb, history files will often get generated. So ignore them.
Signed-off-by: Mike Frysinger <vapier(a)gentoo.org>
---
.gitignore | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index 9c53f5c..e13fc96 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,9 @@ patches-*
patches
series
+# gdb files
+.gdb_history
+
# cscope files
cscope.*
--
1.6.0.3
2
1

[U-Boot] [PATCH 1/1] FPGA: move fpga drivers to drivers/fpga
by Jean-Christophe PLAGNIOL-VILLARD 05 Dec '08
by Jean-Christophe PLAGNIOL-VILLARD 05 Dec '08
05 Dec '08
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj(a)jcrosoft.com>
---
Makefile | 1 +
common/Makefile | 11 -----------
{common => drivers/fpga}/ACEX1K.c | 0
{common => drivers/fpga}/altera.c | 0
{common => drivers/fpga}/cyclon2.c | 0
{common => drivers/fpga}/fpga.c | 0
{common => drivers/fpga}/spartan2.c | 0
{common => drivers/fpga}/spartan3.c | 0
{common => drivers/fpga}/stratixII.c | 0
{common => drivers/fpga}/virtex2.c | 0
{common => drivers/fpga}/xilinx.c | 0
11 files changed, 1 insertions(+), 11 deletions(-)
rename {common => drivers/fpga}/ACEX1K.c (100%)
rename {common => drivers/fpga}/altera.c (100%)
rename {common => drivers/fpga}/cyclon2.c (100%)
rename {common => drivers/fpga}/fpga.c (100%)
rename {common => drivers/fpga}/spartan2.c (100%)
rename {common => drivers/fpga}/spartan3.c (100%)
rename {common => drivers/fpga}/stratixII.c (100%)
rename {common => drivers/fpga}/virtex2.c (100%)
rename {common => drivers/fpga}/xilinx.c (100%)
diff --git a/Makefile b/Makefile
index d6abb4d..cddd571 100644
--- a/Makefile
+++ b/Makefile
@@ -221,6 +221,7 @@ LIBS += disk/libdisk.a
LIBS += drivers/bios_emulator/libatibiosemu.a
LIBS += drivers/block/libblock.a
LIBS += drivers/dma/libdma.a
+LIBS += drivers/fpga/libfpga.a
LIBS += drivers/hwmon/libhwmon.a
LIBS += drivers/i2c/libi2c.a
LIBS += drivers/input/libinput.a
diff --git a/common/Makefile b/common/Makefile
index f00cbd9..14042e6 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -90,18 +90,7 @@ COBJS-$(CONFIG_OF_LIBFDT) += cmd_fdt.o fdt_support.o
COBJS-$(CONFIG_CMD_FDOS) += cmd_fdos.o
COBJS-$(CONFIG_CMD_FLASH) += cmd_flash.o
ifdef CONFIG_FPGA
-COBJS-y += fpga.o
COBJS-$(CONFIG_CMD_FPGA) += cmd_fpga.o
-COBJS-$(CONFIG_FPGA_SPARTAN2) += spartan2.o
-COBJS-$(CONFIG_FPGA_SPARTAN3) += spartan3.o
-COBJS-$(CONFIG_FPGA_VIRTEX2) += virtex2.o
-COBJS-$(CONFIG_FPGA_XILINX) += xilinx.o
-ifdef CONFIG_FPGA_ALTERA
-COBJS-y += altera.o
-COBJS-$(CONFIG_FPGA_ACEX1K) += ACEX1K.o
-COBJS-$(CONFIG_FPGA_CYCLON2) += cyclon2.o
-COBJS-$(CONFIG_FPGA_STRATIX_II) += stratixII.o
-endif
endif
COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o
COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o
diff --git a/common/ACEX1K.c b/drivers/fpga/ACEX1K.c
similarity index 100%
rename from common/ACEX1K.c
rename to drivers/fpga/ACEX1K.c
diff --git a/common/altera.c b/drivers/fpga/altera.c
similarity index 100%
rename from common/altera.c
rename to drivers/fpga/altera.c
diff --git a/common/cyclon2.c b/drivers/fpga/cyclon2.c
similarity index 100%
rename from common/cyclon2.c
rename to drivers/fpga/cyclon2.c
diff --git a/common/fpga.c b/drivers/fpga/fpga.c
similarity index 100%
rename from common/fpga.c
rename to drivers/fpga/fpga.c
diff --git a/common/spartan2.c b/drivers/fpga/spartan2.c
similarity index 100%
rename from common/spartan2.c
rename to drivers/fpga/spartan2.c
diff --git a/common/spartan3.c b/drivers/fpga/spartan3.c
similarity index 100%
rename from common/spartan3.c
rename to drivers/fpga/spartan3.c
diff --git a/common/stratixII.c b/drivers/fpga/stratixII.c
similarity index 100%
rename from common/stratixII.c
rename to drivers/fpga/stratixII.c
diff --git a/common/virtex2.c b/drivers/fpga/virtex2.c
similarity index 100%
rename from common/virtex2.c
rename to drivers/fpga/virtex2.c
diff --git a/common/xilinx.c b/drivers/fpga/xilinx.c
similarity index 100%
rename from common/xilinx.c
rename to drivers/fpga/xilinx.c
--
1.5.6.5
2
2

[U-Boot] [PATCH] drivers/fsl_pci_init: Fix inbound window mapping bug
by beckyb@kernel.crashing.org 04 Dec '08
by beckyb@kernel.crashing.org 04 Dec '08
04 Dec '08
From: Becky Bruce <becky.bruce(a)freescale.com>
The current code will cause the creation of a 4GB window
starting at 0 if we have more than 4GB of RAM installed,
which overlaps with PCI_MEM space and causes pci_bus_to_phys()
to return erroneous information. Limit the size to 4GB - 1;
which causes the code to create one 2GB and one 1GB window
instead.
Signed-off-by: Becky Bruce <beckyb(a)kernel.crashing.org>
Signed-off-by: Kumar Gala <galak(a)kernel.crashing.org>
---
drivers/pci/fsl_pci_init.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/pci/fsl_pci_init.c b/drivers/pci/fsl_pci_init.c
index 7625ccc..e57acba 100644
--- a/drivers/pci/fsl_pci_init.c
+++ b/drivers/pci/fsl_pci_init.c
@@ -58,7 +58,7 @@ void pciauto_config_init(struct pci_controller *hose);
int fsl_pci_setup_inbound_windows(struct pci_region *r)
{
struct pci_region *rgn_base = r;
- u64 sz = min((u64)gd->ram_size, 1ull << 32);
+ u64 sz = min((u64)gd->ram_size, (1ull << 32) - 1);
phys_addr_t phys_start = CONFIG_SYS_PCI_MEMORY_PHYS;
pci_addr_t bus_start = CONFIG_SYS_PCI_MEMORY_BUS;
--
1.5.6.5
2
1