All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/8] sandbox: fdt: Add support for CONFIG_OF_CONTROL
@ 2012-01-23  6:48 ` Simon Glass
  0 siblings, 0 replies; 16+ messages in thread
From: Simon Glass @ 2012-01-23  6:48 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Jerry Van Baren

This adds support for a controlling fdt, mirroring the ARM implementation.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Use #if defined()..#elif defined, instead of #ifdef..#elif defined

 arch/sandbox/include/asm/global_data.h |    1 +
 arch/sandbox/lib/board.c               |    8 ++++++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/sandbox/include/asm/global_data.h b/arch/sandbox/include/asm/global_data.h
index 8d47191..01a7063 100644
--- a/arch/sandbox/include/asm/global_data.h
+++ b/arch/sandbox/include/asm/global_data.h
@@ -45,6 +45,7 @@ typedef	struct global_data {
 	unsigned long	fb_base;	/* base address of frame buffer */
 	u8		*ram_buf;	/* emulated RAM buffer */
 	phys_size_t	ram_size;	/* RAM size */
+	const void	*fdt_blob;	/* Our device tree, NULL if none */
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
 } gd_t;
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
index b7997e9..6d464d6 100644
--- a/arch/sandbox/lib/board.c
+++ b/arch/sandbox/lib/board.c
@@ -156,6 +156,14 @@ void board_init_f(ulong bootflag)
 
 	memset((void *)gd, 0, sizeof(gd_t));
 
+#if defined(CONFIG_OF_EMBED)
+	/* Get a pointer to the FDT */
+	gd->fdt_blob = _binary_dt_dtb_start;
+#elif defined(CONFIG_OF_SEPARATE)
+	/* FDT is at end of image */
+	gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE);
+#endif
+
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
 		if ((*init_fnc_ptr)() != 0)
 			hang();
-- 
1.7.7.3

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

* [U-Boot] [PATCH v3 1/8] sandbox: fdt: Add support for CONFIG_OF_CONTROL
@ 2012-01-23  6:48 ` Simon Glass
  0 siblings, 0 replies; 16+ messages in thread
From: Simon Glass @ 2012-01-23  6:48 UTC (permalink / raw)
  To: u-boot

This adds support for a controlling fdt, mirroring the ARM implementation.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Use #if defined()..#elif defined, instead of #ifdef..#elif defined

 arch/sandbox/include/asm/global_data.h |    1 +
 arch/sandbox/lib/board.c               |    8 ++++++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/sandbox/include/asm/global_data.h b/arch/sandbox/include/asm/global_data.h
index 8d47191..01a7063 100644
--- a/arch/sandbox/include/asm/global_data.h
+++ b/arch/sandbox/include/asm/global_data.h
@@ -45,6 +45,7 @@ typedef	struct global_data {
 	unsigned long	fb_base;	/* base address of frame buffer */
 	u8		*ram_buf;	/* emulated RAM buffer */
 	phys_size_t	ram_size;	/* RAM size */
+	const void	*fdt_blob;	/* Our device tree, NULL if none */
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
 } gd_t;
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
index b7997e9..6d464d6 100644
--- a/arch/sandbox/lib/board.c
+++ b/arch/sandbox/lib/board.c
@@ -156,6 +156,14 @@ void board_init_f(ulong bootflag)
 
 	memset((void *)gd, 0, sizeof(gd_t));
 
+#if defined(CONFIG_OF_EMBED)
+	/* Get a pointer to the FDT */
+	gd->fdt_blob = _binary_dt_dtb_start;
+#elif defined(CONFIG_OF_SEPARATE)
+	/* FDT is at end of image */
+	gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE);
+#endif
+
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
 		if ((*init_fnc_ptr)() != 0)
 			hang();
-- 
1.7.7.3

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

* [U-Boot] [PATCH v3 2/8] sandbox: config: Enable fdt and snprintf() options
  2012-01-23  6:48 ` [U-Boot] " Simon Glass
  (?)
@ 2012-01-23  6:48 ` Simon Glass
  -1 siblings, 0 replies; 16+ messages in thread
From: Simon Glass @ 2012-01-23  6:48 UTC (permalink / raw)
  To: u-boot

Enable fdt code and safe snprintf() options for sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/configs/sandbox.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 10565e6..6790216 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -28,6 +28,12 @@
 /* Number of bits in a C 'long' on this architecture */
 #define CONFIG_SANDBOX_BITS_PER_LONG	64
 
+#define CONFIG_OF_CONTROL
+#define CONFIG_OF_LIBFDT
+#define CONFIG_LMB
+
+#define CONFIG_SYS_VSNPRINTF
+
 /*
  * Size of malloc() pool, although we don't actually use this yet.
  */
-- 
1.7.7.3

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

* [U-Boot] [PATCH v3 3/8] sandbox: gpio: Add basic driver for simulating GPIOs
  2012-01-23  6:48 ` [U-Boot] " Simon Glass
  (?)
  (?)
@ 2012-01-23  6:48 ` Simon Glass
  -1 siblings, 0 replies; 16+ messages in thread
From: Simon Glass @ 2012-01-23  6:48 UTC (permalink / raw)
  To: u-boot

This provides a way of simulating GPIOs by setting values which are seen
by the normal gpio_get/set_value() calls.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Fix gpio_direction_output() to actually set the value
- Use generic GPIO command and interface

Changes in v3:
- Change GPIO numbers to unsigned as per new asm-generic/gpio.h
- Implement GPIO interface more fully (reservation, gpio state)
- Use __func__ when function names are required

 arch/sandbox/include/asm/gpio.h |   66 +++++++++++++
 drivers/gpio/Makefile           |    1 +
 drivers/gpio/sandbox.c          |  194 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 261 insertions(+), 0 deletions(-)
 create mode 100644 arch/sandbox/include/asm/gpio.h
 create mode 100644 drivers/gpio/sandbox.c

diff --git a/arch/sandbox/include/asm/gpio.h b/arch/sandbox/include/asm/gpio.h
new file mode 100644
index 0000000..fddb551
--- /dev/null
+++ b/arch/sandbox/include/asm/gpio.h
@@ -0,0 +1,66 @@
+/*
+ * This is the interface to the sandbox GPIO driver for test code which
+ * wants to change the GPIO values reported to U-Boot.
+ *
+ * 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_GPIO_H
+#define __ASM_SANDBOX_GPIO_H
+
+/* We use the generic interface, and add a back channel */
+#include <asm-generic/gpio.h>
+
+/**
+ * Return the value of a GPIO
+ *
+ * @param gp	GPIO number
+ * @return -1 on error, 0 if GPIO is low, >0 if high
+ */
+int sandbox_gpio_get_value(unsigned gp);
+
+/**
+ * @param gp	GPIO number
+ * @param value	value to set (0 for low, non-zero for high)
+ * @return -1 on error, 0 if ok
+ */
+int sandbox_gpio_set_value(unsigned gp, int value);
+
+/**
+ * Return the direction of a GPIO
+ *
+ * @param gp	GPIO number
+ * @return -1 on error, 0 if GPIO is input, >0 if output
+ */
+int sandbox_gpio_get_direction(unsigned gp);
+
+/**
+ * @param gp	GPIO number
+ * @param output 0 to set as input, 1 to set as output
+ * @return -1 on error, 0 if ok
+ */
+int sandbox_gpio_set_direction(unsigned gp, int output);
+
+/* Display information about each GPIO */
+void gpio_info(void);
+
+#define gpio_status()	gpio_info()
+
+#endif
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 4375a55..fb3b09a 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -34,6 +34,7 @@ COBJS-$(CONFIG_MXS_GPIO)	+= mxs_gpio.o
 COBJS-$(CONFIG_PCA953X)		+= pca953x.o
 COBJS-$(CONFIG_PCA9698)		+= pca9698.o
 COBJS-$(CONFIG_S5P)		+= s5p_gpio.o
+COBJS-$(CONFIG_SANDBOX_GPIO)	+= sandbox.o
 COBJS-$(CONFIG_TEGRA2_GPIO)	+= tegra2_gpio.o
 COBJS-$(CONFIG_DA8XX_GPIO)	+= da8xx_gpio.o
 COBJS-$(CONFIG_ALTERA_PIO)	+= altera_pio.o
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
new file mode 100644
index 0000000..17e601d
--- /dev/null
+++ b/drivers/gpio/sandbox.c
@@ -0,0 +1,194 @@
+/*
+ * 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>
+#include <asm/io.h>
+#include <asm/bitops.h>
+#include <asm-generic/gpio.h>
+#include <asm/gpio.h>
+
+/* Flags for each GPIO */
+#define GPIOF_OUTPUT	(1 << 0)	/* Currently set as an output */
+#define GPIOF_HIGH	(1 << 1)	/* Currently set high */
+#define GPIOF_RESERVED	(1 << 2)	/* Is in use / requested */
+
+struct gpio_state {
+	const char *label;	/* label given by requester */
+	u8 flags;		/* flags (GPIOF_...) */
+};
+
+/*
+ * State of GPIOs
+ * TODO: Put this into sandbox state
+ */
+static struct gpio_state state[CONFIG_SANDBOX_GPIO_COUNT];
+
+/* Access routines for GPIO state */
+static u8 *get_gpio(unsigned gp)
+{
+	assert(gp < CONFIG_SANDBOX_GPIO_COUNT);
+	return &state[gp].flags;
+}
+
+static int get_gpio_flag(unsigned gp, int flag)
+{
+	return (*get_gpio(gp) & flag) != 0;
+}
+
+static void set_gpio_flag(unsigned gp, int flag, int value)
+{
+	u8 *gpio = get_gpio(gp);
+
+	if (value)
+		*gpio |= flag;
+	else
+		*gpio &= ~flag;
+}
+
+int sandbox_gpio_get_value(unsigned gp)
+{
+	if (get_gpio_flag(gp, GPIOF_OUTPUT))
+		printf("sandbox_gpio: get_value on output GPIO %d\n", gp);
+	return *get_gpio(gp) & GPIOF_HIGH;
+}
+
+int sandbox_gpio_set_value(unsigned gp, int value)
+{
+	set_gpio_flag(gp, GPIOF_HIGH, value);
+	return 0;
+}
+
+int sandbox_gpio_get_direction(unsigned gp)
+{
+	return get_gpio_flag(gp, GPIOF_OUTPUT);
+}
+
+int sandbox_gpio_set_direction(unsigned gp, int output)
+{
+	set_gpio_flag(gp, GPIOF_OUTPUT, output);
+	return 0;
+}
+
+static int check_reserved(unsigned gpio, const char *op_name)
+{
+	if (!get_gpio_flag(gpio, GPIOF_RESERVED)) {
+		printf("sandbox_gpio: '%s' on unreserved GPIO\n", op_name);
+		return -1;
+	}
+
+	return 0;
+}
+
+/* These functions implement the public interface within U-Boot */
+
+/* set GPIO port 'gp' as an input */
+int gpio_direction_input(unsigned gp)
+{
+	debug("%s: gp = %d\n", __func__, gp);
+	if (check_reserved(gp, __func__))
+		return -1;
+	set_gpio_flag(gp, GPIOF_OUTPUT, 0);
+
+	return 0;
+}
+
+/* set GPIO port 'gp' as an output, with polarity 'value' */
+int gpio_direction_output(unsigned gp, int value)
+{
+	debug("%s: gp = %d, value = %d\n", __func__, gp, value);
+	if (check_reserved(gp, __func__))
+		return -1;
+	set_gpio_flag(gp, GPIOF_OUTPUT, 1);
+	set_gpio_flag(gp, GPIOF_HIGH, value);
+
+	return 0;
+}
+
+/* read GPIO IN value of port 'gp' */
+int gpio_get_value(unsigned gp)
+{
+	debug("%s: gp = %d\n", __func__, gp);
+	if (check_reserved(gp, __func__))
+		return -1;
+	if (get_gpio_flag(gp, GPIOF_OUTPUT))
+		printf("sandbox_gpio: get_value on output GPIO %d\n", gp);
+
+	return get_gpio_flag(gp, GPIOF_HIGH);
+}
+
+/* write GPIO OUT value to port 'gp' */
+int gpio_set_value(unsigned gp, int value)
+{
+	debug("%s: gp = %d, value = %d\n", __func__, gp, value);
+	if (check_reserved(gp, __func__))
+		return -1;
+	if (get_gpio_flag(gp, GPIOF_OUTPUT)) {
+		set_gpio_flag(gp, GPIOF_HIGH, value);
+	} else {
+		printf("sandbox_gpio: set_value on input GPIO %d\n", gp);
+		return -1;
+	}
+
+	return 0;
+}
+
+int gpio_request(unsigned gp, const char *label)
+{
+	debug("%s: gp = %d, label= %s\n", __func__, gp, label);
+	if (get_gpio_flag(gp, GPIOF_RESERVED)) {
+		printf("sandbox_gpio: request on reserved GPIO\n");
+		return -1;
+	}
+	set_gpio_flag(gp, GPIOF_RESERVED, 1);
+	state[gp].label = label;
+
+	return 0;
+}
+
+int gpio_free(unsigned gp)
+{
+	debug("%s: gp = %d\n", __func__, gp);
+	if (check_reserved(gp, __func__))
+		return -1;
+	set_gpio_flag(gp, GPIOF_RESERVED, 0);
+	state[gp].label = NULL;
+
+	return 0;
+}
+
+/* Display GPIO information */
+void gpio_info(void)
+{
+	unsigned gpio;
+
+	printf("Sandbox GPIOs\n");
+
+	for (gpio = 0; gpio < CONFIG_SANDBOX_GPIO_COUNT; ++gpio) {
+		const char *label = state[gpio].label;
+
+		printf("%4d: %s: %d [%c] %s\n",
+			gpio,
+			get_gpio_flag(gpio, GPIOF_OUTPUT) ? "out" : " in",
+			get_gpio_flag(gpio, GPIOF_HIGH),
+			get_gpio_flag(gpio, GPIOF_RESERVED) ? 'x' : ' ',
+			label ? label : "");
+	}
+}
-- 
1.7.7.3

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

* [U-Boot] [PATCH v3 4/8] sandbox: Enable GPIO driver
  2012-01-23  6:48 ` [U-Boot] " Simon Glass
                   ` (2 preceding siblings ...)
  (?)
@ 2012-01-23  6:48 ` Simon Glass
  -1 siblings, 0 replies; 16+ messages in thread
From: Simon Glass @ 2012-01-23  6:48 UTC (permalink / raw)
  To: u-boot

Enable the new GPIO driver for sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Reduce number of GPIOs from 224 to 20

 include/configs/sandbox.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 6790216..a58a34e 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -34,6 +34,10 @@
 
 #define CONFIG_SYS_VSNPRINTF
 
+#define CONFIG_CMD_GPIO
+#define CONFIG_SANDBOX_GPIO
+#define CONFIG_SANDBOX_GPIO_COUNT	20
+
 /*
  * Size of malloc() pool, although we don't actually use this yet.
  */
-- 
1.7.7.3

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

* [U-Boot] [PATCH v3 5/8] sandbox: Add concept of sandbox state
  2012-01-23  6:48 ` [U-Boot] " Simon Glass
                   ` (3 preceding siblings ...)
  (?)
@ 2012-01-23  6:48 ` Simon Glass
  2012-01-24 23:05   ` Mike Frysinger
  -1 siblings, 1 reply; 16+ messages in thread
From: Simon Glass @ 2012-01-23  6:48 UTC (permalink / raw)
  To: u-boot

The state exists through the life of U-Boot. It can be adjusted by command
line options and perhaps later through a config file. It is available
to U-Boot through state_...() calls (within sandbox code).

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/cpu/Makefile                     |    2 +-
 arch/sandbox/cpu/start.c                      |   10 ++++
 arch/sandbox/cpu/state.c                      |   57 ++++++++++++++++++++++++
 arch/sandbox/include/asm/arch-sandbox/state.h |   59 +++++++++++++++++++++++++
 4 files changed, 127 insertions(+), 1 deletions(-)
 create mode 100644 arch/sandbox/cpu/state.c
 create mode 100644 arch/sandbox/include/asm/arch-sandbox/state.h

diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile
index 2ae0f71..6fd09ff 100644
--- a/arch/sandbox/cpu/Makefile
+++ b/arch/sandbox/cpu/Makefile
@@ -27,7 +27,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(CPU).o
 
-COBJS	:= cpu.o start.o os.o
+COBJS	:= cpu.o os.o start.o state.o
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index a429e29..b3442e8 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -20,9 +20,19 @@
  */
 
 #include <common.h>
+#include <asm/arch/state.h>
 
 int main(int argc, char *argv[])
 {
+	struct sandbox_state *state = NULL;
+	int err;
+
+	err = state_init();
+	if (!err) {
+		state = state_get_current();
+		assert(state);
+	}
+
 	/*
 	 * Do pre- and post-relocation init, then start up U-Boot. This will
 	 * never return.
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
new file mode 100644
index 0000000..a1eb785
--- /dev/null
+++ b/arch/sandbox/cpu/state.c
@@ -0,0 +1,57 @@
+/*
+ * 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>
+#include <asm/arch/gpio.h>
+#include <asm/arch/state.h>
+
+/* Main state record for the sandbox */
+struct sandbox_state main_state;
+struct sandbox_state *state;	/* Pointer to current state record */
+
+int state_is_processor_reset(void)
+{
+	return 1;
+}
+
+void state_record_exit(enum exit_type_id exit_type)
+{
+	state->exit_type = exit_type;
+}
+
+struct sandbox_state *state_get_current(void)
+{
+	assert(state);
+	return state;
+}
+
+int state_init(void)
+{
+	state = &main_state;
+
+	/*
+	 * Example of how to use GPIOs:
+	 *
+	 * sandbox_gpio_set_direction(170, 0);
+	 * sandbox_gpio_set_value(170, 0);
+	 */
+	return 0;
+}
diff --git a/arch/sandbox/include/asm/arch-sandbox/state.h b/arch/sandbox/include/asm/arch-sandbox/state.h
new file mode 100644
index 0000000..3023368
--- /dev/null
+++ b/arch/sandbox/include/asm/arch-sandbox/state.h
@@ -0,0 +1,59 @@
+/*
+ * 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
+ */
+
+/* How we exited U-Boot */
+enum exit_type_id {
+	STATE_EXIT_NORMAL,
+	STATE_EXIT_COLD_REBOOT,
+	STATE_EXIT_POWER_OFF,
+};
+
+/* The complete state of the test system */
+struct sandbox_state {
+	const char *cmd;		/* Command to execute */
+	enum exit_type_id exit_type;	/* How we exited U-Boot */
+};
+
+/**
+ * Check the type of reset that caused U-Boot to run.
+ *
+ * @return 1 = processor reset (cold start), 0 = jump from previous U-Boot
+ */
+int state_is_processor_reset(void);
+
+/**
+ * Record the exit type to be reported by the test program.
+ *
+ * @param exit_type	Exit type to record
+ */
+void state_record_exit(enum exit_type_id exit_type);
+
+/**
+ * Gets a pointer to the current state.
+ *
+ * @return pointer to state
+ */
+struct sandbox_state *state_get_current(void);
+
+/**
+ * Initialize the test system state
+ */
+int state_init(void);
-- 
1.7.7.3

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

* [U-Boot] [PATCH v3 6/8] sandbox: Allow processing instead of or before main loop
  2012-01-23  6:48 ` [U-Boot] " Simon Glass
                   ` (4 preceding siblings ...)
  (?)
@ 2012-01-23  6:48 ` Simon Glass
  -1 siblings, 0 replies; 16+ messages in thread
From: Simon Glass @ 2012-01-23  6:48 UTC (permalink / raw)
  To: u-boot

In order to pass command line arguments to sandbox we need to be able
to act on them. So take control back at the end of board_init_r() from
where we can call the main loop or do something else.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Call cpu_main_loop() from board_init_r()

 arch/sandbox/cpu/start.c                  |    8 ++++++++
 arch/sandbox/include/asm/u-boot-sandbox.h |    3 +++
 arch/sandbox/lib/board.c                  |    7 ++++---
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index b3442e8..d7402be 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -22,6 +22,14 @@
 #include <common.h>
 #include <asm/arch/state.h>
 
+#include <os.h>
+
+void start_main_loop(void)
+{
+	for (;;)
+		main_loop();
+}
+
 int main(int argc, char *argv[])
 {
 	struct sandbox_state *state = NULL;
diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h
index 236b4ee..3743289 100644
--- a/arch/sandbox/include/asm/u-boot-sandbox.h
+++ b/arch/sandbox/include/asm/u-boot-sandbox.h
@@ -35,4 +35,7 @@
 int board_init(void);
 int dram_init(void);
 
+/* start.c */
+void start_main_loop(void);
+
 #endif	/* _U_BOOT_SANDBOX_H_ */
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
index 6d464d6..331ce16 100644
--- a/arch/sandbox/lib/board.c
+++ b/arch/sandbox/lib/board.c
@@ -270,11 +270,12 @@ void board_init_r(gd_t *id, ulong dest_addr)
 #endif
 
 	/*
-	 * For now, run the main loop. Later we might let this be done
-	 * in the main program.
+	 * This function can't return (to match other archs) so call back
+	 * into start.c so that sandbox can do something other than the main
+	 * loop if it likes
 	 */
 	while (1)
-		main_loop();
+		start_main_loop();
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-- 
1.7.7.3

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

* [U-Boot] [PATCH v3 7/8] sandbox: Add flags for open() call
  2012-01-23  6:48 ` [U-Boot] " Simon Glass
                   ` (5 preceding siblings ...)
  (?)
@ 2012-01-23  6:48 ` Simon Glass
  2012-01-24 21:45   ` Mike Frysinger
  2012-02-21  4:41   ` [U-Boot] [PATCH v5 7/9] " Simon Glass
  -1 siblings, 2 replies; 16+ messages in thread
From: Simon Glass @ 2012-01-23  6:48 UTC (permalink / raw)
  To: u-boot

This provides a way for callers to create files for writing. We define
flags which mirror the POSIX values.

Another approach would be to translate the flags at runtime. Perhaps we can
leave to whoever wants to port this to another OS?

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Change open() flags enum to #define

 arch/sandbox/cpu/os.c |    2 +-
 include/os.h          |   16 +++++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 093e7dc..9f93f83 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -47,7 +47,7 @@ ssize_t os_write(int fd, const void *buf, size_t count)
 
 int os_open(const char *pathname, int flags)
 {
-	return open(pathname, flags);
+	return open(pathname, flags, 0777);
 }
 
 int os_close(int fd)
diff --git a/include/os.h b/include/os.h
index f3af4f0..a3c1e84 100644
--- a/include/os.h
+++ b/include/os.h
@@ -1,4 +1,9 @@
 /*
+ * Operating System Interface
+ *
+ * This provides access to useful OS routines for the sandbox architecture.
+ * They are kept in a separate file so we can include system headers.
+ *
  * Copyright (c) 2011 The Chromium OS Authors.
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -19,11 +24,7 @@
  * MA 02111-1307 USA
  */
 
-/*
- * Operating System Interface
- *
- * This provides access to useful OS routines from the sandbox architecture
- */
+struct sandbox_state;
 
 /**
  * Access to the OS read() system call
@@ -45,6 +46,11 @@ ssize_t os_read(int fd, void *buf, size_t count);
  */
 ssize_t os_write(int fd, const void *buf, size_t count);
 
+#define OS_O_RDONLY	0
+#define OS_O_WRONLY	1
+#define	OS_O_RDWR	2
+#define OS_O_CREAT	0100
+
 /**
  * Access to the OS open() system call
  *
-- 
1.7.7.3

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

* [U-Boot] [PATCH v3 8/8] sandbox: Add basic command line parsing
  2012-01-23  6:48 ` [U-Boot] " Simon Glass
                   ` (6 preceding siblings ...)
  (?)
@ 2012-01-23  6:48 ` Simon Glass
  -1 siblings, 0 replies; 16+ messages in thread
From: Simon Glass @ 2012-01-23  6:48 UTC (permalink / raw)
  To: u-boot

This adds simple command-line parsing to sandbox. The idea is that it
sets up the state with options provided, and this state can then be
queried later, as needed.

For now we just allow it to run a command.

Passing a command to U-Boot on stdin is not as convenient IMO.

The parsing code is in os.c since it gives us easy access to getopt() and
friends. We could create a separate parse.c file if this grows.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Clean up, added a few fdt and config patches
- Rebase on master

Changes in v3:
- Only output usage on stderr if we get an error
- Tidy code style around getopt()

 arch/sandbox/cpu/os.c                         |   43 +++++++++++++++++++++++++
 arch/sandbox/cpu/start.c                      |   23 ++++++++++++-
 arch/sandbox/include/asm/arch-sandbox/state.h |    1 +
 include/os.h                                  |   20 +++++++++++
 4 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 9f93f83..4b54fa6 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -21,6 +21,8 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <getopt.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <termios.h>
 #include <time.h>
@@ -30,6 +32,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <linux/types.h>
+#include <asm/arch/state.h>
 
 #include <os.h>
 
@@ -122,3 +125,43 @@ u64 os_get_nsec(void)
 	return tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000;
 #endif
 }
+
+static const char options[] = "c:h";
+
+static const struct option long_options[] = {
+	{"command", required_argument, NULL, 'c'},
+	{"help", no_argument, NULL, 'h'},
+	{NULL, 0, NULL, 0}
+};
+
+void os_usage(int err)
+{
+	if (err < 0)
+		fprintf(stderr, "Try `--help' for more information.\n");
+	fprintf(err < 0 ? stderr : stdout, "u-boot, "
+		"a command line test interface to U-Boot\n\n"
+		"usage:\tu-boot [-ch]\n"
+		"Options:\n"
+		"\t-h\tDisplay help\n"
+		"\t-c <command>\tExecute U-Boot command\n");
+	exit(1);
+}
+
+int os_parse_args(struct sandbox_state *state, int argc, char *argv[])
+{
+	int c;
+
+	while ((c = getopt_long(argc, argv, options, long_options,
+				NULL)) != EOF) {
+		switch (c) {
+		case 'c':
+			state->cmd = optarg;
+			break;
+		case 'h':
+			return 1;
+		default: /* '?' */
+			return -1;
+		}
+	}
+	return 0;
+}
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index d7402be..fa7a907 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -26,8 +26,26 @@
 
 void start_main_loop(void)
 {
-	for (;;)
-		main_loop();
+	struct sandbox_state *state = state_get_current();
+
+	if (state->err)
+		os_usage(state->err);	/* does not return */
+
+	/* Execute command if required */
+	if (state->cmd) {
+		/* TODO: redo this when cmd tidy-up series lands */
+#ifdef CONFIG_SYS_HUSH_PARSER
+		run_command(state->cmd, 0);
+#else
+		parse_string_outer(state->cmd, FLAG_PARSE_SEMICOLON |
+				    FLAG_EXIT_FROM_LOOP);
+#endif
+	} else {
+		for (;;)
+			main_loop();
+	}
+	printf("U-Boot exited with state %d\n", state->exit_type);
+	os_exit(state->exit_type);
 }
 
 int main(int argc, char *argv[])
@@ -39,6 +57,7 @@ int main(int argc, char *argv[])
 	if (!err) {
 		state = state_get_current();
 		assert(state);
+		state->err = os_parse_args(state, argc, argv);
 	}
 
 	/*
diff --git a/arch/sandbox/include/asm/arch-sandbox/state.h b/arch/sandbox/include/asm/arch-sandbox/state.h
index 3023368..1e035fa 100644
--- a/arch/sandbox/include/asm/arch-sandbox/state.h
+++ b/arch/sandbox/include/asm/arch-sandbox/state.h
@@ -30,6 +30,7 @@ enum exit_type_id {
 struct sandbox_state {
 	const char *cmd;		/* Command to execute */
 	enum exit_type_id exit_type;	/* How we exited U-Boot */
+	int err;			/* Error to report from parsing */
 };
 
 /**
diff --git a/include/os.h b/include/os.h
index a3c1e84..f7e8c31 100644
--- a/include/os.h
+++ b/include/os.h
@@ -104,3 +104,23 @@ void os_usleep(unsigned long usec);
  * \return A monotonic increasing time scaled in nano seconds
  */
 u64 os_get_nsec(void);
+
+/**
+ * Parse arguments and update sandbox state.
+ *
+ * @param state		Sandbox state to update
+ * @param argc		Argument count
+ * @param argv		Argument vector
+ * @return 0 if ok, and program should continue;
+ *	1 if ok, but program should stop;
+ *	-1 on error: program should terminate.
+ */
+int os_parse_args(struct sandbox_state *state, int argc, char *argv[]);
+
+/**
+ * Display a usage message on stderr and exit
+ *
+ * @param err		Error code (-ve means the user entered an invalid
+ *			option)
+ */
+void os_usage(int err);
-- 
1.7.7.3

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

* [U-Boot] [PATCH v3 7/8] sandbox: Add flags for open() call
  2012-01-23  6:48 ` [U-Boot] [PATCH v3 7/8] sandbox: Add flags for open() call Simon Glass
@ 2012-01-24 21:45   ` Mike Frysinger
  2012-02-15 22:58     ` Simon Glass
  2012-02-21  4:41   ` [U-Boot] [PATCH v5 7/9] " Simon Glass
  1 sibling, 1 reply; 16+ messages in thread
From: Mike Frysinger @ 2012-01-24 21:45 UTC (permalink / raw)
  To: u-boot

On Monday 23 January 2012 01:48:52 Simon Glass wrote:
> This provides a way for callers to create files for writing. We define
> flags which mirror the POSIX values.

there are no POSIX values, just names.  the way the defines get interpreted is 
left up to implementations.

> @@ -19,11 +24,7 @@
>   * MA 02111-1307 USA
>   */
> 
> -/*
> - * Operating System Interface
> - *
> - * This provides access to useful OS routines from the sandbox
> architecture - */
> +struct sandbox_state;

looks like unrelated stuff got squished into here

> +#define OS_O_RDONLY	0
> +#define OS_O_WRONLY	1
> +#define	OS_O_RDWR	2
> +#define OS_O_CREAT	0100

seems to be whitespace mismatch between "#define" and the actual define.  some 
use tabs and some spaces ?
-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/20120124/854f0820/attachment.pgp>

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

* [U-Boot] [PATCH v3 5/8] sandbox: Add concept of sandbox state
  2012-01-23  6:48 ` [U-Boot] [PATCH v3 5/8] sandbox: Add concept of sandbox state Simon Glass
@ 2012-01-24 23:05   ` Mike Frysinger
  2012-02-15 22:46     ` Simon Glass
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Frysinger @ 2012-01-24 23:05 UTC (permalink / raw)
  To: u-boot

On Monday 23 January 2012 01:48:50 Simon Glass wrote:
> --- a/arch/sandbox/cpu/start.c
> +++ b/arch/sandbox/cpu/start.c
> 
>  int main(int argc, char *argv[])
>  {
> +	struct sandbox_state *state = NULL;
> +	int err;
> +
> +	err = state_init();
> +	if (!err) {
> +		state = state_get_current();
> +		assert(state);
> +	}

i guess a lot of this checking/plumbing only makes sense in the context of 
future work where the state represents a lot more stuff

> --- /dev/null
> +++ b/arch/sandbox/cpu/state.c
>
> +struct sandbox_state main_state;
> +struct sandbox_state *state;	/* Pointer to current state record */

static

> +int state_is_processor_reset(void)
> +{
> +	return 1;
> +}

if the cpu is in reset, then u-boot is dead ...

> +struct sandbox_state *state_get_current(void)
> +{
> +	assert(state);
> +	return state;
> +}

you assert() here and in main() ... i think we can get rid of the one in the 
main() func

> --- /dev/null
> +++ b/arch/sandbox/include/asm/arch-sandbox/state.h

needs ifdef protection against multiple inclusion

> +/* The complete state of the test system */
> +struct sandbox_state {
> +	const char *cmd;		/* Command to execute */
> +	enum exit_type_id exit_type;	/* How we exited U-Boot */
> +};

the argc/argv given to main() should be in here
-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/20120124/5a846502/attachment.pgp>

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

* [U-Boot] [PATCH v3 5/8] sandbox: Add concept of sandbox state
  2012-01-24 23:05   ` Mike Frysinger
@ 2012-02-15 22:46     ` Simon Glass
  0 siblings, 0 replies; 16+ messages in thread
From: Simon Glass @ 2012-02-15 22:46 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Tue, Jan 24, 2012 at 3:05 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday 23 January 2012 01:48:50 Simon Glass wrote:
>> --- a/arch/sandbox/cpu/start.c
>> +++ b/arch/sandbox/cpu/start.c
>>
>> ?int main(int argc, char *argv[])
>> ?{
>> + ? ? struct sandbox_state *state = NULL;
>> + ? ? int err;
>> +
>> + ? ? err = state_init();
>> + ? ? if (!err) {
>> + ? ? ? ? ? ? state = state_get_current();
>> + ? ? ? ? ? ? assert(state);
>> + ? ? }
>
> i guess a lot of this checking/plumbing only makes sense in the context of
> future work where the state represents a lot more stuff

Well we use it for a few things so we need something here, but yes.

>
>> --- /dev/null
>> +++ b/arch/sandbox/cpu/state.c
>>
>> +struct sandbox_state main_state;
>> +struct sandbox_state *state; /* Pointer to current state record */
>
> static

Done

>
>> +int state_is_processor_reset(void)
>> +{
>> + ? ? return 1;
>> +}
>
> if the cpu is in reset, then u-boot is dead ...

That code should not be there, sorry, have removed it.

>
>> +struct sandbox_state *state_get_current(void)
>> +{
>> + ? ? assert(state);
>> + ? ? return state;
>> +}
>
> you assert() here and in main() ... i think we can get rid of the one in the
> main() func
>
>> --- /dev/null
>> +++ b/arch/sandbox/include/asm/arch-sandbox/state.h
>
> needs ifdef protection against multiple inclusion

Done

>
>> +/* The complete state of the test system */
>> +struct sandbox_state {
>> + ? ? const char *cmd; ? ? ? ? ? ? ? ?/* Command to execute */
>> + ? ? enum exit_type_id exit_type; ? ?/* How we exited U-Boot */
>> +};
>
> the argc/argv given to main() should be in here
> -mike

OK I will add this in the last patch which deals with arguments.

Regards,
Simon

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

* [U-Boot] [PATCH v3 7/8] sandbox: Add flags for open() call
  2012-01-24 21:45   ` Mike Frysinger
@ 2012-02-15 22:58     ` Simon Glass
  2012-02-16  3:25       ` Mike Frysinger
  0 siblings, 1 reply; 16+ messages in thread
From: Simon Glass @ 2012-02-15 22:58 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Tue, Jan 24, 2012 at 1:45 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday 23 January 2012 01:48:52 Simon Glass wrote:
>> This provides a way for callers to create files for writing. We define
>> flags which mirror the POSIX values.
>
> there are no POSIX values, just names. ?the way the defines get interpreted is
> left up to implementations.
>
>> @@ -19,11 +24,7 @@
>> ? * MA 02111-1307 USA
>> ? */
>>
>> -/*
>> - * Operating System Interface
>> - *
>> - * This provides access to useful OS routines from the sandbox
>> architecture - */
>> +struct sandbox_state;
>
> looks like unrelated stuff got squished into here

We need to declare the struct. The comment change is because you said
we should put the purpose of the file at the top, and I thought it
didn't really warrant a new commit?

>
>> +#define OS_O_RDONLY ?0
>> +#define OS_O_WRONLY ?1
>> +#define ? ? ?OS_O_RDWR ? ? ? 2
>> +#define OS_O_CREAT ? 0100
>
> seems to be whitespace mismatch between "#define" and the actual define. ?some
> use tabs and some spaces ?
> -mike

Fixed.

Regards,
Simon

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

* [U-Boot] [PATCH v3 7/8] sandbox: Add flags for open() call
  2012-02-15 22:58     ` Simon Glass
@ 2012-02-16  3:25       ` Mike Frysinger
  0 siblings, 0 replies; 16+ messages in thread
From: Mike Frysinger @ 2012-02-16  3:25 UTC (permalink / raw)
  To: u-boot

On Wednesday 15 February 2012 17:58:35 Simon Glass wrote:
> On Tue, Jan 24, 2012 at 1:45 PM, Mike Frysinger wrote:
> > On Monday 23 January 2012 01:48:52 Simon Glass wrote:
> >> -/*
> >> - * Operating System Interface
> >> - *
> >> - * This provides access to useful OS routines from the sandbox
> >> architecture - */
> >> +struct sandbox_state;
> > 
> > looks like unrelated stuff got squished into here
> 
> We need to declare the struct. The comment change is because you said
> we should put the purpose of the file at the top, and I thought it
> didn't really warrant a new commit?

i meant that adding the struct forward decl in this commit doesn't make sense.  
it should be part of one of the sandbox state patches.

deleting the comment is fine, but the changelog should mention that this was on 
purpose and not just an accident.
-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/20120215/f57f1619/attachment.pgp>

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

* [U-Boot] [PATCH v5 7/9] sandbox: Add flags for open() call
  2012-01-23  6:48 ` [U-Boot] [PATCH v3 7/8] sandbox: Add flags for open() call Simon Glass
  2012-01-24 21:45   ` Mike Frysinger
@ 2012-02-21  4:41   ` Simon Glass
  2012-02-21  4:58     ` Mike Frysinger
  1 sibling, 1 reply; 16+ messages in thread
From: Simon Glass @ 2012-02-21  4:41 UTC (permalink / raw)
  To: u-boot

This provides a way for callers to create files for writing. The flags
are translated at runtime, for the ones we support.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Change open() flags enum to #define

Changes in v4:
- Change space to tab in os.h
- Remove unneeded declaration of struct sandbox_state in os.h

Changes in v5:
- Add belts-and-braces decode of OS_O_... flags

 arch/sandbox/cpu/os.c |   24 ++++++++++++++++++++++--
 include/os.h          |   17 +++++++++++------
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 093e7dc..a5c1c0b 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -45,9 +45,29 @@ 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)
+int os_open(const char *pathname, int os_flags)
 {
-	return open(pathname, flags);
+	int flags;
+
+	switch (os_flags & OS_O_MASK) {
+	case OS_O_RDONLY:
+	default:
+		flags = O_RDONLY;
+		break;
+
+	case OS_O_WRONLY:
+		flags = O_WRONLY;
+		break;
+
+	case OS_O_RDWR:
+		flags = O_RDWR;
+		break;
+	}
+
+	if (os_flags & OS_O_CREAT)
+		flags |= O_CREAT;
+
+	return open(pathname, flags, 0777);
 }
 
 int os_close(int fd)
diff --git a/include/os.h b/include/os.h
index f3af4f0..16fb5de 100644
--- a/include/os.h
+++ b/include/os.h
@@ -1,4 +1,9 @@
 /*
+ * Operating System Interface
+ *
+ * This provides access to useful OS routines for the sandbox architecture.
+ * They are kept in a separate file so we can include system headers.
+ *
  * Copyright (c) 2011 The Chromium OS Authors.
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -19,12 +24,6 @@
  * 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
  *
@@ -45,6 +44,12 @@ ssize_t os_read(int fd, void *buf, size_t count);
  */
 ssize_t os_write(int fd, const void *buf, size_t count);
 
+#define OS_O_RDONLY	0
+#define OS_O_WRONLY	1
+#define OS_O_RDWR	2
+#define OS_O_MASK	3	/* Mask for read/write flags */
+#define OS_O_CREAT	0100
+
 /**
  * Access to the OS open() system call
  *
-- 
1.7.7.3

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

* [U-Boot] [PATCH v5 7/9] sandbox: Add flags for open() call
  2012-02-21  4:41   ` [U-Boot] [PATCH v5 7/9] " Simon Glass
@ 2012-02-21  4:58     ` Mike Frysinger
  0 siblings, 0 replies; 16+ messages in thread
From: Mike Frysinger @ 2012-02-21  4:58 UTC (permalink / raw)
  To: u-boot

On Monday 20 February 2012 23:41:36 Simon Glass wrote:
> This provides a way for callers to create files for writing. The flags
> are translated at runtime, for the ones we support.

thanks, merged into my sandbox tree
-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/20120220/5035459b/attachment.pgp>

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

end of thread, other threads:[~2012-02-21  4:58 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-23  6:48 [PATCH v3 1/8] sandbox: fdt: Add support for CONFIG_OF_CONTROL Simon Glass
2012-01-23  6:48 ` [U-Boot] " Simon Glass
2012-01-23  6:48 ` [U-Boot] [PATCH v3 2/8] sandbox: config: Enable fdt and snprintf() options Simon Glass
2012-01-23  6:48 ` [U-Boot] [PATCH v3 3/8] sandbox: gpio: Add basic driver for simulating GPIOs Simon Glass
2012-01-23  6:48 ` [U-Boot] [PATCH v3 4/8] sandbox: Enable GPIO driver Simon Glass
2012-01-23  6:48 ` [U-Boot] [PATCH v3 5/8] sandbox: Add concept of sandbox state Simon Glass
2012-01-24 23:05   ` Mike Frysinger
2012-02-15 22:46     ` Simon Glass
2012-01-23  6:48 ` [U-Boot] [PATCH v3 6/8] sandbox: Allow processing instead of or before main loop Simon Glass
2012-01-23  6:48 ` [U-Boot] [PATCH v3 7/8] sandbox: Add flags for open() call Simon Glass
2012-01-24 21:45   ` Mike Frysinger
2012-02-15 22:58     ` Simon Glass
2012-02-16  3:25       ` Mike Frysinger
2012-02-21  4:41   ` [U-Boot] [PATCH v5 7/9] " Simon Glass
2012-02-21  4:58     ` Mike Frysinger
2012-01-23  6:48 ` [U-Boot] [PATCH v3 8/8] sandbox: Add basic command line parsing Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.