[U-Boot] [RFC PATCH 13/20] sandbox: Add OS dependent layer

Simon Glass sjg at chromium.org
Sat Sep 17 18:48:52 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>
---
 arch/sandbox/config.mk        |    2 +-
 board/sandbox/common/Makefile |   47 +++++++++++++++++++++++++++++++++++++++
 board/sandbox/common/os.c     |   49 +++++++++++++++++++++++++++++++++++++++++
 include/os.h                  |   27 ++++++++++++++++++++++
 4 files changed, 124 insertions(+), 1 deletions(-)
 create mode 100644 board/sandbox/common/Makefile
 create mode 100644 board/sandbox/common/os.c
 create mode 100644 include/os.h

diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index d9956ff..f0f1472 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -17,5 +17,5 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
 
-PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__
+PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__ -I/usr/include
 LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds
diff --git a/board/sandbox/common/Makefile b/board/sandbox/common/Makefile
new file mode 100644
index 0000000..3289368
--- /dev/null
+++ b/board/sandbox/common/Makefile
@@ -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
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(VENDOR).o
+
+COBJS-y += os.o
+
+COBJS	:= $(COBJS-y)
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+all:	$(LIB)
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+clean:
+	rm -f $(SOBJS) $(OBJS)
+
+distclean:	clean
+	rm -f $(LIB) core *.bak $(obj).depend
+
+#########################################################################
+# This is for $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/sandbox/common/os.c b/board/sandbox/common/os.c
new file mode 100644
index 0000000..8df7b7e
--- /dev/null
+++ b/board/sandbox/common/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