[U-Boot] [PATCH v5 01/20] sandbox: Add architecture header files

Simon Glass sjg at chromium.org
Sat Oct 8 01:53:32 CEST 2011


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

This commit generates a list of 44 checkpatch warnings:

0 errors, 44 warnings for 0001-sandbox-Add-architecture-header-files.patch:
warning: arch/sandbox/include/asm/bitops.h,30: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: arch/sandbox/include/asm/bitops.h,32: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: arch/sandbox/include/asm/bitops.h,34: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: arch/sandbox/include/asm/bitops.h,36: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: arch/sandbox/include/asm/bitops.h,44: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: arch/sandbox/include/asm/bitops.h,54: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: arch/sandbox/include/asm/bitops.h,66: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: arch/sandbox/include/asm/bitops.h,76: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: arch/sandbox/include/asm/bitops.h,88: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: arch/sandbox/include/asm/bitops.h,90: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt

(These are the bitops and seem to have volatile in all the other archs also.)

warning: arch/sandbox/include/asm/global_data.h,38: do not add new typedefs

(This is the typedef for gd_t which I think is needed.)

warning: arch/sandbox/include/asm/global_data.h,64: storage class should be at the beginning of the declaration

(This line is:

which I need to keep, so that various files can declare that pointer.)

warning: arch/sandbox/include/asm/posix_types.h,22: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,23: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,24: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,25: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,26: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,27: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,28: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,29: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,30: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,32: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,33: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,34: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,36: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,37: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,38: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,40: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,41: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,42: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,43: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,44: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,45: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,46: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,47: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,48: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,50: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,51: do not add new typedefs
warning: arch/sandbox/include/asm/posix_types.h,54: do not add new typedefs

(These are things like:

typedef unsigned short		__kernel_dev_t;

and I believe they are needed.)

warning: arch/sandbox/include/asm/types.h,26: do not add new typedefs
warning: arch/sandbox/include/asm/types.h,66: do not add new typedefs
warning: arch/sandbox/include/asm/types.h,67: do not add new typedefs
warning: arch/sandbox/include/asm/types.h,68: do not add new typedefs
warning: arch/sandbox/include/asm/u-boot.h,39: do not add new typedefs

(These are similar, and common with other architectures, so I think they are needed.)

Signed-off-by: Simon Glass <sjg at 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

Changes in v4:
- Remove mon_len from global data
- Fix up arm header file incorrectly removed
- Added README note that standalone/API support is not available

Changes in v5:
- Added README note about very basic serial implementation so far
- Remove the XTRN_DECLARE_GLOBAL_DATA_PTR which seems unnecessary
- Add long-winded note about checkpatch warnings in first commit
- Move the introduction of include/asm-generic/gpio.h into a separate commit

 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    |   66 ++++++++++++
 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                        |   53 ++++++++++
 include/common.h                          |    3 +
 15 files changed, 739 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

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..8d47191
--- /dev/null
+++ b/arch/sandbox/include/asm/global_data.h
@@ -0,0 +1,66 @@
+/*
+ * 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 */
+	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 DECLARE_GLOBAL_DATA_PTR     extern 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 at sysgo.de>
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Alex Zuepke <azu at 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 at sysgo.de>
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Alex Zuepke <azu at 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..04692b3
--- /dev/null
+++ b/doc/README.sandbox
@@ -0,0 +1,53 @@
+/*
+ * 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.
+
+Note that standalone/API support is not available at present.
+
+The serial driver is a very simple implementation which reads and writes to
+the console. It does not set the terminal into raw mode, so cursor keys and
+history will not work yet.
+
+
+Tests
+-----
+
+So far we have no tests, but when we do these will be documented here.
diff --git a/include/common.h b/include/common.h
index bcc00e8..243bb4b 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);
-- 
1.7.3.1



More information about the U-Boot mailing list