summaryrefslogtreecommitdiffstats
path: root/common/bootsource.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2013-04-03 10:12:11 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-04-04 10:54:22 +0200
commit7b66d9cdddf2bccb9b88a34317428c44c1b750cc (patch)
tree7f9838baab2476dc6e7ea6b0246ebca533cff09f /common/bootsource.c
parent0994834462c4200dfe8479d8d694226008ca9d72 (diff)
downloadbarebox-7b66d9cdddf2bccb9b88a34317428c44c1b750cc.tar.gz
barebox-7b66d9cdddf2bccb9b88a34317428c44c1b750cc.tar.xz
bootsource: create arch independent bootsource framework
This patch seperates the imx independent from the arch independent code. The following functions and enums are renamed: - imx_bootsource() -> bootsource_get() - imx_set_bootsource() -> bootsource_set() - enum imx_bootsource -> enum bootsource Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/bootsource.c')
-rw-r--r--common/bootsource.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/common/bootsource.c b/common/bootsource.c
new file mode 100644
index 0000000000..6f9ae54ceb
--- /dev/null
+++ b/common/bootsource.c
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright (C) 2011 Marc Reilly <marc@cpdesign.com.au>
+ * Copyright (C) 2013 Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * 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.
+ *
+ */
+
+#include <common.h>
+#include <bootsource.h>
+#include <environment.h>
+#include <magicvar.h>
+
+static const char *bootsource_str[] = {
+ [BOOTSOURCE_UNKNOWN] = "unknown",
+ [BOOTSOURCE_NAND] = "nand",
+ [BOOTSOURCE_NOR] = "nor",
+ [BOOTSOURCE_MMC] = "mmc",
+ [BOOTSOURCE_I2C] = "i2c",
+ [BOOTSOURCE_SPI] = "spi",
+ [BOOTSOURCE_SERIAL] = "serial",
+ [BOOTSOURCE_ONENAND] = "onenand",
+ [BOOTSOURCE_HD] = "harddisk",
+};
+
+static enum bootsource bootsource = BOOTSOURCE_UNKNOWN;
+
+void bootsource_set(enum bootsource src)
+{
+ if (src >= ARRAY_SIZE(bootsource_str))
+ src = BOOTSOURCE_UNKNOWN;
+
+ bootsource = src;
+
+ setenv("bootsource", bootsource_str[src]);
+ export("bootsource");
+}
+
+enum bootsource bootsource_get(void)
+{
+ return bootsource;
+}
+
+BAREBOX_MAGICVAR(bootsource, "The source barebox has been booted from");