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
October 2013
- 187 participants
- 554 discussions

14 Oct '13
(for GIT URL and Changelog see below)
ARM CPUs with the virtualization extension have a new mode called
HYP mode, which allows hypervisors to safely control and monitor
guests. The current hypervisor implementations (KVM and Xen)
require the kernel to be entered in that HYP mode.
This patch series introduces a configuration variable
CONFIG_ARMV7_VIRT which enables code to switch all cores into HYP
mode. This is done automatically during execution of the bootm
command.
The process of switching into HYP mode requires the CPU to be in
secure state initially when entering u-boot, it will then setup some
register and switch to non-secure state. This requires the GIC to be
programmed properly first. Explanations about the details are in the
commit messages of the respective patches.
The patches are structured like this:
1/8: prepare header file
2/8: add monitor handler (assembly)
3/8: add per CPU non-secure switch routine (assembly)
4/8: add system wide non-secure setup (C)
5/8: trigger non-secure switch during bootm command
6/8: add generic SMP functionality
7/8: add HYP mode switching
8/8: board specific code for ARM Versatile Express TC2
Since up to patch 6/8 this code works on non-virtualization capable
CPUs also and as there has been a request, there is now a second
configuration variable CONFIG_ARMV7_NONSEC, which omits the final
HYP mode switch and just goes into non-secure SVC state.
You can specify either (or none) of them, the code cares about
the dependency.
The code aims to be as generic as possible, though currently it has
only been tested on the Versatile Express TC-2 board. The last patch
thus enables the feature for that board and should serve as an
example for supporting other boards.
I have had reports from different parties of successful adaptions to
other boards as well (Arndale, Cubieboard, Chromebook), so I will
create a hypmode-ports branch in the below repository to collect
those patches and prepare them for upstreaming.
For convenience there is a GIT tree which you can pull these patches
from ("hypmode_v5" branch):
git://git.linaro.org/people/aprzywara/u-boot.git
Changes RFC..v1
* not a dedicated command anymore, code run by bootm & friends
* protecting code with #ifdefs to avoid unnecessary inclusion and
accidental crashing (when accessing restricted registers)
* moving prototypes to header file to meet checkpatch recommendation
* adding comment as proposed by Christoffer
Changes v1..v2
mostly style and code layout changes
* restructure assembly code to live in a new file and not start.S
* split smp, nonsec_init and hyp_init to be separate functions
* used named constants from common header files
* split C function to be more readable
* extend comments to be more precise and elaborate
* add provision to override GIC base address (needed for Arndale?)
* add configuration variable to enable VExpress specific SMP code
* use writel/readl for MMIO GIC accesses
* remove superfluous isb instructions
* more minor fixes
Changes v2..v3
* fix clobbering of GICC address actually spoiling the stack
* do CNTFRQ setup in assembly per core (and not only once per SoC)
* moving the new code files into arch/arm/cpu/armv7
* add config variable for doing non-secure switch only
* use actual HYP and secure instructions mnemonics instead of
the encoded byte sequence. This requires more recent compilers.
* make the identification of the CPU core more robust and saner
* use enum for error codes and rename them
* lots of smaller layout and style fixes
Changes v3..v4
* mask reserved bits in CBAR register
* move the VExpress board specific SMP code into the board directory
* embed error reporting in the respective functions and getting
rid of the error code enum at all (by popular demand ;-)
* minor style fixes
Changes v4..v5:
* remove unneeded padding in exception table
* only clear unbanked interrupts in GIC distributor for non-secure
* add a default weak implementation for the smp_waitloop() function,
there only needs to be provided the address of the SMP pen now
* fix compilation error with non-A15 VExpress boards
* adding patch specific changelogs for v3..v4 and v4..v5
Please review, comment ... and commit ;-)
Contributions and comments to support other boards are welcome.
Andre Przywara (8):
ARM: prepare armv7.h to be included from assembly source
ARM: add secure monitor handler to switch to non-secure state
ARM: add assembly routine to switch to non-secure state
ARM: add C function to switch to non-secure state
ARM: trigger non-secure state switch during bootm execution
ARM: add SMP support for non-secure switch
ARM: extend non-secure switch to also go into HYP mode
ARM: VExpress: enable ARMv7 virt support for VExpress A15
arch/arm/cpu/armv7/Makefile | 5 +
arch/arm/cpu/armv7/nonsec_virt.S | 208 ++++++++++++++++++++++++++++++++
arch/arm/cpu/armv7/virt-v7.c | 173 ++++++++++++++++++++++++++
arch/arm/include/asm/armv7.h | 33 ++++-
arch/arm/include/asm/gic.h | 19 +++
arch/arm/lib/bootm.c | 18 +++
board/armltd/vexpress/vexpress_common.c | 15 +++
include/common.h | 2 +
include/configs/vexpress_ca15_tc2.h | 5 +-
9 files changed, 476 insertions(+), 2 deletions(-)
create mode 100644 arch/arm/cpu/armv7/nonsec_virt.S
create mode 100644 arch/arm/cpu/armv7/virt-v7.c
create mode 100644 arch/arm/include/asm/gic.h
--
1.7.12.1
7
36

[U-Boot] [PATCH v14 09/10] arm64: board support of vexpress_aemv8a
by fenghuaï¼ phytium.com.cn 14 Oct '13
by fenghuaï¼ phytium.com.cn 14 Oct '13
14 Oct '13
From: David Feng <fenghua(a)phytium.com.cn>
Signed-off-by: David Feng <fenghua(a)phytium.com.cn>
Signed-off-by: Bhupesh Sharma <bhupesh.sharma(a)freescale.com>
---
board/armltd/vexpress64/Makefile | 27 +++++
board/armltd/vexpress64/vexpress64.c | 50 +++++++++
boards.cfg | 1 +
include/configs/vexpress_aemv8a.h | 191 ++++++++++++++++++++++++++++++++++
4 files changed, 269 insertions(+)
create mode 100644 board/armltd/vexpress64/Makefile
create mode 100644 board/armltd/vexpress64/vexpress64.c
create mode 100644 include/configs/vexpress_aemv8a.h
diff --git a/board/armltd/vexpress64/Makefile b/board/armltd/vexpress64/Makefile
new file mode 100644
index 0000000..f907c92
--- /dev/null
+++ b/board/armltd/vexpress64/Makefile
@@ -0,0 +1,27 @@
+#
+# (C) Copyright 2000-2004
+# Wolfgang Denk, DENX Software Engineering, wd(a)denx.de.
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = $(obj)lib$(BOARD).o
+
+COBJS := vexpress64.o
+
+SRCS := $(COBJS:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS))
+
+$(LIB): $(obj).depend $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
new file mode 100644
index 0000000..dae18d4
--- /dev/null
+++ b/board/armltd/vexpress64/vexpress64.c
@@ -0,0 +1,50 @@
+/*
+ * (C) Copyright 2013
+ * David Feng <fenghua(a)phytium.com.cn>
+ * Sharma Bhupesh <bhupesh.sharma(a)freescale.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#include <common.h>
+#include <malloc.h>
+#include <errno.h>
+#include <netdev.h>
+#include <asm/io.h>
+#include <linux/compiler.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+ return 0;
+}
+
+int dram_init(void)
+{
+ gd->ram_size = PHYS_SDRAM_1_SIZE;
+ return 0;
+}
+
+int timer_init(void)
+{
+ return 0;
+}
+
+/*
+ * Board specific reset that is system reset.
+ */
+void reset_cpu(ulong addr)
+{
+}
+
+/*
+ * Board specific ethernet initialization routine.
+ */
+int board_eth_init(bd_t *bis)
+{
+ int rc = 0;
+#ifdef CONFIG_SMC91111
+ rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
+#endif
+ return rc;
+}
diff --git a/boards.cfg b/boards.cfg
index 85143c6..6d3dd69 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -383,6 +383,7 @@ Active arm pxa - - vpac270
Active arm pxa - icpdas lp8x4x lp8x4x - Sergey Yanovich <ynvich(a)gmail.com>
Active arm pxa - toradex - colibri_pxa270 - Marek Vasut <marek.vasut(a)gmail.com>
Active arm sa1100 - - - jornada - Kristoffer Ericson <kristoffer.ericson(a)gmail.com>
+Active arm armv8 - armltd vexpress64 vexpress_aemv8a vexpress_aemv8a:ARM64 David Feng <fenghua(a)phytium.com.cn>
Active avr32 at32ap at32ap700x atmel - atngw100 - Haavard Skinnemoen <haavard.skinnemoen(a)atmel.com>
Active avr32 at32ap at32ap700x atmel - atngw100mkii - Andreas Bießmann <andreas.devel(a)googlemail.com>
Active avr32 at32ap at32ap700x atmel atstk1000 atstk1002 - Haavard Skinnemoen <haavard.skinnemoen(a)atmel.com>
diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h
new file mode 100644
index 0000000..e93b00f
--- /dev/null
+++ b/include/configs/vexpress_aemv8a.h
@@ -0,0 +1,191 @@
+/*
+ * Configuration for Versatile Express. Parts were derived from other ARM
+ * configurations.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __VEXPRESS_AEMV8A_H
+#define __VEXPRESS_AEMV8A_H
+
+#define DEBUG
+
+#define CONFIG_REMAKE_ELF
+
+/*#define CONFIG_BOOTING_EL1*/
+
+/*#define CONFIG_SYS_GENERIC_BOARD*/
+
+#define CONFIG_SYS_NO_FLASH
+
+#define CONFIG_SUPPORT_RAW_INITRD
+
+/* Cache Definitions */
+#define CONFIG_SYS_DCACHE_OFF
+#define CONFIG_SYS_ICACHE_OFF
+
+#define CONFIG_IDENT_STRING " vexpress_aemv8a"
+#define CONFIG_BOOTP_VCI_STRING "U-boot.armv8.vexpress_aemv8a"
+
+/* Link Definitions */
+#define CONFIG_SYS_TEXT_BASE 0x80000000
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
+
+/* Flat Device Tree Definitions */
+#define CONFIG_OF_LIBFDT
+
+#define CONFIG_DEFAULT_DEVICE_TREE vexpress64
+
+/* SMP Definitions */
+#define CPU_RELEASE_ADDR 0x8007fff0
+
+/* CS register bases for the original memory map. */
+#define V2M_PA_CS0 0x00000000
+#define V2M_PA_CS1 0x14000000
+#define V2M_PA_CS2 0x18000000
+#define V2M_PA_CS3 0x1c000000
+#define V2M_PA_CS4 0x0c000000
+#define V2M_PA_CS5 0x10000000
+
+#define V2M_PERIPH_OFFSET(x) (x << 16)
+#define V2M_SYSREGS (V2M_PA_CS3 + V2M_PERIPH_OFFSET(1))
+#define V2M_SYSCTL (V2M_PA_CS3 + V2M_PERIPH_OFFSET(2))
+#define V2M_SERIAL_BUS_PCI (V2M_PA_CS3 + V2M_PERIPH_OFFSET(3))
+
+#define V2M_BASE 0x80000000
+
+/*
+ * Physical addresses, offset from V2M_PA_CS0-3
+ */
+#define V2M_NOR0 (V2M_PA_CS0)
+#define V2M_NOR1 (V2M_PA_CS4)
+#define V2M_SRAM (V2M_PA_CS1)
+
+/* Common peripherals relative to CS7. */
+#define V2M_AACI (V2M_PA_CS3 + V2M_PERIPH_OFFSET(4))
+#define V2M_MMCI (V2M_PA_CS3 + V2M_PERIPH_OFFSET(5))
+#define V2M_KMI0 (V2M_PA_CS3 + V2M_PERIPH_OFFSET(6))
+#define V2M_KMI1 (V2M_PA_CS3 + V2M_PERIPH_OFFSET(7))
+
+#define V2M_UART0 (V2M_PA_CS3 + V2M_PERIPH_OFFSET(9))
+#define V2M_UART1 (V2M_PA_CS3 + V2M_PERIPH_OFFSET(10))
+#define V2M_UART2 (V2M_PA_CS3 + V2M_PERIPH_OFFSET(11))
+#define V2M_UART3 (V2M_PA_CS3 + V2M_PERIPH_OFFSET(12))
+
+#define V2M_WDT (V2M_PA_CS3 + V2M_PERIPH_OFFSET(15))
+
+#define V2M_TIMER01 (V2M_PA_CS3 + V2M_PERIPH_OFFSET(17))
+#define V2M_TIMER23 (V2M_PA_CS3 + V2M_PERIPH_OFFSET(18))
+
+#define V2M_SERIAL_BUS_DVI (V2M_PA_CS3 + V2M_PERIPH_OFFSET(22))
+#define V2M_RTC (V2M_PA_CS3 + V2M_PERIPH_OFFSET(23))
+
+#define V2M_CF (V2M_PA_CS3 + V2M_PERIPH_OFFSET(26))
+
+#define V2M_CLCD (V2M_PA_CS3 + V2M_PERIPH_OFFSET(31))
+
+/* System register offsets. */
+#define V2M_SYS_CFGDATA (V2M_SYSREGS + 0x0a0)
+#define V2M_SYS_CFGCTRL (V2M_SYSREGS + 0x0a4)
+#define V2M_SYS_CFGSTAT (V2M_SYSREGS + 0x0a8)
+
+/* Generic Timer Definitions */
+#define CONFIG_SYS_CNTFRQ (0x1800000) /* 24MHz */
+
+/* Generic Interrupt Controller Definitions */
+#define GICD_BASE (0x2C001000)
+#define GICC_BASE (0x2C002000)
+
+#define CONFIG_SYS_MEMTEST_START V2M_BASE
+#define CONFIG_SYS_MEMTEST_END (V2M_BASE + 0x80000000)
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128 * 1024)
+
+/* SMSC9115 Ethernet from SMSC9118 family */
+#define CONFIG_SMC9111 1
+#define CONFIG_SMC9111_BASE (0x1a000000)
+
+/* PL011 Serial Configuration */
+#define CONFIG_PL011_SERIAL
+#define CONFIG_PL011_CLOCK 24000000
+#define CONFIG_PL01x_PORTS {(void *)CONFIG_SYS_SERIAL0, \
+ (void *)CONFIG_SYS_SERIAL1}
+#define CONFIG_CONS_INDEX 0
+
+#define CONFIG_BAUDRATE 115200
+#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
+#define CONFIG_SYS_SERIAL0 V2M_UART0
+#define CONFIG_SYS_SERIAL1 V2M_UART1
+
+/* Command line configuration */
+#define CONFIG_MENU
+/*#define CONFIG_MENU_SHOW*/
+#define CONFIG_CMD_CACHE
+#define CONFIG_CMD_BDI
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_PXE
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_FLASH
+#define CONFIG_CMD_IMI
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_MII
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_ECHO
+#define CONFIG_CMD_SOURCE
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+
+/* BOOTP options */
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_BOOTPATH
+#define CONFIG_BOOTP_GATEWAY
+#define CONFIG_BOOTP_HOSTNAME
+#define CONFIG_BOOTP_PXE
+#define CONFIG_BOOTP_PXE_CLIENTARCH 0x100
+
+/* Miscellaneous configurable options */
+#define CONFIG_SYS_LOAD_ADDR (V2M_BASE + 0x10000000)
+
+/* Physical Memory Map */
+#define CONFIG_NR_DRAM_BANKS 1
+#define PHYS_SDRAM_1 (V2M_BASE) /* SDRAM Bank #1 */
+#define PHYS_SDRAM_1_SIZE 0x80000000 /* 2048 MB */
+#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+
+#define CONFIG_SYS_HZ 1000
+
+/* Initial environment variables */
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "loadaddr=0x80100000\0" \
+ "kernel_addr=0x100000\0" \
+ "ramdisk_addr=0x800000\0" \
+ "ramdisk_size=0x2000000\0" \
+ "fdt_high=0xa0000000\0" \
+ "console=ttyAMA0,38400n8\0"
+
+#define CONFIG_BOOTARGS "console=ttyAMA0 root=/dev/ram0"
+#define CONFIG_BOOTCOMMAND "bootm $kernel_addr $ramdisk_addr:$ramdisk_size"
+#define CONFIG_BOOTDELAY -1
+
+/* Store environment at top of flash */
+#define CONFIG_ENV_IS_NOWHERE 1
+#define CONFIG_ENV_SIZE 0x1000
+
+/* Monitor Command Prompt */
+#define CONFIG_SYS_CBSIZE 512 /* Console I/O Buffer Size */
+#define CONFIG_SYS_PROMPT "VExpress# "
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
+ sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot args buffer */
+#define CONFIG_SYS_LONGHELP
+#define CONFIG_CMDLINE_EDITING 1
+#define CONFIG_SYS_MAXARGS 64 /* max command args */
+
+#endif /* __VEXPRESS_AEMV8A_H */
--
1.7.9.5
1
0

13 Oct '13
multiple definitions of `_u_boot_list_2_cmd_2_ls' if CONFIG_CMD_JFFS2
and CONFIG_CMD_FS_GENERIC are defined.
Signed-off-by: Suriyan Ramasami <suriyan.r(a)gmail.com>
---
common/cmd_jffs2.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index bce0983..f38455f 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -606,7 +606,7 @@ U_BOOT_CMD(
" with offset 'off'"
);
U_BOOT_CMD(
- ls, 2, 1, do_jffs2_ls,
+ fsls, 2, 1, do_jffs2_ls,
"list files in a directory (default /)",
"[ directory ]"
);
--
1.7.1
2
2
Hi Everyone,
I have a armv7 board and am looking at the "_start" symbol address, using
the following command:
*nm u-boot | grep -w _start*
It returned the following:
*67000020 T _start*
I couldn't help notice that the the _start value is very "close" in vlaue to
the value of CONFIG_SYS_TEXT_BASE defined in my board file:
*#define CONFIG_SYS_TEXT_BASE 0x67000004*
But, I have searched through the source code, but not found where _start
gets assigned a value.. Could someone please help me understand this ?
Thanks,
~vj
--
View this message in context: http://u-boot.10912.n7.nabble.com/How-Where-does-start-get-assigned-a-value…
Sent from the U-Boot mailing list archive at Nabble.com.
5
7

13 Oct '13
Introduces btrfs file-system to read file from
volume/sub-volumes with btrload command. This
implementation has read-only support.
This btrfs implementation is based on syslinux btrfs
code.
v13: Added pre-calculated crc for BE & LE
v11: Mirro super block check.
v10: patch problem reworked.
v5: merged with master.
v4: btrls command added.
[port of syslinux commit 269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d]
Signed-off-by: Adnan Ali <adnan.ali(a)codethink.co.uk>
---
Makefile | 1 +
common/Makefile | 1 +
common/cmd_btr.c | 65 +++
fs/btrfs/Makefile | 51 ++
fs/btrfs/btrfs.c | 1336 ++++++++++++++++++++++++++++++++++++++++++++
fs/fs.c | 10 +
include/btrfs.h | 417 ++++++++++++++
include/config_fallbacks.h | 4 +
include/crc.h | 5 +
include/fs.h | 1 +
lib/Makefile | 1 +
lib/crc32_c.c | 108 ++++
12 files changed, 2000 insertions(+)
create mode 100644 common/cmd_btr.c
create mode 100644 fs/btrfs/Makefile
create mode 100644 fs/btrfs/btrfs.c
create mode 100644 include/btrfs.h
create mode 100644 lib/crc32_c.c
diff --git a/Makefile b/Makefile
index 55bd55c..bd7981d 100644
--- a/Makefile
+++ b/Makefile
@@ -257,6 +257,7 @@ endif
LIBS-$(CONFIG_OF_EMBED) += dts/libdts.o
LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
LIBS-y += fs/libfs.o \
+ fs/btrfs/libbtrfs.o \
fs/cbfs/libcbfs.o \
fs/cramfs/libcramfs.o \
fs/ext4/libext4fs.o \
diff --git a/common/Makefile b/common/Makefile
index 719fc23..d1fae56 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -73,6 +73,7 @@ COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o
COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o
+COBJS-$(CONFIG_CMD_BTR) += cmd_btr.o
COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
diff --git a/common/cmd_btr.c b/common/cmd_btr.c
new file mode 100644
index 0000000..e22154d
--- /dev/null
+++ b/common/cmd_btr.c
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright 2013 Codethink Limited
+ * Btrfs port to Uboot by
+ * Adnan Ali <adnan.ali(a)codethink.co.uk>
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Boot support
+ */
+#include <fs.h>
+#include <btrfs.h>
+
+char subvolname[BTRFS_MAX_SUBVOL_NAME];
+
+int do_btr_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ if (argc > 5)
+ strcpy(subvolname, argv[5]);
+ else
+ subvolname[0] = '\0';
+
+ return do_load(cmdtp, flag, argc, argv, FS_TYPE_BTR, 16);
+}
+
+
+U_BOOT_CMD(
+btrload, 7, 0, do_btr_fsload,
+ "load binary file from a btr filesystem",
+ "<interface> [<dev[:part]>] <addr> <filename> [subvol_name]\n"
+ " - Load binary file 'filename' from 'dev' on 'interface'\n"
+ " to address 'addr' from better filesystem.\n"
+ " the load stops on end of file.\n"
+ " subvol_name is used read that file from this subvolume.\n"
+ " All numeric parameters are assumed to be hex."
+);
+
+static int do_btr_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ return do_ls(cmdtp, flag, argc, argv, FS_TYPE_BTR);
+}
+
+U_BOOT_CMD(
+ btrls, 4, 1, do_btr_ls,
+ "list files in a directory (default /)",
+ "<interface> [<dev[:part]>] [directory]\n"
+ " - list files from 'dev' on 'interface' in a 'directory'"
+);
+
diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
new file mode 100644
index 0000000..a9e2021
--- /dev/null
+++ b/fs/btrfs/Makefile
@@ -0,0 +1,51 @@
+#
+# (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)libbtrfs.o
+
+AOBJS =
+COBJS-$(CONFIG_FS_BTR) := btrfs.o
+
+SRCS := $(AOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y))
+
+
+all: $(LIB) $(AOBJS)
+
+$(LIB): $(obj).depend $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c
new file mode 100644
index 0000000..f4dec57
--- /dev/null
+++ b/fs/btrfs/btrfs.c
@@ -0,0 +1,1336 @@
+/*
+ * (C) Copyright 2013 Codethink Limited
+ * Btrfs port to Uboot by
+ * Adnan Ali <adnan.ali(a)codethink.co.uk>
+
+ * btrfs.c -- readonly btrfs support for syslinux
+ * Some data structures are derivated from btrfs-tools-0.19 ctree.h
+ * Copyright 2009 Intel Corporation; author: alek.du(a)intel.com
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ */
+
+#include <malloc.h>
+#include <common.h>
+#include <btrfs.h>
+#include <command.h>
+#include <config.h>
+#include <crc.h>
+#include <fs.h>
+#include <linux/compiler.h>
+#include <linux/ctype.h>
+#include <linux/stat.h>
+#include <asm/byteorder.h>
+
+unsigned long btr_part_offset;
+/* Actual file structures (we don't have malloc yet...) */
+struct file files[BTRFS_MAX_OPEN];
+static block_dev_desc_t *btrfs_block_dev_desc;
+static disk_partition_t *part_info;
+struct inode parent_inode;
+
+/* Bit-reflected CRC32C polynomial 0x82F63B78 */
+
+static inline u32 crc32c_le(u32 crc, const char *data, size_t length)
+{
+ return crc32c_cal(crc, data, length);
+}
+
+void btrfs_type(char num)
+{
+ switch (num) {
+ case BTRFS_FILE:
+ puts("<FILE> "); break;
+ case BTRFS_DIR:
+ puts("<DIR> "); break;
+ case BTRFS_SYMLNK:
+ puts("<SYM> "); break;
+ default:
+ puts("<UNKNOWN>"); break;
+ }
+}
+
+static inline __le32 next_psector(__le32 psector, uint32_t skip)
+{
+ if (EXTENT_SPECIAL(psector))
+ return psector;
+ else
+ return psector + skip;
+}
+
+static inline __le32 next_pstart(const struct extent *e)
+{
+ return next_psector(e->pstart, e->len);
+}
+
+static inline struct inode *get_inode(struct inode *inode)
+{
+ inode->refcnt++;
+
+ return inode;
+}
+
+/* compare function used for bin_search */
+typedef int (*cmp_func)(void *ptr1, void *ptr2);
+
+static int bin_search(void *ptr, int item_size, void *cmp_item, cmp_func func,
+ int min, int max, int *slot)
+{
+ int low = min;
+ int high = max;
+ int mid;
+ int ret;
+ unsigned long offset;
+ void *item;
+
+ while (low < high) {
+ mid = (low + high) / 2;
+ offset = mid * item_size;
+
+ item = ptr + offset;
+ ret = func(item, cmp_item);
+
+ if (ret < 0)
+ low = mid + 1;
+ else if (ret > 0)
+ high = mid;
+ else {
+ *slot = mid;
+ return 0;
+ }
+ }
+ *slot = low;
+
+ return 1;
+}
+
+/* XXX: these should go into the filesystem instance structure */
+static struct btrfs_chunk_map chunk_map;
+static struct btrfs_super_block sb;
+static u64 fs_tree;
+/* compare btrfs chunk map in list*/
+static int btrfs_comp_chunk_map(struct btrfs_chunk_map_item *m1,
+ struct btrfs_chunk_map_item *m2)
+{
+ if (__le64_to_cpu(m1->logical) > __le64_to_cpu(m2->logical))
+ return 1;
+
+ if (__le64_to_cpu(m1->logical) < __le64_to_cpu(m2->logical))
+ return -1;
+
+ return 0;
+}
+
+/* insert a new chunk mapping item */
+static void insert_map(struct btrfs_chunk_map_item *item)
+{
+ int ret;
+ int slot;
+ int i;
+
+ if (chunk_map.map == NULL) { /* first item */
+ chunk_map.map_length = BTRFS_MAX_CHUNK_ENTRIES;
+ chunk_map.map = (struct btrfs_chunk_map_item *)
+ malloc(chunk_map.map_length * sizeof(*chunk_map.map));
+ chunk_map.map[0] = *item;
+ chunk_map.cur_length = 1;
+
+ return;
+ }
+ ret = bin_search(chunk_map.map, sizeof(*item), item,
+ (cmp_func)btrfs_comp_chunk_map, 0,
+ chunk_map.cur_length, &slot);
+ if (ret == 0)/* already in map */
+ return;
+
+ if (chunk_map.cur_length == BTRFS_MAX_CHUNK_ENTRIES) {
+ /* should be impossible */
+ puts("too many chunk items\n");
+ return;
+ }
+ for (i = chunk_map.cur_length; i > slot; i--)
+ chunk_map.map[i] = chunk_map.map[i-1];
+ chunk_map.map[slot] = *item;
+ chunk_map.cur_length++;
+}
+
+/*
+ * from sys_chunk_array or chunk_tree, we can convert a logical address to
+ * a physical address we can not support multi device case yet
+ */
+static u64 logical_physical(u64 logical)
+{
+ struct btrfs_chunk_map_item item;
+ int slot, ret;
+
+ item.logical = logical;
+ ret = bin_search(chunk_map.map, sizeof(*chunk_map.map), &item,
+ (cmp_func)btrfs_comp_chunk_map, 0,
+ chunk_map.cur_length, &slot);
+ if (ret == 0)
+ slot++;
+ else if (slot == 0)
+ return -1;
+
+ if (logical >=
+ chunk_map.map[slot-1].logical + chunk_map.map[slot-1].length)
+ return -1;
+
+ return chunk_map.map[slot-1].physical + logical -
+ chunk_map.map[slot-1].logical;
+}
+
+int btrfs_devread(int sector, int byte_offset, int byte_len, char *buf)
+{
+ ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, BTRFS_SS);
+ unsigned block_len;
+
+ /* Get the read to the beginning of a partition */
+ sector += byte_offset >> BTRFS_SECTOR_BITS;
+ byte_offset &= BTRFS_SS - 1;
+
+ if (btrfs_block_dev_desc == NULL) {
+ puts("** Invalid Block Device Descriptor (NULL)\n");
+ return 0;
+ }
+ if (byte_offset != 0) {
+ /* read first part which isn't aligned with start of sector */
+ if (btrfs_block_dev_desc->
+ block_read(btrfs_block_dev_desc->dev,
+ part_info->start + sector, 1,
+ (unsigned long *) sec_buf) != 1) {
+ puts(" ** btrfs_devread() read error **\n");
+ return 0;
+ }
+ memcpy(buf, sec_buf + byte_offset,
+ min(BTRFS_SS - byte_offset, byte_len));
+ buf += min(BTRFS_SS - byte_offset, byte_len);
+ byte_len -= min(BTRFS_SS - byte_offset, byte_len);
+ sector++;
+ }
+ /* read sector aligned part */
+
+ block_len = byte_len & ~(BTRFS_SS - 1);
+
+ if (block_len == 0) {
+ ALLOC_CACHE_ALIGN_BUFFER(u8, p, BTRFS_SS);
+
+ block_len = BTRFS_SS;
+ btrfs_block_dev_desc->block_read(btrfs_block_dev_desc->dev,
+ part_info->start + sector,
+ 1, (unsigned long *)p);
+ memcpy(buf, p, byte_len);
+ return 1;
+ }
+ ALLOC_CACHE_ALIGN_BUFFER(u8, t, block_len);
+ if (btrfs_block_dev_desc->block_read(btrfs_block_dev_desc->dev,
+ part_info->start + sector,
+ block_len / BTRFS_SS,
+ (unsigned long *) t) !=
+ block_len / BTRFS_SS) {
+ debug(" ** %s read error - block\n", __func__);
+ return 0;
+ }
+
+ memcpy(buf, t, block_len);
+ block_len = byte_len & ~(BTRFS_SS - 1);
+ buf += block_len;
+ byte_len -= block_len;
+ sector += block_len / BTRFS_SS;
+ if (byte_len != 0) {
+ /* read rest of data which are not in whole sector */
+ if (btrfs_block_dev_desc->
+ block_read(btrfs_block_dev_desc->dev,
+ part_info->start + sector, 1,
+ (unsigned long *) sec_buf) != 1) {
+ debug("* %s read error - last part\n", __func__);
+ return 0;
+ }
+ memcpy(buf, sec_buf, byte_len);
+ }
+
+ return 1;
+}
+/* btrfs has several super block mirrors, need to calculate their location */
+static inline u64 btrfs_sb_offset(int mirror)
+{
+ u64 start = 16 * 1024;
+
+ if (mirror)
+ return start << (BTRFS_SUPER_MIRROR_SHIFT * mirror);
+
+ return BTRFS_SUPER_INFO_OFFSET;
+}
+
+/* find the most recent super block */
+static int btrfs_read_super_block(struct btrfs_info *fs)
+{
+ int i;
+ u8 fsid[BTRFS_FSID_SIZE];
+ u64 offset;
+ u64 transid = 0;
+ struct btrfs_super_block buf;
+
+ sb.total_bytes = ~0; /* Unknown as of yet */
+
+ /*
+ * Only first header is checked for filesystem verification
+ * mirror of this header can be used if required
+ */
+ /* find most recent super block */
+ for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
+
+ offset = btrfs_sb_offset(i);
+ if (offset >= sb.total_bytes)
+ break;
+
+ if (btrfs_devread((offset/BTRFS_SS), 0,
+ sizeof(struct btrfs_super_block),
+ (char *)&buf) != 1)
+ return -1;
+
+ if (buf.bytenr != offset ||
+ strncmp((char *)(&buf.magic),
+ BTRFS_MAGIC, sizeof(buf.magic)))
+ return -1;
+
+ if (i == 0)
+ memcpy(fsid, buf.fsid, sizeof(fsid));
+ else if (memcmp(fsid, buf.fsid, sizeof(fsid))) {
+ puts("fsid doesn't match\n");
+ return -1;
+ }
+
+ if (buf.generation > transid) {
+ memcpy(&sb, &buf, sizeof(sb));
+ transid = buf.generation;
+ }
+ }
+
+ return 0;
+}
+
+static inline unsigned long btrfs_chunk_item_size(int num_stripes)
+{
+ return sizeof(struct btrfs_chunk) +
+ sizeof(struct btrfs_stripe) * (num_stripes - 1);
+}
+
+static void clear_path(struct btrfs_path *path)
+{
+ memset(path, 0, sizeof(*path));
+}
+
+static int btrfs_comp_keys(struct btrfs_disk_key *k1, struct btrfs_disk_key *k2)
+{
+ if (k1->objectid > k2->objectid)
+ return 1;
+ if (k1->objectid < k2->objectid)
+ return -1;
+ if (k1->type > k2->type)
+ return 1;
+ if (k1->type < k2->type)
+ return -1;
+ if (k1->offset > k2->offset)
+ return 1;
+ if (k1->offset < k2->offset)
+ return -1;
+
+ return 0;
+}
+
+/* compare keys but ignore offset, is useful to enumerate all same kind keys */
+static int btrfs_comp_keys_type(struct btrfs_disk_key *k1,
+ struct btrfs_disk_key *k2)
+{
+ if (k1->objectid > k2->objectid)
+ return 1;
+ if (k1->objectid < k2->objectid)
+ return -1;
+ if (k1->type > k2->type)
+ return 1;
+ if (k1->type < k2->type)
+ return -1;
+
+ return 0;
+}
+
+/* seach tree directly on disk ... */
+static int search_tree(struct btrfs_info *fs, u64 loffset,
+ struct btrfs_disk_key *key, struct btrfs_path *path)
+{
+ u8 buf[BTRFS_MAX_LEAF_SIZE];
+ struct btrfs_header *header = (struct btrfs_header *)buf;
+ struct btrfs_node *node = (struct btrfs_node *)buf;
+ struct btrfs_leaf *leaf = (struct btrfs_leaf *)buf;
+ int slot, ret;
+ u64 offset;
+
+ offset = logical_physical(loffset);
+ btrfs_devread(offset/BTRFS_SS, (offset%BTRFS_SS),
+ sizeof(*header), (char *)header);
+ if (header->level) { /*node*/
+ btrfs_devread(((offset+sizeof(*header))/BTRFS_SS),
+ ((offset+sizeof(*header))%BTRFS_SS),
+ __le32_to_cpu(sb.nodesize) - sizeof(*header),
+ (char *)&node->ptrs[0]);
+ path->itemsnr[header->level] = header->nritems;
+ path->offsets[header->level] = loffset;
+ ret = bin_search(&node->ptrs[0], sizeof(struct btrfs_key_ptr),
+ key, (cmp_func)btrfs_comp_keys,
+ path->slots[header->level], header->nritems, &slot);
+ if (ret && slot > path->slots[header->level])
+ slot--;
+ path->slots[header->level] = slot;
+ ret = search_tree(fs, node->ptrs[slot].blockptr, key, path);
+ } else { /*leaf*/
+ btrfs_devread(((offset+sizeof(*header))/BTRFS_SS),
+ ((offset+sizeof(*header))%BTRFS_SS),
+ (sb.leafsize) - sizeof(*header),
+ (char *)&leaf->items);
+ path->itemsnr[header->level] = header->nritems;
+ path->offsets[0] = loffset;
+ ret = bin_search(&leaf->items[0], sizeof(struct btrfs_item),
+ key, (cmp_func)btrfs_comp_keys, path->slots[0],
+ header->nritems, &slot);
+ if (ret && slot > path->slots[header->level])
+ slot--;
+ path->slots[0] = slot;
+ path->item = leaf->items[slot];
+ btrfs_devread(
+ ((offset + sizeof(*header) + leaf->items[slot].offset)
+ /BTRFS_SS),
+ ((offset + sizeof(*header) + leaf->items[slot].offset)
+ %BTRFS_SS),
+ leaf->items[slot].size, (char *)&path->data);
+ }
+
+ return ret;
+}
+
+/* return 0 if leaf found */
+static int next_leaf(struct btrfs_info *fs, struct btrfs_disk_key *key,
+ struct btrfs_path *path)
+{
+ int slot;
+ int level = 1;
+
+ while (level < BTRFS_MAX_LEVEL) {
+ if (!path->itemsnr[level]) /* no more nodes */
+ return 1;
+
+ slot = path->slots[level] + 1;
+ if (slot >= path->itemsnr[level]) {
+ level++;
+ continue;
+ }
+ path->slots[level] = slot;
+ path->slots[level-1] = 0; /* reset low level slots info */
+ search_tree(fs, path->offsets[level], key, path);
+ break;
+ }
+ if (level == BTRFS_MAX_LEVEL)
+ return 1;
+
+ return 0;
+}
+
+/* return 0 if slot found */
+static int next_slot(struct btrfs_info *fs, struct btrfs_disk_key *key,
+ struct btrfs_path *path)
+{
+ int slot;
+
+ if (!path->itemsnr[0])
+ return 1;
+
+ slot = path->slots[0] + 1;
+ if (slot >= path->itemsnr[0])
+ return 1;
+
+ path->slots[0] = slot;
+ search_tree(fs, path->offsets[0], key, path);
+
+ return 0;
+}
+
+/*
+ * read chunk_array in super block
+ */
+static void btrfs_read_sys_chunk_array(void)
+{
+ struct btrfs_chunk_map_item item;
+ struct btrfs_disk_key *key;
+ struct btrfs_chunk *chunk;
+ int cur;
+
+ /* read chunk array in superblock */
+ cur = 0;
+
+ while (cur < __le32_to_cpu(sb.sys_chunk_array_size)) {
+ key = (struct btrfs_disk_key *)(sb.sys_chunk_array + cur);
+ cur += sizeof(*key);
+ chunk = (struct btrfs_chunk *)(sb.sys_chunk_array + cur);
+ cur += btrfs_chunk_item_size(chunk->num_stripes);
+ /* insert to mapping table, ignore multi stripes */
+ item.logical = key->offset;
+ item.length = chunk->length;
+ item.devid = chunk->stripe.devid;
+ item.physical = chunk->stripe.offset;/*ignore other stripes */
+ insert_map(&item);
+ }
+}
+
+/* read chunk items from chunk_tree and insert them to chunk map */
+static void btrfs_read_chunk_tree(struct btrfs_info *fs)
+{
+ struct btrfs_disk_key search_key;
+ struct btrfs_chunk *chunk;
+ struct btrfs_chunk_map_item item;
+ struct btrfs_path path;
+
+ if (!(__le64_to_cpu(sb.flags) & BTRFS_SUPER_FLAG_METADUMP)) {
+ if (__le64_to_cpu(sb.num_devices) > 1) {
+ debug("warning: only support one btrfs device %lld\n",
+ __le64_to_cpu(sb.num_devices));
+ return;
+ }
+ /* read chunk from chunk_tree */
+ search_key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
+ search_key.type = BTRFS_CHUNK_ITEM_KEY;
+ search_key.offset = 0;
+ clear_path(&path);
+ search_tree(fs, (sb.chunk_root), &search_key, &path);
+ do {
+ do {
+ if (btrfs_comp_keys_type(&search_key,
+ &path.item.key))
+ break;
+ chunk = (struct btrfs_chunk *)(path.data);
+ /* insert to mapping table, ignore stripes */
+ item.logical = path.item.key.offset;
+ item.length = chunk->length;
+ item.devid = chunk->stripe.devid;
+ item.physical = chunk->stripe.offset;
+ insert_map(&item);
+ } while (!next_slot(fs, &search_key, &path));
+ if (btrfs_comp_keys_type(&search_key, &path.item.key))
+ break;
+ } while (!next_leaf(fs, &search_key, &path));
+ }
+}
+
+static inline u64 btrfs_name_hash(const char *name, int len)
+{
+ return btrfs_crc32c((u32)~1, name, len);
+}
+
+static struct inode *btrfs_iget_by_inr(struct btrfs_info *fs, u64 inr)
+{
+ struct inode *inode;
+ struct btrfs_inode_item *inode_item;
+ struct btrfs_disk_key search_key;
+ struct btrfs_path path;
+ struct btrfs_pvt_inode *pvt;
+ int ret;
+
+ /*
+ *FIXME: some BTRFS inode member are u64, while our logical inode
+ *is u32, we may need change them to u64 later
+ */
+ search_key.objectid = inr;
+ search_key.type = BTRFS_INODE_ITEM_KEY;
+ search_key.offset = 0;
+ clear_path(&path);
+ ret = search_tree(fs, fs_tree, &search_key, &path);
+ if (ret) {
+ debug("%s search_tree failed\n", __func__);
+ return NULL;
+ }
+
+ inode_item = (struct btrfs_inode_item *)path.data;
+ inode = alloc_inode(fs, inr, sizeof(struct btrfs_pvt_inode));
+ if (!(inode)) {
+ debug("%s alloc_inode failed\n", __func__);
+ return NULL;
+ }
+ inode->ino = inr;
+ inode->size = inode_item->size;
+ inode->mode = BTRFS_IFTODT(inode_item->mode);
+ if (inode->mode == BTRFS_DT_REG || inode->mode == BTRFS_DT_LNK) {
+ struct btrfs_file_extent_item *extent_item;
+ u64 offset;
+
+ /* get file_extent_item */
+ search_key.type = BTRFS_EXTENT_DATA_KEY;
+ search_key.offset = 0;
+ clear_path(&path);
+ ret = search_tree(fs, fs_tree, &search_key, &path);
+ if (ret)
+ return NULL; /* impossible */
+ extent_item = (struct btrfs_file_extent_item *)path.data;
+ if (extent_item->type == BTRFS_FILE_EXTENT_INLINE)
+ offset = path.offsets[0] + sizeof(struct btrfs_header)
+ + path.item.offset
+ + offsetof(struct btrfs_file_extent_item,
+ disk_bytenr);
+ else
+ offset = extent_item->disk_bytenr;
+ pvt = (struct btrfs_pvt_inode *)inode->pvt;
+ pvt->offset = offset;
+ }
+
+ return inode;
+}
+
+static struct inode *btrfs_iget_root(struct btrfs_info *fs)
+{
+ /* BTRFS_FIRST_CHUNK_TREE_OBJECTID(256) actually
+ * is first OBJECTID for FS_TREE
+ */
+ return btrfs_iget_by_inr(fs, BTRFS_FIRST_CHUNK_TREE_OBJECTID);
+}
+
+static struct inode *btrfs_iget(const char *name, struct inode *parent)
+{
+ struct btrfs_info *fs = parent->fs;
+ struct btrfs_disk_key search_key;
+ struct btrfs_path path;
+ struct btrfs_dir_item dir_item;
+ int ret;
+
+ search_key.objectid = parent->ino;
+ search_key.type = BTRFS_DIR_ITEM_KEY;
+ search_key.offset = btrfs_name_hash(name, strlen(name));
+ clear_path(&path);
+ ret = search_tree(fs, fs_tree, &search_key, &path);
+ if (ret)
+ return NULL;
+
+ dir_item = *(struct btrfs_dir_item *)path.data;
+
+ return btrfs_iget_by_inr(fs, dir_item.location.objectid);
+}
+
+static int btrfs_readlink(struct inode *inode, char *buf)
+{
+ struct btrfs_pvt_inode *pvt = (struct btrfs_pvt_inode *)inode->pvt;
+ btrfs_devread((logical_physical(pvt->offset)/BTRFS_SS),
+ (logical_physical(pvt->offset)%BTRFS_SS),
+ inode->size, (char *)buf);
+ buf[inode->size] = '\0';
+ return inode->size;
+}
+
+static int btrfs_readdir(struct file *file, struct btrfs_dirent *btrfs_dirent)
+{
+ struct btrfs_info *fs = file->fs;
+ struct inode *inode = file->inode;
+ struct btrfs_disk_key search_key;
+ struct btrfs_path path;
+ struct btrfs_dir_item *dir_item;
+ int ret;
+
+ /*
+ * we use file->offset to store last search key.offset, will will search
+ * key that lower that offset, 0 means first search and we will search
+ * -1UL, which is the biggest possible key
+ */
+ search_key.objectid = inode->ino;
+ search_key.type = BTRFS_DIR_ITEM_KEY;
+ search_key.offset = file->offset - 1;
+ clear_path(&path);
+ ret = search_tree(fs, fs_tree, &search_key, &path);
+
+ if (ret) {
+ if (btrfs_comp_keys_type(&search_key, &path.item.key))
+ return -1;
+ }
+
+ dir_item = (struct btrfs_dir_item *)path.data;
+ file->offset = path.item.key.offset;
+ btrfs_dirent->d_ino = dir_item->location.objectid;
+ btrfs_dirent->d_off = file->offset;
+ btrfs_dirent->d_reclen = offsetof(struct btrfs_dirent, d_name)
+ + dir_item->name_len + 1;
+ btrfs_dirent->d_type = BTRFS_IFTODT(dir_item->type);
+ memcpy(btrfs_dirent->d_name, dir_item + 1, dir_item->name_len);
+ btrfs_dirent->d_name[dir_item->name_len] = '\0';
+ btrfs_type(dir_item->type);
+ printf(" %s\n", btrfs_dirent->d_name);
+
+ return 0;
+}
+
+static int btrfs_next_extent(struct inode *inode, uint32_t lstart)
+{
+ struct btrfs_disk_key search_key;
+ struct btrfs_file_extent_item *extent_item;
+ struct btrfs_path path;
+ int ret;
+ u64 offset;
+ struct btrfs_info *fs = inode->fs;
+ struct btrfs_pvt_inode *pvt;
+ u32 sec_shift = BTRFS_SECTOR_BITS;
+ u32 sec_size = BTRFS_SS;
+
+ search_key.objectid = inode->ino;
+ search_key.type = BTRFS_EXTENT_DATA_KEY;
+ search_key.offset = lstart << sec_shift;
+ clear_path(&path);
+ ret = search_tree(fs, fs_tree, &search_key, &path);
+ if (ret) { /* impossible */
+ puts("btrfs: search extent data error\n");
+ return -1;
+ }
+ extent_item = (struct btrfs_file_extent_item *)path.data;
+
+ if (extent_item->encryption) {
+ puts("btrfs: found encrypted data, cannot continue\n");
+ return -1;
+ }
+ if (extent_item->compression) {
+ puts("btrfs: found compressed data, cannot continue\n");
+ return -1;
+ }
+
+ if (extent_item->type == BTRFS_FILE_EXTENT_INLINE) {/* inline file */
+ /* we fake a extent here, and PVT of inode will tell us */
+ offset = path.offsets[0] + sizeof(struct btrfs_header)
+ + path.item.offset
+ + offsetof(struct btrfs_file_extent_item, disk_bytenr);
+ inode->next_extent.len =
+ (inode->size + sec_size - 1) >> sec_shift;
+ } else {
+ offset = extent_item->disk_bytenr + extent_item->offset;
+ inode->next_extent.len =
+ (extent_item->num_bytes + sec_size - 1) >> sec_shift;
+ }
+ inode->next_extent.pstart =
+ logical_physical(offset) >> sec_shift;
+ pvt = (struct btrfs_pvt_inode *)inode->pvt;
+ pvt->offset = offset;
+ return 0;
+}
+
+static uint32_t btrfs_getfssec(struct file *file, char *buf, int sectors,
+ char *have_more)
+{
+ u32 ret;
+ struct btrfs_pvt_inode *pvt =
+ (struct btrfs_pvt_inode *)file->inode->pvt;
+ u32 off = pvt->offset % BTRFS_SS;
+ char handle_inline = 0;
+
+ if (off && !file->offset) {/* inline file first read patch */
+ file->inode->size += off;
+ handle_inline = 1;
+ }
+ ret = generic_getfssec(file, buf, sectors, have_more);
+ if (!ret)
+ return ret;
+
+ off = pvt->offset % BTRFS_SS;
+ if (handle_inline) {/* inline file patch */
+ ret -= off;
+ memcpy(buf, buf + off, ret);
+ }
+
+ return ret;
+}
+
+static void btrfs_get_fs_tree(struct btrfs_info *fs)
+{
+ struct btrfs_disk_key search_key;
+ struct btrfs_path path;
+ struct btrfs_root_item *tree;
+ char subvol_ok = 0;
+
+ /* check if subvol is filled by installer */
+ if (*subvolname) {
+ search_key.objectid = BTRFS_FS_TREE_OBJECTID;
+ search_key.type = BTRFS_ROOT_REF_KEY;
+ search_key.offset = 0;
+ clear_path(&path);
+ if (search_tree(fs, __le64_to_cpu(sb.root), &search_key, &path))
+ next_slot(fs, &search_key, &path);
+ do {
+ do {
+ struct btrfs_root_ref *ref;
+ int pathlen;
+
+ if (btrfs_comp_keys_type(&search_key,
+ &path.item.key))
+ break;
+ ref = (struct btrfs_root_ref *)path.data;
+ pathlen =
+ path.item.size - sizeof(struct btrfs_root_ref);
+
+ debug("sub_vol found %s\n", (char *)(ref+1));
+ if (!strncmp((char *)(ref + 1),
+ subvolname, pathlen)) {
+ subvol_ok = 1;
+ break;
+ }
+ } while (!next_slot(fs, &search_key, &path));
+ if (subvol_ok)
+ break;
+ if (btrfs_comp_keys_type(&search_key, &path.item.key))
+ break;
+ } while (!next_leaf(fs, &search_key, &path));
+ if (!subvol_ok)
+ puts("no subvol found\n");
+ }
+ /* find fs_tree from tree_root */
+ if (subvol_ok)
+ search_key.objectid = path.item.key.offset;
+ else /* "default" volume */
+ search_key.objectid = BTRFS_FS_TREE_OBJECTID;
+ search_key.type = BTRFS_ROOT_ITEM_KEY;
+ search_key.offset = -1;
+ clear_path(&path);
+ search_tree(fs, (sb.root), &search_key, &path);
+ tree = (struct btrfs_root_item *)path.data;
+ fs_tree = tree->bytenr;
+}
+
+/* init. the fs meta data, return the block size shift bits. */
+int btrfs_fs_init(struct btrfs_info *fs)
+{
+ btrfs_read_super_block(fs);
+ if (strncmp((char *)(&sb.magic), BTRFS_MAGIC, sizeof(sb.magic)))
+ return -1;
+
+ btrfs_read_sys_chunk_array();
+ btrfs_read_chunk_tree(fs);
+ btrfs_get_fs_tree(fs);
+ fs->root = btrfs_iget_root(fs);
+ parent_inode = *(fs->root);
+
+ return 1;
+}
+static inline uint16_t file_to_handle(struct file *file)
+{
+ return file ? (file - files) + 1 : 0;
+}
+
+static inline struct file *handle_to_file(uint16_t handle)
+{
+ return handle ? &files[handle - 1] : NULL;
+}
+
+/*
+ * Free a refcounted inode
+ */
+void put_inode(struct inode *inode)
+{
+ while (inode && --inode->refcnt == 0) {
+ struct inode *dead = inode;
+ inode = inode->parent;
+ if (dead->name)
+ free((char *)dead->name);
+ free(dead);
+ }
+}
+
+/*
+ * Get a new inode structure
+ */
+struct inode *alloc_inode(struct btrfs_info *fs, uint32_t ino, size_t data)
+{
+ struct inode *inode = malloc(sizeof(struct inode) + data);
+
+ if (inode) {
+ inode->fs = fs;
+ inode->ino = ino;
+ inode->refcnt = 1;
+ }
+
+ return inode;
+}
+
+/*
+ * Get an empty file structure
+ */
+static struct file *alloc_file(void)
+{
+ int i;
+ struct file *file = files;
+
+ for (i = 0; i < BTRFS_MAX_OPEN; i++) {
+ if (!file->fs)
+ return file;
+
+ file++;
+ }
+
+ return NULL;
+}
+
+/*
+ * Close and free a file structure
+ */
+static inline void free_file(struct file *file)
+{
+ memset(file, 0, sizeof *file);
+}
+
+void close_file(struct file *file)
+{
+ if (file->inode) {
+ file->offset = 0;
+ put_inode(file->inode);
+ }
+}
+
+void btrfs_close_file(struct file *file)
+{
+ if (file->fs)
+ close_file(file);
+ free_file(file);
+}
+
+void btrfs_mangle_name(char *dst, const char *src)
+{
+ char *p = dst, ch, len;
+ int i = BTRFS_FILENAME_MAX-1;
+
+ len = strlen(src);
+ ch = *src;
+ while (!isspace(ch)) {
+ if (*src == '/') {
+ if (src[1] == '/') {
+ src++;
+ i--;
+ continue;
+ }
+ }
+ if (!len)
+ break;
+ i--;
+ len--;
+ *dst++ = *src++;
+ ch = *src;
+ }
+ while (1) {
+ if (dst == p)
+ break;
+ if (dst[-1] != '/')
+ break;
+ if ((dst[-1] == '/') && ((dst - 1) == p))
+ break;
+
+ dst--;
+ i++;
+ }
+
+ i++;
+ for (; i > 0; i--)
+ *dst++ = '\0';
+
+}
+
+int searchdir(const char *name)
+{
+ struct inode *inode = NULL;
+ struct inode *parent = &parent_inode;
+ struct file *file;
+ char *pathbuf = NULL;
+ char *part, *p, echar;
+ int symlink_count = BTRFS_MAX_SYMLINK_CNT;
+
+ file = alloc_file();
+ if (!(file))
+ goto err_no_close;
+
+ p = pathbuf = strdup(name);
+ if (!pathbuf)
+ goto err;
+
+ do {
+got_link:
+ if (*p == '/') {
+ put_inode(parent);
+ parent = &parent_inode;
+ }
+
+ do {
+ inode = get_inode(parent);
+
+ while (*p == '/')
+ p++;
+
+ if (!*p)
+ break;
+
+ part = p;
+ while ((echar = *p) && echar != '/')
+ p++;
+ *p++ = '\0';
+ if (part[0] == '.' && part[1] == '.' &&
+ part[2] == '\0') {
+ if (inode->parent) {
+ put_inode(parent);
+ parent = get_inode(inode->parent);
+ put_inode(inode);
+ inode = NULL;
+ if (!echar) {
+ /* Terminal double dots */
+ inode = parent;
+ parent = inode->parent ?
+ get_inode(inode->parent) : NULL;
+ }
+ }
+ } else if (part[0] != '.' || part[1] != '\0') {
+ inode = btrfs_iget(part, parent);
+ if (!inode)
+ goto err;
+ if (inode->mode == BTRFS_DT_LNK) {
+ char *linkbuf, *q;
+ int name_len = echar ? strlen(p) : 0;
+ int total_len = inode->size +
+ name_len + 2;
+ int link_len;
+
+ if (--symlink_count == 0 ||
+ total_len > BTRFS_MAX_SYMLINK_BUF)
+ goto err;
+
+ linkbuf = malloc(total_len);
+ if (!linkbuf)
+ goto err;
+
+ link_len =
+ btrfs_readlink(inode, linkbuf);
+ if (link_len <= 0) {
+ free(linkbuf);
+ goto err;
+ }
+
+ q = linkbuf + link_len;
+
+ if (echar) {
+ if (link_len > 0 &&
+ q[-1] != '/')
+ *q++ = '/';
+ memcpy(q, p, name_len+1);
+ } else {
+ *q = '\0';
+ }
+
+ free(pathbuf);
+ p = pathbuf = linkbuf;
+ put_inode(inode);
+ inode = NULL;
+ goto got_link;
+ }
+
+ inode->name = (u8 *)strdup(part);
+
+ inode->parent = parent;
+ parent = NULL;
+
+ if (!echar)
+ break;
+
+ if (inode->mode != BTRFS_DT_DIR)
+ goto err;
+
+ parent = inode;
+ inode = NULL;
+ }
+ } while (echar);
+ } while (0);
+
+ free(pathbuf);
+ pathbuf = NULL;
+ put_inode(parent);
+ parent = NULL;
+
+ if (!inode)
+ goto err;
+
+ file->inode = inode;
+ file->offset = 0;
+
+ return file_to_handle(file);
+
+err:
+ put_inode(inode);
+ put_inode(parent);
+ if (pathbuf != NULL)
+ free(pathbuf);
+ btrfs_close_file(file);
+err_no_close:
+ return -1;
+}
+
+int btrfs_open_file(const char *name, struct com32_filedata *filedata)
+{
+ int rv;
+ struct file *file;
+ char mangled_name[BTRFS_FILENAME_MAX];
+
+ btrfs_mangle_name(mangled_name, name);
+ rv = searchdir(mangled_name);
+ if (rv < 0)
+ return rv;
+
+ file = handle_to_file(rv);
+ filedata->size = file->inode->size;
+ filedata->handle = rv;
+
+ return rv;
+}
+
+static void get_next_extent(struct inode *inode)
+{
+ /* The logical start address that we care about... */
+ uint32_t lstart = inode->this_extent.lstart + inode->this_extent.len;
+
+ if (btrfs_next_extent(inode, lstart))
+ inode->next_extent.len = 0; /* ERROR */
+ inode->next_extent.lstart = lstart;
+}
+
+int getfssec(struct com32_filedata *filedata, char * buf)
+{
+ int sectors;
+ char have_more;
+ uint32_t bytes_read;
+ struct file *file;
+ if (filedata->size >= 512) {
+ sectors = filedata->size/BTRFS_SS;
+ sectors += (filedata->size%BTRFS_SS) ? 1 : 0;
+ } else
+ sectors = 2;
+
+ file = handle_to_file(filedata->handle);
+
+ bytes_read = btrfs_getfssec(file, buf, sectors, &have_more);
+
+ return bytes_read;
+}
+
+uint32_t generic_getfssec(struct file *file, char *buf,
+ int sectors, char *have_more)
+{
+ struct inode *inode = file->inode;
+ uint32_t bytes_read = 0;
+ uint32_t bytes_left = inode->size - file->offset;
+ uint32_t sectors_left = (bytes_left + BTRFS_SS - 1) >> 9;
+ uint32_t lsector;
+
+ if (sectors > sectors_left)
+ sectors = sectors_left;
+
+ if (!sectors)
+ return 0;
+
+ lsector = file->offset >> 9;
+
+ if (lsector < inode->this_extent.lstart ||
+ lsector >= inode->this_extent.lstart + inode->this_extent.len) {
+ /* inode->this_extent unusable, maybe next_extent is... */
+ inode->this_extent = inode->next_extent;
+ }
+
+ if (lsector < inode->this_extent.lstart ||
+ lsector >= inode->this_extent.lstart + inode->this_extent.len) {
+ /* Still nothing useful... */
+ inode->this_extent.lstart = lsector;
+ inode->this_extent.len = 0;
+ } else {
+ /* We have some usable information */
+ uint32_t delta = lsector - inode->this_extent.lstart;
+ inode->this_extent.lstart = lsector;
+ inode->this_extent.len -= delta;
+ inode->this_extent.pstart
+ = next_psector(inode->this_extent.pstart, delta);
+ }
+
+ while (sectors) {
+ uint32_t chunk;
+ size_t len;
+
+ while (sectors > inode->this_extent.len) {
+ if (!inode->next_extent.len ||
+ inode->next_extent.lstart !=
+ inode->this_extent.lstart +
+ inode->this_extent.len)
+ get_next_extent(inode);
+ if (!inode->this_extent.len) {
+ /* Doesn't matter if it's contiguous... */
+ inode->this_extent = inode->next_extent;
+ if (!inode->next_extent.len) {
+ sectors = 0; /* Failed to get anything*/
+ break;
+ }
+ } else if (inode->next_extent.len &&
+ inode->next_extent.pstart ==
+ next_pstart(&inode->this_extent)) {
+ /* Coalesce extents and loop */
+ inode->this_extent.len +=
+ inode->next_extent.len;
+ } else {
+ /* Discontiguous extents */
+ break;
+ }
+ }
+
+ chunk = min(sectors, inode->this_extent.len);
+ len = chunk << 9;
+
+ if (inode->this_extent.pstart == BTRFS_EXTENT_ZERO) {
+ memset(buf, 0, len);
+ } else {
+ btrfs_block_dev_desc->block_read(
+ btrfs_block_dev_desc->dev, part_info->start +
+ (inode->this_extent.pstart), chunk, buf);
+ inode->this_extent.pstart += chunk;
+ }
+
+ buf += len;
+ sectors -= chunk;
+ bytes_read += len;
+ inode->this_extent.lstart += chunk;
+ inode->this_extent.len -= chunk;
+ }
+
+ bytes_read = min(bytes_read, bytes_left);
+ file->offset += bytes_read;
+
+ if (have_more)
+ *have_more = bytes_read < bytes_left;
+
+ return bytes_read;
+}
+
+/*
+ * Open a directory
+ */
+struct _DIR_ *opendir(const char *path)
+{
+ int rv;
+ struct file *file;
+ rv = searchdir(path);
+ if (rv < 0)
+ return NULL;
+
+ file = handle_to_file(rv);
+
+ if (file->inode->mode != BTRFS_DT_DIR) {
+ btrfs_close_file(file);
+ return NULL;
+ }
+
+ return (struct _DIR_ *)file;
+}
+
+/*
+ * Read one directory entry at one time
+ */
+struct btrfs_dirent *readdir(struct _DIR_ *dir)
+{
+ static struct btrfs_dirent buf;
+ struct file *dd_dir = (struct file *)dir;
+ int rv = -1;
+
+ if (dd_dir)
+ rv = btrfs_readdir(dd_dir, &buf);
+
+ return rv < 0 ? NULL : &buf;
+}
+
+/*
+ * Btrfs file-system Interface
+ *
+ */
+
+struct btrfs_info fs;
+
+/*
+ * mount btrfs file-system
+ */
+int btrfs_probe(block_dev_desc_t *rbdd, disk_partition_t *info)
+{
+ btrfs_block_dev_desc = rbdd;
+ part_info = info;
+ btr_part_offset = info->start;
+ if (btrfs_fs_init(&fs) < 0) {
+ puts("btrfs probe failed\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Read file data
+ */
+int btrfs_read_file(const char *filename, void *buf, int offset, int len)
+{
+ int file_len = 0;
+ int len_read;
+ struct com32_filedata filedata;
+ int handle;
+ if (offset != 0) {
+ puts("** Cannot support non-zero offset **\n");
+ return -1;
+ }
+
+ handle = btrfs_open_file(filename, &filedata);
+ if (handle < 0) {
+ debug("** File not found %s Invalid handle**\n", filename);
+ return -1;
+ }
+
+ /*file handle is valid get the size of the file*/
+ len = filedata.size;
+ if (len == 0)
+ len = file_len;
+
+ len_read = getfssec(&filedata, (char *)buf);
+ if (len_read != len) {
+ debug("** Unable to read file %s **\n", filename);
+ return -1;
+ }
+
+ return len_read;
+}
+
+/*
+ * Show directory entries
+ */
+int btrfs_ls(const char *dirn)
+{
+ struct btrfs_dirent *de;
+ char *dirname = (char *)dirn;
+ struct _DIR_ *dir;
+
+ if (*dirname == '/' && *(dirname+1) == 0)
+ *dirname = '.';
+
+ dir = opendir(dirname);
+ if (dir == NULL)
+ return -1;
+
+ /* readdir prints contents on media*/
+ de = readdir(dir);
+ while (de != NULL)
+ de = readdir(dir);
+
+ return 0;
+}
+
+/*
+ * umount btrfs file-system
+ */
+void btrfs_close(void)
+{
+}
diff --git a/fs/fs.c b/fs/fs.c
index 6f5063c..b8c3603 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -17,6 +17,7 @@
#include <config.h>
#include <common.h>
#include <part.h>
+#include <btrfs.h>
#include <ext4fs.h>
#include <fat.h>
#include <fs.h>
@@ -88,6 +89,15 @@ static struct fstype_info fstypes[] = {
.read = fs_read_sandbox,
},
#endif
+#ifdef CONFIG_FS_BTR
+ {
+ .fstype = FS_TYPE_BTR,
+ .probe = btrfs_probe,
+ .close = btrfs_close,
+ .ls = btrfs_ls,
+ .read = btrfs_read_file,
+ },
+#endif
{
.fstype = FS_TYPE_ANY,
.probe = fs_probe_unsupported,
diff --git a/include/btrfs.h b/include/btrfs.h
new file mode 100644
index 0000000..6246670
--- /dev/null
+++ b/include/btrfs.h
@@ -0,0 +1,417 @@
+#ifndef _BTRFS_H_
+#define _BTRFS_H_
+
+#include <asm/byteorder.h>
+/* type that store on disk, but it is same as cpu type for i386 arch */
+
+#define BTRFS_CURRENTDIR_MAX 15
+#define BTRFS_MAX_OPEN 5
+#define BTRFS_FILENAME_MAX 20
+#define BTRFS_MAX_SYMLINK_CNT 20
+#define BTRFS_MAX_SYMLINK_BUF 4096
+#define BTRFS_SECTOR_SHIFT(fs) ((fs)->sector_shift)
+#define BTRFS_IFTODT(mode) (((mode) & 0170000) >> 12)
+#define BTRFS_SECTOR_SIZE 0x200
+#define BTRFS_SECTOR_BITS 9
+#define BTRFS_EXTENT_ZERO ((uint32_t)-1) /* All-zero extent */
+#define BTRFS_EXTENT_VOID ((uint32_t)-2) /* Invalid information */
+#define BTRFS_DT_LNK 10
+#define BTRFS_DT_REG 8
+#define BTRFS_DT_DIR 4
+#define EXTENT_SPECIAL(x) ((x) >= BTRFS_EXTENT_VOID)
+#define BTRFS_MAX_SUBVOL_NAME 50
+
+#define BTRFS_FILE 1
+#define BTRFS_DIR 2
+#define BTRFS_SYMLNK 7
+#define BTRFS_SS BTRFS_SECTOR_SIZE
+
+extern char subvolname[BTRFS_MAX_SUBVOL_NAME];
+struct _DIR_;
+
+struct com32_filedata {
+ size_t size; /* File size */
+ int blocklg2; /* log2(block size) */
+ uint16_t handle; /* File handle */
+};
+
+struct btrfs_info {
+ const struct fs_ops *fs_ops;
+ struct device *fs_dev;
+ void *btrfs_info; /* The fs-specific information */
+ int sector_shift, sector_size;
+ int block_shift, block_size;
+ struct inode *root, *cwd; /* Root and current directories */
+ char cwd_name[BTRFS_CURRENTDIR_MAX]; /* Current directory by name */
+};
+/*
+ * Extent structure: contains the mapping of some chunk of a file
+ * that is contiguous on disk.
+ */
+struct extent {
+ uint64_t pstart;
+ uint32_t lstart; /* Logical start sector */
+ uint32_t len; /* Number of contiguous sectors */
+} __packed;
+
+
+struct inode {
+ struct btrfs_info *fs; /* The filesystem inode is associated with */
+ struct inode *parent; /* Parent directory, if any */
+ const u8 *name; /* Name, valid for generic path search only */
+ uint32_t refcnt;
+ uint32_t mode; /* FILE , DIR or SYMLINK */
+ uint32_t size;
+ uint32_t blocks; /* How many blocks the file take */
+ uint32_t ino; /* Inode number */
+ uint32_t atime; /* Access time */
+ uint32_t mtime; /* Modify time */
+ uint32_t ctime; /* Create time */
+ uint32_t dtime; /* Delete time */
+ uint32_t flags;
+ uint32_t file_acl;
+ struct extent this_extent, next_extent;
+ u8 pvt[0]; /* Private filesystem data */
+} __packed;
+struct file {
+ struct btrfs_info *fs;
+ uint64_t offset; /* for next read */
+ struct inode *inode; /* The file-specific information */
+} __packed;
+
+#define NAME_MAX 20
+struct btrfs_dirent {
+ uint32_t d_ino;
+ uint32_t d_off;
+ uint16_t d_reclen;
+ uint16_t d_type;
+ char d_name[NAME_MAX + 1];
+};
+
+#define btrfs_crc32c crc32c_le
+
+#define BTRFS_SUPER_INFO_OFFSET (64 * 1024)
+#define BTRFS_SUPER_INFO_SIZE 4096
+#define BTRFS_MAX_LEAF_SIZE 4096
+#define BTRFS_BLOCK_SHIFT 12
+
+#define BTRFS_SUPER_MIRROR_MAX 3
+#define BTRFS_SUPER_MIRROR_SHIFT 12
+#define BTRFS_CSUM_SIZE 32
+#define BTRFS_FSID_SIZE 16
+#define BTRFS_LABEL_SIZE 256
+#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
+#define BTRFS_UUID_SIZE 16
+
+#define BTRFS_MAGIC "_BHRfS_M"
+
+#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
+
+#define BTRFS_DEV_ITEM_KEY 216
+#define BTRFS_CHUNK_ITEM_KEY 228
+#define BTRFS_ROOT_REF_KEY 156
+#define BTRFS_ROOT_ITEM_KEY 132
+#define BTRFS_EXTENT_DATA_KEY 108
+#define BTRFS_DIR_ITEM_KEY 84
+#define BTRFS_INODE_ITEM_KEY 1
+
+#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
+#define BTRFS_FS_TREE_OBJECTID 5ULL
+
+#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
+
+#define BTRFS_FILE_EXTENT_INLINE 0
+#define BTRFS_FILE_EXTENT_REG 1
+#define BTRFS_FILE_EXTENT_PREALLOC 2
+
+#define BTRFS_MAX_LEVEL 8
+#define BTRFS_MAX_CHUNK_ENTRIES 256
+
+#define BTRFS_FT_REG_FILE 1
+#define BTRFS_FT_DIR 2
+#define BTRFS_FT_SYMLINK 7
+
+#define ROOT_DIR_WORD 0x002f
+
+struct btrfs_dev_item {
+ uint64_t devid;
+ uint64_t total_bytes;
+ uint64_t bytes_used;
+ uint32_t io_align;
+ uint32_t io_width;
+ uint32_t sector_size;
+ uint64_t type;
+ uint64_t generation;
+ uint64_t start_offset;
+ uint32_t dev_group;
+ u8 seek_speed;
+ u8 bandwidth;
+ u8 uuid[BTRFS_UUID_SIZE];
+ u8 fsid[BTRFS_UUID_SIZE];
+} __packed;
+
+struct btrfs_super_block {
+ u8 csum[BTRFS_CSUM_SIZE];
+ /* the first 4 fields must match struct btrfs_header */
+ u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
+ uint64_t bytenr; /* this block number */
+ uint64_t flags;
+
+ /* allowed to be different from the btrfs_header from here own down */
+ uint64_t magic;
+ uint64_t generation;
+ uint64_t root;
+ uint64_t chunk_root;
+ uint64_t log_root;
+
+ /* this will help find the new super based on the log root */
+ uint64_t log_root_transid;
+ uint64_t total_bytes;
+ uint64_t bytes_used;
+ uint64_t root_dir_objectid;
+ uint64_t num_devices;
+ uint32_t sectorsize;
+ uint32_t nodesize;
+ uint32_t leafsize;
+ uint32_t stripesize;
+ uint32_t sys_chunk_array_size;
+ uint64_t chunk_root_generation;
+ uint64_t compat_flags;
+ uint64_t compat_ro_flags;
+ uint64_t incompat_flags;
+ __le16 csum_type;
+ u8 root_level;
+ u8 chunk_root_level;
+ u8 log_root_level;
+ struct btrfs_dev_item dev_item;
+
+ char label[BTRFS_LABEL_SIZE];
+
+ uint64_t cache_generation;
+
+ /* future expansion */
+ uint64_t reserved[31];
+ u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
+} __packed;
+
+struct btrfs_disk_key {
+ uint64_t objectid;
+ u8 type;
+ uint64_t offset;
+} __packed;
+
+struct btrfs_stripe {
+ uint64_t devid;
+ uint64_t offset;
+ u8 dev_uuid[BTRFS_UUID_SIZE];
+} __packed;
+
+struct btrfs_chunk {
+ uint64_t length;
+ uint64_t owner;
+ uint64_t stripe_len;
+ uint64_t type;
+ uint32_t io_align;
+ uint32_t io_width;
+ uint32_t sector_size;
+ __le16 num_stripes;
+ __le16 sub_stripes;
+ struct btrfs_stripe stripe;
+} __packed;
+
+struct btrfs_header {
+ /* these first four must match the super block */
+ u8 csum[BTRFS_CSUM_SIZE];
+ u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
+ uint64_t bytenr; /* which block this node is supposed to live in */
+ uint64_t flags;
+
+ /* allowed to be different from the super from here on down */
+ u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
+ uint64_t generation;
+ uint64_t owner;
+ uint32_t nritems;
+ u8 level;
+} __packed;
+
+struct btrfs_item {
+ struct btrfs_disk_key key;
+ uint32_t offset;
+ uint32_t size;
+} __packed;
+
+struct btrfs_leaf {
+ struct btrfs_header header;
+ struct btrfs_item items[];
+} __packed;
+
+struct btrfs_key_ptr {
+ struct btrfs_disk_key key;
+ uint64_t blockptr;
+ uint64_t generation;
+} __packed;
+
+struct btrfs_node {
+ struct btrfs_header header;
+ struct btrfs_key_ptr ptrs[];
+} __packed;
+
+/* remember how we get to a node/leaf */
+struct btrfs_path {
+ uint64_t offsets[BTRFS_MAX_LEVEL];
+ uint32_t itemsnr[BTRFS_MAX_LEVEL];
+ uint32_t slots[BTRFS_MAX_LEVEL];
+ /* remember last slot's item and data */
+ struct btrfs_item item;
+ u32 data[BTRFS_MAX_LEAF_SIZE];
+};
+
+/* store logical offset to physical offset mapping */
+struct btrfs_chunk_map_item {
+ uint64_t logical;
+ uint64_t length;
+ uint64_t devid;
+ uint64_t physical;
+};
+
+struct btrfs_chunk_map {
+ struct btrfs_chunk_map_item *map;
+ uint32_t map_length;
+ uint32_t cur_length;
+};
+
+struct btrfs_timespec {
+ uint64_t sec;
+ uint32_t nsec;
+} __packed;
+
+struct btrfs_inode_item {
+ /* nfs style generation number */
+ uint64_t generation;
+ /* transid that last touched this inode */
+ uint64_t transid;
+ uint64_t size;
+ uint64_t nbytes;
+ uint64_t block_group;
+ uint32_t nlink;
+ uint32_t uid;
+ uint32_t gid;
+ uint32_t mode;
+ uint64_t rdev;
+ uint64_t flags;
+
+ /* modification sequence number for NFS */
+ uint64_t sequence;
+
+ /*
+ * a little future expansion, for more than this we can
+ * just grow the inode item and version it
+ */
+ uint64_t reserved[4];
+ struct btrfs_timespec atime;
+ struct btrfs_timespec ctime;
+ struct btrfs_timespec mtime;
+ struct btrfs_timespec otime;
+} __packed;
+
+struct btrfs_root_item {
+ struct btrfs_inode_item inode;
+ uint64_t generation;
+ uint64_t root_dirid;
+ uint64_t bytenr;
+ uint64_t byte_limit;
+ uint64_t bytes_used;
+ uint64_t last_snapshot;
+ uint64_t flags;
+ uint32_t refs;
+ struct btrfs_disk_key drop_progress;
+ u8 drop_level;
+ u8 level;
+} __packed;
+
+struct btrfs_dir_item {
+ struct btrfs_disk_key location;
+ uint64_t transid;
+ __le16 data_len;
+ __le16 name_len;
+ u8 type;
+} __packed;
+
+struct btrfs_file_extent_item {
+ uint64_t generation;
+ uint64_t ram_bytes;
+ u8 compression;
+ u8 encryption;
+ __le16 other_encoding; /* spare for later use */
+ u8 type;
+ uint64_t disk_bytenr;
+ uint64_t disk_num_bytes;
+ uint64_t offset;
+ uint64_t num_bytes;
+} __packed;
+
+struct btrfs_root_ref {
+ uint64_t dirid;
+ uint64_t sequence;
+ __le16 name_len;
+} __packed;
+
+/*
+ * btrfs private inode information
+ */
+struct btrfs_pvt_inode {
+ uint64_t offset;
+};
+
+
+int btrfs_probe(block_dev_desc_t *rbdd , disk_partition_t *info);
+
+/*
+ *search through disk and mount file-system
+ */
+int btrfs_fs_init(struct btrfs_info *fs);
+
+/*
+ *save inode in list
+ */
+void put_inode(struct inode *inode);
+
+/*
+ *memory allocation for new inode
+ */
+struct inode *alloc_inode(struct btrfs_info *fs, uint32_t ino, size_t data);
+
+/*
+ * open btrfs file
+ */
+int btrfs_open_file(const char *name, struct com32_filedata *filedata);
+/*
+ * reading data from file
+ */
+int getfssec(struct com32_filedata *filedata, char *buf);
+uint32_t generic_getfssec(struct file *file, char *buf,
+ int sectors, char *have_more);
+
+/*
+ * mount btrfs file-system
+ */
+int btrfs_probe(block_dev_desc_t *rbdd , disk_partition_t *info);
+
+/*
+ * listing file/directory on btrfs partition/disk
+ */
+int btrfs_ls(const char *);
+
+/*
+ * read file data
+ */
+int btrfs_read_file(const char *filename, void *buf, int offset, int len);
+
+/*
+ * umount btrfs file-system
+ */
+void btrfs_close(void);
+
+#define PVT(i) ((struct btrfs_pvt_inode *)((i)->pvt))
+
+#endif
diff --git a/include/config_fallbacks.h b/include/config_fallbacks.h
index bfb9680..28a0a66 100644
--- a/include/config_fallbacks.h
+++ b/include/config_fallbacks.h
@@ -26,4 +26,8 @@
#define CONFIG_EXT4_WRITE
#endif
+#if defined(CONFIG_CMD_BTR) && !defined(CONFIG_FS_BTR)
+#define CONFIG_FS_BTR
+#endif
+
#endif /* __CONFIG_FALLBACKS_H */
diff --git a/include/crc.h b/include/crc.h
index 10560c9..be3bf0b 100644
--- a/include/crc.h
+++ b/include/crc.h
@@ -97,4 +97,9 @@ cyg_ether_crc32_accumulate(uint32_t crc, unsigned char *s, int len);
extern uint16_t cyg_crc16(unsigned char *s, int len);
+
+/* CRC calculate for btrfs file-system*/
+
+u32 crc32c_cal(u32 crc, const char *data, size_t length);
+
#endif /* _SERVICES_CRC_CRC_H_ */
diff --git a/include/fs.h b/include/fs.h
index b6d69e5..a8b97ea 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -22,6 +22,7 @@
#define FS_TYPE_FAT 1
#define FS_TYPE_EXT 2
#define FS_TYPE_SANDBOX 3
+#define FS_TYPE_BTR 4
/*
* Tell the fs layer which block device an partition to use for future
diff --git a/lib/Makefile b/lib/Makefile
index 86ca1a6..9518b72 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -67,6 +67,7 @@ COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o
COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o
endif
COBJS-y += crc32.o
+COBJS-y += crc32_c.o
COBJS-y += ctype.o
COBJS-y += div64.o
COBJS-y += linux_string.o
diff --git a/lib/crc32_c.c b/lib/crc32_c.c
new file mode 100644
index 0000000..a6bc17d
--- /dev/null
+++ b/lib/crc32_c.c
@@ -0,0 +1,108 @@
+/*
+ * Copied from Linux kernel crypto/crc32c.c
+ * Copyright (c) 2004 Cisco Systems, Inc.
+ * Copyright (c) 2008 Herbert Xu <herbert(a)gondor.apana.org.au>
+ *
+ * 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.
+ *
+ */
+#include <linux/stat.h>
+#include <command.h>
+#include <asm/byteorder.h>
+#include <linux/compiler.h>
+#include <common.h>
+#include <config.h>
+
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+#include <watchdog.h>
+#endif
+#include <u-boot/crc.h>
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
+
+static const uint32_t crc32c_table[256] = {
+ (0x00000000), (0xf26b8303), (0xe13b70f7), (0x1350f3f4),
+ (0xc79a971f), (0x35f1141c), (0x26a1e7e8), (0xd4ca64eb),
+ (0x8ad958cf), (0x78b2dbcc), (0x6be22838), (0x9989ab3b),
+ (0x4d43cfd0), (0xbf284cd3), (0xac78bf27), (0x5e133c24),
+ (0x105ec76f), (0xe235446c), (0xf165b798), (0x030e349b),
+ (0xd7c45070), (0x25afd373), (0x36ff2087), (0xc494a384),
+ (0x9a879fa0), (0x68ec1ca3), (0x7bbcef57), (0x89d76c54),
+ (0x5d1d08bf), (0xaf768bbc), (0xbc267848), (0x4e4dfb4b),
+ (0x20bd8ede), (0xd2d60ddd), (0xc186fe29), (0x33ed7d2a),
+ (0xe72719c1), (0x154c9ac2), (0x061c6936), (0xf477ea35),
+ (0xaa64d611), (0x580f5512), (0x4b5fa6e6), (0xb93425e5),
+ (0x6dfe410e), (0x9f95c20d), (0x8cc531f9), (0x7eaeb2fa),
+ (0x30e349b1), (0xc288cab2), (0xd1d83946), (0x23b3ba45),
+ (0xf779deae), (0x05125dad), (0x1642ae59), (0xe4292d5a),
+ (0xba3a117e), (0x4851927d), (0x5b016189), (0xa96ae28a),
+ (0x7da08661), (0x8fcb0562), (0x9c9bf696), (0x6ef07595),
+ (0x417b1dbc), (0xb3109ebf), (0xa0406d4b), (0x522bee48),
+ (0x86e18aa3), (0x748a09a0), (0x67dafa54), (0x95b17957),
+ (0xcba24573), (0x39c9c670), (0x2a993584), (0xd8f2b687),
+ (0x0c38d26c), (0xfe53516f), (0xed03a29b), (0x1f682198),
+ (0x5125dad3), (0xa34e59d0), (0xb01eaa24), (0x42752927),
+ (0x96bf4dcc), (0x64d4cecf), (0x77843d3b), (0x85efbe38),
+ (0xdbfc821c), (0x2997011f), (0x3ac7f2eb), (0xc8ac71e8),
+ (0x1c661503), (0xee0d9600), (0xfd5d65f4), (0x0f36e6f7),
+ (0x61c69362), (0x93ad1061), (0x80fde395), (0x72966096),
+ (0xa65c047d), (0x5437877e), (0x4767748a), (0xb50cf789),
+ (0xeb1fcbad), (0x197448ae), (0x0a24bb5a), (0xf84f3859),
+ (0x2c855cb2), (0xdeeedfb1), (0xcdbe2c45), (0x3fd5af46),
+ (0x7198540d), (0x83f3d70e), (0x90a324fa), (0x62c8a7f9),
+ (0xb602c312), (0x44694011), (0x5739b3e5), (0xa55230e6),
+ (0xfb410cc2), (0x092a8fc1), (0x1a7a7c35), (0xe811ff36),
+ (0x3cdb9bdd), (0xceb018de), (0xdde0eb2a), (0x2f8b6829),
+ (0x82f63b78), (0x709db87b), (0x63cd4b8f), (0x91a6c88c),
+ (0x456cac67), (0xb7072f64), (0xa457dc90), (0x563c5f93),
+ (0x082f63b7), (0xfa44e0b4), (0xe9141340), (0x1b7f9043),
+ (0xcfb5f4a8), (0x3dde77ab), (0x2e8e845f), (0xdce5075c),
+ (0x92a8fc17), (0x60c37f14), (0x73938ce0), (0x81f80fe3),
+ (0x55326b08), (0xa759e80b), (0xb4091bff), (0x466298fc),
+ (0x1871a4d8), (0xea1a27db), (0xf94ad42f), (0x0b21572c),
+ (0xdfeb33c7), (0x2d80b0c4), (0x3ed04330), (0xccbbc033),
+ (0xa24bb5a6), (0x502036a5), (0x4370c551), (0xb11b4652),
+ (0x65d122b9), (0x97baa1ba), (0x84ea524e), (0x7681d14d),
+ (0x2892ed69), (0xdaf96e6a), (0xc9a99d9e), (0x3bc21e9d),
+ (0xef087a76), (0x1d63f975), (0x0e330a81), (0xfc588982),
+ (0xb21572c9), (0x407ef1ca), (0x532e023e), (0xa145813d),
+ (0x758fe5d6), (0x87e466d5), (0x94b49521), (0x66df1622),
+ (0x38cc2a06), (0xcaa7a905), (0xd9f75af1), (0x2b9cd9f2),
+ (0xff56bd19), (0x0d3d3e1a), (0x1e6dcdee), (0xec064eed),
+ (0xc38d26c4), (0x31e6a5c7), (0x22b65633), (0xd0ddd530),
+ (0x0417b1db), (0xf67c32d8), (0xe52cc12c), (0x1747422f),
+ (0x49547e0b), (0xbb3ffd08), (0xa86f0efc), (0x5a048dff),
+ (0x8ecee914), (0x7ca56a17), (0x6ff599e3), (0x9d9e1ae0),
+ (0xd3d3e1ab), (0x21b862a8), (0x32e8915c), (0xc083125f),
+ (0x144976b4), (0xe622f5b7), (0xf5720643), (0x07198540),
+ (0x590ab964), (0xab613a67), (0xb831c993), (0x4a5a4a90),
+ (0x9e902e7b), (0x6cfbad78), (0x7fab5e8c), (0x8dc0dd8f),
+ (0xe330a81a), (0x115b2b19), (0x020bd8ed), (0xf0605bee),
+ (0x24aa3f05), (0xd6c1bc06), (0xc5914ff2), (0x37faccf1),
+ (0x69e9f0d5), (0x9b8273d6), (0x88d28022), (0x7ab90321),
+ (0xae7367ca), (0x5c18e4c9), (0x4f48173d), (0xbd23943e),
+ (0xf36e6f75), (0x0105ec76), (0x12551f82), (0xe03e9c81),
+ (0x34f4f86a), (0xc69f7b69), (0xd5cf889d), (0x27a40b9e),
+ (0x79b737ba), (0x8bdcb4b9), (0x988c474d), (0x6ae7c44e),
+ (0xbe2da0a5), (0x4c4623a6), (0x5f16d052), (0xad7d5351),
+};
+
+/* ========================================================================= */
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define DO_CRC(x) crc = crc32c_table[(crc ^ (x)) & 255] ^ (crc >> 8)
+# else
+# define DO_CRC(x) crc = crc32c_table[((crc >> 24) ^ (x)) & 255] ^ (crc << 8)
+# endif
+
+u32 crc32c_cal(u32 crc, const char *data, size_t length)
+{
+ while (length--)
+ crc = DO_CRC(*data++);
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+ WATCHDOG_RESET();
+#endif
+ return crc;
+}
--
1.7.9.5
1
1

13 Oct '13
Remove the last uses of symbol offsets in ARM U-Boot.
Remove some needless uses of _TEXT_BASE.
Remove all _TEXT_BASE definitions.
Signed-off-by: Albert ARIBAUD <albert.u.boot(a)aribaud.net>
---
NOTE: this is not intended for inclusion in 2013.10. :)
_TEXT_BASE was only used by ARM to allow resolution of
symbol offsets, themselves only needed due to absolute
relocations.
In some places, _TEXT_BASE was locally defined only
to provide a literal for CONFIG_SYS_TEXT_BASE when the
latter could have been used directly.
Sometimes even, _TEXT_BASE was defined but unused.
Since all relocations in ARM are relative, offsets,
_TEXT_BASE and CONFIG_SYS_SYM_OFFSETS can be completely
removed, and their uses can be replaced with adequate
use of compiler-generated symbols from sections.c file.
README | 6 ------
arch/arm/cpu/arm1136/start.S | 27 ---------------------------
arch/arm/cpu/arm1176/start.S | 27 ---------------------------
arch/arm/cpu/arm720t/start.S | 26 --------------------------
arch/arm/cpu/arm920t/start.S | 26 --------------------------
arch/arm/cpu/arm926ejs/at91/lowlevel_init.S | 14 +-------------
arch/arm/cpu/arm926ejs/mxs/start.S | 27 ---------------------------
arch/arm/cpu/arm926ejs/start.S | 27 ---------------------------
arch/arm/cpu/arm946es/start.S | 26 --------------------------
arch/arm/cpu/arm_intcm/start.S | 26 --------------------------
arch/arm/cpu/armv7/omap3/lowlevel_init.S | 3 ---
arch/arm/cpu/armv7/start.S | 23 -----------------------
arch/arm/cpu/ixp/start.S | 26 --------------------------
arch/arm/cpu/pxa/start.S | 27 ---------------------------
arch/arm/cpu/sa1100/start.S | 26 --------------------------
arch/arm/lib/board.c | 12 ++++++------
board/armltd/integrator/lowlevel_init.S | 2 +-
board/cm4008/flash.c | 2 +-
board/cm41xx/flash.c | 2 +-
board/mpl/vcma9/lowlevel_init.S | 5 +----
board/mx1ads/lowlevel_init.S | 4 ----
board/samsung/goni/lowlevel_init.S | 3 ---
board/samsung/smdk2410/lowlevel_init.S | 5 +----
board/samsung/smdk5250/lowlevel_init.S | 5 +----
board/samsung/smdkc100/lowlevel_init.S | 3 ---
board/ti/omap5912osk/lowlevel_init.S | 4 ----
board/ti/omap730p2/lowlevel_init.S | 3 ---
common/board_f.c | 18 +++++++-----------
common/board_r.c | 4 ++--
include/asm-generic/sections.h | 26 +++++++-------------------
30 files changed, 29 insertions(+), 406 deletions(-)
diff --git a/README b/README
index 0bb1ad5..1f9e16f 100644
--- a/README
+++ b/README
@@ -3522,12 +3522,6 @@ Configuration Settings:
its config.mk file). If you find problems enabling this option on
your board please report the problem and send patches!
-- CONFIG_SYS_SYM_OFFSETS
- This is set by architectures that use offsets for link symbols
- instead of absolute values. So bss_start is obtained using an
- offset _bss_start_ofs from CONFIG_SYS_TEXT_BASE, rather than
- directly. You should not need to touch this setting.
-
- CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC (OMAP only)
This is set by OMAP boards for the max time that reset should
be asserted. See doc/README.omap-reset-time for details on how
diff --git a/arch/arm/cpu/arm1136/start.S b/arch/arm/cpu/arm1136/start.S
index bd1e067..d15124b 100644
--- a/arch/arm/cpu/arm1136/start.S
+++ b/arch/arm/cpu/arm1136/start.S
@@ -70,32 +70,6 @@ _end_vect:
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
@@ -295,7 +269,6 @@ cpu_init_crit:
#ifdef CONFIG_SPL_BUILD
.align 5
do_hang:
- ldr sp, _TEXT_BASE /* use 32 words about stack */
bl hang /* hang and never return */
#else /* !CONFIG_SPL_BUILD */
.align 5
diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S
index ffd7dd0..ce62011 100644
--- a/arch/arm/cpu/arm1176/start.S
+++ b/arch/arm/cpu/arm1176/start.S
@@ -77,33 +77,6 @@ _end_vect:
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
/* IRQ stack memory (calculated at run-time) + 8 bytes */
.globl IRQ_STACK_START_IN
IRQ_STACK_START_IN:
diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S
index b6bfacf..e167e4c 100644
--- a/arch/arm/cpu/arm720t/start.S
+++ b/arch/arm/cpu/arm720t/start.S
@@ -67,32 +67,6 @@ _pad: .word 0x12345678 /* now 16*4=64 */
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
diff --git a/arch/arm/cpu/arm920t/start.S b/arch/arm/cpu/arm920t/start.S
index a67b659..7bf094a 100644
--- a/arch/arm/cpu/arm920t/start.S
+++ b/arch/arm/cpu/arm920t/start.S
@@ -55,32 +55,6 @@ _fiq: .word fiq
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
diff --git a/arch/arm/cpu/arm926ejs/at91/lowlevel_init.S b/arch/arm/cpu/arm926ejs/at91/lowlevel_init.S
index 39de2f4..7d1a633 100644
--- a/arch/arm/cpu/arm926ejs/at91/lowlevel_init.S
+++ b/arch/arm/cpu/arm926ejs/at91/lowlevel_init.S
@@ -26,27 +26,18 @@
#define CONFIG_SYS_MATRIX_EBICSA_VAL CONFIG_SYS_MATRIX_EBI0CSA_VAL
#endif
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE
-
.globl lowlevel_init
.type lowlevel_init,function
lowlevel_init:
- mov r5, pc /* r5 = POS1 + 4 current */
POS1:
+ adr r5, POS1 /* r5 = POS1 run time */
ldr r0, =POS1 /* r0 = POS1 compile */
- ldr r2, _TEXT_BASE
- sub r0, r0, r2 /* r0 = POS1-_TEXT_BASE (POS1 relative) */
sub r5, r5, r0 /* r0 = CONFIG_SYS_TEXT_BASE-1 */
- sub r5, r5, #4 /* r1 = text base - current */
/* memory control configuration 1 */
ldr r0, =SMRDATA
ldr r2, =SMRDATA1
- ldr r1, _TEXT_BASE
- sub r0, r0, r1
- sub r2, r2, r1
add r0, r0, r5
add r2, r2, r5
0:
@@ -149,9 +140,6 @@ PLL_setup_end:
ldr r0, =SMRDATA1
ldr r2, =SMRDATA2
- ldr r1, _TEXT_BASE
- sub r0, r0, r1
- sub r2, r2, r1
add r0, r0, r5
add r2, r2, r5
2:
diff --git a/arch/arm/cpu/arm926ejs/mxs/start.S b/arch/arm/cpu/arm926ejs/mxs/start.S
index 3e454ae..f06a9ca 100644
--- a/arch/arm/cpu/arm926ejs/mxs/start.S
+++ b/arch/arm/cpu/arm926ejs/mxs/start.S
@@ -101,32 +101,6 @@ fiq:
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#ifdef CONFIG_SPL_TEXT_BASE
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
@@ -198,6 +172,5 @@ _reset:
bx lr
_hang:
- ldr sp, _TEXT_BASE /* switch to abort stack */
1:
bl 1b /* hang and never return */
diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S
index 5360f55..0717327 100644
--- a/arch/arm/cpu/arm926ejs/start.S
+++ b/arch/arm/cpu/arm926ejs/start.S
@@ -102,32 +102,6 @@ _fiq:
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
@@ -330,7 +304,6 @@ flush_dcache:
#ifdef CONFIG_SPL_BUILD
.align 5
do_hang:
- ldr sp, _TEXT_BASE /* switch to abort stack */
1:
bl 1b /* hang and never return */
#else /* !CONFIG_SPL_BUILD */
diff --git a/arch/arm/cpu/arm946es/start.S b/arch/arm/cpu/arm946es/start.S
index e16b088..7d50145 100644
--- a/arch/arm/cpu/arm946es/start.S
+++ b/arch/arm/cpu/arm946es/start.S
@@ -71,32 +71,6 @@ _vectors_end:
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
diff --git a/arch/arm/cpu/arm_intcm/start.S b/arch/arm/cpu/arm_intcm/start.S
index 5783df1..7404ea7 100644
--- a/arch/arm/cpu/arm_intcm/start.S
+++ b/arch/arm/cpu/arm_intcm/start.S
@@ -67,32 +67,6 @@ _fiq:
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
diff --git a/arch/arm/cpu/armv7/omap3/lowlevel_init.S b/arch/arm/cpu/armv7/omap3/lowlevel_init.S
index 6f7261b..78577b1 100644
--- a/arch/arm/cpu/armv7/omap3/lowlevel_init.S
+++ b/arch/arm/cpu/armv7/omap3/lowlevel_init.S
@@ -17,9 +17,6 @@
#include <asm/arch/clocks_omap3.h>
#include <linux/linkage.h>
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE /* sdram load addr from config.mk */
-
#ifdef CONFIG_SPL_BUILD
ENTRY(save_boot_params)
ldr r4, =omap3_boot_device
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index ef62fc8..a5c749b 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -63,29 +63,6 @@ _end_vect:
*
*************************************************************************/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
diff --git a/arch/arm/cpu/ixp/start.S b/arch/arm/cpu/ixp/start.S
index 1362234..7a34a39 100644
--- a/arch/arm/cpu/ixp/start.S
+++ b/arch/arm/cpu/ixp/start.S
@@ -80,32 +80,6 @@ _fiq: .word fiq
* - jump to second stage
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S
index 303ca84..5d33788 100644
--- a/arch/arm/cpu/pxa/start.S
+++ b/arch/arm/cpu/pxa/start.S
@@ -84,32 +84,6 @@ _end_vect:
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
@@ -316,7 +290,6 @@ cpu_init_crit:
#ifdef CONFIG_SPL_BUILD
.align 5
do_hang:
- ldr sp, _TEXT_BASE /* use 32 words about stack */
bl hang /* hang and never return */
#else /* !CONFIG_SPL_BUILD */
.align 5
diff --git a/arch/arm/cpu/sa1100/start.S b/arch/arm/cpu/sa1100/start.S
index 27bcda5..bf80937 100644
--- a/arch/arm/cpu/sa1100/start.S
+++ b/arch/arm/cpu/sa1100/start.S
@@ -56,32 +56,6 @@ _fiq: .word fiq
*************************************************************************
*/
-.globl _TEXT_BASE
-_TEXT_BASE:
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
- .word CONFIG_SPL_TEXT_BASE
-#else
- .word CONFIG_SYS_TEXT_BASE
-#endif
-
-/*
- * These are defined in the board-specific linker script.
- * Subtracting _start from them lets the linker put their
- * relative position in the executable instead of leaving
- * them null.
- */
-.globl _bss_start_ofs
-_bss_start_ofs:
- .word __bss_start - _start
-
-.globl _bss_end_ofs
-_bss_end_ofs:
- .word __bss_end - _start
-
-.globl _end_ofs
-_end_ofs:
- .word _end - _start
-
#ifdef CONFIG_USE_IRQ
/* IRQ stack memory (calculated at run-time) */
.globl IRQ_STACK_START
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 34f50b0..f8ac573 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -105,8 +105,8 @@ static int display_banner(void)
{
printf("\n\n%s\n\n", version_string);
debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
- _TEXT_BASE,
- _bss_start_ofs + _TEXT_BASE, _bss_end_ofs + _TEXT_BASE);
+ (ulong)&_start,
+ (ulong)&__bss_start, (ulong)&__bss_end);
#ifdef CONFIG_MODEM_SUPPORT
debug("Modem Support enabled\n");
#endif
@@ -277,13 +277,13 @@ void board_init_f(ulong bootflag)
memset((void *)gd, 0, sizeof(gd_t));
- gd->mon_len = _bss_end_ofs;
+ gd->mon_len = (ulong)&__bss_end - (ulong)_start;
#ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */
gd->fdt_blob = _binary_dt_dtb_start;
#elif defined CONFIG_OF_SEPARATE
/* FDT is at end of image */
- gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE);
+ gd->fdt_blob = &_end;
#endif
/* Allow the early environment to override the fdt address */
gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
@@ -451,7 +451,7 @@ void board_init_f(ulong bootflag)
gd->relocaddr = addr;
gd->start_addr_sp = addr_sp;
- gd->reloc_off = addr - _TEXT_BASE;
+ gd->reloc_off = addr - (ulong)&_start;
debug("relocation Offset is: %08lx\n", gd->reloc_off);
if (new_fdt) {
memcpy(new_fdt, gd->fdt_blob, fdt_size);
@@ -516,7 +516,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
- monitor_flash_len = _end_ofs;
+ monitor_flash_len = (ulong)&__rel_dyn_end - (ulong)_start;
/* Enable caches */
enable_caches();
diff --git a/board/armltd/integrator/lowlevel_init.S b/board/armltd/integrator/lowlevel_init.S
index 4e2da40..27cf054 100644
--- a/board/armltd/integrator/lowlevel_init.S
+++ b/board/armltd/integrator/lowlevel_init.S
@@ -183,7 +183,7 @@ cm_remap:
/* Now 0x00000000 is writeable, replace the vectors */
ldr r0, =_start /* r0 <- start of vectors */
- ldr r2, =_TEXT_BASE /* r2 <- past vectors */
+ add r2, r0, #64 /* r2 <- past vectors */
sub r1,r1,r1 /* destination 0x00000000 */
copy_vec:
diff --git a/board/cm4008/flash.c b/board/cm4008/flash.c
index 2511928..8315a57 100644
--- a/board/cm4008/flash.c
+++ b/board/cm4008/flash.c
@@ -57,7 +57,7 @@ unsigned long flash_init (void)
*/
flash_protect (FLAG_PROTECT_SET,
CONFIG_SYS_FLASH_BASE,
- CONFIG_SYS_FLASH_BASE + _bss_start_ofs,
+ CONFIG_SYS_FLASH_BASE + (__bss_end - __bss_start),
&flash_info[0]);
return size;
diff --git a/board/cm41xx/flash.c b/board/cm41xx/flash.c
index 2511928..8315a57 100644
--- a/board/cm41xx/flash.c
+++ b/board/cm41xx/flash.c
@@ -57,7 +57,7 @@ unsigned long flash_init (void)
*/
flash_protect (FLAG_PROTECT_SET,
CONFIG_SYS_FLASH_BASE,
- CONFIG_SYS_FLASH_BASE + _bss_start_ofs,
+ CONFIG_SYS_FLASH_BASE + (__bss_end - __bss_start),
&flash_info[0]);
return size;
diff --git a/board/mpl/vcma9/lowlevel_init.S b/board/mpl/vcma9/lowlevel_init.S
index b889cf9..cca9c0c 100644
--- a/board/mpl/vcma9/lowlevel_init.S
+++ b/board/mpl/vcma9/lowlevel_init.S
@@ -197,13 +197,10 @@
#define REFCNT_266 0
/**************************************/
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE
-
.globl lowlevel_init
lowlevel_init:
/* use r0 to relocate DATA read/write to flash rather than memory ! */
- ldr r0, _TEXT_BASE
+ ldr r0, =CONFIG_SYS_TEXT_BASE
ldr r13, =BWSCON
/* enable minimal access to PLD */
diff --git a/board/mx1ads/lowlevel_init.S b/board/mx1ads/lowlevel_init.S
index d1e472a..3e713cc 100644
--- a/board/mx1ads/lowlevel_init.S
+++ b/board/mx1ads/lowlevel_init.S
@@ -16,10 +16,6 @@
#define SDCTL0 0x221000
#define SDCTL1 0x221004
-
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE
-
.globl lowlevel_init
lowlevel_init:
/* memory controller init */
diff --git a/board/samsung/goni/lowlevel_init.S b/board/samsung/goni/lowlevel_init.S
index 726211a..d52bc09 100644
--- a/board/samsung/goni/lowlevel_init.S
+++ b/board/samsung/goni/lowlevel_init.S
@@ -22,9 +22,6 @@
* r9 has Mobile DDR size, 1 means 1GiB, 2 means 2GiB and so on
*/
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE
-
.globl lowlevel_init
lowlevel_init:
mov r11, lr
diff --git a/board/samsung/smdk2410/lowlevel_init.S b/board/samsung/smdk2410/lowlevel_init.S
index c7b78fd..5de04f1 100644
--- a/board/samsung/smdk2410/lowlevel_init.S
+++ b/board/samsung/smdk2410/lowlevel_init.S
@@ -110,16 +110,13 @@
#define REFCNT 1113 /* period=15.6us, HCLK=60Mhz, (2048+1-15.6*60) */
/**************************************/
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE
-
.globl lowlevel_init
lowlevel_init:
/* memory control configuration */
/* make r0 relative the current location so that it */
/* reads SMRDATA out of FLASH rather than memory ! */
ldr r0, =SMRDATA
- ldr r1, _TEXT_BASE
+ ldr r1, =CONFIG_SYS_TEXT_BASE
sub r0, r0, r1
ldr r1, =BWSCON /* Bus Width Status Controller */
add r2, r0, #13*4
diff --git a/board/samsung/smdk5250/lowlevel_init.S b/board/samsung/smdk5250/lowlevel_init.S
index 9003e2d..9395179 100644
--- a/board/samsung/smdk5250/lowlevel_init.S
+++ b/board/samsung/smdk5250/lowlevel_init.S
@@ -10,9 +10,6 @@
#include <version.h>
#include <asm/arch/cpu.h>
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE
-
.globl lowlevel_init
lowlevel_init:
@@ -47,7 +44,7 @@ lowlevel_init:
ldr r0, =0x0ffffff /* r0 <- Mask Bits*/
bic r1, pc, r0 /* pc <- current addr of code */
/* r1 <- unmasked bits of pc */
- ldr r2, _TEXT_BASE /* r2 <- original base addr in ram */
+ ldr r2, =CONFIG_SYS_TEXT_BASE /* r2 <- original base addr in ram */
bic r2, r2, r0 /* r2 <- unmasked bits of r2*/
cmp r1, r2 /* compare r1, r2 */
beq 1f /* r0 == r1 then skip sdram init */
diff --git a/board/samsung/smdkc100/lowlevel_init.S b/board/samsung/smdkc100/lowlevel_init.S
index 4df0974..65e6b7a 100644
--- a/board/samsung/smdkc100/lowlevel_init.S
+++ b/board/samsung/smdkc100/lowlevel_init.S
@@ -17,9 +17,6 @@
* r5 has zero always
*/
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE
-
.globl lowlevel_init
lowlevel_init:
mov r9, lr
diff --git a/board/ti/omap5912osk/lowlevel_init.S b/board/ti/omap5912osk/lowlevel_init.S
index cad0a5a..e05a1c7 100644
--- a/board/ti/omap5912osk/lowlevel_init.S
+++ b/board/ti/omap5912osk/lowlevel_init.S
@@ -18,10 +18,6 @@
#include <./configs/omap1510.h>
#endif
-
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE /* sdram load addr from config.mk */
-
.globl lowlevel_init
lowlevel_init:
diff --git a/board/ti/omap730p2/lowlevel_init.S b/board/ti/omap730p2/lowlevel_init.S
index 795c495..c7ea21b 100644
--- a/board/ti/omap730p2/lowlevel_init.S
+++ b/board/ti/omap730p2/lowlevel_init.S
@@ -24,9 +24,6 @@
#include <./configs/omap730.h>
#endif
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE /* sdram load addr from config.mk */
-
.globl lowlevel_init
lowlevel_init:
/* Save callers address in r11 - r11 must never be modified */
diff --git a/common/board_f.c b/common/board_f.c
index 0ada1af..decd7f2 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -149,13 +149,9 @@ static int display_text_info(void)
#ifndef CONFIG_SANDBOX
ulong bss_start, bss_end;
-#ifdef CONFIG_SYS_SYM_OFFSETS
- bss_start = _bss_start_ofs + _TEXT_BASE;
- bss_end = _bss_end_ofs + _TEXT_BASE;
-#else
bss_start = (ulong)&__bss_start;
bss_end = (ulong)&__bss_end;
-#endif
+
debug("U-Boot code: %08X -> %08lX BSS: -> %08lX\n",
CONFIG_SYS_TEXT_BASE, bss_start, bss_end);
#endif
@@ -275,8 +271,8 @@ static int zero_global_data(void)
static int setup_mon_len(void)
{
-#ifdef CONFIG_SYS_SYM_OFFSETS
- gd->mon_len = _bss_end_ofs;
+#ifdef __ARM__
+ gd->mon_len = (ulong)&__bss_end - (ulong)_start;
#elif defined(CONFIG_SANDBOX)
gd->mon_len = (ulong)&_end - (ulong)_init;
#else
@@ -358,11 +354,11 @@ static int setup_fdt(void)
gd->fdt_blob = _binary_dt_dtb_start;
#elif defined CONFIG_OF_SEPARATE
/* FDT is at end of image */
-# ifdef CONFIG_SYS_SYM_OFFSETS
- gd->fdt_blob = (void *)(_end_ofs + CONFIG_SYS_TEXT_BASE);
-# else
+#ifdef CONFIG_ARM
+ gd->fdt_blob = (ulong *)__rel_dyn_end;
+#else
gd->fdt_blob = (ulong *)&_end;
-# endif
+#endif
#elif defined(CONFIG_OF_HOSTFILE)
if (read_fdt_from_file()) {
puts("Failed to read control FDT\n");
diff --git a/common/board_r.c b/common/board_r.c
index 86ca1cb..ce84753 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -128,8 +128,8 @@ __weak int fixup_cpu(void)
static int initr_reloc_global_data(void)
{
-#ifdef CONFIG_SYS_SYM_OFFSETS
- monitor_flash_len = _end_ofs;
+#ifdef __ARM__
+ monitor_flash_len = __rel_dyn_end - __image_copy_start;
#elif !defined(CONFIG_SANDBOX)
monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
#endif
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 7e1eb4b..458952f 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -63,28 +63,16 @@ extern char __image_copy_end[];
extern void _start(void);
/*
- * ARM needs to use offsets for symbols, since the values of some symbols
- * are not resolved prior to relocation (and are just 0). Maybe this can be
- * resolved, or maybe other architectures are similar, iwc this should be
- * promoted to an architecture option.
+ * ARM defines its symbols as char[]. Other arches define them as ulongs.
*/
#ifdef CONFIG_ARM
-#define CONFIG_SYS_SYM_OFFSETS
-#endif
-
-#ifdef CONFIG_SYS_SYM_OFFSETS
-/* Start/end of the relocation entries, as an offset from _start */
-extern ulong _rel_dyn_start_ofs;
-extern ulong _rel_dyn_end_ofs;
-
-/* End of the region to be relocated, as an offset form _start */
-extern ulong _image_copy_end_ofs;
-extern ulong _bss_start_ofs; /* BSS start relative to _start */
-extern ulong _bss_end_ofs; /* BSS end relative to _start */
-extern ulong _end_ofs; /* end of image relative to _start */
-
-extern ulong _TEXT_BASE; /* code start */
+extern char __bss_start[];
+extern char __bss_end[];
+extern char __image_copy_start[];
+extern char __image_copy_end[];
+extern char __rel_dyn_start[];
+extern char __rel_dyn_end[];
#else /* don't use offsets: */
--
1.8.3.2
1
0
This patchset improves the mx28evk default environment so it is
easier to use by users when testing the NAND support.
It provides a set of new environment routines as:
- update_nand_kernel
- update_nand_fdt
- update_nand_filesystem
and allow for easy NAND boot using:
'run nandboot'
This has been tested using:
Samsung 4G NAND, part-#: K9LBG08U0D-PCB0
Otavio Salvador (3):
mx28evk: Use 512k for fdt partition to align it
mx28evk: Add 'nandboot' environment command
mx28evk: Extend environment to easy write of NAND system
include/configs/mx28evk.h | 55 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 52 insertions(+), 3 deletions(-)
--
1.8.4.rc3
1
3

[U-Boot] [PATCH v5] PCIe:change the method to get the address of a requested capability in configuration space.
by Zhao Qiang 12 Oct '13
by Zhao Qiang 12 Oct '13
12 Oct '13
Previously, the address of a requested capability is define like that
"#define PCI_DCR 0x78"
But, the addresses of capabilities is different with regard to PCIe revs.
So this method is not flexible.
Now a function to get the address of a requested capability is added and used.
It can get the address dynamically by capability ID.
The step of this function:
1. Read Status register in PCIe configuration space to confirm that
Capabilities List is valid.
2. Find the address of Capabilities Pointer Register.
3. Find the address of requested capability from the first capability.
Signed-off-by: Zhao Qiang <B45475(a)freescale.com>
---
Changes for v2:
-Put an variable into "#ifdef" and "#endif"
Changes for v3:
-Modify the patch description
Changes for v4:
-Rebase on u-boot master branch
Changes for v5:
-Remove a blank
arch/powerpc/include/asm/fsl_pci.h | 18 -----------
drivers/pci/fsl_pci_init.c | 44 +++++++++++++++++++-------
drivers/pci/pci.c | 65 ++++++++++++++++++++++++++++++++++++++
include/pci.h | 10 ++++++
4 files changed, 107 insertions(+), 30 deletions(-)
diff --git a/arch/powerpc/include/asm/fsl_pci.h b/arch/powerpc/include/asm/fsl_pci.h
index 749411c..5be718b 100644
--- a/arch/powerpc/include/asm/fsl_pci.h
+++ b/arch/powerpc/include/asm/fsl_pci.h
@@ -18,24 +18,6 @@
/* Freescale-specific PCI config registers */
#define FSL_PCI_PBFR 0x44
-#ifdef CONFIG_SYS_FSL_PCI_VER_3_X
-/* Currently only the PCIe capability is used, so hardcode the offset.
- * if more capabilities need to be justified, the capability link method
- * should be applied here
- */
-#define FSL_PCIE_CAP_ID 0x70
-#define PCI_DCR 0x78 /* PCIe Device Control Register */
-#define PCI_DSR 0x7a /* PCIe Device Status Register */
-#define PCI_LSR 0x82 /* PCIe Link Status Register */
-#define PCI_LCR 0x80 /* PCIe Link Control Register */
-#else
-#define FSL_PCIE_CAP_ID 0x4c
-#define PCI_DCR 0x54 /* PCIe Device Control Register */
-#define PCI_DSR 0x56 /* PCIe Device Status Register */
-#define PCI_LSR 0x5e /* PCIe Link Status Register */
-#define PCI_LCR 0x5c /* PCIe Link Control Register */
-#endif
-
#define FSL_PCIE_CFG_RDY 0x4b0
#define FSL_PROG_IF_AGENT 0x1
diff --git a/drivers/pci/fsl_pci_init.c b/drivers/pci/fsl_pci_init.c
index d55db1a..2085cd6 100644
--- a/drivers/pci/fsl_pci_init.c
+++ b/drivers/pci/fsl_pci_init.c
@@ -295,6 +295,15 @@ void fsl_pci_init(struct pci_controller *hose, struct fsl_pci_info *pci_info)
int enabled, r, inbound = 0;
u16 ltssm;
u8 temp8, pcie_cap;
+ int pcie_cap_pos;
+ int pci_dcr;
+ int pci_dsr;
+ int pci_lsr;
+
+#if defined(CONFIG_FSL_PCIE_DISABLE_ASPM)
+ int pci_lcr;
+#endif
+
volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *)cfg_addr;
struct pci_region *reg = hose->regions + hose->region_count;
pci_dev_t dev = PCI_BDF(hose->first_busno, 0, 0);
@@ -367,7 +376,12 @@ void fsl_pci_init(struct pci_controller *hose, struct fsl_pci_info *pci_info)
hose->region_count++;
/* see if we are a PCIe or PCI controller */
- pci_hose_read_config_byte(hose, dev, FSL_PCIE_CAP_ID, &pcie_cap);
+ pcie_cap_pos = pci_hose_find_capability(hose, dev, PCI_CAP_ID_EXP);
+ pci_dcr = pcie_cap_pos + 0x08;
+ pci_dsr = pcie_cap_pos + 0x0a;
+ pci_lsr = pcie_cap_pos + 0x12;
+
+ pci_hose_read_config_byte(hose, dev, pcie_cap_pos, &pcie_cap);
#ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
/* boot from PCIE --master */
@@ -406,15 +420,16 @@ void fsl_pci_init(struct pci_controller *hose, struct fsl_pci_info *pci_info)
* - Master PERR (pci)
* - ICCA (PCIe)
*/
- pci_hose_read_config_dword(hose, dev, PCI_DCR, &temp32);
+ pci_hose_read_config_dword(hose, dev, pci_dcr, &temp32);
temp32 |= 0xf000e; /* set URR, FER, NFER (but not CER) */
- pci_hose_write_config_dword(hose, dev, PCI_DCR, temp32);
+ pci_hose_write_config_dword(hose, dev, pci_dcr, temp32);
#if defined(CONFIG_FSL_PCIE_DISABLE_ASPM)
+ pci_lcr = pcie_cap_pos + 0x10;
temp32 = 0;
- pci_hose_read_config_dword(hose, dev, PCI_LCR, &temp32);
+ pci_hose_read_config_dword(hose, dev, pci_lcr, &temp32);
temp32 &= ~0x03; /* Disable ASPM */
- pci_hose_write_config_dword(hose, dev, PCI_LCR, temp32);
+ pci_hose_write_config_dword(hose, dev, pci_lcr, temp32);
udelay(1);
#endif
if (pcie_cap == PCI_CAP_ID_EXP) {
@@ -494,7 +509,7 @@ void fsl_pci_init(struct pci_controller *hose, struct fsl_pci_info *pci_info)
out_be32(&pci->pme_msg_int_en, 0xffffffff);
/* Print the negotiated PCIe link width */
- pci_hose_read_config_word(hose, dev, PCI_LSR, &temp16);
+ pci_hose_read_config_word(hose, dev, pci_lsr, &temp16);
printf("x%d, regs @ 0x%lx\n", (temp16 & 0x3f0 ) >> 4,
pci_info->regs);
@@ -541,9 +556,9 @@ void fsl_pci_init(struct pci_controller *hose, struct fsl_pci_info *pci_info)
out_be32(&pci->pme_msg_det, 0xffffffff);
out_be32(&pci->pedr, 0xffffffff);
- pci_hose_read_config_word (hose, dev, PCI_DSR, &temp16);
+ pci_hose_read_config_word(hose, dev, pci_dsr, &temp16);
if (temp16) {
- pci_hose_write_config_word(hose, dev, PCI_DSR, 0xffff);
+ pci_hose_write_config_word(hose, dev, pci_dsr, 0xffff);
}
pci_hose_read_config_word (hose, dev, PCI_SEC_STATUS, &temp16);
@@ -554,10 +569,12 @@ void fsl_pci_init(struct pci_controller *hose, struct fsl_pci_info *pci_info)
int fsl_is_pci_agent(struct pci_controller *hose)
{
+ int pcie_cap_pos;
u8 pcie_cap;
pci_dev_t dev = PCI_BDF(hose->first_busno, 0, 0);
- pci_hose_read_config_byte(hose, dev, FSL_PCIE_CAP_ID, &pcie_cap);
+ pcie_cap_pos = pci_hose_find_capability(hose, dev, PCI_CAP_ID_EXP);
+ pci_hose_read_config_byte(hose, dev, pcie_cap_pos, &pcie_cap);
if (pcie_cap == PCI_CAP_ID_EXP) {
u8 header_type;
@@ -582,6 +599,7 @@ int fsl_pci_init_port(struct fsl_pci_info *pci_info,
volatile ccsr_fsl_pci_t *pci;
struct pci_region *r;
pci_dev_t dev = PCI_BDF(busno,0,0);
+ int pcie_cap_pos;
u8 pcie_cap;
pci = (ccsr_fsl_pci_t *) pci_info->regs;
@@ -631,11 +649,11 @@ int fsl_pci_init_port(struct fsl_pci_info *pci_info,
#endif
}
- pci_hose_read_config_byte(hose, dev, FSL_PCIE_CAP_ID, &pcie_cap);
+ pcie_cap_pos = pci_hose_find_capability(hose, dev, PCI_CAP_ID_EXP);
+ pci_hose_read_config_byte(hose, dev, pcie_cap_pos, &pcie_cap);
printf("PCI%s%x: Bus %02x - %02x\n", pcie_cap == PCI_CAP_ID_EXP ?
"e" : "", pci_info->pci_num,
hose->first_busno, hose->last_busno);
-
return(hose->last_busno + 1);
}
@@ -643,13 +661,15 @@ int fsl_pci_init_port(struct fsl_pci_info *pci_info,
void fsl_pci_config_unlock(struct pci_controller *hose)
{
pci_dev_t dev = PCI_BDF(hose->first_busno,0,0);
+ int pcie_cap_pos;
u8 pcie_cap;
u16 pbfr;
if (!fsl_is_pci_agent(hose))
return;
- pci_hose_read_config_byte(hose, dev, FSL_PCIE_CAP_ID, &pcie_cap);
+ pcie_cap_pos = pci_hose_find_capability(hose, dev, PCI_CAP_ID_EXP);
+ pci_hose_read_config_byte(hose, dev, pcie_cap_pos, &pcie_cap);
if (pcie_cap != 0x0) {
/* PCIe - set CFG_READY bit of Configuration Ready Register */
pci_hose_write_config_byte(hose, dev, FSL_PCIE_CFG_RDY, 0x1);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2c07158..ed113bf 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -722,3 +722,68 @@ void pci_init(void)
/* now call board specific pci_init()... */
pci_init_board();
}
+
+/* Returns the address of the requested capability structure within the
+ * device's PCI configuration space or 0 in case the device does not
+ * support it.
+ * */
+int pci_hose_find_capability(struct pci_controller *hose, pci_dev_t dev,
+ int cap)
+{
+ int pos;
+ u8 hdr_type;
+
+ pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &hdr_type);
+
+ pos = pci_hose_find_cap_start(hose, dev, hdr_type & 0x7F);
+
+ if (pos)
+ pos = pci_find_cap(hose, dev, pos, cap);
+
+ return pos;
+}
+
+/* Find the header pointer to the Capabilities*/
+int pci_hose_find_cap_start(struct pci_controller *hose, pci_dev_t dev,
+ u8 hdr_type)
+{
+ u16 status;
+
+ pci_hose_read_config_word(hose, dev, PCI_STATUS, &status);
+
+ if (!(status & PCI_STATUS_CAP_LIST))
+ return 0;
+
+ switch (hdr_type) {
+ case PCI_HEADER_TYPE_NORMAL:
+ case PCI_HEADER_TYPE_BRIDGE:
+ return PCI_CAPABILITY_LIST;
+ case PCI_HEADER_TYPE_CARDBUS:
+ return PCI_CB_CAPABILITY_LIST;
+ default:
+ return 0;
+ }
+}
+
+int pci_find_cap(struct pci_controller *hose, pci_dev_t dev, int pos, int cap)
+{
+ int ttl = PCI_FIND_CAP_TTL;
+ u8 id;
+ u8 next_pos;
+
+ while (ttl--) {
+ pci_hose_read_config_byte(hose, dev, pos, &next_pos);
+ if (next_pos < CAP_START_POS)
+ break;
+ next_pos &= ~3;
+ pos = (int) next_pos;
+ pci_hose_read_config_byte(hose, dev,
+ pos + PCI_CAP_LIST_ID, &id);
+ if (id == 0xff)
+ break;
+ if (id == cap)
+ return pos;
+ pos += PCI_CAP_LIST_NEXT;
+ }
+ return 0;
+}
diff --git a/include/pci.h b/include/pci.h
index 911ba89..d462479 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -410,6 +410,9 @@
#define PCI_MAX_PCI_DEVICES 32
#define PCI_MAX_PCI_FUNCTIONS 8
+#define PCI_FIND_CAP_TTL 0x48
+#define CAP_START_POS 0x40
+
/* Include the ID list */
#include <pci_ids.h>
@@ -647,6 +650,13 @@ extern int pci_hose_config_device(struct pci_controller *hose,
pci_addr_t mem,
unsigned long command);
+extern int pci_hose_find_capability(struct pci_controller *hose, pci_dev_t dev,
+ int cap);
+extern int pci_hose_find_cap_start(struct pci_controller *hose, pci_dev_t dev,
+ u8 hdr_type);
+extern int pci_find_cap(struct pci_controller *hose, pci_dev_t dev, int pos,
+ int cap);
+
const char * pci_class_str(u8 class);
int pci_last_busno(void);
--
1.8.0
1
0
V2 patchset for TI SoC's that support xHCI controllers
Dan Murphy (6):
usb: omap: Move the xhci-omap header file to common location
usb: omap5: Update the board_usb_init api
usb: omap: Move the usb phy code to the usb/phy directory
usb: dra7xx: Add support for dra7xx xhci USB host
usb: am437x: Add support for am437x xhci USB host
ARM: omap5-evm: Move MAC creation to misc_init
arch/arm/cpu/armv7/omap5/prcm-regs.c | 1 +
arch/arm/include/asm/arch-am33xx/hardware_am43xx.h | 10 ++
arch/arm/include/asm/arch-omap5/clock.h | 4 +
arch/arm/include/asm/omap_common.h | 1 +
board/ti/dra7xx/evm.c | 6 -
board/ti/dra7xx/mux_data.h | 1 +
board/ti/omap5_uevm/evm.c | 41 ++---
drivers/usb/host/xhci-omap.c | 184 +------------------
drivers/usb/phy/Makefile | 1 +
.../usb/{host/xhci-omap.c => phy/omap_usb_phy.c} | 187 +++++++-------------
include/configs/am43xx_evm.h | 11 ++
include/configs/dra7xx_evm.h | 11 ++
.../arch-omap5 => include/linux/usb}/xhci-omap.h | 16 ++
13 files changed, 146 insertions(+), 328 deletions(-)
copy drivers/usb/{host/xhci-omap.c => phy/omap_usb_phy.c} (58%)
rename {arch/arm/include/asm/arch-omap5 => include/linux/usb}/xhci-omap.h (86%)
--
1.7.9.5
2
8
Is there a policy that new source files upstreamed to u-boot contain
registered SPDX license identifiers? I see that there are still about 1900
source files that have no SPDX identifier, and about 6000 that do. The
reason I'm asking is that our company has a dual license (for GPL2.0 or
Proprietary), and would like to know if it is possible to submit code that
has the legacy dual license first (and register/clean up SPDX later), or if
we need to do the internal legal and register the appropriate licenses with
spdx.org first before submission upstream?
Another question is related to http://spdx.org/about-spdx/faqs
*How does one represent a file or package that is dual licensed
(i.e., a license choice)?*
SPDX license information can be represented using conjunctive or
disjunctive regular expressions. For example, a file that is dual licensed
under either the GPL-2.0 or MIT would be represented using the following
disjunctive expression: (GPL-2.0 *or* MIT).
So my question is whether a dual license can be registered with spdx or is
it necessary to split the dual license and show the "or" condition above.
In other words, is the "or" parsing critical to license clearing reports?
Thanks.
3
2