summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-12-02 15:04:38 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-12-15 10:39:02 +0800
commitf69fabee4a120cebaeff2359350e62bd960088f4 (patch)
treee6222e60194f156e5491e6319cc96327f81214f2
parent9dec4ac0431895f027cfa72e8e0656d3d69e3e63 (diff)
downloadpetitboot-f69fabee4a120cebaeff2359350e62bd960088f4.zip
petitboot-f69fabee4a120cebaeff2359350e62bd960088f4.tar.gz
discover/powerpc: Separate ipmi bootdev handling into separate functions
We'd like to add a new backend to the bootdev storage, so move the common bootdev-handling code into separate functions, moving ipmi_bootdev_is_valid to ipmi.c. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--discover/ipmi.c15
-rw-r--r--discover/ipmi.h1
-rw-r--r--discover/platform-powerpc.c57
3 files changed, 43 insertions, 30 deletions
diff --git a/discover/ipmi.c b/discover/ipmi.c
index 4bcdf30..b8f1830 100644
--- a/discover/ipmi.c
+++ b/discover/ipmi.c
@@ -1,6 +1,21 @@
#include "ipmi.h"
+bool ipmi_bootdev_is_valid(int x)
+{
+ switch (x) {
+ case IPMI_BOOTDEV_NONE:
+ case IPMI_BOOTDEV_NETWORK:
+ case IPMI_BOOTDEV_DISK:
+ case IPMI_BOOTDEV_SAFE:
+ case IPMI_BOOTDEV_CDROM:
+ case IPMI_BOOTDEV_SETUP:
+ return true;
+ }
+
+ return false;
+}
+
bool ipmi_present(void)
{
return false;
diff --git a/discover/ipmi.h b/discover/ipmi.h
index 0ed6068..157cca8 100644
--- a/discover/ipmi.h
+++ b/discover/ipmi.h
@@ -13,6 +13,7 @@ enum ipmi_bootdev {
IPMI_BOOTDEV_SETUP = 0x6,
};
+bool ipmi_bootdev_is_valid(int x);
bool ipmi_present(void);
#endif /* _IPMI_H */
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index e5dac9e..6ae28f4 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -583,6 +583,30 @@ static void set_exclusive_devtype(struct config *config,
config->boot_priorities[1].priority = -1;
}
+static void set_ipmi_bootdev(struct config *config, enum ipmi_bootdev bootdev)
+{
+ switch (bootdev) {
+ case IPMI_BOOTDEV_NONE:
+ break;
+ case IPMI_BOOTDEV_DISK:
+ set_exclusive_devtype(config, DEVICE_TYPE_DISK);
+ break;
+ case IPMI_BOOTDEV_NETWORK:
+ set_exclusive_devtype(config, DEVICE_TYPE_NETWORK);
+ break;
+ case IPMI_BOOTDEV_CDROM:
+ set_exclusive_devtype(config, DEVICE_TYPE_OPTICAL);
+ break;
+ case IPMI_BOOTDEV_SETUP:
+ config->autoboot_enabled = false;
+ break;
+ case IPMI_BOOTDEV_SAFE:
+ config->autoboot_enabled = false;
+ config->safe_mode = true;
+ break;
+ }
+}
+
static int read_bootdev_sysparam(const char *name, uint8_t *val)
{
uint8_t buf[2];
@@ -613,18 +637,10 @@ static int read_bootdev_sysparam(const char *name, uint8_t *val)
pb_debug("powerpc: sysparam %s: 0x%02x\n", name, buf[0]);
- switch (buf[0]) {
- default:
+ if (!ipmi_bootdev_is_valid(buf[0]))
return -1;
- case IPMI_BOOTDEV_NONE:
- case IPMI_BOOTDEV_NETWORK:
- case IPMI_BOOTDEV_DISK:
- case IPMI_BOOTDEV_SAFE:
- case IPMI_BOOTDEV_CDROM:
- case IPMI_BOOTDEV_SETUP:
- *val = buf[0];
- }
+ *val = buf[0];
return 0;
}
@@ -687,26 +703,7 @@ static void parse_opal_sysparams(struct config *config)
if (!next_valid)
next_bootdev = default_bootdev;
- switch (next_bootdev) {
- case IPMI_BOOTDEV_NONE:
- return;
- case IPMI_BOOTDEV_DISK:
- set_exclusive_devtype(config, DEVICE_TYPE_DISK);
- break;
- case IPMI_BOOTDEV_NETWORK:
- set_exclusive_devtype(config, DEVICE_TYPE_NETWORK);
- break;
- case IPMI_BOOTDEV_CDROM:
- set_exclusive_devtype(config, DEVICE_TYPE_OPTICAL);
- break;
- case IPMI_BOOTDEV_SETUP:
- config->autoboot_enabled = false;
- break;
- case IPMI_BOOTDEV_SAFE:
- config->autoboot_enabled = false;
- config->safe_mode = true;
- break;
- }
+ set_ipmi_bootdev(config, next_bootdev);
}
static int load_config(struct platform *p, struct config *config)
OpenPOWER on IntegriCloud