+
+ if (resp[0] != 0) {
+ pb_log("platform: non-zero completion code %d from IPMI req\n",
+ resp[0]);
+ return -1;
+ }
+
+ /* check for correct parameter version */
+ if ((resp[1] & 0xf) != 0x1) {
+ pb_log("platform: unexpected version (0x%x) in "
+ "boot options response\n", resp[0]);
+ return -1;
+ }
+
+ /* check for valid paramters */
+ if (resp[2] & 0x80) {
+ pb_debug("platform: boot options are invalid/locked\n");
+ return -1;
+ }
+
+ *persistent = false;
+
+ /* check for valid flags */
+ if (!(resp[3] & 0x80)) {
+ pb_debug("platform: boot flags are invalid, ignoring\n");
+ return 0;
+ }
+
+ *persistent = resp[3] & 0x40;
+ *bootdev = (resp[4] >> 2) & 0x0f;
+ return 0;
+}
+
+static int set_ipmi_os_boot_sensor(struct platform_powerpc *platform)
+{
+ int sensor_number;
+ uint16_t resp_len;
+ uint8_t resp[1];
+ uint8_t req[] = {
+ 0x00, /* sensor number: os boot */
+ 0xA9, /* operation: set everything */
+ 0x00, /* sensor reading: none */
+ 0x40, /* assertion mask lsb: set state 6 */
+ 0x00, /* assertion mask msb: none */
+ 0x00, /* deassertion mask lsb: none */
+ 0x00, /* deassertion mask msb: none */
+ 0x00, /* event data 1: none */
+ 0x00, /* event data 2: none */
+ 0x00, /* event data 3: none */
+ };
+
+ sensor_number = get_ipmi_sensor(platform, IPMI_SENSOR_ID_OS_BOOT);
+ if (sensor_number < 0) {
+ pb_log("Couldn't find OS boot sensor in device tree\n");
+ return -1;
+ }
+
+ req[0] = sensor_number;
+
+ resp_len = sizeof(resp);
+
+ ipmi_transaction(platform->ipmi, IPMI_NETFN_SE,
+ IPMI_CMD_SENSOR_SET,
+ req, sizeof(req),
+ resp, &resp_len,
+ ipmi_timeout); return 0;
+
+ return 0;