[PATCH 1/3] lib: Move ipmi_bootdev enum to types.h

Samuel Mendoza-Jonas sam.mj at au1.ibm.com
Fri Apr 10 13:52:05 AEST 2015


Move the ipmi_bootdev definition to types.h to support returning
descriptive strings to the system configuration UI.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj at au1.ibm.com>
---
 discover/ipmi.h             | 11 ++---------
 discover/platform-powerpc.c |  1 +
 lib/types/types.c           | 20 ++++++++++++++++++++
 lib/types/types.h           | 11 +++++++++++
 4 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/discover/ipmi.h b/discover/ipmi.h
index e60ff61..325fbe0 100644
--- a/discover/ipmi.h
+++ b/discover/ipmi.h
@@ -4,6 +4,8 @@
 #include <stdbool.h>
 #include <stdint.h>
 
+#include <types/types.h>
+
 enum ipmi_netfn {
 	IPMI_NETFN_CHASSIS = 0x0,
 };
@@ -13,15 +15,6 @@ enum ipmi_cmd {
 	IPMI_CMD_CHASSIS_GET_SYSTEM_BOOT_OPTIONS	= 0x09,
 };
 
-enum ipmi_bootdev {
-	IPMI_BOOTDEV_NONE = 0x00,
-	IPMI_BOOTDEV_NETWORK = 0x01,
-	IPMI_BOOTDEV_DISK = 0x2,
-	IPMI_BOOTDEV_SAFE = 0x3,
-	IPMI_BOOTDEV_CDROM = 0x5,
-	IPMI_BOOTDEV_SETUP = 0x6,
-};
-
 struct ipmi;
 
 bool ipmi_present(void);
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index 4aae561..5cbf1b8 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -707,6 +707,7 @@ static void set_ipmi_bootdev(struct config *config, enum ipmi_bootdev bootdev,
 	case IPMI_BOOTDEV_DISK:
 	case IPMI_BOOTDEV_NETWORK:
 	case IPMI_BOOTDEV_CDROM:
+	default:
 		break;
 	case IPMI_BOOTDEV_SETUP:
 		config->autoboot_enabled = false;
diff --git a/lib/types/types.c b/lib/types/types.c
index 059e52a..95a3a48 100644
--- a/lib/types/types.c
+++ b/lib/types/types.c
@@ -2,6 +2,26 @@
 #include <types/types.h>
 #include <i18n/i18n.h>
 
+const char *ipmi_bootdev_display_name(enum ipmi_bootdev bootdev)
+{
+	switch (bootdev) {
+	case IPMI_BOOTDEV_NONE:
+		return _("None");
+	case IPMI_BOOTDEV_NETWORK:
+		return _("Network");
+	case IPMI_BOOTDEV_DISK:
+		return _("Disk");
+	case IPMI_BOOTDEV_SAFE:
+		return _("Safe Mode");
+	case IPMI_BOOTDEV_CDROM:
+		return _("Optical");
+	case IPMI_BOOTDEV_SETUP:
+		return _("Setup Mode");
+	default:
+		return _("Unknown");
+	}
+}
+
 const char *device_type_display_name(enum device_type type)
 {
 	switch (type) {
diff --git a/lib/types/types.h b/lib/types/types.h
index 3bb8c9b..e5c7e3e 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -13,6 +13,17 @@ enum device_type {
 	DEVICE_TYPE_UNKNOWN,
 };
 
+enum ipmi_bootdev {
+	IPMI_BOOTDEV_NONE = 0x00,
+	IPMI_BOOTDEV_NETWORK = 0x01,
+	IPMI_BOOTDEV_DISK = 0x2,
+	IPMI_BOOTDEV_SAFE = 0x3,
+	IPMI_BOOTDEV_CDROM = 0x5,
+	IPMI_BOOTDEV_SETUP = 0x6,
+	IPMI_BOOTDEV_INVALID = 0xff,
+};
+
+const char *ipmi_bootdev_display_name(enum ipmi_bootdev bootdev);
 const char *device_type_display_name(enum device_type type);
 const char *device_type_name(enum device_type type);
 enum device_type find_device_type(const char *str);
-- 
2.1.0



More information about the Petitboot mailing list