summaryrefslogtreecommitdiffstats
path: root/discover/platform-powerpc.c
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2015-04-21 16:17:57 +1000
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-04-21 16:20:31 +1000
commit6600e73fe891d5006c34f694e97e37eefceb921d (patch)
tree9b74311c1e7c1a6511fe5848165cec0e4e15c1b8 /discover/platform-powerpc.c
parentf166fe2b62d781109e3a88736db96613af8c71d9 (diff)
downloadtalos-petitboot-6600e73fe891d5006c34f694e97e37eefceb921d.tar.gz
talos-petitboot-6600e73fe891d5006c34f694e97e37eefceb921d.zip
discover/platform-powerpc: Set IPMI OS boot sensor
This is to indicate to a BMC that we have initiated OS boot. This patch manually parses the device tree for the sensor information. In the future this could be replaced by libfdt or similar. Discover the id of your OS Boot sensor: $ sudo ipmitool sensor get "OS Boot" Locating sensor record... Sensor ID : OS Boot (0x5a) Entity ID : 35.0 (Operating System) Sensor Type (Discrete): OS Boot (0x1f) Sensor Reading : 0h Event Message Control : Per-threshold Assertion Events : OS Boot [boot completed - device not specified] Assertions Enabled : OS Boot [A: boot completed] [C: boot completed] [PXE boot completed] [Diagnostic boot completed] [CD-ROM boot completed] [ROM boot completed] [boot completed - device not specified] [Installation started] [Installation completed] [Installation aborted] [Installation failed] OEM : 0 In this case it is 0x1f. Note that the sesnor is currently asserted iwth boot completed - device not specified. Test by clearing all assertions in the OS Boot sensor: $ sudo ipmitool raw 0x04 0x30 0x5a 0x30 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 $ sudo ipmitool sensor get "OS Boot" Locating sensor record... Sensor ID : OS Boot (0x5a) Entity ID : 35.0 (Operating System) Sensor Type (Discrete): OS Boot (0x1f) Sensor Reading : 0h Event Message Control : Per-threshold Assertions Enabled : OS Boot [A: boot completed] [C: boot completed] [PXE boot completed] [Diagnostic boot completed] [CD-ROM boot completed] [ROM boot completed] [boot completed - device not specified] [Installation started] [Installation completed] [Installation aborted] [Installation failed] OEM : 0 Then reboot your system. The assertion event should once more say "boot completed - device not specified". Signed-off-by: Joel Stanley <joel@jms.id.au>
Diffstat (limited to 'discover/platform-powerpc.c')
-rw-r--r--discover/platform-powerpc.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index a293ce9..4cc91fa 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -17,6 +17,7 @@
#include "platform.h"
#include "ipmi.h"
+#include "dt.h"
static const char *partition = "common";
static const char *sysparams_dir = "/sys/firmware/opal/sysparams/";
@@ -39,6 +40,8 @@ struct platform_powerpc {
uint8_t *bootdev, bool *persistent);
int (*clear_ipmi_bootdev)(
struct platform_powerpc *platform);
+ int (*set_os_boot_sensor)(
+ struct platform_powerpc *platform);
};
static const char *known_params[] = {
@@ -792,6 +795,42 @@ static int get_ipmi_bootdev_ipmi(struct platform_powerpc *platform,
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 */
+ 0x10, /* operation: set assertion bits */
+ 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;
+}
static int load_config(struct platform *p, struct config *config)
{
@@ -838,6 +877,9 @@ static void pre_boot(struct platform *p, const struct config *config)
if (!config->ipmi_bootdev_persistent && platform->clear_ipmi_bootdev)
platform->clear_ipmi_bootdev(platform);
+
+ if (platform->set_os_boot_sensor)
+ platform->set_os_boot_sensor(platform);
}
static int get_sysinfo(struct platform *p, struct system_info *sysinfo)
@@ -875,7 +917,7 @@ static bool probe(struct platform *p, void *ctx)
if (!S_ISDIR(statbuf.st_mode))
return false;
- platform = talloc(ctx, struct platform_powerpc);
+ platform = talloc_zero(ctx, struct platform_powerpc);
list_init(&platform->params);
p->platform_data = platform;
@@ -885,6 +927,7 @@ static bool probe(struct platform *p, void *ctx)
platform->ipmi = ipmi_open(platform);
platform->get_ipmi_bootdev = get_ipmi_bootdev_ipmi;
platform->clear_ipmi_bootdev = clear_ipmi_bootdev_ipmi;
+ platform->set_os_boot_sensor = set_ipmi_os_boot_sensor;
} else if (!stat(sysparams_dir, &statbuf)) {
pb_debug("platform: using sysparams for IPMI paramters\n");
OpenPOWER on IntegriCloud