From 4f345d5673bc68122bcc5018a97fda2d8275437d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 19 Jan 2012 22:57:29 -0500 Subject: sandbox: add ifdef protection to os.h Acked-by: Simon Glass Signed-off-by: Mike Frysinger --- include/os.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/os.h b/include/os.h index f3af4f0e0e..c17a8a52ab 100644 --- a/include/os.h +++ b/include/os.h @@ -25,6 +25,9 @@ * This provides access to useful OS routines from the sandbox architecture */ +#ifndef __OS_H__ +#define __OS_H__ + /** * Access to the OS read() system call * @@ -98,3 +101,5 @@ void os_usleep(unsigned long usec); * \return A monotonic increasing time scaled in nano seconds */ u64 os_get_nsec(void); + +#endif -- cgit v1.2.3 From e2dcefcb404df39fc38786f4b76e3b94d4f476e1 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 25 Oct 2011 13:02:58 +0200 Subject: sandbox: add lseek helper Follow up patches want to be able to seek fd's. Acked-by: Simon Glass Signed-off-by: Mike Frysinger --- include/os.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/os.h b/include/os.h index c17a8a52ab..f74766d16c 100644 --- a/include/os.h +++ b/include/os.h @@ -48,6 +48,21 @@ ssize_t os_read(int fd, void *buf, size_t count); */ ssize_t os_write(int fd, const void *buf, size_t count); +/** + * Access to the OS lseek() system call + * + * \param fd File descriptor as returned by os_open() + * \param offset File offset (based on whence) + * \param whence Position offset is relative to (see below) + * \return new file offset + */ +off_t os_lseek(int fd, off_t offset, int whence); + +/* Defines for "whence" in os_lseek() */ +#define OS_SEEK_SET 0 +#define OS_SEEK_CUR 1 +#define OS_SEEK_END 2 + /** * Access to the OS open() system call * -- cgit v1.2.3 From 7b06b66cd7f9f4d33cfd3e68046c094a43024cda Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 15 Feb 2012 15:51:12 -0800 Subject: sandbox: config: enable fdt and snprintf() options Enable fdt code and safe snprintf() options for sandbox. Signed-off-by: Simon Glass Signed-off-by: Mike Frysinger --- include/configs/sandbox.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 10565e69c3..6790216751 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. */ -- cgit v1.2.3 From d9165153caea9f342410ed3ac87cb68768ebec78 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Feb 2012 23:56:58 -0500 Subject: sandbox: add flags for open() call 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 Signed-off-by: Mike Frysinger --- include/os.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/os.h b/include/os.h index f74766d16c..6b7ee474f0 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 - */ - #ifndef __OS_H__ #define __OS_H__ @@ -72,6 +71,12 @@ off_t os_lseek(int fd, off_t offset, int whence); */ int os_open(const char *pathname, int flags); +#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 close() system call * -- cgit v1.2.3 From eef448e1efeb589a3f725977a339a83d86b91331 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 15 Feb 2012 15:51:14 -0800 Subject: sandbox: enable GPIO driver Enable the new GPIO driver for sandbox. Signed-off-by: Simon Glass Signed-off-by: Mike Frysinger --- include/configs/sandbox.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 6790216751..a58a34e58c 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. */ -- cgit v1.2.3 From 70db4212fcdb080444a23dccaf673b68a3ffc1fa Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 15 Feb 2012 15:51:16 -0800 Subject: sandbox: add getopt support 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. New flags are declared with the SB_CMDLINE_OPT_SHORT helper macro, pointers are automatically gathered up in a special section, and then the core code takes care of gathering them up and processing at runtime. This way there is no central place where we have to store a list of flags with ifdefs. Signed-off-by: Simon Glass Signed-off-by: Mike Frysinger --- include/os.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/os.h b/include/os.h index 6b7ee474f0..45729c1e44 100644 --- a/include/os.h +++ b/include/os.h @@ -27,6 +27,8 @@ #ifndef __OS_H__ #define __OS_H__ +struct sandbox_state; + /** * Access to the OS read() system call * @@ -122,4 +124,16 @@ void os_usleep(unsigned long usec); */ 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[]); + #endif -- cgit v1.2.3 From 9d72e67b79a454dcd6847bcd80c9929e0ec9054d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 26 Feb 2012 17:46:30 -0500 Subject: sandbox: mark os_exit as noreturn Signed-off-by: Mike Frysinger --- include/os.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/os.h b/include/os.h index 45729c1e44..699682a408 100644 --- a/include/os.h +++ b/include/os.h @@ -95,7 +95,7 @@ int os_close(int fd); * * @param exit_code exit code for U-Boot */ -void os_exit(int exit_code); +void os_exit(int exit_code) __attribute__((noreturn)); /** * Put tty into raw mode to mimic serial console better -- cgit v1.2.3