From dbb7234b2a5e7d2cdb6658156de8d2d5b54033d7 Mon Sep 17 00:00:00 2001 From: Vasili Galka Date: Tue, 10 Jun 2014 16:14:56 +0300 Subject: x86: Enable 32-bit build using x86_64 multilib toolchain Until now building the x86 arch boards required 32-bit toolchain. As many x86_64 toolchains come with 32-bit support (multilib) that's a good idea to enable build with such toolchains. The change required was to specify the usage of 32-bit explicitly to the compiler and the linker (-m32 and -m elf_i386 flags) and locate the right libgcc path. Signed-off-by: Vasili Galka Acked-by: Simon Glass diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 38cb7c9..3106079 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -16,17 +16,18 @@ PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \ PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86) PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm PLATFORM_CPPFLAGS += -DREALMODE_BASE=0x7c0 +PLATFORM_CPPFLAGS += -march=i386 -m32 # Support generic board on x86 __HAVE_ARCH_GENERIC_BOARD := y PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden -PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions +PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions -m elf_i386 LDFLAGS_FINAL += --gc-sections -pie LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3 LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3 -export NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) +export NORMAL_LIBGCC = $(shell $(CC) $(PLATFORM_CPPFLAGS) -print-libgcc-file-name) CONFIG_USE_PRIVATE_LIBGCC := arch/x86/lib diff --git a/arch/x86/cpu/config.mk b/arch/x86/cpu/config.mk index c1568cac..4b2c873 100644 --- a/arch/x86/cpu/config.mk +++ b/arch/x86/cpu/config.mk @@ -7,7 +7,7 @@ CROSS_COMPILE ?= i386-linux- -PLATFORM_CPPFLAGS += -DCONFIG_X86 -D__I386__ -march=i386 -Werror +PLATFORM_CPPFLAGS += -DCONFIG_X86 -D__I386__ -Werror # DO NOT MODIFY THE FOLLOWING UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! LDPPFLAGS += -DRESET_SEG_START=0xffff0000 -- cgit v0.10.2 From 4d907025d6a530c0f3d2e869331e863c3e3cc3c2 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 12 Jun 2014 10:28:32 -0600 Subject: sandbox: restore ability to access host fs through standard commands Commit 95fac6ab4589 "sandbox: Use os functions to read host device tree" removed the ability for get_device_and_partition() to handle the "host" device type, and redirect accesses to it to the host filesystem. This broke some unit tests that use this feature. So, revert that change. The code added back by this patch is slightly different to pacify checkpatch. However, we're then left with "host" being both: - A pseudo device that accesses the hosts real filesystem. - An emulated block device, which accesses "sectors" inside a file stored on the host. In order to resolve this discrepancy, rename the pseudo device from host to hostfs, and adjust the unit-tests for this change. The "help sb" output is modified to reflect this rename, and state where the host and hostfs devices should be used. Signed-off-by: Stephen Warren Tested-by: Josh Wu Acked-by: Simon Glass Tested-by: Simon Glass diff --git a/common/cmd_sandbox.c b/common/cmd_sandbox.c index 00982b1..3d9fce7 100644 --- a/common/cmd_sandbox.c +++ b/common/cmd_sandbox.c @@ -114,11 +114,13 @@ static int do_sandbox(cmd_tbl_t *cmdtp, int flag, int argc, U_BOOT_CMD( sb, 8, 1, do_sandbox, "Miscellaneous sandbox commands", - "load host [ ] - " + "load hostfs - [ ] - " "load a file from host\n" - "sb ls host - list files on host\n" - "sb save host [] - " + "sb ls hostfs - - list files on host\n" + "sb save hostfs - [] - " "save a file to host\n" "sb bind [] - bind \"host\" device to file\n" - "sb info [] - show device binding & info" + "sb info [] - show device binding & info\n" + "sb commands use the \"hostfs\" device. The \"host\" device is used\n" + "with standard IO commands such as fatls or ext2load" ); diff --git a/disk/part.c b/disk/part.c index b3097e3..baceb19 100644 --- a/disk/part.c +++ b/disk/part.c @@ -510,6 +510,25 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str, int part; disk_partition_t tmpinfo; + /* + * Special-case a psuedo block device "hostfs", to allow access to the + * host's own filesystem. + */ + if (0 == strcmp(ifname, "hostfs")) { + *dev_desc = NULL; + info->start = 0; + info->size = 0; + info->blksz = 0; + info->bootable = 0; + strcpy((char *)info->type, BOOT_PART_TYPE); + strcpy((char *)info->name, "Sandbox host"); +#ifdef CONFIG_PARTITION_UUIDS + info->uuid[0] = 0; +#endif + + return 0; + } + /* If no dev_part_str, use bootdevice environment variable */ if (!dev_part_str || !strlen(dev_part_str) || !strcmp(dev_part_str, "-")) diff --git a/test/command_ut.c b/test/command_ut.c index b2666bf..ae6466d 100644 --- a/test/command_ut.c +++ b/test/command_ut.c @@ -165,12 +165,12 @@ static int do_ut_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #ifdef CONFIG_SANDBOX /* File existence */ - HUSH_TEST(e, "-e host - creating_this_file_breaks_uboot_unit_test", n); - run_command("sb save host - creating_this_file_breaks_uboot_unit_test 0 1", 0); - HUSH_TEST(e, "-e host - creating_this_file_breaks_uboot_unit_test", y); + HUSH_TEST(e, "-e hostfs - creating_this_file_breaks_uboot_unit_test", n); + run_command("sb save hostfs - creating_this_file_breaks_uboot_unit_test 0 1", 0); + HUSH_TEST(e, "-e hostfs - creating_this_file_breaks_uboot_unit_test", y); /* Perhaps this could be replaced by an "rm" shell command one day */ assert(!os_unlink("creating_this_file_breaks_uboot_unit_test")); - HUSH_TEST(e, "-e host - creating_this_file_breaks_uboot_unit_test", n); + HUSH_TEST(e, "-e hostfs - creating_this_file_breaks_uboot_unit_test", n); #endif #endif diff --git a/test/vboot/vboot_test.sh b/test/vboot/vboot_test.sh index cc67bed..8074fc6 100755 --- a/test/vboot/vboot_test.sh +++ b/test/vboot/vboot_test.sh @@ -14,7 +14,7 @@ set -e run_uboot() { echo -n "Test Verified Boot Run: $1: " ${uboot} -d sandbox-u-boot.dtb >${tmp} -c ' -sb load host 0 100 test.fit; +sb load hostfs - 100 test.fit; fdt addr 100; bootm 100; reset' -- cgit v0.10.2 From 9c38c070085b566e2fc3f7696cdd4362c2759285 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 11 Jun 2014 10:26:23 -0600 Subject: sandbox: terminate os_dirent_ls() result list Each node in the linked-list that os_dirent_ls() returns has its next pointer set only when the next node is created. For the last node in the list, there is no next node, so this never happens, and the next pointer is never initialized. Explicitly initialize the next pointer so that it isn't dangling. Without this, "sb ls" might crash. Signed-off-by: Stephen Warren Acked-by: Simon Glass diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 57d04a4..1c4aa3f 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -341,6 +341,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) ret = -ENOMEM; goto done; } + next->next = NULL; strcpy(next->name, entry.d_name); switch (entry.d_type) { case DT_REG: -- cgit v0.10.2 From 1638d98052e0d03e46d504b21ec1b88ecfcd87aa Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 12 Jun 2014 12:26:15 +0900 Subject: sandbox: change local_irq_save() to macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit local_irq_save() should be a macro, not a function because local_irq_save() saves flag to the given argument. GCC is silent about this issue, but Clang warns: In file included from lib/asm-offsets.c:15: In file included from include/common.h:20: In file included from include/linux/bitops.h:110: arch/sandbox/include/asm/bitops.h:59:17: warning: variable 'flags' is uninitialized when used here [-Wuninitialized] local_irq_save(flags); ^~~~~ That change causes another warning: In file included from include/linux/bitops.h:110:0, from include/common.h:20, from lib/asm-offsets.c:15: arch/sandbox/include/asm/bitops.h: In function ‘test_and_set_bit’: arch/sandbox/include/asm/bitops.h:56:16: warning: unused variable ‘flags’ [-Wunused-variable] So, flags should be set to __always_unused. Signed-off-by: Masahiro Yamada Cc: Simon Glass Cc: Jeroen Hofstee Acked-by: Simon Glass Acked-by: Jeroen Hofstee diff --git a/arch/sandbox/include/asm/bitops.h b/arch/sandbox/include/asm/bitops.h index 74219c5..e807c4e 100644 --- a/arch/sandbox/include/asm/bitops.h +++ b/arch/sandbox/include/asm/bitops.h @@ -17,6 +17,7 @@ #ifndef __ASM_SANDBOX_BITOPS_H #define __ASM_SANDBOX_BITOPS_H +#include #include #ifdef __KERNEL__ @@ -53,7 +54,7 @@ static inline int __test_and_set_bit(int nr, void *addr) static inline int test_and_set_bit(int nr, void *addr) { - unsigned long flags; + unsigned long __always_unused flags; int out; local_irq_save(flags); @@ -75,7 +76,7 @@ static inline int __test_and_clear_bit(int nr, void *addr) static inline int test_and_clear_bit(int nr, void *addr) { - unsigned long flags; + unsigned long __always_unused flags; int out; local_irq_save(flags); diff --git a/arch/sandbox/include/asm/system.h b/arch/sandbox/include/asm/system.h index 066acc5..02beed3 100644 --- a/arch/sandbox/include/asm/system.h +++ b/arch/sandbox/include/asm/system.h @@ -8,10 +8,7 @@ #define __ASM_SANDBOX_SYSTEM_H /* Define this as nops for sandbox architecture */ -static inline void local_irq_save(unsigned flags __attribute__((unused))) -{ -} - +#define local_irq_save(x) #define local_irq_enable() #define local_irq_disable() #define local_save_flags(x) -- cgit v0.10.2