public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot
@ 2011-09-27  0:10 Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 01/21] sandbox: Add architecture header files Simon Glass
                   ` (20 more replies)
  0 siblings, 21 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot


This patch set points towards a possible way to improve the test
infrastructure in U-Boot. The goal is to have a test suite that can run in
a minute or two on a Linux PC and test all non-platform code.

This RFC aims to be just enough boot to U-Boot to a command prompt. You
can type help; anything else will probably segfault :-) Press Ctrl-C to
exit.

This patch set does not include some other code I have been playing around
with, like a SPI flash driver and sandbox 'state' (so the state can be
examined and modified to test failure modes and the like).

$ ./u-boot

U-Boot 2011.09-rc1-00041-ge50de7d-dirty (Sep 17 2011 - 08:17:40)

DRAM:  128 MiB
Using default environment

In:    serial
Out:   serial
Err:   serial

Detail
======
We can break the U-Boot code base into two parts:

1. Platform code, which is SOC-specifc. At present this is the CPU
init (arch/xxx/cpu/...) and SOC-specific drivers (mostly in the
drivers directory). There is also a small amount of generic CPU code
in arch/xxx/lib and some board-specific code/drivers (e.g. drivers not
within the SOC).

2. Portable/Generic U-Boot code, which is cross-platform. This
includes many drivers, the various commands, file system support,
things like the MMC, USB and network stacks, etc.

My focus in this patch set is the second part of the code base - all the
code which is not platform-specific, but can still have bugs.

Proposal
========
To a large extent, testing of this part of the code base could simply
be built on one or more of the available platforms. We could then run
the tests on that platform, and announce that the code base works fine
on that platform. Obviously the platform needs to support all possible
features of U-Boot.

However, this approach fails to take advantage of two useful
properties of this code:

- It is cross-platform, and even runs on x86
- It is standalone, requiring no OS libraries to run

For speed, debugging and convenience, it would be nice to run U-Boot
under a generic Linux environment on a workstation, and test all the
generic non-platform code. The basic problem with this is that the
non-platform code requires the platform code to operate. Even the x86
platform code is designed for standalone operation on a particular x86
board, and is not suitable for running under x86 Linux.

To get around this I propose that we create a new ?sandbox?
architecture. We write code in ?arch/sandbox? which can run under
Linux. Since all the non-platform code will happily run under this new
?architecture?, we can then write tests which run quickly under x86
Linux (or another Linux for that matter). This U-Boot 'architecture'
should build natively on any 32/64-bit Linux machine since it just
uses standard Linux system calls. Calls to Linux would be entirely
within this arch/sandbox subdirectory.

Benefit
=======
What will this buy us? Well we can do things like:

- Create a test SPI flash device, which is file-backed. Use this to
write a test of the cmd_sf layer by issuing a series of commands and
making sure that the correct SPI flash contents is obtained

- Create a test MMC or IDE device, backed by a file. Use this to issue
ext2 and fat commands to manipulate the filesystem. Then loopback
mount the file and check from Linux that U-Boot did the right thing

- Create a test Ethernet device with a mocked remote host attached.
Use this to issue network commands like bootp and tftp and check that
the correct results are obtained.

Ultimately (one day) we might have a set of unit tests for U-Boot
which can run to very quickly check that a patch does not break the
core U-Boot code.

Building
========

make ARCH=sandbox sandbox_config
make ARCH=sandbox all

(The lds script is targeted for bfd and might not work with the gold linker)

Comments
========
Comments are welcome and I have cc'd those who showed an interest to my
initial email. My goal is to create a real patch set in the next few weeks.

Please excuse the checkpatch violations, many of which seem to be less than
useful. This code is a bit rough in places, but I want comments on it before
polishing. There are a few strange things needed in the build as well, which
I hope to improve.

Changes in v2:
- Rebase to master
- Tidy top-level Makefile to minimise changes
- Try to avoid needing __attribute__((unused)) by assigning to an existing var
- Remove CONFIG_SYS_SDRAM_BASE which is always 0 for sandbox boards
- Fix #define<tab>
- Remove CONFIG_LMB
- Move os layer into arch/sandbox
- Remove clean and dist-clean targets from Makefile
- Try and fail to remove the global -I/usr/include
- Fix cast of int to pointer instead of just removing the code
- Move lds script out of the board directory
- Fix commit message typo, sadly
- Remove ARM cruft from Makefile
- Remove version_string and make display_banner() call display_options()
- Tidy up DRAM logic (but I think it is still needed to fit in with U-Boot)
- Remove use of CONFIG_SYS_NO_FLASH
- Make board_init_f() call board_init_r() for now
- Make board_init_r() call main_loop() for now
- Remove setting of LDSCRIPT (top level Makefile does this anyway)
- Add comment to do_reset() to justify the sandbox implementation
- Move lds script into cpu/sandbox
- Update commit message to remove 'temporary'
- Allow __WORDSIZE to be defined in Makefile / elsewhere
- Split this change out from 'Add architecture image support'
- Removed unneeded clock.h
- Moved gpio.h to asm-generic, removed GPIO_COUNT
- Removed kernel cruft from posix_types.h
- Removed dummy field from struct pt_regs
- Remove contents of string.h; instead include linux/string.h
- Remove unneeded functions in u-boot-sandbox.h
- Remove contents of unaligned.h; instead include asm-generic/unaligned.h

Changes in v3:
- Change U-Boot's dependency generation to permit per-file flags
- Remove variable assignment and rely on 'volatile' to perform the read
- Add note about Merek's patch set
- Add os_exit() which always exits with success for now
- Add function comments to header file
- Call os_exit() in do_reset()
- Move cpu files into arch/sandbox/cpu
- Change do_reset() back to what it was
- Add architecture image support for sandbox

Simon Glass (21):
  sandbox: Add architecture header files
  Fix use of int as pointer in image.c
  sandbox: Add architecture image support
  sandbox: Add compiler defines to support a 64-bit x86_64 platform
  sandbox: Add cpu files
  sandbox: Add architecture lib files
  sandbox: Add sandbox board
  sandbox: Add board info for architecture
  sandbox: Add bootm support
  sandbox: Disable built-in malloc
  sandbox: Disable standalone/API support
  sandbox: Force command sections to be 4-byte aligned
  sandbox: Add OS dependent layer
  sandbox: Add board_init()
  sandbox: Add main program
  sandbox: Add serial uart
  sandbox: Add basic config file
  Remove unused variable warnings in cmd_mem, cmd_nvedit
  Use uintptr_t for 32/64-bit compatibility
  Adjust dependency rules to permit per-file flags
  sandbox: Makefile changes to build sandbox architecture

 .gitignore                                |    2 +-
 Makefile                                  |   23 ++-
 arch/sandbox/config.mk                    |   20 ++
 arch/sandbox/cpu/Makefile                 |   50 +++++
 arch/sandbox/cpu/cpu.c                    |   62 ++++++
 arch/sandbox/cpu/os.c                     |   55 ++++++
 arch/sandbox/cpu/u-boot.lds               |   34 ++++
 arch/sandbox/include/asm/bitops.h         |  162 ++++++++++++++++
 arch/sandbox/include/asm/byteorder.h      |   40 ++++
 arch/sandbox/include/asm/config.h         |   26 +++
 arch/sandbox/include/asm/global_data.h    |   68 +++++++
 arch/sandbox/include/asm/io.h             |   41 ++++
 arch/sandbox/include/asm/posix_types.h    |   57 ++++++
 arch/sandbox/include/asm/ptrace.h         |   38 ++++
 arch/sandbox/include/asm/string.h         |   23 +++
 arch/sandbox/include/asm/system.h         |   36 ++++
 arch/sandbox/include/asm/types.h          |   72 +++++++
 arch/sandbox/include/asm/u-boot-sandbox.h |   38 ++++
 arch/sandbox/include/asm/u-boot.h         |   61 ++++++
 arch/sandbox/include/asm/unaligned.h      |   23 +++
 arch/sandbox/lib/Makefile                 |   51 +++++
 arch/sandbox/lib/board.c                  |  288 +++++++++++++++++++++++++++++
 arch/sandbox/lib/interrupts.c             |   39 ++++
 board/sandbox/common/Makefile             |   41 ++++
 board/sandbox/common/board.c              |   25 +++
 board/sandbox/common/main.c               |   33 ++++
 board/sandbox/sandbox/Makefile            |   44 +++++
 board/sandbox/sandbox/sandbox.c           |   54 ++++++
 boards.cfg                                |    1 +
 common/Makefile                           |    2 +
 common/cmd_bdinfo.c                       |   34 +++-
 common/cmd_bootm.c                        |    9 +-
 common/cmd_mem.c                          |   10 +-
 common/cmd_nvedit.c                       |    3 +-
 common/fdt_support.c                      |    8 +-
 common/image.c                            |    4 +-
 config.mk                                 |    7 +
 doc/README.sandbox                        |   47 +++++
 drivers/serial/Makefile                   |    1 +
 drivers/serial/sandbox.c                  |   67 +++++++
 include/asm-generic/gpio.h                |   25 +++
 include/command.h                         |    3 +-
 include/common.h                          |    3 +
 include/compiler.h                        |   12 +-
 include/configs/sandbox.h                 |   77 ++++++++
 include/image.h                           |    9 +-
 include/linux/string.h                    |    2 +
 include/os.h                              |   70 +++++++
 rules.mk                                  |   23 ++-
 49 files changed, 1880 insertions(+), 43 deletions(-)
 create mode 100644 arch/sandbox/config.mk
 create mode 100644 arch/sandbox/cpu/Makefile
 create mode 100644 arch/sandbox/cpu/cpu.c
 create mode 100644 arch/sandbox/cpu/os.c
 create mode 100644 arch/sandbox/cpu/u-boot.lds
 create mode 100644 arch/sandbox/include/asm/bitops.h
 create mode 100644 arch/sandbox/include/asm/byteorder.h
 create mode 100644 arch/sandbox/include/asm/config.h
 create mode 100644 arch/sandbox/include/asm/global_data.h
 create mode 100644 arch/sandbox/include/asm/io.h
 create mode 100644 arch/sandbox/include/asm/posix_types.h
 create mode 100644 arch/sandbox/include/asm/ptrace.h
 create mode 100644 arch/sandbox/include/asm/string.h
 create mode 100644 arch/sandbox/include/asm/system.h
 create mode 100644 arch/sandbox/include/asm/types.h
 create mode 100644 arch/sandbox/include/asm/u-boot-sandbox.h
 create mode 100644 arch/sandbox/include/asm/u-boot.h
 create mode 100644 arch/sandbox/include/asm/unaligned.h
 create mode 100644 arch/sandbox/lib/Makefile
 create mode 100644 arch/sandbox/lib/board.c
 create mode 100644 arch/sandbox/lib/interrupts.c
 create mode 100644 board/sandbox/common/Makefile
 create mode 100644 board/sandbox/common/board.c
 create mode 100644 board/sandbox/common/main.c
 create mode 100644 board/sandbox/sandbox/Makefile
 create mode 100644 board/sandbox/sandbox/sandbox.c
 create mode 100644 doc/README.sandbox
 create mode 100644 drivers/serial/sandbox.c
 create mode 100644 include/asm-generic/gpio.h
 create mode 100644 include/configs/sandbox.h
 create mode 100644 include/os.h

-- 
1.7.3.1

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 01/21] sandbox: Add architecture header files
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03  5:56   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 02/21] Fix use of int as pointer in image.c Simon Glass
                   ` (19 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This adds required header files for the sandbox architecture, and a basic
description of what sandbox is (README.sandbox).

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Removed unneeded clock.h
- Moved gpio.h to asm-generic, removed GPIO_COUNT
- Removed kernel cruft from posix_types.h
- Removed dummy field from struct pt_regs
- Remove contents of string.h; instead include linux/string.h
- Remove unneeded functions in u-boot-sandbox.h
- Remove contents of unaligned.h; instead include asm-generic/unaligned.h

 arch/sandbox/include/asm/bitops.h         |  162 +++++++++++++++++++++++++++++
 arch/sandbox/include/asm/byteorder.h      |   40 +++++++
 arch/sandbox/include/asm/config.h         |   26 +++++
 arch/sandbox/include/asm/global_data.h    |   68 ++++++++++++
 arch/sandbox/include/asm/io.h             |   41 +++++++
 arch/sandbox/include/asm/posix_types.h    |   57 ++++++++++
 arch/sandbox/include/asm/ptrace.h         |   38 +++++++
 arch/sandbox/include/asm/string.h         |   23 ++++
 arch/sandbox/include/asm/system.h         |   36 +++++++
 arch/sandbox/include/asm/types.h          |   72 +++++++++++++
 arch/sandbox/include/asm/u-boot-sandbox.h |   38 +++++++
 arch/sandbox/include/asm/u-boot.h         |   61 +++++++++++
 arch/sandbox/include/asm/unaligned.h      |   23 ++++
 doc/README.sandbox                        |   47 +++++++++
 include/asm-generic/gpio.h                |   25 +++++
 include/common.h                          |    3 +
 include/linux/string.h                    |    2 +
 17 files changed, 762 insertions(+), 0 deletions(-)
 create mode 100644 arch/sandbox/include/asm/bitops.h
 create mode 100644 arch/sandbox/include/asm/byteorder.h
 create mode 100644 arch/sandbox/include/asm/config.h
 create mode 100644 arch/sandbox/include/asm/global_data.h
 create mode 100644 arch/sandbox/include/asm/io.h
 create mode 100644 arch/sandbox/include/asm/posix_types.h
 create mode 100644 arch/sandbox/include/asm/ptrace.h
 create mode 100644 arch/sandbox/include/asm/string.h
 create mode 100644 arch/sandbox/include/asm/system.h
 create mode 100644 arch/sandbox/include/asm/types.h
 create mode 100644 arch/sandbox/include/asm/u-boot-sandbox.h
 create mode 100644 arch/sandbox/include/asm/u-boot.h
 create mode 100644 arch/sandbox/include/asm/unaligned.h
 create mode 100644 doc/README.sandbox
 create mode 100644 include/asm-generic/gpio.h

diff --git a/arch/sandbox/include/asm/bitops.h b/arch/sandbox/include/asm/bitops.h
new file mode 100644
index 0000000..87a4527
--- /dev/null
+++ b/arch/sandbox/include/asm/bitops.h
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * Copyright 1995, Russell King.
+ * Various bits and pieces copyrights include:
+ *  Linus Torvalds (test_bit).
+ *
+ * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
+ *
+ * Please note that the code in this file should never be included
+ * from user space.  Many of these are not implemented in assembler
+ * since they would be too costly.  Also, they require priviledged
+ * instructions (which are not available from user mode) to ensure
+ * that they are atomic.
+ */
+
+#ifndef __ASM_SANDBOX_BITOPS_H
+#define __ASM_SANDBOX_BITOPS_H
+
+#include <asm/system.h>
+
+#ifdef __KERNEL__
+
+#define smp_mb__before_clear_bit()	do { } while (0)
+#define smp_mb__after_clear_bit()	do { } while (0)
+
+/*
+ * Function prototypes to keep gcc -Wall happy.
+ */
+extern void set_bit(int nr, volatile void *addr);
+
+extern void clear_bit(int nr, volatile void *addr);
+
+extern void change_bit(int nr, volatile void *addr);
+
+static inline void __change_bit(int nr, volatile void *addr)
+{
+	unsigned long mask = BIT_MASK(nr);
+	unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+	*p ^= mask;
+}
+
+static inline int __test_and_set_bit(int nr, volatile void *addr)
+{
+	unsigned long mask = BIT_MASK(nr);
+	unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+	unsigned long old = *p;
+
+	*p = old | mask;
+	return (old & mask) != 0;
+}
+
+static inline int test_and_set_bit(int nr, volatile void *addr)
+{
+	unsigned long flags;
+	int out;
+
+	local_irq_save(flags);
+	out = __test_and_set_bit(nr, addr);
+	local_irq_restore(flags);
+
+	return out;
+}
+
+static inline int __test_and_clear_bit(int nr, volatile void *addr)
+{
+	unsigned long mask = BIT_MASK(nr);
+	unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+	unsigned long old = *p;
+
+	*p = old & ~mask;
+	return (old & mask) != 0;
+}
+
+static inline int test_and_clear_bit(int nr, volatile void *addr)
+{
+	unsigned long flags;
+	int out;
+
+	local_irq_save(flags);
+	out = __test_and_clear_bit(nr, addr);
+	local_irq_restore(flags);
+
+	return out;
+}
+
+extern int test_and_change_bit(int nr, volatile void *addr);
+
+static inline int __test_and_change_bit(int nr, volatile void *addr)
+{
+	unsigned long mask = BIT_MASK(nr);
+	unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+	unsigned long old = *p;
+
+	*p = old ^ mask;
+	return (old & mask) != 0;
+}
+
+extern int find_first_zero_bit(void *addr, unsigned size);
+extern int find_next_zero_bit(void *addr, int size, int offset);
+
+/*
+ * This routine doesn't need to be atomic.
+ */
+static inline int test_bit(int nr, const void *addr)
+{
+	return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7));
+}
+
+/*
+ * ffz = Find First Zero in word. Undefined if no zero exists,
+ * so code should check against ~0UL first..
+ */
+static inline unsigned long ffz(unsigned long word)
+{
+	int k;
+
+	word = ~word;
+	k = 31;
+	if (word & 0x0000ffff) {
+		k -= 16; word <<= 16;
+	}
+	if (word & 0x00ff0000) {
+		k -= 8;  word <<= 8;
+	}
+	if (word & 0x0f000000) {
+		k -= 4;  word <<= 4;
+	}
+	if (word & 0x30000000) {
+		k -= 2;  word <<= 2;
+	}
+	if (word & 0x40000000)
+		k -= 1;
+	return k;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+#define hweight32(x) generic_hweight32(x)
+#define hweight16(x) generic_hweight16(x)
+#define hweight8(x) generic_hweight8(x)
+
+#define ext2_set_bit			test_and_set_bit
+#define ext2_clear_bit			test_and_clear_bit
+#define ext2_test_bit			test_bit
+#define ext2_find_first_zero_bit	find_first_zero_bit
+#define ext2_find_next_zero_bit		find_next_zero_bit
+
+/* Bitmap functions for the minix filesystem. */
+#define minix_test_and_set_bit(nr, addr)	test_and_set_bit(nr, addr)
+#define minix_set_bit(nr, addr)			set_bit(nr, addr)
+#define minix_test_and_clear_bit(nr, addr)	test_and_clear_bit(nr, addr)
+#define minix_test_bit(nr, addr)		test_bit(nr, addr)
+#define minix_find_first_zero_bit(addr, size)	find_first_zero_bit(addr, size)
+
+#endif /* __KERNEL__ */
+
+#endif /* _ARM_BITOPS_H */
diff --git a/arch/sandbox/include/asm/byteorder.h b/arch/sandbox/include/asm/byteorder.h
new file mode 100644
index 0000000..ff87284
--- /dev/null
+++ b/arch/sandbox/include/asm/byteorder.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_SANDBOX_BYTEORDER_H
+#define __ASM_SANDBOX_BYTEORDER_H
+
+
+#include <asm/types.h>
+
+#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
+#  define __BYTEORDER_HAS_U64__
+#  define __SWAB_64_THRU_32__
+#endif
+
+#ifdef CONFIG_SANDBOX_BIG_ENDIAN
+#include <linux/byteorder/big_endian.h>
+#else
+#include <linux/byteorder/little_endian.h>
+#endif
+
+#endif
diff --git a/arch/sandbox/include/asm/config.h b/arch/sandbox/include/asm/config.h
new file mode 100644
index 0000000..2ef0564
--- /dev/null
+++ b/arch/sandbox/include/asm/config.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#ifndef _ASM_CONFIG_H_
+#define _ASM_CONFIG_H_
+
+#define CONFIG_SANDBOX_ARCH
+
+#endif
diff --git a/arch/sandbox/include/asm/global_data.h b/arch/sandbox/include/asm/global_data.h
new file mode 100644
index 0000000..4bfe38d
--- /dev/null
+++ b/arch/sandbox/include/asm/global_data.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * (C) Copyright 2002-2010
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef	__ASM_GBL_DATA_H
+#define __ASM_GBL_DATA_H
+/*
+ * The following data structure is placed in some memory wich is
+ * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
+ * some locked parts of the data cache) to allow for a minimum set of
+ * global variables during system initialization (until we have set
+ * up the memory controller so that we can use RAM).
+ *
+ * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t)
+ */
+
+typedef	struct	global_data {
+	bd_t		*bd;
+	unsigned long	flags;
+	unsigned long	baudrate;
+	unsigned long	have_console;	/* serial_init() was called */
+	unsigned long	env_addr;	/* Address  of Environment struct */
+	unsigned long	env_valid;	/* Checksum of Environment valid? */
+	unsigned long	fb_base;	/* base address of frame buffer */
+	u8		*ram_buf;	/* emulated RAM buffer */
+	phys_size_t	ram_size;	/* RAM size */
+	unsigned long	mon_len;	/* monitor len */
+	void		**jt;		/* jump table */
+	char		env_buf[32];	/* buffer for getenv() before reloc. */
+} gd_t;
+
+/*
+ * Global Data Flags
+ */
+#define	GD_FLG_RELOC		0x00001	/* Code was relocated to RAM */
+#define	GD_FLG_DEVINIT		0x00002	/* Devices have been initialized */
+#define	GD_FLG_SILENT		0x00004	/* Silent mode */
+#define	GD_FLG_POSTFAIL		0x00008	/* Critical POST test failed */
+#define	GD_FLG_POSTSTOP		0x00010	/* POST seqeunce aborted */
+#define	GD_FLG_LOGINIT		0x00020	/* Log Buffer has been initialized */
+#define GD_FLG_DISABLE_CONSOLE	0x00040	/* Disable console (in & out) */
+#define GD_FLG_ENV_READY	0x00080	/* Env. imported into hash table */
+
+#define XTRN_DECLARE_GLOBAL_DATA_PTR    extern
+#define DECLARE_GLOBAL_DATA_PTR     XTRN_DECLARE_GLOBAL_DATA_PTR gd_t *gd
+
+#endif /* __ASM_GBL_DATA_H */
diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
new file mode 100644
index 0000000..0392d21
--- /dev/null
+++ b/arch/sandbox/include/asm/io.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * 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
+ */
+
+/*
+ * Given a physical address and a length, return a virtual address
+ * that can be used to access the memory range with the caching
+ * properties specified by "flags".
+ */
+#define MAP_NOCACHE	(0)
+#define MAP_WRCOMBINE	(0)
+#define MAP_WRBACK	(0)
+#define MAP_WRTHROUGH	(0)
+
+void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);
+
+/*
+ * Take down a mapping set up by map_physmem().
+ */
+static inline void unmap_physmem(void *vaddr, unsigned long flags)
+{
+
+}
diff --git a/arch/sandbox/include/asm/posix_types.h b/arch/sandbox/include/asm/posix_types.h
new file mode 100644
index 0000000..ec18ed7
--- /dev/null
+++ b/arch/sandbox/include/asm/posix_types.h
@@ -0,0 +1,57 @@
+/*
+ *  linux/include/asm-arm/posix_types.h
+ *
+ *  Copyright (C) 1996-1998 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Changelog:
+ *   27-06-1996	RMK	Created
+ */
+#ifndef __ARCH_ARM_POSIX_TYPES_H
+#define __ARCH_ARM_POSIX_TYPES_H
+
+/*
+ * This file is generally used by user-level software, so you need to
+ * be a little careful about namespace pollution etc.  Also, we cannot
+ * assume GCC is being used.
+ */
+
+typedef unsigned short		__kernel_dev_t;
+typedef unsigned long		__kernel_ino_t;
+typedef unsigned short		__kernel_mode_t;
+typedef unsigned short		__kernel_nlink_t;
+typedef long			__kernel_off_t;
+typedef int			__kernel_pid_t;
+typedef unsigned short		__kernel_ipc_pid_t;
+typedef unsigned short		__kernel_uid_t;
+typedef unsigned short		__kernel_gid_t;
+#if CONFIG_SANDBOX_BITS_PER_LONG == 32
+typedef unsigned int		__kernel_size_t;
+typedef int			__kernel_ssize_t;
+typedef int			__kernel_ptrdiff_t;
+#else
+typedef unsigned long		__kernel_size_t;
+typedef long			__kernel_ssize_t;
+typedef long			__kernel_ptrdiff_t;
+#endif
+typedef long			__kernel_time_t;
+typedef long			__kernel_suseconds_t;
+typedef long			__kernel_clock_t;
+typedef int			__kernel_daddr_t;
+typedef char			*__kernel_caddr_t;
+typedef unsigned short		__kernel_uid16_t;
+typedef unsigned short		__kernel_gid16_t;
+typedef unsigned int		__kernel_uid32_t;
+typedef unsigned int		__kernel_gid32_t;
+
+typedef unsigned short		__kernel_old_uid_t;
+typedef unsigned short		__kernel_old_gid_t;
+
+#ifdef __GNUC__
+typedef long long		__kernel_loff_t;
+#endif
+
+#endif
diff --git a/arch/sandbox/include/asm/ptrace.h b/arch/sandbox/include/asm/ptrace.h
new file mode 100644
index 0000000..613d459
--- /dev/null
+++ b/arch/sandbox/include/asm/ptrace.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_SANDBOX_PTRACE_H
+#define __ASM_SANDBOX_PTRACE_H
+
+#ifndef __ASSEMBLY__
+/* This is not used in the sandbox architecture, but required by U-Boot */
+struct pt_regs {
+};
+
+#ifdef __KERNEL__
+extern void show_regs(struct pt_regs *);
+
+#endif
+
+#endif /* __ASSEMBLY__ */
+
+#endif
diff --git a/arch/sandbox/include/asm/string.h b/arch/sandbox/include/asm/string.h
new file mode 100644
index 0000000..89b7f06
--- /dev/null
+++ b/arch/sandbox/include/asm/string.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * 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 <linux/string.h>
diff --git a/arch/sandbox/include/asm/system.h b/arch/sandbox/include/asm/system.h
new file mode 100644
index 0000000..78cdc9fa8
--- /dev/null
+++ b/arch/sandbox/include/asm/system.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_SANDBOX_SYSTEM_H
+#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_enable()
+#define local_irq_disable()
+#define local_save_flags(x)
+#define local_irq_restore(x)
+
+#endif
diff --git a/arch/sandbox/include/asm/types.h b/arch/sandbox/include/asm/types.h
new file mode 100644
index 0000000..2316c2d
--- /dev/null
+++ b/arch/sandbox/include/asm/types.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_SANDBOX_TYPES_H
+#define __ASM_SANDBOX_TYPES_H
+
+typedef unsigned short umode_t;
+
+/*
+ * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
+ * header files exported to user space
+ */
+
+typedef __signed__ char __s8;
+typedef unsigned char __u8;
+
+typedef __signed__ short __s16;
+typedef unsigned short __u16;
+
+typedef __signed__ int __s32;
+typedef unsigned int __u32;
+
+#if defined(__GNUC__)
+__extension__ typedef __signed__ long long __s64;
+__extension__ typedef unsigned long long __u64;
+#endif
+
+/*
+ * These aren't exported outside the kernel to avoid name space clashes
+ */
+#ifdef __KERNEL__
+
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+#define BITS_PER_LONG	CONFIG_SANDBOX_BITS_PER_LONG
+
+typedef unsigned long dma_addr_t;
+typedef unsigned long phys_addr_t;
+typedef unsigned long phys_size_t;
+
+#endif /* __KERNEL__ */
+
+#endif
diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h
new file mode 100644
index 0000000..236b4ee
--- /dev/null
+++ b/arch/sandbox/include/asm/u-boot-sandbox.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Alex Zuepke <azu@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
+ */
+
+#ifndef _U_BOOT_SANDBOX_H_
+#define _U_BOOT_SANDBOX_H_
+
+/* board/.../... */
+int board_init(void);
+int dram_init(void);
+
+#endif	/* _U_BOOT_SANDBOX_H_ */
diff --git a/arch/sandbox/include/asm/u-boot.h b/arch/sandbox/include/asm/u-boot.h
new file mode 100644
index 0000000..7d91847
--- /dev/null
+++ b/arch/sandbox/include/asm/u-boot.h
@@ -0,0 +1,61 @@
+/*
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Alex Zuepke <azu@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
+ *
+ ********************************************************************
+ * NOTE: This header file defines an interface to U-Boot. Including
+ * this (unmodified) header file in another file is considered normal
+ * use of U-Boot, and does *not* fall under the heading of "derived
+ * work".
+ ********************************************************************
+ */
+
+#ifndef _U_BOOT_H_
+#define _U_BOOT_H_	1
+
+typedef struct bd_info {
+	unsigned long	bi_memstart;	/* start of DRAM memory */
+	phys_size_t	bi_memsize;	/* size	 of DRAM memory in bytes */
+	unsigned long	bi_flashstart;	/* start of FLASH memory */
+	unsigned long	bi_flashsize;	/* size	 of FLASH memory */
+	unsigned long	bi_flashoffset; /* reserved area for startup monitor */
+	unsigned long	bi_sramstart;	/* start of SRAM memory */
+	unsigned long	bi_sramsize;	/* size	 of SRAM memory */
+	unsigned long	bi_bootflags;	/* boot / reboot flag (for LynxOS) */
+	unsigned long	bi_ip_addr;	/* IP Address */
+	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
+	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
+	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
+	unsigned int	bi_baudrate;	/* Console Baudrate */
+	unsigned long   bi_boot_params;	/* where this board expects params */
+	struct				/* RAM configuration */
+	{
+		ulong start;
+		ulong size;
+	} bi_dram[CONFIG_NR_DRAM_BANKS];
+} bd_t;
+
+#endif	/* _U_BOOT_H_ */
diff --git a/arch/sandbox/include/asm/unaligned.h b/arch/sandbox/include/asm/unaligned.h
new file mode 100644
index 0000000..6cf9780
--- /dev/null
+++ b/arch/sandbox/include/asm/unaligned.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * 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 <asm-generic/unaligned.h>
diff --git a/doc/README.sandbox b/doc/README.sandbox
new file mode 100644
index 0000000..58f3883
--- /dev/null
+++ b/doc/README.sandbox
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * 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
+ */
+
+Native Execution of U-Boot
+==========================
+
+The 'sandbox' architecture is designed to allow U-Boot to run under Linux on
+almost any hardware. To achieve this it builds U-Boot (so far as possible)
+as a normal C application with a main() and normal C libraries.
+
+All of U-Boot's architecture-specific code therefore cannot be built as part
+of the sandbox U-Boot. The purpose of running U-Boot under Linux is to test
+all the generic code, not specific to any one architecture. The idea is to
+create unit tests which we can run to test this upper level code.
+
+CONFIG_SANDBOX is defined when building a native board.
+
+The chosen vendor and board names are also 'sandbox', so there is a single
+board in board/sandbox/sandbox.
+
+CONFIG_SANDBOX_BIG_ENDIAN should be defined when running on big-endian
+machines.
+
+
+Tests
+-----
+
+So far we have no tests, but when we do these will be documented here.
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
new file mode 100644
index 0000000..316b34c
--- /dev/null
+++ b/include/asm-generic/gpio.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * 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
+ */
+
+int gpio_direction_input(int gp);
+int gpio_direction_output(int gp, int value);
+int gpio_get_value(int gp);
+void gpio_set_value(int gp, int value);
diff --git a/include/common.h b/include/common.h
index d244bd4..2a39df3 100644
--- a/include/common.h
+++ b/include/common.h
@@ -302,6 +302,9 @@ int	setenv	     (const char *, const char *);
 #ifdef CONFIG_X86		/* x86 version to be fixed! */
 # include <asm/u-boot-x86.h>
 #endif /* CONFIG_X86 */
+#ifdef CONFIG_SANDBOX
+# include <asm/u-boot-sandbox.h>	/* TODO(sjg) what needs to be fixed? */
+#endif
 
 #ifdef CONFIG_AUTO_COMPLETE
 int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
diff --git a/include/linux/string.h b/include/linux/string.h
index 6239039..3cd06a8 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -1,6 +1,8 @@
 #ifndef _LINUX_STRING_H_
 #define _LINUX_STRING_H_
 
+#include <linux/string.h>
+
 #include <linux/types.h>	/* for size_t */
 #include <linux/stddef.h>	/* for NULL */
 
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 02/21] Fix use of int as pointer in image.c
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 01/21] sandbox: Add architecture header files Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 03/21] sandbox: Add architecture image support Simon Glass
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

It is better to use %p in this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
---
Changes in v2:
- Split this change out from 'Add architecture image support'

 common/image.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/image.c b/common/image.c
index d38ce4a..fc475cd 100644
--- a/common/image.c
+++ b/common/image.c
@@ -1581,7 +1581,7 @@ int boot_get_fdt (int flag, int argc, char * const argv[], bootm_headers_t *imag
 			goto error;
 		}
 
-		printf ("   Booting using the fdt blob at 0x%x\n", (int)fdt_blob);
+		printf("   Booting using the fdt blob at 0x%p\n", fdt_blob);
 
 	} else if (images->legacy_hdr_valid &&
 			image_check_type (&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
@@ -1600,7 +1600,7 @@ int boot_get_fdt (int flag, int argc, char * const argv[], bootm_headers_t *imag
 		if (fdt_len) {
 
 			fdt_blob = (char *)fdt_data;
-			printf ("   Booting using the fdt at 0x%x\n", (int)fdt_blob);
+			printf("   Booting using the fdt at 0x%p\n", fdt_blob);
 
 			if (fdt_check_header (fdt_blob) != 0) {
 				fdt_error ("image is not a fdt");
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 03/21] sandbox: Add architecture image support
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 01/21] sandbox: Add architecture header files Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 02/21] Fix use of int as pointer in image.c Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 04/21] sandbox: Add compiler defines to support a 64-bit x86_64 platform Simon Glass
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

We won't actually load an image with this architecture, but we still need to
define it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Add architecture image support for sandbox

 include/image.h |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/image.h b/include/image.h
index 352e4a0..2cf7243 100644
--- a/include/image.h
+++ b/include/image.h
@@ -106,6 +106,7 @@
 #define IH_ARCH_BLACKFIN	16	/* Blackfin	*/
 #define IH_ARCH_AVR32		17	/* AVR32	*/
 #define IH_ARCH_ST200	        18	/* STMicroelectronics ST200  */
+#define IH_ARCH_SANDBOX		19	/* Sandbox architecture (test only) */
 
 /*
  * Image Types
@@ -484,7 +485,9 @@ void image_print_contents (const void *hdr);
 #ifndef USE_HOSTCC
 static inline int image_check_target_arch (const image_header_t *hdr)
 {
-#if defined(__ARM__)
+#if defined(CONFIG_SANDBOX_ARCH)
+	if (!image_check_arch(hdr, IH_ARCH_SANDBOX))
+#elif defined(__ARM__)
 	if (!image_check_arch (hdr, IH_ARCH_ARM))
 #elif defined(__avr32__)
 	if (!image_check_arch (hdr, IH_ARCH_AVR32))
@@ -636,7 +639,9 @@ void fit_conf_print (const void *fit, int noffset, const char *p);
 #ifndef USE_HOSTCC
 static inline int fit_image_check_target_arch (const void *fdt, int node)
 {
-#if defined(__ARM__)
+#if defined(CONFIG_SANDBOX_ARCH)
+	if (!fit_image_check_arch(fdt, node, IH_ARCH_SANDBOX))
+#elif defined(__ARM__)
 	if (!fit_image_check_arch (fdt, node, IH_ARCH_ARM))
 #elif defined(__avr32__)
 	if (!fit_image_check_arch (fdt, node, IH_ARCH_AVR32))
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 04/21] sandbox: Add compiler defines to support a 64-bit x86_64 platform
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (2 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 03/21] sandbox: Add architecture image support Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 05/21] sandbox: Add cpu files Simon Glass
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This sets __WORDSIZE to 8 correctly on 64-bit machines.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Update commit message to remove 'temporary'
- Allow __WORDSIZE to be defined in Makefile / elsewhere

 include/compiler.h |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/include/compiler.h b/include/compiler.h
index 4e047c7..dc1a259 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -111,11 +111,21 @@ typedef unsigned int uint;
 #include <linux/types.h>
 #include <asm/byteorder.h>
 
+#if __SIZEOF_LONG__ == 8
+# define __WORDSIZE	64
+#elif __SIZEOF_LONG__ == 4
+# define __WORDSIZE	32
+#elif !defined __WORDSIZE
+#error "__SIZEOF_LONG__ has unexpected value"
+#endif
+
 /* Types for `void *' pointers. */
 #if __WORDSIZE == 64
 typedef unsigned long int       uintptr_t;
-#else
+#elif __WORDSIZE == 32
 typedef unsigned int            uintptr_t;
+#else
+#error "__WORDSIZE has unexpected value"
 #endif
 
 #endif
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 05/21] sandbox: Add cpu files
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (3 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 04/21] sandbox: Add compiler defines to support a 64-bit x86_64 platform Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03  6:10   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 06/21] sandbox: Add architecture lib files Simon Glass
                   ` (15 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This is an initial implementation with all functions defined but not working.

The lds file is very simple since we can mostly rely on the linker defaults.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Remove setting of LDSCRIPT (top level Makefile does this anyway)
- Add comment to do_reset() to justify the sandbox implementation
- Move lds script into cpu/sandbox

Changes in v3:
- Change do_reset() back to what it was
- Move cpu files into arch/sandbox/cpu

 arch/sandbox/config.mk      |   20 +++++++++++++
 arch/sandbox/cpu/Makefile   |   47 ++++++++++++++++++++++++++++++++
 arch/sandbox/cpu/cpu.c      |   63 +++++++++++++++++++++++++++++++++++++++++++
 arch/sandbox/cpu/u-boot.lds |   34 +++++++++++++++++++++++
 4 files changed, 164 insertions(+), 0 deletions(-)
 create mode 100644 arch/sandbox/config.mk
 create mode 100644 arch/sandbox/cpu/Makefile
 create mode 100644 arch/sandbox/cpu/cpu.c
 create mode 100644 arch/sandbox/cpu/u-boot.lds

diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
new file mode 100644
index 0000000..ab33026
--- /dev/null
+++ b/arch/sandbox/config.mk
@@ -0,0 +1,20 @@
+# Copyright (c) 2011 The Chromium OS Authors.
+# 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
+
+PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__
diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile
new file mode 100644
index 0000000..8dfa828
--- /dev/null
+++ b/arch/sandbox/cpu/Makefile
@@ -0,0 +1,47 @@
+#
+# Copyright (c) 2011 The Chromium OS Authors.
+#
+# (C) Copyright 2000-2003
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(CPU).o
+
+COBJS	:= cpu.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
new file mode 100644
index 0000000..554cae8
--- /dev/null
+++ b/arch/sandbox/cpu/cpu.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	/*
+	 * This is considered normal termination for now. We wil call os_exit()
+	 * when available.
+	 */
+	return 0;
+}
+
+/* delay x useconds */
+void __udelay(unsigned long usec)
+{
+	/* Ignore this for now */
+}
+
+unsigned long timer_get_us(void)
+{
+	return 0;
+}
+
+int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+{
+	return -1;
+}
+
+int cleanup_before_linux(void)
+{
+	return 0;
+}
+
+void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
+{
+	return (void *)(gd->ram_buf + paddr);
+}
+
+void flush_dcache_range(unsigned long start, unsigned long stop)
+{
+}
diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
new file mode 100644
index 0000000..2d2e50f
--- /dev/null
+++ b/arch/sandbox/cpu/u-boot.lds
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * 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
+ */
+
+SECTIONS
+{
+  __u_boot_cmd_start = .;
+  .u_boot_cmd : { *(.u_boot_cmd) }
+  __u_boot_cmd_end = .;
+  __bss_start = .;
+
+}
+
+INSERT BEFORE .data;
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 06/21] sandbox: Add architecture lib files
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (4 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 05/21] sandbox: Add cpu files Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03  6:15   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 07/21] sandbox: Add sandbox board Simon Glass
                   ` (14 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

These files are taken from the ARM board implementation and then reduced
to remove unneeded cruft.

Ideally we would work towards unifying arch/xxx/lib files, particularly
board.c.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Fix commit message typo, sadly
- Remove ARM cruft from Makefile
- Remove version_string and make display_banner() call display_options()
- Tidy up DRAM logic (but I think it is still needed to fit in with U-Boot)
- Remove use of CONFIG_SYS_NO_FLASH
- Make board_init_f() call board_init_r() for now
- Make board_init_r() call main_loop() for now

 arch/sandbox/lib/Makefile     |   51 +++++++
 arch/sandbox/lib/board.c      |  288 +++++++++++++++++++++++++++++++++++++++++
 arch/sandbox/lib/interrupts.c |   39 ++++++
 3 files changed, 378 insertions(+), 0 deletions(-)
 create mode 100644 arch/sandbox/lib/Makefile
 create mode 100644 arch/sandbox/lib/board.c
 create mode 100644 arch/sandbox/lib/interrupts.c

diff --git a/arch/sandbox/lib/Makefile b/arch/sandbox/lib/Makefile
new file mode 100644
index 0000000..fbe579b
--- /dev/null
+++ b/arch/sandbox/lib/Makefile
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2011 The Chromium OS Authors.
+#
+# (C) Copyright 2002-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(ARCH).o
+
+COBJS-y	+= board.o
+COBJS-y	+= interrupts.o
+
+SRCS	:= $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+
+# Always build libsandbox.o
+TARGETS	:= $(LIB)
+
+all:	$(TARGETS)
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
new file mode 100644
index 0000000..4e61e9c
--- /dev/null
+++ b/arch/sandbox/lib/board.c
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * (C) Copyright 2002-2006
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@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
+ */
+
+/*
+ * This file was taken from ARM and changed to remove things we don't
+ * need. This is most of it, so have tried to avoid being over-zealous!
+ * For example, we want to have an emulation of the 'DRAM' used by
+ * U-Boot.
+ *
+ * has been talk upstream of unifying the architectures w.r.t board.c,
+ * so the less change here the better.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <malloc.h>
+#include <stdio_dev.h>
+#include <timestamp.h>
+#include <version.h>
+#include <serial.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/************************************************************************
+ * Init Utilities							*
+ ************************************************************************
+ * Some of this code should be moved into the core functions,
+ * or dropped completely,
+ * but let's get it working (again) first...
+ */
+
+static int display_banner(void)
+{
+	display_options();
+	debug("U-Boot code: %08lX -> %08lX  BSS: -> %08lX\n",
+	       _TEXT_BASE,
+	       _bss_start_ofs+_TEXT_BASE, _bss_end_ofs+_TEXT_BASE);
+
+	return 0;
+}
+
+/**
+ * Configure and report on the DRAM configuration, which in our case is
+ * fairly simple.
+ */
+static int display_dram_config(void)
+{
+	ulong size = 0;
+	int i;
+
+	debug("RAM Configuration:\n");
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+#ifdef DEBUG
+		printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
+		print_size(gd->bd->bi_dram[i].size, "\n");
+#endif
+		size += gd->bd->bi_dram[i].size;
+	}
+	puts("DRAM:  ");
+	print_size(size, "\n");
+	return 0;
+}
+
+/*
+ * Breathe some life into the board...
+ *
+ * Initialize a serial port as console, and carry out some hardware
+ * tests.
+ *
+ * The first part of initialization is running from Flash memory;
+ * its main purpose is to initialize the RAM so that we
+ * can relocate the monitor code to RAM.
+ */
+
+/*
+ * All attempts to come up with a "common" initialization sequence
+ * that works for all boards and architectures failed: some of the
+ * requirements are just _too_ different. To get rid of the resulting
+ * mess of board dependent #ifdef'ed code we now make the whole
+ * initialization sequence configurable to the user.
+ *
+ * The requirements for any new initalization function is simple: it
+ * receives a pointer to the "global data" structure as it's only
+ * argument, and returns an integer return code, where 0 means
+ * "continue" and != 0 means "fatal error, hang the system".
+ */
+typedef int (init_fnc_t) (void);
+
+void __dram_init_banksize(void)
+{
+	gd->bd->bi_dram[0].start = 0;
+	gd->bd->bi_dram[0].size =  gd->ram_size;
+}
+
+void dram_init_banksize(void)
+	__attribute__((weak, alias("__dram_init_banksize")));
+
+init_fnc_t *init_sequence[] = {
+#if defined(CONFIG_ARCH_CPU_INIT)
+	arch_cpu_init,		/* basic arch cpu dependent setup */
+#endif
+#if defined(CONFIG_BOARD_EARLY_INIT_F)
+	board_early_init_f,
+#endif
+	timer_init,		/* initialize timer */
+	env_init,		/* initialize environment */
+	serial_init,		/* serial communications setup */
+	console_init_f,		/* stage 1 init of console */
+	display_banner,		/* say that we are here */
+#if defined(CONFIG_DISPLAY_CPUINFO)
+	print_cpuinfo,		/* display cpu info (and speed) */
+#endif
+#if defined(CONFIG_DISPLAY_BOARDINFO)
+	checkboard,		/* display board info */
+#endif
+	dram_init,		/* configure available RAM banks */
+	NULL,
+};
+
+void board_init_f(ulong bootflag)
+{
+	init_fnc_t **init_fnc_ptr;
+	uchar *mem;
+	unsigned long addr_sp, addr, size;
+
+	gd = malloc(sizeof(gd_t));
+	assert(gd);
+
+	memset((void *)gd, 0, sizeof(gd_t));
+
+	gd->mon_len = 0; /* _bss_end_ofs;*/
+
+	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
+		if ((*init_fnc_ptr)() != 0)
+			hang();
+	}
+
+	size = 128 * 1024 * 1024;
+	mem = malloc(size);
+	assert(mem);
+	gd->ram_buf = mem;
+	addr = (ulong)(mem + size);
+
+	/*
+	 * reserve memory for malloc() arena
+	 */
+	addr_sp = addr - TOTAL_MALLOC_LEN;
+	debug("Reserving %dk for malloc() at: %08lx\n",
+			TOTAL_MALLOC_LEN >> 10, addr_sp);
+	/*
+	 * (permanently) allocate a Board Info struct
+	 * and a permanent copy of the "global" data
+	 */
+	addr_sp -= sizeof(bd_t);
+	gd->bd = (bd_t *) addr_sp;
+	debug("Reserving %zu Bytes for Board Info at: %08lx\n",
+			sizeof(bd_t), addr_sp);
+
+#ifdef CONFIG_POST
+	post_bootmode_init();
+	post_run(NULL, POST_ROM | post_bootmode_get(0));
+#endif
+
+	/* Ram ist board specific, so move it to board code ... */
+	dram_init_banksize();
+	display_dram_config();	/* and display it */
+
+	/* We don't relocate, so just run the post-relocation code */
+	board_init_r(NULL, 0);
+
+	/* NOTREACHED - no way out of command loop except booting */
+}
+
+/************************************************************************
+ *
+ * This is the next part if the initialization sequence: we are now
+ * running from RAM and have a "normal" C environment, i. e. global
+ * data can be written, BSS has been cleared, the stack size in not
+ * that critical any more, etc.
+ *
+ ************************************************************************
+ */
+
+void board_init_r(gd_t *id, ulong dest_addr)
+{
+
+	if (id)
+		gd = id;
+
+	gd->flags |= GD_FLG_RELOC;	/* tell others: relocation done */
+
+	board_init();	/* Setup chipselects */
+
+#ifdef CONFIG_SERIAL_MULTI
+	serial_initialize();
+#endif
+
+#ifdef CONFIG_POST
+	post_output_backlog();
+#endif
+
+#if 0 /* Sandbox uses system malloc for now */
+	/* The Malloc area is immediately below the monitor copy in DRAM */
+	malloc_start = dest_addr - TOTAL_MALLOC_LEN;
+	mem_malloc_init(malloc_start, TOTAL_MALLOC_LEN);
+#endif
+
+	/* initialize environment */
+	env_relocate();
+
+	/* IP Address */
+	gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
+
+	stdio_init();	/* get the devices list going. */
+
+	jumptable_init();
+
+	console_init_r();	/* fully init console as a device */
+
+#if defined(CONFIG_DISPLAY_BOARDINFO_LATE)
+	checkboard();
+#endif
+
+#if defined(CONFIG_ARCH_MISC_INIT)
+	/* miscellaneous arch dependent initialisations */
+	arch_misc_init();
+#endif
+#if defined(CONFIG_MISC_INIT_R)
+	/* miscellaneous platform dependent initialisations */
+	misc_init_r();
+#endif
+
+	 /* set up exceptions */
+	interrupt_init();
+	/* enable exceptions */
+	enable_interrupts();
+
+#ifdef BOARD_LATE_INIT
+	board_late_init();
+#endif
+
+#ifdef CONFIG_POST
+	post_run(NULL, POST_RAM | post_bootmode_get(0));
+#endif
+
+	/*
+	 * For now, run the main loop. Later we might let this be done
+	 * in the main program.
+	 */
+	while (1)
+		main_loop();
+
+	/* NOTREACHED - no way out of command loop except booting */
+}
+
+void hang(void)
+{
+	puts("### ERROR ### Please RESET the board ###\n");
+	for (;;)
+		;
+}
diff --git a/arch/sandbox/lib/interrupts.c b/arch/sandbox/lib/interrupts.c
new file mode 100644
index 0000000..d350108
--- /dev/null
+++ b/arch/sandbox/lib/interrupts.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+
+int interrupt_init(void)
+{
+	return 0;
+}
+
+void enable_interrupts(void)
+{
+	return;
+}
+int disable_interrupts(void)
+{
+	return 0;
+}
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 07/21] sandbox: Add sandbox board
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (5 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 06/21] sandbox: Add architecture lib files Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 08/21] sandbox: Add board info for architecture Simon Glass
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This adds basic files for the sandbox board. The lds file is very simple
since we can rely mostly on the linker defaults.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Remove clean and dist-clean targets from Makefile
- Move lds script out of the board directory

 board/sandbox/sandbox/Makefile  |   44 +++++++++++++++++++++++++++++++
 board/sandbox/sandbox/sandbox.c |   54 +++++++++++++++++++++++++++++++++++++++
 boards.cfg                      |    1 +
 3 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 board/sandbox/sandbox/Makefile
 create mode 100644 board/sandbox/sandbox/sandbox.c

diff --git a/board/sandbox/sandbox/Makefile b/board/sandbox/sandbox/Makefile
new file mode 100644
index 0000000..985ee2c
--- /dev/null
+++ b/board/sandbox/sandbox/Makefile
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 2011 The Chromium OS Authors.
+#
+# 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 Foundatio; 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
+
+$(shell mkdir -p $(obj)../common)
+
+LIB	= $(obj)lib$(BOARD).o
+
+COBJS	:= $(BOARD).o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/sandbox/sandbox/sandbox.c b/board/sandbox/sandbox/sandbox.c
new file mode 100644
index 0000000..c12c231
--- /dev/null
+++ b/board/sandbox/sandbox/sandbox.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+
+/*
+ * Pointer to initial global data area
+ *
+ * Here we initialize it.
+ */
+#undef	XTRN_DECLARE_GLOBAL_DATA_PTR
+#define XTRN_DECLARE_GLOBAL_DATA_PTR	/* empty = allocate here */
+DECLARE_GLOBAL_DATA_PTR;
+
+gd_t *gd;
+
+
+void flush_cache(unsigned long start, unsigned long size)
+{
+}
+
+ulong get_timer(ulong base)
+{
+	return 0;
+}
+
+int timer_init(void)
+{
+	return 0;
+}
+
+int dram_init(void)
+{
+	gd->ram_size = CONFIG_DRAM_SIZE;
+	return 0;
+}
diff --git a/boards.cfg b/boards.cfg
index 8a5bfc1..2af8473 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -259,6 +259,7 @@ tcm-bf518                    blackfin    blackfin
 tcm-bf537                    blackfin    blackfin
 eNET                         x86         x86        eNET                -              sc520       eNET:SYS_TEXT_BASE=0x38040000
 eNET_SRAM                    x86         x86        eNET                -              sc520       eNET:SYS_TEXT_BASE=0x19000000
+sandbox                      sandbox     sandbox     sandbox             sandbox        -
 idmr                         m68k        mcf52x2
 TASREG                       m68k        mcf52x2     tasreg              esd
 M5208EVBE                    m68k        mcf52x2     m5208evbe           freescale
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 08/21] sandbox: Add board info for architecture
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (6 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 07/21] sandbox: Add sandbox board Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 09/21] sandbox: Add bootm support Simon Glass
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This is required for the bdinfo command to work.

This also cleans up the #ifdef mess for ethernet and lnum a little.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 common/cmd_bdinfo.c |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index 6051120..0faca6f 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -31,11 +31,14 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static void print_num(const char *, ulong);
 
-#if !(defined(CONFIG_ARM) || defined(CONFIG_M68K)) || defined(CONFIG_CMD_NET)
+#if !(defined(CONFIG_ARM) || defined(CONFIG_M68K) || defined(CONFIG_SANDBOX))
+	|| defined(CONFIG_CMD_NET)
+#define HAVE_PRINT_ETH
 static void print_eth(int idx);
 #endif
 
-#if (!defined(CONFIG_ARM) && !defined(CONFIG_X86))
+#if (!defined(CONFIG_ARM) && !defined(CONFIG_X86) && !defined(CONFIG_SANDBOX))
+#define HAVE_PRINT_LNUM
 static void print_lnum(const char *, u64);
 #endif
 
@@ -413,6 +416,29 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
+#elif defined(CONFIG_SANDBOX)
+
+int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	int i;
+	bd_t *bd = gd->bd;
+
+	print_num("boot_params", (ulong)bd->bi_boot_params);
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+		print_num("DRAM bank", i);
+		print_num("-> start", bd->bi_dram[i].start);
+		print_num("-> size", bd->bi_dram[i].size);
+	}
+
+#if defined(CONFIG_CMD_NET)
+	print_eth(0);
+	printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
+#endif
+	print_num("FB base  ", gd->fb_base);
+	return 0;
+}
+
 #else
  #error "a case for this architecture does not exist!"
 #endif
@@ -422,7 +448,7 @@ static void print_num(const char *name, ulong value)
 	printf("%-12s= 0x%08lX\n", name, value);
 }
 
-#if !(defined(CONFIG_ARM) || defined(CONFIG_M68K)) || defined(CONFIG_CMD_NET)
+#ifdef HAVE_PRINT_ETH
 static void print_eth(int idx)
 {
 	char name[10], *val;
@@ -437,7 +463,7 @@ static void print_eth(int idx)
 }
 #endif
 
-#if (!defined(CONFIG_ARM) && !defined(CONFIG_X86))
+#ifdef HAVE_PRINT_LNUM
 static void print_lnum(const char *name, u64 value)
 {
 	printf("%-12s= 0x%.8llX\n", name, value);
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 09/21] sandbox: Add bootm support
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (7 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 08/21] sandbox: Add board info for architecture Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 10/21] sandbox: Disable built-in malloc Simon Glass
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This adds sandbox architecture support to bootm, although it is probably
not useful to load sandbox code into the address space and execute it.

This change at least make the file build correctly on 64-bit machines.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Fix cast of int to pointer instead of just removing the code

 common/cmd_bootm.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 8909ee7..47bd505 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -187,6 +187,8 @@ void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
   #define IH_INITRD_ARCH IH_ARCH_SH
 #elif defined(__sparc__)
   #define IH_INITRD_ARCH IH_ARCH_SPARC
+#elif defined(CONFIG_SANDBOX_ARCH)
+  #define IH_INITRD_ARCH IH_ARCH_SANDBOX
 #else
 # error Unknown CPU type
 #endif
@@ -462,9 +464,8 @@ static int bootm_start_standalone(ulong iflag, int argc, char * const argv[])
 		setenv("filesize", buf);
 		return 0;
 	}
-	appl = (int (*)(int, char * const []))ntohl(images.ep);
+	appl = (int (*)(int, char * const []))(ulong)ntohl(images.ep);
 	(*appl)(argc-1, &argv[1]);
-
 	return 0;
 }
 
@@ -488,14 +489,14 @@ static cmd_tbl_t cmd_bootm_sub[] = {
 int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int ret = 0;
-	int state;
+	long state;
 	cmd_tbl_t *c;
 	boot_os_fn *boot_fn;
 
 	c = find_cmd_tbl(argv[1], &cmd_bootm_sub[0], ARRAY_SIZE(cmd_bootm_sub));
 
 	if (c) {
-		state = (int)c->cmd;
+		state = (long)c->cmd;
 
 		/* treat start special since it resets the state machine */
 		if (state == BOOTM_STATE_START) {
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 10/21] sandbox: Disable built-in malloc
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (8 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 09/21] sandbox: Add bootm support Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 11/21] sandbox: Disable standalone/API support Simon Glass
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

We prefer to U-Boot's malloc but for now it is easier to use the C library's
version.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 common/Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 2edbd71..8d17a54 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -29,7 +29,9 @@ LIB	= $(obj)libcommon.o
 ifndef CONFIG_SPL_BUILD
 COBJS-y += main.o
 COBJS-y += command.o
+ifndef CONFIG_SANDBOX
 COBJS-y += dlmalloc.o
+endif
 COBJS-y += exports.o
 COBJS-$(CONFIG_SYS_HUSH_PARSER) += hush.o
 COBJS-y += image.o
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 11/21] sandbox: Disable standalone/API support
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (9 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 10/21] sandbox: Disable built-in malloc Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03 19:37   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 12/21] sandbox: Force command sections to be 4-byte aligned Simon Glass
                   ` (9 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This is not useful on the sandbox architecture since we can simply link all
our code with U-Boot. Also, loading native code doesn't make a lot of sense.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 Makefile |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e9ba6a4..672b5cd 100644
--- a/Makefile
+++ b/Makefile
@@ -137,9 +137,7 @@ unexport CDPATH
 
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
-SUBDIRS	= tools \
-	  examples/standalone \
-	  examples/api
+SUBDIRS	= tools
 
 .PHONY : $(SUBDIRS) $(VERSION_FILE)
 
@@ -156,6 +154,11 @@ sinclude $(obj)include/autoconf.mk
 include $(obj)include/config.mk
 export	ARCH CPU BOARD VENDOR SOC
 
+ifndef CONFIG_SANDBOX
+SUBDIRS += examples/standalone \
+	  examples/api
+endif
+
 # set default to nothing for native builds
 ifeq ($(HOSTARCH),$(ARCH))
 CROSS_COMPILE ?=
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 12/21] sandbox: Force command sections to be 4-byte aligned
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (10 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 11/21] sandbox: Disable standalone/API support Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03 19:34   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 13/21] sandbox: Add OS dependent layer Simon Glass
                   ` (8 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

By default sections are 16-byte aligned on some architectures, but the
command name structure (struct cmd_tbl_s) does not have padding to
16 bytes. This change reduces the alignment to 4-bytes so that the command
table can be accessed correctly on any architecture.

(Note: this needs doing properly)

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 include/command.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/command.h b/include/command.h
index f1accd0..c270110 100644
--- a/include/command.h
+++ b/include/command.h
@@ -117,7 +117,8 @@ extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #define CMD_FLAG_REPEAT		0x0001	/* repeat last command		*/
 #define CMD_FLAG_BOOTD		0x0002	/* command is from bootd	*/
 
-#define Struct_Section  __attribute__ ((unused,section (".u_boot_cmd")))
+#define Struct_Section  __attribute__((unused, section(".u_boot_cmd"), \
+		aligned(4)))
 
 #ifdef CONFIG_AUTO_COMPLETE
 # define _CMD_COMPLETE(x) x,
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 13/21] sandbox: Add OS dependent layer
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (11 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 12/21] sandbox: Force command sections to be 4-byte aligned Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03 19:27   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 14/21] sandbox: Add board_init() Simon Glass
                   ` (7 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

We want to keep all OS-dependent code in once place, with a simple interface
to U-Boot. For now, this is that place.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Move os layer into arch/sandbox
- Remove clean and dist-clean targets from Makefile
- Try and fail to remove the global -I/usr/include

Changes in v3:
- Add os_exit() which always exits with success for now
- Add function comments to header file
- Call os_exit() in do_reset()
- Move cpu files into arch/sandbox/cpu

 arch/sandbox/cpu/Makefile |    5 ++-
 arch/sandbox/cpu/cpu.c    |    7 ++--
 arch/sandbox/cpu/os.c     |   55 +++++++++++++++++++++++++++++++++++
 include/os.h              |   70 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 132 insertions(+), 5 deletions(-)
 create mode 100644 arch/sandbox/cpu/os.c
 create mode 100644 include/os.h

diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile
index 8dfa828..1a0b260 100644
--- a/arch/sandbox/cpu/Makefile
+++ b/arch/sandbox/cpu/Makefile
@@ -23,11 +23,14 @@
 # MA 02111-1307 USA
 #
 
+# os.c is build in the system environment, so needs standard includes
+CPPFLAGS_arch/sandbox/cpu/os.o += -I/usr/include
+
 include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(CPU).o
 
-COBJS	:= cpu.o
+COBJS	:= cpu.o os.o
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 554cae8..168c7b4 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -20,15 +20,14 @@
  */
 
 #include <common.h>
+#include <os.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	/*
-	 * This is considered normal termination for now. We wil call os_exit()
-	 * when available.
-	 */
+	/* This is considered normal termination for now */
+	os_exit();
 	return 0;
 }
 
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
new file mode 100644
index 0000000..78befbb
--- /dev/null
+++ b/arch/sandbox/cpu/os.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * 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 <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <os.h>
+
+/* Operating System Interface */
+
+ssize_t os_read(int fd, void *buf, size_t count)
+{
+	return read(fd, buf, count);
+}
+
+ssize_t os_write(int fd, const void *buf, size_t count)
+{
+	return write(fd, buf, count);
+}
+
+int os_open(const char *pathname, int flags)
+{
+	return open(pathname, flags);
+}
+
+int os_close(int fd)
+{
+	return close(fd);
+}
+
+void os_exit(void)
+{
+	exit(EXIT_SUCCESS);
+}
diff --git a/include/os.h b/include/os.h
new file mode 100644
index 0000000..f6165a7
--- /dev/null
+++ b/include/os.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * 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
+ */
+
+/*
+ * Operating System Interface
+ *
+ * This provides access to useful OS routines from the sandbox architecture
+ */
+
+/**
+ * Access to the OS read() system call
+ *
+ * \param fd	File descriptor as returned by os_open()
+ * \param buf	Buffer to place data
+ * \param count	Number of bytes to read
+ * \return number of bytes read, or -1 on error
+ */
+ssize_t os_read(int fd, void *buf, size_t count);
+
+/**
+ * Access to the OS write() system call
+ *
+ * \param fd	File descriptor as returned by os_open()
+ * \param buf	Buffer containing data to write
+ * \param count	Number of bytes to write
+ * \return number of bytes written, or -1 on error
+ */
+ssize_t os_write(int fd, const void *buf, size_t count);
+
+/**
+ * Access to the OS open() system call
+ *
+ * \param pathname	Pathname of file to open
+ * \param flags		Flags, like O_RDONLY, O_RDWR
+ * \return file descriptor, or -1 on error
+ */
+int os_open(const char *pathname, int flags);
+
+/**
+ * Access to the OS close() system call
+ *
+ * \param fd	File descriptor to close
+ * \return 0 on success, -1 on error
+ */
+int os_close(int fd);
+
+/**
+ * Access to the OS exit() system call
+ *
+ * This exits with an EXIT_SUCCESS error code
+ */
+void os_exit(void);
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 14/21] sandbox: Add board_init()
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (12 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 13/21] sandbox: Add OS dependent layer Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03 19:33   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 15/21] sandbox: Add main program Simon Glass
                   ` (6 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

Create a basic empty board_init() to get us running.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 board/sandbox/common/Makefile |   41 +++++++++++++++++++++++++++++++++++++++++
 board/sandbox/common/board.c  |   25 +++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 0 deletions(-)
 create mode 100644 board/sandbox/common/Makefile
 create mode 100644 board/sandbox/common/board.c

diff --git a/board/sandbox/common/Makefile b/board/sandbox/common/Makefile
new file mode 100644
index 0000000..8a282e8
--- /dev/null
+++ b/board/sandbox/common/Makefile
@@ -0,0 +1,41 @@
+# Copyright (c) 2011 The Chromium OS Authors.
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(VENDOR).o
+
+COBJS-y += board.o
+
+COBJS	:= $(COBJS-y)
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+all:	$(LIB)
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+# This is for $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/sandbox/common/board.c b/board/sandbox/common/board.c
new file mode 100644
index 0000000..de3cf06
--- /dev/null
+++ b/board/sandbox/common/board.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * 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
+ */
+
+void board_init(void)
+{
+	/* Nothing to do here for the moment */
+}
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 15/21] sandbox: Add main program
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (13 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 14/21] sandbox: Add board_init() Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 16/21] sandbox: Add serial uart Simon Glass
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

Add a main program so that we can run U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 board/sandbox/common/Makefile |    2 +-
 board/sandbox/common/main.c   |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 board/sandbox/common/main.c

diff --git a/board/sandbox/common/Makefile b/board/sandbox/common/Makefile
index 8a282e8..3d03405 100644
--- a/board/sandbox/common/Makefile
+++ b/board/sandbox/common/Makefile
@@ -21,7 +21,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(VENDOR).o
 
-COBJS-y += board.o
+COBJS-y += board.o main.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/board/sandbox/common/main.c b/board/sandbox/common/main.c
new file mode 100644
index 0000000..685793e
--- /dev/null
+++ b/board/sandbox/common/main.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+
+int main(int argc, char *argv[])
+{
+	/*
+	 * Do pre- and post-relocation init, then start up U-Boot. This will
+	 * never return.
+	 */
+	board_init_f(0);
+
+	return 0;
+}
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 16/21] sandbox: Add serial uart
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (14 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 15/21] sandbox: Add main program Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03 19:42   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 17/21] sandbox: Add basic config file Simon Glass
                   ` (4 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This uart simply writes to stdout and reads from stdin. We might imagine
instead buffering the data so that a test interface can check output and
inject input.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 drivers/serial/Makefile  |    1 +
 drivers/serial/sandbox.c |   67 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100644 drivers/serial/sandbox.c

diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 1dcc1c7..6309549 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -53,6 +53,7 @@ COBJS-$(CONFIG_SA1100_SERIAL) += serial_sa1100.o
 COBJS-$(CONFIG_S3C24X0_SERIAL) += serial_s3c24x0.o
 COBJS-$(CONFIG_S3C44B0_SERIAL) += serial_s3c44b0.o
 COBJS-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
+COBJS-$(CONFIG_SANDBOX_SERIAL) += sandbox.o
 COBJS-$(CONFIG_SCIF_CONSOLE) += serial_sh.o
 COBJS-$(CONFIG_TEGRA2) += serial_tegra2.o
 
diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
new file mode 100644
index 0000000..7c4b11b
--- /dev/null
+++ b/drivers/serial/sandbox.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * 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
+ */
+
+/*
+ * This provide a test serial port. It provides an emulated serial port where
+ * a test program and read out the serial output and inject serial input for
+ * U-Boot.
+ */
+
+#include <common.h>
+#include <os.h>
+
+int serial_init(void)
+{
+	return 0;
+}
+
+void serial_exit(void)
+{
+}
+
+void serial_setbrg(void)
+{
+}
+
+void serial_putc(const char ch)
+{
+	os_write(1, &ch, 1);
+}
+
+void serial_puts(const char *str)
+{
+	while (*str)
+		serial_putc(*str++);
+}
+
+int serial_getc(void)
+{
+	char buf;
+	int count;
+
+	count = os_read(0, &buf, 1);
+	return count == 1 ? buf : 0;
+}
+
+int serial_tstc(void)
+{
+	return 0;
+}
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 17/21] sandbox: Add basic config file
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (15 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 16/21] sandbox: Add serial uart Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03 19:42   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 18/21] Remove unused variable warnings in cmd_mem, cmd_nvedit Simon Glass
                   ` (3 subsequent siblings)
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This basic provides required features along with a basic command set.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Remove CONFIG_SYS_SDRAM_BASE which is always 0 for sandbox boards
- Fix #define<tab>
- Remove CONFIG_LMB

 include/configs/sandbox.h |   77 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 77 insertions(+), 0 deletions(-)
 create mode 100644 include/configs/sandbox.h

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
new file mode 100644
index 0000000..0d678f6
--- /dev/null
+++ b/include/configs/sandbox.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * 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
+ */
+
+#define CONFIG_NR_DRAM_BANKS	1
+#define CONFIG_DRAM_SIZE	(128 << 20)
+
+/* Number of bits in a C 'long' on this architecture */
+#define CONFIG_SANDBOX_BITS_PER_LONG	64
+
+/*
+ * Size of malloc() pool, although we don't actually use this yet.
+ */
+#define CONFIG_SYS_MALLOC_LEN		(4 << 20)	/* 4MB  */
+
+#define CONFIG_SYS_PROMPT		"=>"	/* Command Prompt */
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
+#define CONFIG_SYS_LONGHELP			/* #undef to save memory */
+#define CONFIG_SYS_CBSIZE		1024	/* Console I/O Buffer Size */
+
+/* Print Buffer Size */
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_MAXARGS	16
+
+/* turn on command-line edit/c/auto */
+#define CONFIG_CMDLINE_EDITING
+#define CONFIG_COMMAND_HISTORY
+#define CONFIG_AUTOCOMPLETE
+
+#define CONFIG_ENV_SIZE		8192
+#define CONFIG_ENV_IS_NOWHERE
+
+#define CONFIG_SYS_HZ			1000
+
+/* Memory things - we don't really want a memory test */
+#define CONFIG_SYS_LOAD_ADDR		0x10000000
+#define CONFIG_SYS_MEMTEST_START	0x10000000
+#define CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_MEMTEST_START + 0x1000)
+#define CONFIG_PHYS_64BIT
+
+#define CONFIG_BAUDRATE			115200
+#define CONFIG_SYS_BAUDRATE_TABLE	{4800, 9600, 19200, 38400, 57600,\
+					115200}
+#define CONFIG_SANDBOX_SERIAL
+
+#define CONFIG_SYS_NO_FLASH
+
+/* include default commands */
+#include <config_cmd_default.h>
+
+/* We don't have networking support yet */
+#undef CONFIG_CMD_NET
+#undef CONFIG_CMD_NFS
+
+#define CONFIG_BOOTARGS ""
+
+#define CONFIG_EXTRA_ENV_SETTINGS	"stdin=serial\0" \
+					"stdout=serial\0" \
+					"stderr=serial\0"
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 18/21] Remove unused variable warnings in cmd_mem, cmd_nvedit
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (16 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 17/21] sandbox: Add basic config file Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility Simon Glass
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

There are a few variables set but not used - this marks these as unused
for the compiler.

Merek's GCC4.6 patch series fixes these so this patch does not need to be
applied if you have these:
- GCC4.6: Squash warning in cmd_mem.c
- GCC4.6: Squash warning in cmd_nvedit.c

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Try to avoid needing __attribute__((unused)) by assigning to an existing var

Changes in v3:
- Remove variable assignment and rely on 'volatile' to perform the read
- Add note about Merek's patch set

 common/cmd_mem.c    |    8 ++++----
 common/cmd_nvedit.c |    3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 4daa1b3..e84cc4e 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -471,7 +471,7 @@ int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	ulong	addr, length, i, junk;
+	ulong	addr, length, i;
 	int	size;
 	volatile uint	*longp;
 	volatile ushort *shortp;
@@ -518,7 +518,7 @@ int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			longp = (uint *)addr;
 			i = length;
 			while (i-- > 0)
-				junk = *longp++;
+				*longp++;
 		}
 	}
 	if (size == 2) {
@@ -526,14 +526,14 @@ int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			shortp = (ushort *)addr;
 			i = length;
 			while (i-- > 0)
-				junk = *shortp++;
+				*shortp++;
 		}
 	}
 	for (;;) {
 		cp = (u_char *)addr;
 		i = length;
 		while (i-- > 0)
-			junk = *cp++;
+			*cp++;
 	}
 }
 
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index e8b116d..101bc49 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -460,7 +460,6 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char buffer[CONFIG_SYS_CBSIZE];
 	char *init_val;
-	int len;
 
 	if (argc < 2)
 		return cmd_usage(cmdtp);
@@ -468,7 +467,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/* Set read buffer to initial value or empty sting */
 	init_val = getenv(argv[1]);
 	if (init_val)
-		len = sprintf(buffer, "%s", init_val);
+		sprintf(buffer, "%s", init_val);
 	else
 		buffer[0] = '\0';
 
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (17 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 18/21] Remove unused variable warnings in cmd_mem, cmd_nvedit Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03 18:57   ` Mike Frysinger
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 20/21] Adjust dependency rules to permit per-file flags Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 21/21] sandbox: Makefile changes to build sandbox architecture Simon Glass
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

This fixes a few problems when building on 64-bit machines.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 common/cmd_mem.c     |    2 +-
 common/fdt_support.c |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index e84cc4e..28476d7 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -937,7 +937,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			if (readback != val) {
 				printf ("\nMem error @ 0x%08X: "
 					"found %08lX, expected %08lX\n",
-					(uint)addr, readback, val);
+					(uint)(uintptr_t)addr, readback, val);
 				errs++;
 				if (ctrlc()) {
 					putc ('\n');
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 19b2ef6..9bed3ce 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -495,7 +495,7 @@ int fdt_resize(void *blob)
 	total = fdt_num_mem_rsv(blob);
 	for (i = 0; i < total; i++) {
 		fdt_get_mem_rsv(blob, i, &addr, &size);
-		if (addr == (uint64_t)(u32)blob) {
+		if (addr == (uintptr_t)blob) {
 			fdt_del_mem_rsv(blob, i);
 			break;
 		}
@@ -511,14 +511,14 @@ int fdt_resize(void *blob)
 		fdt_size_dt_strings(blob) + 5 * sizeof(struct fdt_reserve_entry);
 
 	/* Make it so the fdt ends on a page boundary */
-	actualsize = ALIGN(actualsize + ((uint)blob & 0xfff), 0x1000);
-	actualsize = actualsize - ((uint)blob & 0xfff);
+	actualsize = ALIGN(actualsize + ((uintptr_t)blob & 0xfff), 0x1000);
+	actualsize = actualsize - ((uintptr_t)blob & 0xfff);
 
 	/* Change the fdt header to reflect the correct size */
 	fdt_set_totalsize(blob, actualsize);
 
 	/* Add the new reservation */
-	ret = fdt_add_mem_rsv(blob, (uint)blob, actualsize);
+	ret = fdt_add_mem_rsv(blob, (uintptr_t)blob, actualsize);
 	if (ret < 0)
 		return ret;
 
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 20/21] Adjust dependency rules to permit per-file flags
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (18 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-04  1:10   ` Simon Glass
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 21/21] sandbox: Makefile changes to build sandbox architecture Simon Glass
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

The dependency rules are currently done in a shell 'for' loop. This does not
permit Makefile variables to adjust preprocessor flags as is done with normal
compile flags, using the CFLAGS_path/file.o syntax.

This change moves the dependency generation into the Makefile itself, and
permits a CPPFLAGS_path/file.o to adjust preprocessor flags on a file or
directory basis.

The CPPFLAGS_... variable is also folded into CFLAGS during the build.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Change U-Boot's dependency generation to permit per-file flags

 .gitignore |    2 +-
 config.mk  |    7 +++++++
 rules.mk   |   23 ++++++++++++-----------
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/.gitignore b/.gitignore
index dbf545f..7ba0dd9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,7 +39,7 @@
 # Generated files
 #
 
-*.depend
+*.depend*
 /LOG
 /errlog
 /reloc_off
diff --git a/config.mk b/config.mk
index e2b440d..3fa9eef 100644
--- a/config.mk
+++ b/config.mk
@@ -277,6 +277,13 @@ export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS
 BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
 ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
 ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
+EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))
+ALL_CFLAGS += $(EXTRA_CPPFLAGS)
+
+# The _DEP version uses the $< file target (for dependency generation)
+# See rules.mk
+EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \
+		$(CPPFLAGS_$(BCURDIR))
 $(obj)%.s:	%.S
 	$(CPP) $(ALL_AFLAGS) -o $@ $<
 $(obj)%.o:	%.S
diff --git a/rules.mk b/rules.mk
index d79fcd3..56b9044 100644
--- a/rules.mk
+++ b/rules.mk
@@ -25,17 +25,18 @@
 
 _depend:	$(obj).depend
 
-$(obj).depend:	$(src)Makefile $(TOPDIR)/config.mk $(SRCS) $(HOSTSRCS)
-		@rm -f $@
-		@touch $@
-		@for f in $(SRCS); do \
-			g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
-			$(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
-		done
-		@for f in $(HOSTSRCS); do \
-			g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
-			$(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
-		done
+DEPS := $(basename $(patsubst %,$(obj).depend.%,$(SRCS)))
+
+$(obj).depend:	$(src)Makefile $(TOPDIR)/config.mk $(DEPS) $(HOSTSRCS)
+	cat /dev/null $(DEPS) >$@
+	@for f in $(HOSTSRCS); do \
+		g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
+		$(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
+	done
+
+$(obj).depend.%:	%.c
+	$(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \
+		-MQ $(addsuffix .o,$(basename $<)) $< >$@
 
 $(HOSTOBJS): $(obj)%.o: %.c
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 21/21] sandbox: Makefile changes to build sandbox architecture
  2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
                   ` (19 preceding siblings ...)
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 20/21] Adjust dependency rules to permit per-file flags Simon Glass
@ 2011-09-27  0:10 ` Simon Glass
  2011-10-03 19:31   ` Mike Frysinger
  20 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-09-27  0:10 UTC (permalink / raw)
  To: u-boot

At this point U-Boot will build and run on x86 under Linux.

The idea is to define a new architecture called 'sandbox', alongside ARM
and x86. This runs natively on Linux to suit the host machine. All
hardware access is either omitted or emulated.

The purpose of this system is to test the bulk of the non-hardware-specific
U-Boot code. We can mock the SPI flash, GPIOs, UART and keyboard, then test
that U-Boot behaves as we wish.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Rebase to master
- Tidy top-level Makefile to minimise changes

 Makefile |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 672b5cd..47f6103 100644
--- a/Makefile
+++ b/Makefile
@@ -199,8 +199,9 @@ endif
 
 #########################################################################
 # U-Boot objects....order is important (i.e. start must be first)
-
+ifneq ($(CPU),sandbox)
 OBJS  = $(CPUDIR)/start.o
+endif
 ifeq ($(CPU),x86)
 OBJS += $(CPUDIR)/start16.o
 OBJS += $(CPUDIR)/resetvec.o
@@ -401,12 +402,19 @@ $(obj)u-boot.ubl:       $(obj)u-boot-nand.bin
 		$(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
 		-e $(CONFIG_SYS_TEXT_BASE) -d $< $@
 
+ifeq ($(CONFIG_SANDBOX),y)
+GEN_UBOOT = \
+		cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
+			-Wl,--start-group $(__LIBS) -Wl,--end-group \
+			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
+else
 GEN_UBOOT = \
-		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
-		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
+		UNDEF_SYM=`$(UNDEF)`; \
 		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \
 			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
 			-Map u-boot.map -o u-boot
+endif
+
 $(obj)u-boot:	depend \
 		$(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
 		$(GEN_UBOOT)
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 01/21] sandbox: Add architecture header files
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 01/21] sandbox: Add architecture header files Simon Glass
@ 2011-10-03  5:56   ` Mike Frysinger
  2011-10-04  0:10     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03  5:56 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:35 Simon Glass wrote:
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -1,6 +1,8 @@
>  #ifndef _LINUX_STRING_H_
>  #define _LINUX_STRING_H_
> 
> +#include <linux/string.h>
> +
>  #include <linux/types.h>	/* for size_t */
>  #include <linux/stddef.h>	/* for NULL */

hmm, this can't be right ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/647c4e65/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 05/21] sandbox: Add cpu files
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 05/21] sandbox: Add cpu files Simon Glass
@ 2011-10-03  6:10   ` Mike Frysinger
  2011-10-03 19:25     ` Mike Frysinger
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03  6:10 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:39 Simon Glass wrote:
> --- /dev/null
> +++ b/arch/sandbox/cpu/cpu.c
>
> +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> +{
> +	/*
> +	 * This is considered normal termination for now. We wil call os_exit()
> +	 * when available.
> +	 */
> +	return 0;
> +}

os_exit(0) ?

> +int cleanup_before_linux(void)
> +{
> +	return 0;
> +}

this is an ARM wart ... drop it

> +void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long
> flags)
> +{
> +	return (void *)(gd->ram_buf + paddr);
> +}

please add a comment as to why you need this trickery
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/0db24f82/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 06/21] sandbox: Add architecture lib files
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 06/21] sandbox: Add architecture lib files Simon Glass
@ 2011-10-03  6:15   ` Mike Frysinger
  2011-10-04  0:02     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03  6:15 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:40 Simon Glass wrote:
> +	gd->mon_len = 0; /* _bss_end_ofs;*/

i'd scrub references to this and drop it from the global header

> +	size = 128 * 1024 * 1024;
> +	mem = malloc(size);
> +	assert(mem);
> +	gd->ram_buf = mem;

shouldn't this 128 MiB be a config ?

> +#ifdef CONFIG_POST
> +	post_bootmode_init();
> +	post_run(NULL, POST_ROM | post_bootmode_get(0));
> +#endif

i wonder if you shouldn't just drop all the POST stuff for now ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/275e299a/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility Simon Glass
@ 2011-10-03 18:57   ` Mike Frysinger
  2011-10-04  5:24     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03 18:57 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:53 Simon Glass wrote:
> --- a/common/cmd_mem.c
> +++ b/common/cmd_mem.c
>
>  				printf ("\nMem error @ 0x%08X: "
>  					"found %08lX, expected %08lX\n",
> -					(uint)addr, readback, val);
> +					(uint)(uintptr_t)addr, readback, val);

could you change the printf format to %#p instead (and drop the casts 
completely for "addr") ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/a48d49be/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 05/21] sandbox: Add cpu files
  2011-10-03  6:10   ` Mike Frysinger
@ 2011-10-03 19:25     ` Mike Frysinger
  0 siblings, 0 replies; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03 19:25 UTC (permalink / raw)
  To: u-boot

On Monday, October 03, 2011 02:10:25 Mike Frysinger wrote:
> On Monday, September 26, 2011 20:10:39 Simon Glass wrote:
> > --- /dev/null
> > +++ b/arch/sandbox/cpu/cpu.c
> > 
> > +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> > +{
> > +	/*
> > +	 * This is considered normal termination for now. We wil call 
os_exit()
> > +	 * when available.
> > +	 */
> > +	return 0;
> > +}
> 
> os_exit(0) ?

nm, i see the other patch now
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/ee36e22c/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 13/21] sandbox: Add OS dependent layer
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 13/21] sandbox: Add OS dependent layer Simon Glass
@ 2011-10-03 19:27   ` Mike Frysinger
  2011-10-03 23:44     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03 19:27 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:47 Simon Glass wrote:
> --- /dev/null
> +++ b/include/os.h
> +/**
> + * Access to the OS exit() system call
> + *
> + * This exits with an EXIT_SUCCESS error code
> + */
> +void os_exit(void);

any reason for not allowing people to pass the actual error code ?  would be 
handy i think if you could exit with non-zero codes ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/cb0ee921/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 21/21] sandbox: Makefile changes to build sandbox architecture
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 21/21] sandbox: Makefile changes to build sandbox architecture Simon Glass
@ 2011-10-03 19:31   ` Mike Frysinger
  2011-10-04  0:51     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03 19:31 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:55 Simon Glass wrote:
> --- a/Makefile
> +++ b/Makefile
>
> +ifneq ($(CPU),sandbox)
>  OBJS  = $(CPUDIR)/start.o
> +endif

if you moved arch/sandbox/common/main.c to arch/sandbox/cpu/start.c, you 
wouldn't need this.  and logically, it seems like a good place for main() to 
be ...

> +ifeq ($(CONFIG_SANDBOX),y)
> +GEN_UBOOT = \
> +		cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
> +			-Wl,--start-group $(__LIBS) -Wl,--end-group \
> +			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot

unfortunate that you can't utilize UNDEF_SYM ...

>  GEN_UBOOT = \
> -		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
> -		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;
> +		UNDEF_SYM=`$(UNDEF)`; \

i don't see you defining "UNDEF" anywhere in this patch series ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/ac25b4cd/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 14/21] sandbox: Add board_init()
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 14/21] sandbox: Add board_init() Simon Glass
@ 2011-10-03 19:33   ` Mike Frysinger
  2011-10-04  0:17     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03 19:33 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:48 Simon Glass wrote:
> Create a basic empty board_init() to get us running.

why not just drop this from your sandbox core init ?  this isn't standardized 
across arches, so if you don't need it, i would scrub it.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/405731ce/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 12/21] sandbox: Force command sections to be 4-byte aligned
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 12/21] sandbox: Force command sections to be 4-byte aligned Simon Glass
@ 2011-10-03 19:34   ` Mike Frysinger
  2011-10-04  0:05     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03 19:34 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:46 Simon Glass wrote:
> By default sections are 16-byte aligned on some architectures, but the
> command name structure (struct cmd_tbl_s) does not have padding to
> 16 bytes. This change reduces the alignment to 4-bytes so that the command
> table can be accessed correctly on any architecture.

where is this coming from ?  why does it need to be 4 byte ?  could you 
elaborate on the issue you ran into ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/e60627ee/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 11/21] sandbox: Disable standalone/API support
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 11/21] sandbox: Disable standalone/API support Simon Glass
@ 2011-10-03 19:37   ` Mike Frysinger
  2011-10-04  0:13     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03 19:37 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:45 Simon Glass wrote:
> This is not useful on the sandbox architecture since we can simply link all
> our code with U-Boot. Also, loading native code doesn't make a lot of
> sense.

the standalone code would be useful tests i think ... after all, you're given 
an exported API from u-boot which are high level functions like I/O.

but getting them to work in the sandbox environment probably will be tricky to 
say the least ... perhaps add a note in the README.sandbox ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/54b56062/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 16/21] sandbox: Add serial uart
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 16/21] sandbox: Add serial uart Simon Glass
@ 2011-10-03 19:42   ` Mike Frysinger
  2011-10-04  0:21     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03 19:42 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:50 Simon Glass wrote:
> +int serial_init(void)
> +{
> +	return 0;
> +}

this probably should set the tty to raw input with termios.  if you're not 
familiar with the termios API, just lemme know, and i can send you a chunk of 
code to do what you need.

> +void serial_exit(void)
> +{
> +}

no one actually implements this :).  just delete it, and i'll delete the 
prototype from common.h.

> +int serial_tstc(void)
> +{
> +	return 0;
> +}

once serial_init() reconfigures the tty to a more "serial" like mode, you can 
implement this properly.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/a8a4f83c/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 17/21] sandbox: Add basic config file
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 17/21] sandbox: Add basic config file Simon Glass
@ 2011-10-03 19:42   ` Mike Frysinger
  2011-10-04  0:23     ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-03 19:42 UTC (permalink / raw)
  To: u-boot

On Monday, September 26, 2011 20:10:51 Simon Glass wrote:
> --- /dev/null
> +++ b/include/configs/sandbox.h

needs ifdef protection against multiple inclusion
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/3a59e9d2/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 13/21] sandbox: Add OS dependent layer
  2011-10-03 19:27   ` Mike Frysinger
@ 2011-10-03 23:44     ` Simon Glass
  2011-10-03 23:49       ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-10-03 23:44 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Mon, Oct 3, 2011 at 12:27 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:47 Simon Glass wrote:
>> --- /dev/null
>> +++ b/include/os.h
>> +/**
>> + * Access to the OS exit() system call
>> + *
>> + * This exits with an EXIT_SUCCESS error code
>> + */
>> +void os_exit(void);
>
> any reason for not allowing people to pass the actual error code ? ?would be
> handy i think if you could exit with non-zero codes ...
> -mike
>

Only just that I was trying to avoid adding code I don't use. But fair
enough, I will change it.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 13/21] sandbox: Add OS dependent layer
  2011-10-03 23:44     ` Simon Glass
@ 2011-10-03 23:49       ` Simon Glass
  0 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-10-03 23:49 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 3, 2011 at 4:44 PM, Simon Glass <sjg@chromium.org> wrote:

> Hi Mike,
>
> On Mon, Oct 3, 2011 at 12:27 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> > On Monday, September 26, 2011 20:10:47 Simon Glass wrote:
> >> --- /dev/null
> >> +++ b/include/os.h
> >> +/**
> >> + * Access to the OS exit() system call
> >> + *
> >> + * This exits with an EXIT_SUCCESS error code
> >> + */
> >> +void os_exit(void);
> >
> > any reason for not allowing people to pass the actual error code ?  would
> be
> > handy i think if you could exit with non-zero codes ...
> > -mike
> >
>
> Only just that I was trying to avoid adding code I don't use. But fair
> enough, I will change it.
>

(also I didn't have access to EXIT_SUCCESS - but we can just use 0).


>
> Regards,
> Simon
>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 06/21] sandbox: Add architecture lib files
  2011-10-03  6:15   ` Mike Frysinger
@ 2011-10-04  0:02     ` Simon Glass
  0 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-10-04  0:02 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Sun, Oct 2, 2011 at 11:15 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:40 Simon Glass wrote:
>> + ? ? gd->mon_len = 0; /* _bss_end_ofs;*/
>
> i'd scrub references to this and drop it from the global header

OK

>
>> + ? ? size = 128 * 1024 * 1024;
>> + ? ? mem = malloc(size);
>> + ? ? assert(mem);
>> + ? ? gd->ram_buf = mem;
>
> shouldn't this 128 MiB be a config ?

Will add one.

>
>> +#ifdef CONFIG_POST
>> + ? ? post_bootmode_init();
>> + ? ? post_run(NULL, POST_ROM | post_bootmode_get(0));
>> +#endif
>
> i wonder if you shouldn't just drop all the POST stuff for now ...
> -mike
>

OK will do.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 12/21] sandbox: Force command sections to be 4-byte aligned
  2011-10-03 19:34   ` Mike Frysinger
@ 2011-10-04  0:05     ` Simon Glass
  0 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-10-04  0:05 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Mon, Oct 3, 2011 at 12:34 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:46 Simon Glass wrote:
>> By default sections are 16-byte aligned on some architectures, but the
>> command name structure (struct cmd_tbl_s) does not have padding to
>> 16 bytes. This change reduces the alignment to 4-bytes so that the command
>> table can be accessed correctly on any architecture.
>
> where is this coming from ? ?why does it need to be 4 byte ? ?could you
> elaborate on the issue you ran into ?
> -mike
>

Yes, we have a structure cmd_tbl_s in include/command.h which is a
certain size. We use the linker to collect elements of an array of
these structures and then at run-time we want this array to be
accessible.

If the linker puts padding between elements then we cannot access the
array properly.

I need to take another look at this though, as I didn't spend much
time on it at the time.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 01/21] sandbox: Add architecture header files
  2011-10-03  5:56   ` Mike Frysinger
@ 2011-10-04  0:10     ` Simon Glass
  0 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-10-04  0:10 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Sun, Oct 2, 2011 at 10:56 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:35 Simon Glass wrote:
>> --- a/include/linux/string.h
>> +++ b/include/linux/string.h
>> @@ -1,6 +1,8 @@
>> ?#ifndef _LINUX_STRING_H_
>> ?#define _LINUX_STRING_H_
>>
>> +#include <linux/string.h>
>> +
>> ?#include <linux/types.h> ? ? /* for size_t */
>> ?#include <linux/stddef.h> ? ?/* for NULL */
>
> hmm, this can't be right ...
> -mike
>

No, it is not - and odd that it compiles. I will fix.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 11/21] sandbox: Disable standalone/API support
  2011-10-03 19:37   ` Mike Frysinger
@ 2011-10-04  0:13     ` Simon Glass
  2011-10-04  0:40       ` Mike Frysinger
  0 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-10-04  0:13 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Mon, Oct 3, 2011 at 12:37 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:45 Simon Glass wrote:
>> This is not useful on the sandbox architecture since we can simply link all
>> our code with U-Boot. Also, loading native code doesn't make a lot of
>> sense.
>
> the standalone code would be useful tests i think ... after all, you're given
> an exported API from u-boot which are high level functions like I/O.
>
> but getting them to work in the sandbox environment probably will be tricky to
> say the least ... perhaps add a note in the README.sandbox ?
> -mike
>

Yes I will add a note. But it's hard to see why it wouldn't be better
just to link against U-Boot. Or are you thinking of lashing a file
system stress tester to U-Boot somehow?

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 14/21] sandbox: Add board_init()
  2011-10-03 19:33   ` Mike Frysinger
@ 2011-10-04  0:17     ` Simon Glass
  0 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-10-04  0:17 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Mon, Oct 3, 2011 at 12:33 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:48 Simon Glass wrote:
>> Create a basic empty board_init() to get us running.
>
> why not just drop this from your sandbox core init ? ?this isn't standardized
> across arches, so if you don't need it, i would scrub it.
> -mike
>

OK, will do.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 16/21] sandbox: Add serial uart
  2011-10-03 19:42   ` Mike Frysinger
@ 2011-10-04  0:21     ` Simon Glass
  2011-10-04  1:10       ` Mike Frysinger
  0 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-10-04  0:21 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Mon, Oct 3, 2011 at 12:42 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:50 Simon Glass wrote:
>> +int serial_init(void)
>> +{
>> + ? ? return 0;
>> +}
>
> this probably should set the tty to raw input with termios. ?if you're not
> familiar with the termios API, just lemme know, and i can send you a chunk of
> code to do what you need.

Yes I know what you mean.

How would this cope with having a script controlling it? We would need
to check for a terminal and do something different in that case,
right?

Can we leave this until later?

>
>> +void serial_exit(void)
>> +{
>> +}
>
> no one actually implements this :). ?just delete it, and i'll delete the
> prototype from common.h.

OK

>
>> +int serial_tstc(void)
>> +{
>> + ? ? return 0;
>> +}
>
> once serial_init() reconfigures the tty to a more "serial" like mode, you can
> implement this properly.
> -mike
>

Well yes, but I would prefer to leave this for now.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 17/21] sandbox: Add basic config file
  2011-10-03 19:42   ` Mike Frysinger
@ 2011-10-04  0:23     ` Simon Glass
  0 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-10-04  0:23 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Mon, Oct 3, 2011 at 12:42 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:51 Simon Glass wrote:
>> --- /dev/null
>> +++ b/include/configs/sandbox.h
>
> needs ifdef protection against multiple inclusion
> -mike
>

OK, will do.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 11/21] sandbox: Disable standalone/API support
  2011-10-04  0:13     ` Simon Glass
@ 2011-10-04  0:40       ` Mike Frysinger
  2011-10-04  0:54         ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-04  0:40 UTC (permalink / raw)
  To: u-boot

On Monday, October 03, 2011 20:13:03 Simon Glass wrote:
> On Mon, Oct 3, 2011 at 12:37 PM, Mike Frysinger wrote:
> > On Monday, September 26, 2011 20:10:45 Simon Glass wrote:
> >> This is not useful on the sandbox architecture since we can simply link
> >> all our code with U-Boot. Also, loading native code doesn't make a lot
> >> of sense.
> > 
> > the standalone code would be useful tests i think ... after all, you're
> > given an exported API from u-boot which are high level functions like
> > I/O.
> > 
> > but getting them to work in the sandbox environment probably will be
> > tricky to say the least ... perhaps add a note in the README.sandbox ?
> 
> Yes I will add a note. But it's hard to see why it wouldn't be better
> just to link against U-Boot. Or are you thinking of lashing a file
> system stress tester to U-Boot somehow?

i would like to see automatic testing of the exported API in the same way that 
standalone applications work.  so u-boot runs, loads an arbitrary blob into 
its external memory, and then jumps into it.

if we have tun/tap networking, this should be easy to get arbitrary files into 
its memory space ... after that, it's a "simple" matter of jumping into the 
middle of its code :).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/8c467161/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 21/21] sandbox: Makefile changes to build sandbox architecture
  2011-10-03 19:31   ` Mike Frysinger
@ 2011-10-04  0:51     ` Simon Glass
  2011-10-04  1:05       ` Mike Frysinger
  0 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-10-04  0:51 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Mon, Oct 3, 2011 at 12:31 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:55 Simon Glass wrote:
>> --- a/Makefile
>> +++ b/Makefile
>>
>> +ifneq ($(CPU),sandbox)
>> ?OBJS ?= $(CPUDIR)/start.o
>> +endif
>
> if you moved arch/sandbox/common/main.c to arch/sandbox/cpu/start.c, you
> wouldn't need this. ?and logically, it seems like a good place for main() to
> be ...

Yes, this does make sense - it will change it.

>
>> +ifeq ($(CONFIG_SANDBOX),y)
>> +GEN_UBOOT = \
>> + ? ? ? ? ? ? cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
>> + ? ? ? ? ? ? ? ? ? ? -Wl,--start-group $(__LIBS) -Wl,--end-group \
>> + ? ? ? ? ? ? ? ? ? ? $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
>
> unfortunate that you can't utilize UNDEF_SYM ...

Well I can add a hack to make it empty, but I'm not sure what it buys
us. The main issue is that I don't want to pass any link flags from
LDFLAGS, etc. I could put that magic into config.mk perhaps (and this
might be a better place for it), but it is something of a special case
wherever it goes.

>
>> ?GEN_UBOOT = \
>> - ? ? ? ? ? ? UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
>> - ? ? ? ? ? ? sed ?-n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;
>> + ? ? ? ? ? ? UNDEF_SYM=`$(UNDEF)`; \
>
> i don't see you defining "UNDEF" anywhere in this patch series ...
> -mike
>

No I was experimenting with trying to make the Makefile more common -
will revert this.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 11/21] sandbox: Disable standalone/API support
  2011-10-04  0:40       ` Mike Frysinger
@ 2011-10-04  0:54         ` Simon Glass
  0 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-10-04  0:54 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Mon, Oct 3, 2011 at 5:40 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, October 03, 2011 20:13:03 Simon Glass wrote:
>> On Mon, Oct 3, 2011 at 12:37 PM, Mike Frysinger wrote:
>> > On Monday, September 26, 2011 20:10:45 Simon Glass wrote:
>> >> This is not useful on the sandbox architecture since we can simply link
>> >> all our code with U-Boot. Also, loading native code doesn't make a lot
>> >> of sense.
>> >
>> > the standalone code would be useful tests i think ... after all, you're
>> > given an exported API from u-boot which are high level functions like
>> > I/O.
>> >
>> > but getting them to work in the sandbox environment probably will be
>> > tricky to say the least ... perhaps add a note in the README.sandbox ?
>>
>> Yes I will add a note. But it's hard to see why it wouldn't be better
>> just to link against U-Boot. Or are you thinking of lashing a file
>> system stress tester to U-Boot somehow?
>
> i would like to see automatic testing of the exported API in the same way that
> standalone applications work. ?so u-boot runs, loads an arbitrary blob into
> its external memory, and then jumps into it.
>
> if we have tun/tap networking, this should be easy to get arbitrary files into
> its memory space ... after that, it's a "simple" matter of jumping into the
> middle of its code :).
> -mike
>

OK I see. I suppose another way would be to call the API functions
directly, since you will miss arch-specific bugs this way. But it
sounds interesting.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 21/21] sandbox: Makefile changes to build sandbox architecture
  2011-10-04  0:51     ` Simon Glass
@ 2011-10-04  1:05       ` Mike Frysinger
  0 siblings, 0 replies; 58+ messages in thread
From: Mike Frysinger @ 2011-10-04  1:05 UTC (permalink / raw)
  To: u-boot

On Monday, October 03, 2011 20:51:50 Simon Glass wrote:
> On Mon, Oct 3, 2011 at 12:31 PM, Mike Frysinger wrote:
> > On Monday, September 26, 2011 20:10:55 Simon Glass wrote:
> >> +ifeq ($(CONFIG_SANDBOX),y)
> >> +GEN_UBOOT = \
> >> +             cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
> >> +                     -Wl,--start-group $(__LIBS) -Wl,--end-group \
> >> +                     $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
> > 
> > unfortunate that you can't utilize UNDEF_SYM ...
> 
> Well I can add a hack to make it empty, but I'm not sure what it buys
> us. The main issue is that I don't want to pass any link flags from
> LDFLAGS, etc. I could put that magic into config.mk perhaps (and this
> might be a better place for it), but it is something of a special case
> wherever it goes.

hmm, i guess you're not using -Wl,--gc-sections mostly because you ignore 
$(LDFLAGS).  i wonder if you did something like:
COMMA = ,
	... $(patsubst %,-Wl$(COMMA)%,$(LDFLAGS)) ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/64939c95/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 16/21] sandbox: Add serial uart
  2011-10-04  0:21     ` Simon Glass
@ 2011-10-04  1:10       ` Mike Frysinger
  0 siblings, 0 replies; 58+ messages in thread
From: Mike Frysinger @ 2011-10-04  1:10 UTC (permalink / raw)
  To: u-boot

On Monday, October 03, 2011 20:21:15 Simon Glass wrote:
> On Mon, Oct 3, 2011 at 12:42 PM, Mike Frysinger wrote:
> > On Monday, September 26, 2011 20:10:50 Simon Glass wrote:
> >> +int serial_init(void)
> >> +{
> >> +     return 0;
> >> +}
> > 
> > this probably should set the tty to raw input with termios.  if you're
> > not familiar with the termios API, just lemme know, and i can send you a
> > chunk of code to do what you need.
> 
> Yes I know what you mean.
> 
> How would this cope with having a script controlling it? We would need
> to check for a terminal and do something different in that case,
> right?

i don't think so.  it's just changing the input from being buffered to not.

otherwise, fun things like tab completion wouldn't work since stdin is being 
line buffered by default.

> Can we leave this until later?

sure ... toss it into the README ;)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/2d36b4af/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 20/21] Adjust dependency rules to permit per-file flags
  2011-09-27  0:10 ` [U-Boot] [PATCH v3 20/21] Adjust dependency rules to permit per-file flags Simon Glass
@ 2011-10-04  1:10   ` Simon Glass
  2011-10-10  2:50     ` Mike Frysinger
  0 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-10-04  1:10 UTC (permalink / raw)
  To: u-boot

Hi,

On Mon, Sep 26, 2011 at 5:10 PM, Simon Glass <sjg@chromium.org> wrote:
> The dependency rules are currently done in a shell 'for' loop. This does not
> permit Makefile variables to adjust preprocessor flags as is done with normal
> compile flags, using the CFLAGS_path/file.o syntax.
>
> This change moves the dependency generation into the Makefile itself, and
> permits a CPPFLAGS_path/file.o to adjust preprocessor flags on a file or
> directory basis.
>
> The CPPFLAGS_... variable is also folded into CFLAGS during the build.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in v3:
> - Change U-Boot's dependency generation to permit per-file flags
>
> ?.gitignore | ? ?2 +-
> ?config.mk ?| ? ?7 +++++++
> ?rules.mk ? | ? 23 ++++++++++++-----------
> ?3 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/.gitignore b/.gitignore
> index dbf545f..7ba0dd9 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -39,7 +39,7 @@
> ?# Generated files
> ?#
>
> -*.depend
> +*.depend*
> ?/LOG
> ?/errlog
> ?/reloc_off
> diff --git a/config.mk b/config.mk
> index e2b440d..3fa9eef 100644
> --- a/config.mk
> +++ b/config.mk
> @@ -277,6 +277,13 @@ export ? ? CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS
> ?BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
> ?ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
> ?ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
> +EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))
> +ALL_CFLAGS += $(EXTRA_CPPFLAGS)
> +
> +# The _DEP version uses the $< file target (for dependency generation)
> +# See rules.mk
> +EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \
> + ? ? ? ? ? ? ? $(CPPFLAGS_$(BCURDIR))
> ?$(obj)%.s: ? ? %.S
> ? ? ? ?$(CPP) $(ALL_AFLAGS) -o $@ $<
> ?$(obj)%.o: ? ? %.S
> diff --git a/rules.mk b/rules.mk
> index d79fcd3..56b9044 100644
> --- a/rules.mk
> +++ b/rules.mk
> @@ -25,17 +25,18 @@
>
> ?_depend: ? ? ? $(obj).depend
>
> -$(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(SRCS) $(HOSTSRCS)
> - ? ? ? ? ? ? ? @rm -f $@
> - ? ? ? ? ? ? ? @touch $@
> - ? ? ? ? ? ? ? @for f in $(SRCS); do \
> - ? ? ? ? ? ? ? ? ? ? ? g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
> - ? ? ? ? ? ? ? ? ? ? ? $(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
> - ? ? ? ? ? ? ? done
> - ? ? ? ? ? ? ? @for f in $(HOSTSRCS); do \
> - ? ? ? ? ? ? ? ? ? ? ? g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
> - ? ? ? ? ? ? ? ? ? ? ? $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
> - ? ? ? ? ? ? ? done
> +DEPS := $(basename $(patsubst %,$(obj).depend.%,$(SRCS)))
> +
> +$(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(DEPS) $(HOSTSRCS)
> + ? ? ? cat /dev/null $(DEPS) >$@
> + ? ? ? @for f in $(HOSTSRCS); do \
> + ? ? ? ? ? ? ? g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
> + ? ? ? ? ? ? ? $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
> + ? ? ? done
> +
> +$(obj).depend.%: ? ? ? %.c
> + ? ? ? $(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \
> + ? ? ? ? ? ? ? -MQ $(addsuffix .o,$(basename $<)) $< >$@
>
> ?$(HOSTOBJS): $(obj)%.o: %.c
> ? ? ? ?$(HOSTCC) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
> --
> 1.7.3.1
>
>

Sadly this doesn't work for two reasons:

1. It ignores .S files (which is easy to fix)

2. It doesn't like paths like ../common/fred.c. I can fix that with a
patsubst I suspect.

Does anyone have better ideas on how to deal with this?

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility
  2011-10-03 18:57   ` Mike Frysinger
@ 2011-10-04  5:24     ` Simon Glass
  2011-10-10  2:54       ` Mike Frysinger
  0 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2011-10-04  5:24 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Mon, Oct 3, 2011 at 11:57 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, September 26, 2011 20:10:53 Simon Glass wrote:
>> --- a/common/cmd_mem.c
>> +++ b/common/cmd_mem.c
>>
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? printf ("\nMem error @ 0x%08X: "
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "found %08lX, expected %08lX\n",
>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (uint)addr, readback, val);
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (uint)(uintptr_t)addr, readback, val);
>
> could you change the printf format to %#p instead (and drop the casts
> completely for "addr") ?
> -mike
>

Well it's not complete clear where we want to go with this. My current
thinking is that the emulated memory will be small (in 2011 terms) -
maybe 128MB. The real memory of the machine is not accessible since it
doesn't make sense. So perhaps just because the host happens to be a
64-bit machine we don't suddenly want to be printing 64-bit addresses.

So the answer is 'yes' but for now I'm not sure that's the right thing
to do. I have another patch which enables 'md', etc. but of course
only within the 128MB 'emulated' memory area.

It actually brings up a question - does U-Boot run on 64-machines?

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 20/21] Adjust dependency rules to permit per-file flags
  2011-10-04  1:10   ` Simon Glass
@ 2011-10-10  2:50     ` Mike Frysinger
  2011-10-10  3:45       ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-10  2:50 UTC (permalink / raw)
  To: u-boot

On Monday 03 October 2011 21:10:17 Simon Glass wrote:
> Hi,
> 
> On Mon, Sep 26, 2011 at 5:10 PM, Simon Glass <sjg@chromium.org> wrote:
> > The dependency rules are currently done in a shell 'for' loop. This does
> > not permit Makefile variables to adjust preprocessor flags as is done
> > with normal compile flags, using the CFLAGS_path/file.o syntax.
> > 
> > This change moves the dependency generation into the Makefile itself, and
> > permits a CPPFLAGS_path/file.o to adjust preprocessor flags on a file or
> > directory basis.
> > 
> > The CPPFLAGS_... variable is also folded into CFLAGS during the build.
> > 
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> > Changes in v3:
> > - Change U-Boot's dependency generation to permit per-file flags
> > 
> >  .gitignore |    2 +-
> >  config.mk  |    7 +++++++
> >  rules.mk   |   23 ++++++++++++-----------
> >  3 files changed, 20 insertions(+), 12 deletions(-)
> > 
> > diff --git a/.gitignore b/.gitignore
> > index dbf545f..7ba0dd9 100644
> > --- a/.gitignore
> > +++ b/.gitignore
> > @@ -39,7 +39,7 @@
> >  # Generated files
> >  #
> > 
> > -*.depend
> > +*.depend*
> >  /LOG
> >  /errlog
> >  /reloc_off
> > diff --git a/config.mk b/config.mk
> > index e2b440d..3fa9eef 100644
> > --- a/config.mk
> > +++ b/config.mk
> > @@ -277,6 +277,13 @@ export     CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS
> > PLATFORM_RELFLAGS CPPFLAGS CFLAGS BCURDIR = $(subst
> > $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
> >  ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
> >  ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
> > +EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))
> > +ALL_CFLAGS += $(EXTRA_CPPFLAGS)
> > +
> > +# The _DEP version uses the $< file target (for dependency generation)
> > +# See rules.mk
> > +EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename
> > $<))) \ +               $(CPPFLAGS_$(BCURDIR))
> >  $(obj)%.s:     %.S
> >        $(CPP) $(ALL_AFLAGS) -o $@ $<
> >  $(obj)%.o:     %.S
> > diff --git a/rules.mk b/rules.mk
> > index d79fcd3..56b9044 100644
> > --- a/rules.mk
> > +++ b/rules.mk
> > @@ -25,17 +25,18 @@
> > 
> >  _depend:       $(obj).depend
> > 
> > -$(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(SRCS) $(HOSTSRCS)
> > -               @rm -f $@
> > -               @touch $@
> > -               @for f in $(SRCS); do \
> > -                       g=`basename $$f | sed -e
> > 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \ -                       $(CC) -M
> > $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \ -               done
> > -               @for f in $(HOSTSRCS); do \
> > -                       g=`basename $$f | sed -e
> > 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \ -                       $(HOSTCC) -M
> > $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \ -               done
> > +DEPS := $(basename $(patsubst %,$(obj).depend.%,$(SRCS)))
> > +
> > +$(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(DEPS) $(HOSTSRCS)
> > +       cat /dev/null $(DEPS) >$@
> > +       @for f in $(HOSTSRCS); do \
> > +               g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`;
> > \ +               $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ;
> > \ +       done
> > +
> > +$(obj).depend.%:       %.c
> > +       $(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \
> > +               -MQ $(addsuffix .o,$(basename $<)) $< >$@
> > 
> >  $(HOSTOBJS): $(obj)%.o: %.c
> >        $(HOSTCC) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F))
> > $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c --
> > 1.7.3.1
> 
> Sadly this doesn't work for two reasons:
> 
> 1. It ignores .S files (which is easy to fix)
> 
> 2. It doesn't like paths like ../common/fred.c. I can fix that with a
> patsubst I suspect.
> 
> Does anyone have better ideas on how to deal with this?

what if we move away from a single .depend file ?  most every project i see out 
there utilizes one .depend file per source.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111009/a6000dca/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility
  2011-10-04  5:24     ` Simon Glass
@ 2011-10-10  2:54       ` Mike Frysinger
  2011-10-10  3:49         ` Simon Glass
  2011-10-11  2:46         ` Aaron Williams
  0 siblings, 2 replies; 58+ messages in thread
From: Mike Frysinger @ 2011-10-10  2:54 UTC (permalink / raw)
  To: u-boot

On Tuesday 04 October 2011 01:24:56 Simon Glass wrote:
> On Mon, Oct 3, 2011 at 11:57 AM, Mike Frysinger wrote:
> > On Monday, September 26, 2011 20:10:53 Simon Glass wrote:
> >> --- a/common/cmd_mem.c
> >> +++ b/common/cmd_mem.c
> >> 
> >>                               printf ("\nMem error @ 0x%08X: "
> >>                                       "found %08lX, expected %08lX\n",
> >> -                                     (uint)addr, readback, val);
> >> +                                     (uint)(uintptr_t)addr, readback,
> >> val);
> > 
> > could you change the printf format to %#p instead (and drop the casts
> > completely for "addr") ?
> 
> Well it's not complete clear where we want to go with this. My current
> thinking is that the emulated memory will be small (in 2011 terms) -
> maybe 128MB. The real memory of the machine is not accessible since it
> doesn't make sense. So perhaps just because the host happens to be a
> 64-bit machine we don't suddenly want to be printing 64-bit addresses.
> 
> So the answer is 'yes' but for now I'm not sure that's the right thing
> to do. I have another patch which enables 'md', etc. but of course
> only within the 128MB 'emulated' memory area.
> 
> It actually brings up a question - does U-Boot run on 64-machines?

i don't believe u-boot runs on any 64bit system (or at least, in 64bit mode).  
there's quite a lot of random assumptions all over the tree where pointers are 
stored in 32bits, so for making sandbox work on 64bit stuff, i would focus on 
making stuff work with minimal intrusion for 32bit systems.

although thinking about this a bit more, %p will not zero pad its output (i 
think even if you specify like "08" it'll get ignored).  but maybe people 
don't care as normally this output shouldn't occur ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111009/4559bc63/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 20/21] Adjust dependency rules to permit per-file flags
  2011-10-10  2:50     ` Mike Frysinger
@ 2011-10-10  3:45       ` Simon Glass
  0 siblings, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-10-10  3:45 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Sun, Oct 9, 2011 at 7:50 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday 03 October 2011 21:10:17 Simon Glass wrote:
>> Hi,
>>
>> On Mon, Sep 26, 2011 at 5:10 PM, Simon Glass <sjg@chromium.org> wrote:
>> > The dependency rules are currently done in a shell 'for' loop. This does
>> > not permit Makefile variables to adjust preprocessor flags as is done
>> > with normal compile flags, using the CFLAGS_path/file.o syntax.
>> >
>> > This change moves the dependency generation into the Makefile itself, and
>> > permits a CPPFLAGS_path/file.o to adjust preprocessor flags on a file or
>> > directory basis.
>> >
>> > The CPPFLAGS_... variable is also folded into CFLAGS during the build.
>> >
>> > Signed-off-by: Simon Glass <sjg@chromium.org>
>> > ---
>> > Changes in v3:
>> > - Change U-Boot's dependency generation to permit per-file flags
>> >
>> > ?.gitignore | ? ?2 +-
>> > ?config.mk ?| ? ?7 +++++++
>> > ?rules.mk ? | ? 23 ++++++++++++-----------
>> > ?3 files changed, 20 insertions(+), 12 deletions(-)
>> >
>> > diff --git a/.gitignore b/.gitignore
>> > index dbf545f..7ba0dd9 100644
>> > --- a/.gitignore
>> > +++ b/.gitignore
>> > @@ -39,7 +39,7 @@
>> > ?# Generated files
>> > ?#
>> >
>> > -*.depend
>> > +*.depend*
>> > ?/LOG
>> > ?/errlog
>> > ?/reloc_off
>> > diff --git a/config.mk b/config.mk
>> > index e2b440d..3fa9eef 100644
>> > --- a/config.mk
>> > +++ b/config.mk
>> > @@ -277,6 +277,13 @@ export ? ? CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS
>> > PLATFORM_RELFLAGS CPPFLAGS CFLAGS BCURDIR = $(subst
>> > $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
>> > ?ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
>> > ?ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
>> > +EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))
>> > +ALL_CFLAGS += $(EXTRA_CPPFLAGS)
>> > +
>> > +# The _DEP version uses the $< file target (for dependency generation)
>> > +# See rules.mk
>> > +EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename
>> > $<))) \ + ? ? ? ? ? ? ? $(CPPFLAGS_$(BCURDIR))
>> > ?$(obj)%.s: ? ? %.S
>> > ? ? ? ?$(CPP) $(ALL_AFLAGS) -o $@ $<
>> > ?$(obj)%.o: ? ? %.S
>> > diff --git a/rules.mk b/rules.mk
>> > index d79fcd3..56b9044 100644
>> > --- a/rules.mk
>> > +++ b/rules.mk
>> > @@ -25,17 +25,18 @@
>> >
>> > ?_depend: ? ? ? $(obj).depend
>> >
>> > -$(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(SRCS) $(HOSTSRCS)
>> > - ? ? ? ? ? ? ? @rm -f $@
>> > - ? ? ? ? ? ? ? @touch $@
>> > - ? ? ? ? ? ? ? @for f in $(SRCS); do \
>> > - ? ? ? ? ? ? ? ? ? ? ? g=`basename $$f | sed -e
>> > 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \ - ? ? ? ? ? ? ? ? ? ? ? $(CC) -M
>> > $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \ - ? ? ? ? ? ? ? done
>> > - ? ? ? ? ? ? ? @for f in $(HOSTSRCS); do \
>> > - ? ? ? ? ? ? ? ? ? ? ? g=`basename $$f | sed -e
>> > 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \ - ? ? ? ? ? ? ? ? ? ? ? $(HOSTCC) -M
>> > $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \ - ? ? ? ? ? ? ? done
>> > +DEPS := $(basename $(patsubst %,$(obj).depend.%,$(SRCS)))
>> > +
>> > +$(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(DEPS) $(HOSTSRCS)
>> > + ? ? ? cat /dev/null $(DEPS) >$@
>> > + ? ? ? @for f in $(HOSTSRCS); do \
>> > + ? ? ? ? ? ? ? g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`;
>> > \ + ? ? ? ? ? ? ? $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ;
>> > \ + ? ? ? done
>> > +
>> > +$(obj).depend.%: ? ? ? %.c
>> > + ? ? ? $(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \
>> > + ? ? ? ? ? ? ? -MQ $(addsuffix .o,$(basename $<)) $< >$@
>> >
>> > ?$(HOSTOBJS): $(obj)%.o: %.c
>> > ? ? ? ?$(HOSTCC) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F))
>> > $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c --
>> > 1.7.3.1
>>
>> Sadly this doesn't work for two reasons:
>>
>> 1. It ignores .S files (which is easy to fix)
>>
>> 2. It doesn't like paths like ../common/fred.c. I can fix that with a
>> patsubst I suspect.
>>
>> Does anyone have better ideas on how to deal with this?
>
> what if we move away from a single .depend file ? ?most every project i see out
> there utilizes one .depend file per source.
> -mike
>

That is essentially what my patch does for the most part - the
non-host files are generated with a separate rule and then combined
later into a single file. Combining them is just a convenience for the
Makefile - easier to include one file than 50, that's all.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility
  2011-10-10  2:54       ` Mike Frysinger
@ 2011-10-10  3:49         ` Simon Glass
  2011-10-11  2:46         ` Aaron Williams
  1 sibling, 0 replies; 58+ messages in thread
From: Simon Glass @ 2011-10-10  3:49 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Sun, Oct 9, 2011 at 7:54 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 04 October 2011 01:24:56 Simon Glass wrote:
>> On Mon, Oct 3, 2011 at 11:57 AM, Mike Frysinger wrote:
>> > On Monday, September 26, 2011 20:10:53 Simon Glass wrote:
>> >> --- a/common/cmd_mem.c
>> >> +++ b/common/cmd_mem.c
>> >>
>> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? printf ("\nMem error @ 0x%08X: "
>> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "found %08lX, expected %08lX\n",
>> >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (uint)addr, readback, val);
>> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (uint)(uintptr_t)addr, readback,
>> >> val);
>> >
>> > could you change the printf format to %#p instead (and drop the casts
>> > completely for "addr") ?
>>
>> Well it's not complete clear where we want to go with this. My current
>> thinking is that the emulated memory will be small (in 2011 terms) -
>> maybe 128MB. The real memory of the machine is not accessible since it
>> doesn't make sense. So perhaps just because the host happens to be a
>> 64-bit machine we don't suddenly want to be printing 64-bit addresses.
>>
>> So the answer is 'yes' but for now I'm not sure that's the right thing
>> to do. I have another patch which enables 'md', etc. but of course
>> only within the 128MB 'emulated' memory area.
>>
>> It actually brings up a question - does U-Boot run on 64-machines?
>
> i don't believe u-boot runs on any 64bit system (or at least, in 64bit mode).
> there's quite a lot of random assumptions all over the tree where pointers are
> stored in 32bits, so for making sandbox work on 64bit stuff, i would focus on
> making stuff work with minimal intrusion for 32bit systems.

Yes - I don't seem a lot of use in having massive amounts of RAM for
testing U-Boot, so 32-bit addresses should be fine for now.

>
> although thinking about this a bit more, %p will not zero pad its output (i
> think even if you specify like "08" it'll get ignored). ?but maybe people
> don't care as normally this output shouldn't occur ?
> -mike
>

Yes %p is not quite what we want, but as you say this is an error condition.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility
  2011-10-10  2:54       ` Mike Frysinger
  2011-10-10  3:49         ` Simon Glass
@ 2011-10-11  2:46         ` Aaron Williams
  2011-10-11  4:52           ` Mike Frysinger
  1 sibling, 1 reply; 58+ messages in thread
From: Aaron Williams @ 2011-10-11  2:46 UTC (permalink / raw)
  To: u-boot

Our OCTEON platform is a 64-bit SOC and we run it in the MIPS N32 ABI mode 
(64-bit registers, 32-bit address space). In our case we use virtual memory so 
we can move U-Boot to the top of memory which is often above 4GB. The only 
changes we had to make to U-Boot was that drivers need to use the proper 
mapping functions and support 64-bit physical addresses. Generally the 
hardware devices support this and the driver changes have been minimal. Some 
of our boards have over 8GB of RAM installed and 4GB is common for us. With 
the hole we create for our boot bus (flash, etc.) that means that in many 
cases U-Boot is loaded above the 32-bit boundary. By using a couple of TLB 
entries on MIPS we always map U-Boot to 0xC0000000 no matter where it is 
executing from. While a 64-bit U-Boot would be nice, we don't really need it 
since the TLB solves all of our issues. I would rather see drivers better make 
use of the proper mapping functions and support 64-bit physical addresses as 
well as use wrappers for accessing the PCI register space. (in our case all of 
our SOC registers require 64-bit addresses).

-Aaron

On Sunday, October 09, 2011 07:54:50 PM Mike Frysinger wrote:
> On Tuesday 04 October 2011 01:24:56 Simon Glass wrote:
> > On Mon, Oct 3, 2011 at 11:57 AM, Mike Frysinger wrote:
> > > On Monday, September 26, 2011 20:10:53 Simon Glass wrote:
> > >> --- a/common/cmd_mem.c
> > >> +++ b/common/cmd_mem.c
> > >> 
> > >>                               printf ("\nMem error @ 0x%08X: "
> > >>                               
> > >>                                       "found %08lX, expected %08lX\n",
> > >> 
> > >> -                                     (uint)addr, readback, val);
> > >> +                                     (uint)(uintptr_t)addr, readback,
> > >> val);
> > > 
> > > could you change the printf format to %#p instead (and drop the casts
> > > completely for "addr") ?
> > 
> > Well it's not complete clear where we want to go with this. My current
> > thinking is that the emulated memory will be small (in 2011 terms) -
> > maybe 128MB. The real memory of the machine is not accessible since it
> > doesn't make sense. So perhaps just because the host happens to be a
> > 64-bit machine we don't suddenly want to be printing 64-bit addresses.
> > 
> > So the answer is 'yes' but for now I'm not sure that's the right thing
> > to do. I have another patch which enables 'md', etc. but of course
> > only within the 128MB 'emulated' memory area.
> > 
> > It actually brings up a question - does U-Boot run on 64-machines?
> 
> i don't believe u-boot runs on any 64bit system (or at least, in 64bit
> mode). there's quite a lot of random assumptions all over the tree where
> pointers are stored in 32bits, so for making sandbox work on 64bit stuff,
> i would focus on making stuff work with minimal intrusion for 32bit
> systems.
> 
> although thinking about this a bit more, %p will not zero pad its output (i
> think even if you specify like "08" it'll get ignored).  but maybe people
> don't care as normally this output shouldn't occur ?
> -mike

-- 
Aaron Williams <Aaron.Williams@cavium.com>
 (408) 943-7198

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility
  2011-10-11  2:46         ` Aaron Williams
@ 2011-10-11  4:52           ` Mike Frysinger
  2011-10-11  5:41             ` Aaron Williams
  0 siblings, 1 reply; 58+ messages in thread
From: Mike Frysinger @ 2011-10-11  4:52 UTC (permalink / raw)
  To: u-boot

On Monday 10 October 2011 22:46:10 Aaron Williams wrote:
> Our OCTEON platform is a 64-bit SOC and we run it in the MIPS N32 ABI mode
> (64-bit registers, 32-bit address space).

right, n32 == 32bit pointers, so i don't consider that a port with 64bit 
pointer issues

> rather see drivers better make use of the proper mapping functions and
> support 64-bit physical addresses as well as use wrappers for accessing
> the PCI register space. (in our case all of our SOC registers require
> 64-bit addresses).

what exactly are "proper mapping functions" ?  you mean things like the 
kernel's ioremap() ?

also, please don't top post
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111011/28f41ec3/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility
  2011-10-11  4:52           ` Mike Frysinger
@ 2011-10-11  5:41             ` Aaron Williams
  2011-10-14  4:18               ` Mike Frysinger
  0 siblings, 1 reply; 58+ messages in thread
From: Aaron Williams @ 2011-10-11  5:41 UTC (permalink / raw)
  To: u-boot

On Monday, October 10, 2011 09:52:59 PM Mike Frysinger wrote:
> On Monday 10 October 2011 22:46:10 Aaron Williams wrote:
> > Our OCTEON platform is a 64-bit SOC and we run it in the MIPS N32 ABI
> > mode (64-bit registers, 32-bit address space).
> 
> right, n32 == 32bit pointers, so i don't consider that a port with 64bit
> pointer issues
> 
> > rather see drivers better make use of the proper mapping functions and
> > support 64-bit physical addresses as well as use wrappers for accessing
> > the PCI register space. (in our case all of our SOC registers require
> > 64-bit addresses).
> 
> what exactly are "proper mapping functions" ?  you mean things like the
> kernel's ioremap() ?
> 
> also, please don't top post
> -mike

I mean using functions like pci_virt_to_mem(). I have fixed a couple of 
drivers such as the USB EHCI driver and Intel E1000 driver to make use of this 
on our platform. We also can optionally perform I/O remapping so that PCI 
devices that only support 32-bit addressing can still access the memory where 
U-Boot is located. I have found that numerous drivers assume that an address 
in a pointer can be used directly for DMA which is not the case on MIPS since 
U-Boot typically runs in KSEG0 (0x8000000) which is aliased to physical memory 
address 0.

The other area I have seen issues is where drivers do not use 
readl/writel/etc. to access the registers. It is even easier if they use a 
macro per-driver since in our case we might use different functions to access 
the underlying hardware registers depending on if they're part of our SOC or 
on the PCIe bus since they map to different 64-bit I/O areas.

Now none of these actually require 64-bit pointers, just 64-bit physical 
addresses. We even support 64-bit ELF executables loaded from U-Boot as well 
as the 64-bit Linux kernel (we don't support a 32-bit kernel any longer) and 
basically make use of a 64-bit version of memcpy.

64-bit support would be useful for the various memory functions, i.e. md, mw, 
mm, md5sum, etc. It can also be useful for loading images to higher addresses. 
It's not essential though and currently we added separate commands for 
accessing 64-bit addresses.

One of these daya I need to work on getting some of our patches back upstream 
since some of them are quite useful for other platforms as well.

Even though we use virtual memory for U-Boot the number of changes to U-Boot 
has been very minimal except for drivers and even then the changes can be 
portable (i.e. using pci_virt_to_mem(). It actually simplifies things in that 
we don't have to deal with remapping. Some drivers like the proposed one for 
the Silicon Image SATA controller work as-is. The virtual memory allows the 
same U-Boot image to run from anywhere in memory. We use a single image 
whether we're booting out of NOR flash or over PCI. We also support multiple 
flash images (standard and failsafe). We perform the mapping before any C code 
is executed so we don't have to worry about relocation when U-Boot copies 
itself to the top of RAM and begins executing there. We do have a very 
different lib/board.c however, in order to deal with our SOC.

I think moving U-Boot to be fully 64-bit will be a lot more difficult compared 
to what we are doing since a lot of code assumes addresses are 32-bit. Our VM 
change allows U-Boot to remain 32-bit while still being able to support a 64-
bit platform.

-Aaron
-- 
Aaron Williams <Aaron.Williams@cavium.com>
 (408) 943-7198

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility
  2011-10-11  5:41             ` Aaron Williams
@ 2011-10-14  4:18               ` Mike Frysinger
  0 siblings, 0 replies; 58+ messages in thread
From: Mike Frysinger @ 2011-10-14  4:18 UTC (permalink / raw)
  To: u-boot

On Tuesday 11 October 2011 01:41:07 Aaron Williams wrote:
> One of these daya I need to work on getting some of our patches back
> upstream since some of them are quite useful for other platforms as well.

yeah, for things like changing pci drivers to use pci_virt_to_mem() or 
changing pointer derefs to asm/io.h helpers, that sounds like things we all 
want.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111014/7df2ee52/attachment.pgp 

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2011-10-14  4:18 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27  0:10 [U-Boot] [PATCH v3 0/21] New 'sandbox' test architecture for U-Boot Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 01/21] sandbox: Add architecture header files Simon Glass
2011-10-03  5:56   ` Mike Frysinger
2011-10-04  0:10     ` Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 02/21] Fix use of int as pointer in image.c Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 03/21] sandbox: Add architecture image support Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 04/21] sandbox: Add compiler defines to support a 64-bit x86_64 platform Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 05/21] sandbox: Add cpu files Simon Glass
2011-10-03  6:10   ` Mike Frysinger
2011-10-03 19:25     ` Mike Frysinger
2011-09-27  0:10 ` [U-Boot] [PATCH v3 06/21] sandbox: Add architecture lib files Simon Glass
2011-10-03  6:15   ` Mike Frysinger
2011-10-04  0:02     ` Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 07/21] sandbox: Add sandbox board Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 08/21] sandbox: Add board info for architecture Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 09/21] sandbox: Add bootm support Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 10/21] sandbox: Disable built-in malloc Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 11/21] sandbox: Disable standalone/API support Simon Glass
2011-10-03 19:37   ` Mike Frysinger
2011-10-04  0:13     ` Simon Glass
2011-10-04  0:40       ` Mike Frysinger
2011-10-04  0:54         ` Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 12/21] sandbox: Force command sections to be 4-byte aligned Simon Glass
2011-10-03 19:34   ` Mike Frysinger
2011-10-04  0:05     ` Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 13/21] sandbox: Add OS dependent layer Simon Glass
2011-10-03 19:27   ` Mike Frysinger
2011-10-03 23:44     ` Simon Glass
2011-10-03 23:49       ` Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 14/21] sandbox: Add board_init() Simon Glass
2011-10-03 19:33   ` Mike Frysinger
2011-10-04  0:17     ` Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 15/21] sandbox: Add main program Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 16/21] sandbox: Add serial uart Simon Glass
2011-10-03 19:42   ` Mike Frysinger
2011-10-04  0:21     ` Simon Glass
2011-10-04  1:10       ` Mike Frysinger
2011-09-27  0:10 ` [U-Boot] [PATCH v3 17/21] sandbox: Add basic config file Simon Glass
2011-10-03 19:42   ` Mike Frysinger
2011-10-04  0:23     ` Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 18/21] Remove unused variable warnings in cmd_mem, cmd_nvedit Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 19/21] Use uintptr_t for 32/64-bit compatibility Simon Glass
2011-10-03 18:57   ` Mike Frysinger
2011-10-04  5:24     ` Simon Glass
2011-10-10  2:54       ` Mike Frysinger
2011-10-10  3:49         ` Simon Glass
2011-10-11  2:46         ` Aaron Williams
2011-10-11  4:52           ` Mike Frysinger
2011-10-11  5:41             ` Aaron Williams
2011-10-14  4:18               ` Mike Frysinger
2011-09-27  0:10 ` [U-Boot] [PATCH v3 20/21] Adjust dependency rules to permit per-file flags Simon Glass
2011-10-04  1:10   ` Simon Glass
2011-10-10  2:50     ` Mike Frysinger
2011-10-10  3:45       ` Simon Glass
2011-09-27  0:10 ` [U-Boot] [PATCH v3 21/21] sandbox: Makefile changes to build sandbox architecture Simon Glass
2011-10-03 19:31   ` Mike Frysinger
2011-10-04  0:51     ` Simon Glass
2011-10-04  1:05       ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox