summaryrefslogtreecommitdiffstats
path: root/arch/x86
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/x86
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/x86')
-rw-r--r--arch/x86/Makefile2
-rw-r--r--arch/x86/boards/x86_generic/Makefile1
-rw-r--r--arch/x86/boards/x86_generic/config.h21
-rw-r--r--arch/x86/boards/x86_generic/env/bin/boot37
-rw-r--r--arch/x86/boards/x86_generic/env/bin/init15
-rw-r--r--arch/x86/boards/x86_generic/env/config31
-rw-r--r--arch/x86/boards/x86_generic/generic_pc.c140
-rw-r--r--arch/x86/configs/generic_defconfig2
8 files changed, 247 insertions, 2 deletions
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 2e2cb810d7..57c5dbc3b0 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -26,7 +26,7 @@ all: $(KBUILD_IMAGE)
ifneq ($(board-y),)
-BOARD := board/$(board-y)/
+BOARD := arch/x86/boards/$(board-y)/
else
BOARD :=
endif
diff --git a/arch/x86/boards/x86_generic/Makefile b/arch/x86/boards/x86_generic/Makefile
new file mode 100644
index 0000000000..248240da07
--- /dev/null
+++ b/arch/x86/boards/x86_generic/Makefile
@@ -0,0 +1 @@
+obj-y += generic_pc.o
diff --git a/arch/x86/boards/x86_generic/config.h b/arch/x86/boards/x86_generic/config.h
new file mode 100644
index 0000000000..39bea1844b
--- /dev/null
+++ b/arch/x86/boards/x86_generic/config.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2009 Juergen Beisert, Pengutronix
+ *
+ * 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
+ *
+ */
+
+/* nothing special yet */
diff --git a/arch/x86/boards/x86_generic/env/bin/boot b/arch/x86/boards/x86_generic/env/bin/boot
new file mode 100644
index 0000000000..fcfffe3194
--- /dev/null
+++ b/arch/x86/boards/x86_generic/env/bin/boot
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+. /env/config
+
+if [ x$1 = xdisk ]; then
+ root=disk
+ kernel=disk
+fi
+
+if [ x$1 = xnet ]; then
+ root=net
+ kernel=net
+fi
+
+if [ x$ip = xdhcp ]; then
+ bootargs="$bootargs ip=dhcp"
+else
+ bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::"
+fi
+
+if [ x$root = xdisk ]; then
+ bootargs="$bootargs root=$rootpart_disk rootfstype=$rootpart_fs rw"
+else
+ bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp rw"
+fi
+
+if [ $kernel = net ]; then
+ if [ x$ip = xdhcp ]; then
+ dhcp
+ fi
+ tftp $uimage uImage || exit 1
+ bootm uImage
+else
+ bootargs="BOOT_IMAGE=$kernel_device auto $bootargs"
+ linux16 $kernel_device
+fi
+
diff --git a/arch/x86/boards/x86_generic/env/bin/init b/arch/x86/boards/x86_generic/env/bin/init
new file mode 100644
index 0000000000..2924a4449a
--- /dev/null
+++ b/arch/x86/boards/x86_generic/env/bin/init
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+PATH=/env/bin
+export PATH
+
+. /env/config
+
+echo
+echo -n "Hit any key to stop autoboot: "
+timeout -a $autoboot_timeout
+if [ $? != 0 ]; then
+ exit
+fi
+
+boot
diff --git a/arch/x86/boards/x86_generic/env/config b/arch/x86/boards/x86_generic/env/config
new file mode 100644
index 0000000000..dd57aad716
--- /dev/null
+++ b/arch/x86/boards/x86_generic/env/config
@@ -0,0 +1,31 @@
+#
+# basic config
+#
+# boot source: 'disk' or 'net'
+kernel=disk
+root=disk
+
+# data for the NFS case
+nfsroot="/path/to/nfs_root"
+
+# data for the disk case
+kernel_device=/dev/biosdisk0.1
+rootpart_disk=/dev/sda1
+rootpart_fs=ext2
+
+baudrate=115200
+serial=ttyS0
+
+# use UART for console
+bootargs="console=$serial,$baudrate"
+
+autoboot_timeout=3
+
+# use 'dhcp' to do dhcp in uboot and in kernel
+# ip=dhcp
+# or set your networking parameters here
+# eth0.ipaddr=192.168.3.11
+# eth0.netmask=255.255.255.0
+# eth0.gateway=a.b.c.d
+# eth0.serverip=192.168.3.10
+# eth0.ethaddr=aa.bb.cc.dd.ee.ff
diff --git a/arch/x86/boards/x86_generic/generic_pc.c b/arch/x86/boards/x86_generic/generic_pc.c
new file mode 100644
index 0000000000..bd93bc168d
--- /dev/null
+++ b/arch/x86/boards/x86_generic/generic_pc.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2009 Juergen Beisert, Pengutronix
+ *
+ * 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
+ *
+ */
+
+/**
+ * @file
+ * @brief Generic PC support to let barebox acting as a boot loader
+ */
+
+#include <common.h>
+#include <types.h>
+#include <driver.h>
+#include <init.h>
+#include <asm/syslib.h>
+#include <ns16550.h>
+
+static struct memory_platform_data ram_pdata = {
+ .name = "ram0",
+ .flags = DEVFS_RDWR,
+};
+
+static struct device_d sdram_dev = {
+ .name = "mem",
+ .size = 16 * 1024 * 1024,
+ .map_base = 0,
+ .platform_data = &ram_pdata,
+};
+
+static struct device_d bios_disk_dev = {
+ .name = "biosdrive",
+ .size = 1,
+};
+
+/*
+ * These datas are from the MBR, created by the linker and filled by the
+ * setup tool while installing barebox on the disk drive
+ */
+extern uint64_t pers_env_storage;
+extern uint16_t pers_env_size;
+extern uint8_t pers_env_drive;
+
+/**
+ * Persistant environment "not used" marker.
+ * Note: Must be in accordance to the value the tool "setup_mbr" writes.
+ */
+#define PATCH_AREA_PERS_SIZE_UNUSED 0x000
+
+static int devices_init(void)
+{
+ int rc;
+
+ sdram_dev.size = bios_get_memsize(); /* extended memory only */
+ sdram_dev.size <<= 10;
+
+ register_device(&sdram_dev);
+ register_device(&bios_disk_dev);
+
+ if (pers_env_size != PATCH_AREA_PERS_SIZE_UNUSED) {
+ rc = devfs_add_partition("disk0", /* FIXME */
+ pers_env_storage * 512,
+ (unsigned)pers_env_size * 512,
+ DEVFS_PARTITION_FIXED, "env0");
+ printf("Partition: %d\n", rc);
+ } else
+ printf("No persistant storage defined\n");
+
+ return 0;
+}
+device_initcall(devices_init);
+
+#ifdef CONFIG_DRIVER_SERIAL_NS16550
+
+static struct NS16550_plat serial_plat = {
+ .clock = 1843200,
+ .f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR,
+ .reg_read = x86_uart_read,
+ .reg_write = x86_uart_write,
+};
+
+/* we are expecting always one serial interface */
+static struct device_d generic_pc_serial_device = {
+ .name = "serial_ns16550",
+ .map_base = 0x3f8,
+ .size = 8,
+ .platform_data = (void *)&serial_plat,
+};
+
+static int pc_console_init(void)
+{
+ /* Register the serial port */
+ return register_device(&generic_pc_serial_device);
+}
+console_initcall(pc_console_init);
+
+#endif
+
+/** @page generic_pc Generic PC based bootloader
+
+This platform acts as a generic PC based bootloader. It depends on at least
+one boot media that is connected locally (no network boot) and can be
+handled by the regular BIOS (any kind of hard disks for example).
+
+The created @a barebox image can be used to boot a standard x86 bzImage
+Linux kernel.
+
+Refer section @ref x86_bootloader_preparations how to do so.
+
+How to get the binary image:
+
+Using the default configuration:
+
+@code
+make ARCH=x86 generic_defconfig
+@endcode
+
+Build the binary image:
+
+@code
+make ARCH=x86 CROSS_COMPILE=x86compiler
+@endcode
+
+@note replace the 'x86compiler' with your x86 (cross) compiler.
+
+*/
diff --git a/arch/x86/configs/generic_defconfig b/arch/x86/configs/generic_defconfig
index 091f696e3a..3c72242415 100644
--- a/arch/x86/configs/generic_defconfig
+++ b/arch/x86/configs/generic_defconfig
@@ -63,7 +63,7 @@ CONFIG_CONSOLE_ACTIVATE_FIRST=y
# CONFIG_OF_FLAT_TREE is not set
CONFIG_PARTITION=y
CONFIG_DEFAULT_ENVIRONMENT=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="board/x86_generic/env"
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/x86/boards/x86_generic/env"
#
# Debugging