[U-Boot] [RFC PATCH v2 13/20] sandbox: Add OS dependent layer
Simon Glass
sjg at chromium.org
Fri Sep 23 18:22:15 CEST 2011
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 at 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
arch/sandbox/config.mk | 3 ++
arch/sandbox/cpu/sandbox/Makefile | 7 ++++-
arch/sandbox/cpu/sandbox/os.c | 49 +++++++++++++++++++++++++++++++++++++
include/os.h | 27 ++++++++++++++++++++
4 files changed, 85 insertions(+), 1 deletions(-)
create mode 100644 arch/sandbox/cpu/sandbox/os.c
create mode 100644 include/os.h
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index ab33026..8aa5b3c 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -18,3 +18,6 @@
# MA 02111-1307 USA
PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__
+
+# Use this until we get cpu/sandbox/Makefile doing its job
+PLATFORM_CPPFLAGS += -I/usr/include
diff --git a/arch/sandbox/cpu/sandbox/Makefile b/arch/sandbox/cpu/sandbox/Makefile
index 8dfa828..71360a5 100644
--- a/arch/sandbox/cpu/sandbox/Makefile
+++ b/arch/sandbox/cpu/sandbox/Makefile
@@ -23,11 +23,16 @@
# MA 02111-1307 USA
#
+# I want to do this, but it doesn't seem to work
+CFLAGS_arch/sandbox/cpu/sandbox/os.o += -I/usr/include
+# does the config.mk line only work with board/ ?
+# BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
+
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/sandbox/os.c b/arch/sandbox/cpu/sandbox/os.c
new file mode 100644
index 0000000..8df7b7e
--- /dev/null
+++ b/arch/sandbox/cpu/sandbox/os.c
@@ -0,0 +1,49 @@
+/*
+ * 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 <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);
+}
diff --git a/include/os.h b/include/os.h
new file mode 100644
index 0000000..3010920
--- /dev/null
+++ b/include/os.h
@@ -0,0 +1,27 @@
+/*
+ * 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 */
+
+ssize_t os_read(int fd, void *buf, size_t count);
+ssize_t os_write(int fd, const void *buf, size_t count);
+int os_open(const char *pathname, int flags);
+int os_close(int fd);
--
1.7.3.1
More information about the U-Boot
mailing list