summaryrefslogtreecommitdiffstats
path: root/arch/sandbox/board
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2010-07-22 05:00:13 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-07-23 08:35:25 +0200
commitd8c86961b333a9c88cf2aa4282a43b8382e9b810 (patch)
treecf8b39db96805a2ed876ba14f6824a96ebffc906 /arch/sandbox/board
parentd879de38e8430eeb9b37b7b6a2ac3341b0b029f7 (diff)
downloadbarebox-d8c86961b333a9c88cf2aa4282a43b8382e9b810.tar.gz
barebox-d8c86961b333a9c88cf2aa4282a43b8382e9b810.tar.xz
move boards to arch/<architecure>/boards
this will allow each arch to handle the boards more simply and depending on there need the env var BOARD will refer to the current board dirent for sandbox as we have only one board the board dirent is arch/sandbox/board Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox/board')
-rw-r--r--arch/sandbox/board/.gitignore1
-rw-r--r--arch/sandbox/board/Makefile9
-rw-r--r--arch/sandbox/board/barebox.lds.S229
-rw-r--r--arch/sandbox/board/board.c42
-rw-r--r--arch/sandbox/board/clock.c48
-rw-r--r--arch/sandbox/board/config.h6
-rw-r--r--arch/sandbox/board/console.c52
-rw-r--r--arch/sandbox/board/env/bin/init7
-rw-r--r--arch/sandbox/board/env/config8
-rw-r--r--arch/sandbox/board/hostfile.c114
10 files changed, 516 insertions, 0 deletions
diff --git a/arch/sandbox/board/.gitignore b/arch/sandbox/board/.gitignore
new file mode 100644
index 0000000000..d1165788c9
--- /dev/null
+++ b/arch/sandbox/board/.gitignore
@@ -0,0 +1 @@
+barebox.lds
diff --git a/arch/sandbox/board/Makefile b/arch/sandbox/board/Makefile
new file mode 100644
index 0000000000..8abe5dde08
--- /dev/null
+++ b/arch/sandbox/board/Makefile
@@ -0,0 +1,9 @@
+obj-y += board.o
+obj-y += clock.o
+obj-y += hostfile.o
+obj-y += console.o
+
+CPPFLAGS_barebox.lds = -U$(SUBARCH) -DELF_ARCH=$(ELF_ARCH) \
+ -DELF_FORMAT="$(ELF_FORMAT)"
+extra-y += barebox.lds
+
diff --git a/arch/sandbox/board/barebox.lds.S b/arch/sandbox/board/barebox.lds.S
new file mode 100644
index 0000000000..53e9f6021a
--- /dev/null
+++ b/arch/sandbox/board/barebox.lds.S
@@ -0,0 +1,229 @@
+#include <asm-generic/barebox.lds.h>
+
+OUTPUT_FORMAT(ELF_FORMAT)
+OUTPUT_ARCH(ELF_ARCH)
+ENTRY(_start)
+
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ PROVIDE (__executable_start = 0x400000); . = 0x400000 + SIZEOF_HEADERS;
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .gnu.hash : { *(.gnu.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .rel.dyn :
+ {
+ *(.rel.init)
+ *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
+ *(.rel.fini)
+ *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
+ *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
+ *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
+ *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
+ *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
+ *(.rel.ctors)
+ *(.rel.dtors)
+ *(.rel.got)
+ *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
+ *(.rel.ldata .rel.ldata.* .rel.gnu.linkonce.l.*)
+ *(.rel.lbss .rel.lbss.* .rel.gnu.linkonce.lb.*)
+ *(.rel.lrodata .rel.lrodata.* .rel.gnu.linkonce.lr.*)
+ }
+ .rela.dyn :
+ {
+ *(.rela.init)
+ *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
+ *(.rela.fini)
+ *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
+ *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
+ *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
+ *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
+ *(.rela.ctors)
+ *(.rela.dtors)
+ *(.rela.got)
+ *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
+ *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*)
+ *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*)
+ *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*)
+ }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ .init :
+ {
+ KEEP (*(.init))
+ } =0x90909090
+ .plt : { *(.plt) }
+ .text :
+ {
+ *(.text .stub .text.* .gnu.linkonce.t.*)
+ KEEP (*(.text.*personality*))
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ } =0x90909090
+ .fini :
+ {
+ KEEP (*(.fini))
+ } =0x90909090
+
+ . = ALIGN(64);
+ __barebox_initcalls_start = .;
+ __barebox_initcalls : { INITCALLS }
+ __barebox_initcalls_end = .;
+ . = ALIGN(64);
+ __barebox_cmd_start = .;
+ __barebox_cmd : { BAREBOX_CMDS }
+ __barebox_cmd_end = .;
+
+ PROVIDE (__etext = .);
+ PROVIDE (_etext = .);
+ PROVIDE (etext = .);
+ .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
+ .rodata1 : { *(.rodata1) }
+ .eh_frame_hdr : { *(.eh_frame_hdr) }
+ .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
+ .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
+ /* Adjust the address for the data segment. We want to adjust up to
+ the same address within the page on the next page up. */
+ . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
+ /* Exception handling */
+ .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
+ .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
+ /* Thread Local Storage sections */
+ .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
+ .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ }
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ }
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ }
+ .ctors :
+ {
+ /* gcc uses crtbegin.o to find the start of
+ the constructors, so we make sure it is
+ first. Because this is a wildcard, it
+ doesn't matter if the user does not
+ actually link against crtbegin.o; the
+ linker won't look for a file to match a
+ wildcard. The wildcard also means that it
+ doesn't matter which directory crtbegin.o
+ is in. */
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*crtbegin?.o(.ctors))
+ /* We don't want to include the .ctor section from
+ the crtend.o file until after the sorted ctors.
+ The .ctor section from the crtend file contains the
+ end of ctors marker and it must be last */
+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ }
+ .dtors :
+ {
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*crtbegin?.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ }
+ .jcr : { KEEP (*(.jcr)) }
+ .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
+ .dynamic : { *(.dynamic) }
+ .got : { *(.got) }
+ . = DATA_SEGMENT_RELRO_END (24, .);
+ .got.plt : { *(.got.plt) }
+ .data :
+ {
+ *(.data .data.* .gnu.linkonce.d.*)
+ KEEP (*(.gnu.linkonce.d.*personality*))
+ SORT(CONSTRUCTORS)
+ }
+ .data1 : { *(.data1) }
+ _edata = .; PROVIDE (edata = .);
+ __bss_start = .;
+ .bss :
+ {
+ *(.dynbss)
+ *(.bss .bss.* .gnu.linkonce.b.*)
+ *(COMMON)
+ /* Align here to ensure that the .bss section occupies space up to
+ _end. Align after .bss to ensure correct alignment even if the
+ .bss section disappears because there are no input sections.
+ FIXME: Why do we need it? When there is no .bss section, we don't
+ pad the .data section. */
+ . = ALIGN(. != 0 ? 64 / 8 : 1);
+ }
+ .lbss :
+ {
+ *(.dynlbss)
+ *(.lbss .lbss.* .gnu.linkonce.lb.*)
+ *(LARGE_COMMON)
+ }
+ . = ALIGN(64 / 8);
+ .lrodata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
+ {
+ *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
+ }
+ .ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
+ {
+ *(.ldata .ldata.* .gnu.linkonce.l.*)
+ . = ALIGN(. != 0 ? 64 / 8 : 1);
+ }
+ . = ALIGN(64 / 8);
+ _end = .; PROVIDE (end = .);
+ . = DATA_SEGMENT_END (.);
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ /DISCARD/ : { *(.note.GNU-stack) }
+}
+
diff --git a/arch/sandbox/board/board.c b/arch/sandbox/board/board.c
new file mode 100644
index 0000000000..84017eb50d
--- /dev/null
+++ b/arch/sandbox/board/board.c
@@ -0,0 +1,42 @@
+/*
+ * board.c
+ *
+ * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * 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 version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 <driver.h>
+#include <malloc.h>
+#include <mach/linux.h>
+#include <init.h>
+#include <errno.h>
+
+static struct device_d tap_device = {
+ .name = "tap",
+};
+
+static int devices_init(void)
+{
+ register_device(&tap_device);
+
+ return 0;
+}
+
+device_initcall(devices_init);
+
diff --git a/arch/sandbox/board/clock.c b/arch/sandbox/board/clock.c
new file mode 100644
index 0000000000..b15086432c
--- /dev/null
+++ b/arch/sandbox/board/clock.c
@@ -0,0 +1,48 @@
+/*
+ * clock.c - wrapper between a barebox clocksource and linux
+ *
+ * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * 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 version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 <init.h>
+#include <clock.h>
+#include <mach/linux.h>
+
+static uint64_t linux_clocksource_read(void)
+{
+ return linux_get_time();
+}
+
+static struct clocksource cs = {
+ .read = linux_clocksource_read,
+ .mask = 0xffffffff,
+ .shift = 10,
+};
+
+static int clocksource_init (void)
+{
+ cs.mult = clocksource_hz2mult(1000 * 1000 * 1000, cs.shift);
+
+ init_clock(&cs);
+
+ return 0;
+}
+
+core_initcall(clocksource_init);
diff --git a/arch/sandbox/board/config.h b/arch/sandbox/board/config.h
new file mode 100644
index 0000000000..c96d762f2d
--- /dev/null
+++ b/arch/sandbox/board/config.h
@@ -0,0 +1,6 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define __SANDBOX__
+
+#endif /* __CONFIG_H */
diff --git a/arch/sandbox/board/console.c b/arch/sandbox/board/console.c
new file mode 100644
index 0000000000..2959e85c7a
--- /dev/null
+++ b/arch/sandbox/board/console.c
@@ -0,0 +1,52 @@
+/*
+ * console.c - register a console device
+ *
+ * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * 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 version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 <driver.h>
+#include <mach/linux.h>
+#include <xfuncs.h>
+
+int barebox_register_console(char *name, int stdinfd, int stdoutfd)
+{
+ struct device_d *dev;
+ struct linux_console_data *data;
+
+ dev = xzalloc(sizeof(struct device_d) + sizeof(struct linux_console_data));
+
+ data = (struct linux_console_data *)(dev + 1);
+
+ dev->platform_data = data;
+ strcpy(dev->name, name);
+
+ strcpy(dev->name, "console");
+
+ if (stdinfd >= 0)
+ data->flags = CONSOLE_STDIN;
+ if (stdoutfd >= 0)
+ data->flags |= CONSOLE_STDOUT | CONSOLE_STDERR;
+
+ data->stdoutfd = stdoutfd;
+ data->stdinfd = stdinfd;
+
+ return register_device(dev);
+}
+
diff --git a/arch/sandbox/board/env/bin/init b/arch/sandbox/board/env/bin/init
new file mode 100644
index 0000000000..a7cb7d563d
--- /dev/null
+++ b/arch/sandbox/board/env/bin/init
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+PATH=/env/bin
+export PATH
+
+. /env/config
+
diff --git a/arch/sandbox/board/env/config b/arch/sandbox/board/env/config
new file mode 100644
index 0000000000..2b148b6daa
--- /dev/null
+++ b/arch/sandbox/board/env/config
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+eth0.ipaddr=172.0.0.2
+eth0.netmask=255.255.255.0
+eth0.gateway=172.0.0.1
+eth0.serverip=172.0.0.1
+eth0.ethaddr=80:81:82:83:84:85
+
diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
new file mode 100644
index 0000000000..ad625d7a6e
--- /dev/null
+++ b/arch/sandbox/board/hostfile.c
@@ -0,0 +1,114 @@
+/*
+ * hostfile.c - use files from the host to simalute barebox devices
+ *
+ * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * 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 version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 <driver.h>
+#include <malloc.h>
+#include <mach/linux.h>
+#include <init.h>
+#include <errno.h>
+#include <mach/hostfile.h>
+#include <xfuncs.h>
+
+struct hf_priv {
+ struct cdev cdev;
+ struct hf_platform_data *pdata;
+};
+
+static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
+{
+ struct hf_platform_data *hf = cdev->priv;
+ int fd = hf->fd;
+
+ if (linux_lseek(fd, offset) != offset)
+ return -EINVAL;
+
+ return linux_read(fd, buf, count);
+}
+
+static ssize_t hf_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags)
+{
+ struct hf_platform_data *hf = cdev->priv;
+ int fd = hf->fd;
+
+ if (linux_lseek(fd, offset) != offset)
+ return -EINVAL;
+
+ return linux_write(fd, buf, count);
+}
+
+static void hf_info(struct device_d *dev)
+{
+ struct hf_platform_data *hf = dev->platform_data;
+
+ printf("file: %s\n", hf->filename);
+}
+
+static struct file_operations hf_fops = {
+ .read = hf_read,
+ .write = hf_write,
+};
+
+static int hf_probe(struct device_d *dev)
+{
+ struct hf_platform_data *hf = dev->platform_data;
+ struct hf_priv *priv = xzalloc(sizeof(*priv));
+
+ priv->pdata = hf;
+
+ priv->cdev.name = hf->name;
+ priv->cdev.size = hf->size;
+ priv->cdev.ops = &hf_fops;
+ priv->cdev.priv = hf;
+ devfs_create(&priv->cdev);
+
+ return 0;
+}
+
+static struct driver_d hf_drv = {
+ .name = "hostfile",
+ .probe = hf_probe,
+ .info = hf_info,
+};
+
+static int hf_init(void)
+{
+ return register_driver(&hf_drv);
+}
+
+device_initcall(hf_init);
+
+int barebox_register_filedev(struct hf_platform_data *hf)
+{
+ struct device_d *dev;
+
+ dev = xzalloc(sizeof(struct device_d));
+
+ dev->platform_data = hf;
+
+ strcpy(dev->name, "hostfile");
+ dev->size = hf->size;
+ dev->map_base = hf->map_base;
+
+ return register_device(dev);
+}
+