12 #include <file/file.h>
13 #include <talloc/talloc.h>
14 #include <list/list.h>
16 #include <process/process.h>
22 static const char *partition = "common";
23 static const char *sysparams_dir = "/sys/firmware/opal/sysparams/";
24 static const char *devtree_dir = "/proc/device-tree/";
25 static const int ipmi_timeout = 5000; /* milliseconds. */
31 struct list_item list;
34 struct platform_powerpc {
37 bool ipmi_bootdev_persistent;
38 int (*get_ipmi_bootdev)(
39 struct platform_powerpc *platform,
40 uint8_t *bootdev, bool *persistent);
41 int (*clear_ipmi_bootdev)(
42 struct platform_powerpc *platform,
44 int (*set_os_boot_sensor)(
45 struct platform_powerpc *platform);
48 static const char *known_params[] = {
57 "petitboot,snapshots?",
61 #define to_platform_powerpc(p) \
62 (struct platform_powerpc *)(p->platform_data)
64 /* a partition max a max size of 64k * 16bytes = 1M */
65 static const int max_partition_size = 64 * 1024 * 16;
67 static bool param_is_known(const char *param, unsigned int len)
69 const char *known_param;
72 for (i = 0; known_params[i]; i++) {
73 known_param = known_params[i];
74 if (len == strlen(known_param) &&
75 !strncmp(param, known_param, len))
82 static int parse_nvram_params(struct platform_powerpc *platform,
85 char *pos, *name, *value;
86 unsigned int paramlen;
89 /* discard 2 header lines:
96 for (i = 0; i < len; i++) {
104 fprintf(stderr, "failure parsing nvram output\n");
108 for (pos = buf + i; pos < buf + len; pos += paramlen + 1) {
109 unsigned int namelen;
113 newline = strchr(pos, '\n');
119 paramlen = strlen(pos);
122 value = strchr(pos, '=');
126 namelen = value - name;
130 if (!param_is_known(name, namelen))
135 param = talloc(platform, struct param);
136 param->modified = false;
137 param->name = talloc_strndup(platform, name, namelen);
138 param->value = talloc_strdup(platform, value);
139 list_add(&platform->params, ¶m->list);
145 static int parse_nvram(struct platform_powerpc *platform)
147 struct process *process;
152 argv[1] = "--print-config";
153 argv[2] = "--partition";
157 process = process_create(platform);
158 process->path = "nvram";
159 process->argv = argv;
160 process->keep_stdout = true;
162 rc = process_run_sync(process);
164 if (rc || !process_exit_ok(process)) {
165 fprintf(stderr, "nvram process returned "
166 "non-zero exit status\n");
169 rc = parse_nvram_params(platform, process->stdout_buf,
170 process->stdout_len);
173 process_release(process);
177 static int write_nvram(struct platform_powerpc *platform)
179 struct process *process;
185 argv[1] = "--update-config";
187 argv[3] = "--partition";
191 process = process_create(platform);
192 process->path = "nvram";
193 process->argv = argv;
195 list_for_each_entry(&platform->params, param, list) {
198 if (!param->modified)
201 paramstr = talloc_asprintf(platform, "%s=%s",
202 param->name, param->value);
205 rc = process_run_sync(process);
207 talloc_free(paramstr);
209 if (rc || !process_exit_ok(process)) {
211 pb_log("nvram update process returned "
212 "non-zero exit status\n");
217 process_release(process);
221 static const char *get_param(struct platform_powerpc *platform,
226 list_for_each_entry(&platform->params, param, list)
227 if (!strcmp(param->name, name))
232 static void set_param(struct platform_powerpc *platform, const char *name,
237 list_for_each_entry(&platform->params, param, list) {
238 if (strcmp(param->name, name))
241 if (!strcmp(param->value, value))
244 talloc_free(param->value);
245 param->value = talloc_strdup(param, value);
246 param->modified = true;
251 param = talloc(platform, struct param);
252 param->modified = true;
253 param->name = talloc_strdup(platform, name);
254 param->value = talloc_strdup(platform, value);
255 list_add(&platform->params, ¶m->list);
258 static int parse_hwaddr(struct interface_config *ifconf, char *str)
262 if (strlen(str) != strlen("00:00:00:00:00:00"))
265 for (i = 0; i < HWADDR_SIZE; i++) {
269 byte[0] = str[i * 3 + 0];
270 byte[1] = str[i * 3 + 1];
273 x = strtoul(byte, &endp, 16);
274 if (endp != byte + 2)
277 ifconf->hwaddr[i] = x & 0xff;
283 static int parse_one_interface_config(struct config *config,
286 struct interface_config *ifconf;
289 ifconf = talloc_zero(config, struct interface_config);
291 if (!confstr || !strlen(confstr))
294 /* first token should be the mac address */
295 tok = strtok_r(confstr, ",", &saveptr);
299 if (parse_hwaddr(ifconf, tok))
302 /* second token is the method */
303 tok = strtok_r(NULL, ",", &saveptr);
304 if (!tok || !strlen(tok) || !strcmp(tok, "ignore")) {
305 ifconf->ignore = true;
307 } else if (!strcmp(tok, "dhcp")) {
308 ifconf->method = CONFIG_METHOD_DHCP;
310 } else if (!strcmp(tok, "static")) {
311 ifconf->method = CONFIG_METHOD_STATIC;
313 /* ip/mask, [optional] gateway */
314 tok = strtok_r(NULL, ",", &saveptr);
317 ifconf->static_config.address =
318 talloc_strdup(ifconf, tok);
320 tok = strtok_r(NULL, ",", &saveptr);
322 ifconf->static_config.gateway =
323 talloc_strdup(ifconf, tok);
327 pb_log("Unknown network configuration method %s\n", tok);
331 config->network.interfaces = talloc_realloc(config,
332 config->network.interfaces,
333 struct interface_config *,
334 ++config->network.n_interfaces);
336 config->network.interfaces[config->network.n_interfaces - 1] = ifconf;
344 static int parse_one_dns_config(struct config *config,
347 char *tok, *saveptr = NULL;
349 for (tok = strtok_r(confstr, ",", &saveptr); tok;
350 tok = strtok_r(NULL, ",", &saveptr)) {
352 char *server = talloc_strdup(config, tok);
354 config->network.dns_servers = talloc_realloc(config,
355 config->network.dns_servers, const char *,
356 ++config->network.n_dns_servers);
358 config->network.dns_servers[config->network.n_dns_servers - 1]
365 static void populate_network_config(struct platform_powerpc *platform,
366 struct config *config)
368 char *val, *saveptr = NULL;
372 cval = get_param(platform, "petitboot,network");
373 if (!cval || !strlen(cval))
376 val = talloc_strdup(config, cval);
381 tok = strtok_r(i == 0 ? val : NULL, " ", &saveptr);
385 if (!strncasecmp(tok, "dns,", strlen("dns,")))
386 parse_one_dns_config(config, tok + strlen("dns,"));
388 parse_one_interface_config(config, tok);
395 static int read_bootdev(void *ctx, char **pos, struct autoboot_option *opt)
397 char *delim = strchr(*pos, ' ');
398 int len, prefix = 0, rc = -1;
399 enum device_type type;
401 if (!strncmp(*pos, "uuid:", strlen("uuid:"))) {
402 prefix = strlen("uuid:");
403 opt->boot_type = BOOT_DEVICE_UUID;
405 } else if (!strncmp(*pos, "mac:", strlen("mac:"))) {
406 prefix = strlen("mac:");
407 opt->boot_type = BOOT_DEVICE_UUID;
410 type = find_device_type(*pos);
411 if (type != DEVICE_TYPE_UNKNOWN) {
413 opt->boot_type = BOOT_DEVICE_TYPE;
418 if (opt->boot_type == BOOT_DEVICE_UUID) {
420 len = (int)(delim - *pos) - prefix;
424 opt->uuid = talloc_strndup(ctx, *pos + prefix, len);
427 /* Always advance pointer to next option or end */
431 *pos += strlen(*pos);
436 static void populate_bootdev_config(struct platform_powerpc *platform,
437 struct config *config)
439 struct autoboot_option *opt, *new = NULL;
440 char *pos, *end, *old_dev = NULL;
441 const char delim = ' ';
442 unsigned int n_new = 0;
446 /* Check for old-style bootdev */
447 val = get_param(platform, "petitboot,bootdev");
448 if (val && strlen(val)) {
449 pos = talloc_strdup(config, val);
450 if (!strncmp(val, "uuid:", strlen("uuid:")))
451 old_dev = talloc_strdup(config,
452 val + strlen("uuid:"));
453 else if (!strncmp(val, "mac:", strlen("mac:")))
454 old_dev = talloc_strdup(config,
455 val + strlen("mac:"));
458 /* Check for ordered bootdevs */
459 val = get_param(platform, "petitboot,bootdevs");
460 if (!val || !strlen(val)) {
463 pos = talloc_strdup(config, val);
464 end = strchr(pos, '\0');
467 while (pos && pos < end) {
468 opt = talloc(config, struct autoboot_option);
470 if (read_bootdev(config, &pos, opt)) {
471 pb_log("bootdev config is in an unknown format "
472 "(expected uuid:... or mac:...)");
474 if (strchr(pos, delim))
479 new = talloc_realloc(config, new, struct autoboot_option,
487 if (!n_new && !old_dev) {
488 /* If autoboot has been disabled, clear the default options */
489 if (!config->autoboot_enabled) {
490 talloc_free(config->autoboot_opts);
491 config->n_autoboot_opts = 0;
496 conflict = old_dev && (!n_new ||
497 new[0].boot_type == BOOT_DEVICE_TYPE ||
498 /* Canonical UUIDs are 36 characters long */
499 strncmp(new[0].uuid, old_dev, 36));
502 talloc_free(config->autoboot_opts);
503 config->autoboot_opts = new;
504 config->n_autoboot_opts = n_new;
509 * Difference detected, defer to old format in case it has been updated
512 pb_debug("Old autoboot bootdev detected\n");
513 talloc_free(config->autoboot_opts);
514 config->autoboot_opts = talloc(config, struct autoboot_option);
515 config->autoboot_opts[0].boot_type = BOOT_DEVICE_UUID;
516 config->autoboot_opts[0].uuid = talloc_strdup(config, old_dev);
517 config->n_autoboot_opts = 1;
520 static void populate_config(struct platform_powerpc *platform,
521 struct config *config)
525 unsigned long timeout;
527 /* if the "auto-boot?' property is present and "false", disable auto
529 val = get_param(platform, "auto-boot?");
530 config->autoboot_enabled = !val || strcmp(val, "false");
532 val = get_param(platform, "petitboot,timeout");
534 timeout = strtoul(val, &end, 10);
536 if (timeout >= INT_MAX)
538 config->autoboot_timeout_sec = (int)timeout;
542 val = get_param(platform, "petitboot,language");
543 config->lang = val ? talloc_strdup(config, val) : NULL;
545 populate_network_config(platform, config);
547 populate_bootdev_config(platform, config);
549 if (!config->debug) {
550 val = get_param(platform, "petitboot,debug?");
551 config->debug = val && !strcmp(val, "true");
554 val = get_param(platform, "petitboot,write?");
556 config->allow_writes = !strcmp(val, "true");
558 val = get_param(platform, "petitboot,snapshots?");
560 config->disable_snapshots = !strcmp(val, "false");
563 static char *iface_config_str(void *ctx, struct interface_config *config)
567 /* todo: HWADDR size is hardcoded as 6, but we may need to handle
568 * different hardware address formats */
569 str = talloc_asprintf(ctx, "%02x:%02x:%02x:%02x:%02x:%02x,",
570 config->hwaddr[0], config->hwaddr[1],
571 config->hwaddr[2], config->hwaddr[3],
572 config->hwaddr[4], config->hwaddr[5]);
574 if (config->ignore) {
575 str = talloc_asprintf_append(str, "ignore");
577 } else if (config->method == CONFIG_METHOD_DHCP) {
578 str = talloc_asprintf_append(str, "dhcp");
580 } else if (config->method == CONFIG_METHOD_STATIC) {
581 str = talloc_asprintf_append(str, "static,%s%s%s",
582 config->static_config.address,
583 config->static_config.gateway ? "," : "",
584 config->static_config.gateway ?: "");
589 static char *dns_config_str(void *ctx, const char **dns_servers, int n)
594 str = talloc_strdup(ctx, "dns,");
595 for (i = 0; i < n; i++) {
596 str = talloc_asprintf_append(str, "%s%s",
604 static void update_string_config(struct platform_powerpc *platform,
605 const char *name, const char *value)
609 cur = get_param(platform, name);
611 /* don't set an empty parameter if it doesn't already exist */
612 if (!cur && !strlen(value))
615 set_param(platform, name, value);
618 static void update_network_config(struct platform_powerpc *platform,
619 struct config *config)
624 val = talloc_strdup(platform, "");
626 for (i = 0; i < config->network.n_interfaces; i++) {
627 char *iface_str = iface_config_str(platform,
628 config->network.interfaces[i]);
629 val = talloc_asprintf_append(val, "%s%s",
630 *val == '\0' ? "" : " ", iface_str);
631 talloc_free(iface_str);
634 if (config->network.n_dns_servers) {
635 char *dns_str = dns_config_str(platform,
636 config->network.dns_servers,
637 config->network.n_dns_servers);
638 val = talloc_asprintf_append(val, "%s%s",
639 *val == '\0' ? "" : " ", dns_str);
640 talloc_free(dns_str);
643 update_string_config(platform, "petitboot,network", val);
648 static void update_bootdev_config(struct platform_powerpc *platform,
649 struct config *config)
651 char *val = NULL, *boot_str = NULL, *tmp = NULL, *first = NULL;
652 struct autoboot_option *opt;
653 const char delim = ' ';
656 if (!config->n_autoboot_opts)
658 else if (config->autoboot_opts[0].boot_type == BOOT_DEVICE_UUID)
659 first = talloc_asprintf(config, "uuid:%s",
660 config->autoboot_opts[0].uuid);
664 for (i = 0; i < config->n_autoboot_opts; i++) {
665 opt = &config->autoboot_opts[i];
666 switch (opt->boot_type) {
667 case BOOT_DEVICE_TYPE:
668 boot_str = talloc_asprintf(config, "%s%c",
669 device_type_name(opt->type),
672 case BOOT_DEVICE_UUID:
673 boot_str = talloc_asprintf(config, "uuid:%s%c",
677 tmp = val = talloc_asprintf_append(val, "%s", boot_str);
680 update_string_config(platform, "petitboot,bootdevs", val);
681 update_string_config(platform, "petitboot,bootdev", first);
684 talloc_free(boot_str);
687 static int update_config(struct platform_powerpc *platform,
688 struct config *config, struct config *defaults)
693 if (config->autoboot_enabled == defaults->autoboot_enabled)
696 val = config->autoboot_enabled ? "true" : "false";
697 update_string_config(platform, "auto-boot?", val);
699 if (config->autoboot_timeout_sec == defaults->autoboot_timeout_sec)
702 val = tmp = talloc_asprintf(platform, "%d",
703 config->autoboot_timeout_sec);
705 if (config->ipmi_bootdev == IPMI_BOOTDEV_INVALID &&
706 platform->clear_ipmi_bootdev) {
707 platform->clear_ipmi_bootdev(platform,
708 config->ipmi_bootdev_persistent);
709 config->ipmi_bootdev = IPMI_BOOTDEV_NONE;
710 config->ipmi_bootdev_persistent = false;
713 update_string_config(platform, "petitboot,timeout", val);
717 val = config->lang ?: "";
718 update_string_config(platform, "petitboot,language", val);
720 if (config->allow_writes == defaults->allow_writes)
723 val = config->allow_writes ? "true" : "false";
724 update_string_config(platform, "petitboot,write?", val);
726 update_network_config(platform, config);
728 update_bootdev_config(platform, config);
730 return write_nvram(platform);
733 static void set_ipmi_bootdev(struct config *config, enum ipmi_bootdev bootdev,
736 config->ipmi_bootdev = bootdev;
737 config->ipmi_bootdev_persistent = persistent;
740 case IPMI_BOOTDEV_NONE:
741 case IPMI_BOOTDEV_DISK:
742 case IPMI_BOOTDEV_NETWORK:
743 case IPMI_BOOTDEV_CDROM:
746 case IPMI_BOOTDEV_SETUP:
747 config->autoboot_enabled = false;
749 case IPMI_BOOTDEV_SAFE:
750 config->autoboot_enabled = false;
751 config->safe_mode = true;
756 static int read_bootdev_sysparam(const char *name, uint8_t *val)
762 assert(strlen(sysparams_dir) + strlen(name) < sizeof(path));
763 snprintf(path, sizeof(path), "%s%s", sysparams_dir, name);
765 fd = open(path, O_RDONLY);
767 pb_debug("powerpc: can't access sysparam %s\n",
772 rc = read(fd, buf, sizeof(buf));
776 /* bootdev definitions should only be one byte in size */
778 pb_debug("powerpc: sysparam %s read returned %d\n",
783 pb_debug("powerpc: sysparam %s: 0x%02x\n", name, buf[0]);
785 if (!ipmi_bootdev_is_valid(buf[0]))
792 static int write_bootdev_sysparam(const char *name, uint8_t val)
797 assert(strlen(sysparams_dir) + strlen(name) < sizeof(path));
798 snprintf(path, sizeof(path), "%s%s", sysparams_dir, name);
800 fd = open(path, O_WRONLY);
802 pb_debug("powerpc: can't access sysparam %s for writing\n",
809 rc = write(fd, &val, sizeof(val));
810 if (rc == sizeof(val)) {
815 if (rc <= 0 && errno != EINTR) {
816 pb_log("powerpc: error updating sysparam %s: %s",
817 name, strerror(errno));
826 pb_debug("powerpc: set sysparam %s: 0x%02x\n", name, val);
831 static int clear_ipmi_bootdev_sysparams(
832 struct platform_powerpc *platform __attribute__((unused)),
836 /* invalidate default-boot-device setting */
837 write_bootdev_sysparam("default-boot-device", 0xff);
839 /* invalidate next-boot-device setting */
840 write_bootdev_sysparam("next-boot-device", 0xff);
845 static int get_ipmi_bootdev_sysparams(
846 struct platform_powerpc *platform __attribute__((unused)),
847 uint8_t *bootdev, bool *persistent)
849 uint8_t next_bootdev, default_bootdev;
850 bool next_valid, default_valid;
853 rc = read_bootdev_sysparam("next-boot-device", &next_bootdev);
854 next_valid = rc == 0;
856 rc = read_bootdev_sysparam("default-boot-device", &default_bootdev);
857 default_valid = rc == 0;
859 /* nothing valid? no need to change the config */
860 if (!next_valid && !default_valid)
863 *persistent = !next_valid;
864 *bootdev = next_valid ? next_bootdev : default_bootdev;
868 static int clear_ipmi_bootdev_ipmi(struct platform_powerpc *platform,
869 bool persistent __attribute__((unused)))
874 0x05, /* parameter selector: boot flags */
875 0x80, /* data 1: valid */
876 0x00, /* data 2: bootdev: no override */
877 0x00, /* data 3: system defaults */
878 0x00, /* data 4: no request for shared mode, mux defaults */
879 0x00, /* data 5: no instance request */
882 resp_len = sizeof(resp);
884 ipmi_transaction(platform->ipmi, IPMI_NETFN_CHASSIS,
885 IPMI_CMD_CHASSIS_SET_SYSTEM_BOOT_OPTIONS,
892 static int get_ipmi_bootdev_ipmi(struct platform_powerpc *platform,
893 uint8_t *bootdev, bool *persistent)
899 0x05, /* parameter selector: boot flags */
900 0x00, /* no set selector */
901 0x00, /* no block selector */
904 resp_len = sizeof(resp);
905 rc = ipmi_transaction(platform->ipmi, IPMI_NETFN_CHASSIS,
906 IPMI_CMD_CHASSIS_GET_SYSTEM_BOOT_OPTIONS,
911 pb_log("platform: error reading IPMI boot options\n");
915 if (resp_len != sizeof(resp)) {
916 pb_log("platform: unexpected length (%d) in "
917 "boot options response\n", resp_len);
922 pb_log("platform: non-zero completion code %d from IPMI req\n",
927 /* check for correct parameter version */
928 if ((resp[1] & 0xf) != 0x1) {
929 pb_log("platform: unexpected version (0x%x) in "
930 "boot options response\n", resp[0]);
934 /* check for valid paramters */
935 if (resp[2] & 0x80) {
936 pb_debug("platform: boot options are invalid/locked\n");
942 /* check for valid flags */
943 if (!(resp[3] & 0x80)) {
944 pb_debug("platform: boot flags are invalid, ignoring\n");
948 *persistent = resp[3] & 0x40;
949 *bootdev = (resp[4] >> 2) & 0x0f;
953 static int set_ipmi_os_boot_sensor(struct platform_powerpc *platform)
959 0x00, /* sensor number: os boot */
960 0xA9, /* operation: set everything */
961 0x00, /* sensor reading: none */
962 0x40, /* assertion mask lsb: set state 6 */
963 0x00, /* assertion mask msb: none */
964 0x00, /* deassertion mask lsb: none */
965 0x00, /* deassertion mask msb: none */
966 0x00, /* event data 1: none */
967 0x00, /* event data 2: none */
968 0x00, /* event data 3: none */
971 sensor_number = get_ipmi_sensor(platform, IPMI_SENSOR_ID_OS_BOOT);
972 if (sensor_number < 0) {
973 pb_log("Couldn't find OS boot sensor in device tree\n");
977 req[0] = sensor_number;
979 resp_len = sizeof(resp);
981 ipmi_transaction(platform->ipmi, IPMI_NETFN_SE,
985 ipmi_timeout); return 0;
990 static void get_ipmi_bmc_mac(struct platform *p, uint8_t *buf)
992 struct platform_powerpc *platform = p->platform_data;
993 uint16_t resp_len = 8;
995 uint8_t req[] = { 0x1, 0x5, 0x0, 0x0 };
998 rc = ipmi_transaction(platform->ipmi, IPMI_NETFN_TRANSPORT,
999 IPMI_CMD_TRANSPORT_GET_LAN_PARAMS,
1004 pb_debug("BMC MAC resp [%d][%d]:\n", rc, resp_len);
1006 if (rc == 0 && resp_len > 0) {
1007 for (i = 2; i < resp_len; i++) {
1008 pb_debug(" %x", resp[i]);
1009 buf[i - 2] = resp[i];
1015 static int load_config(struct platform *p, struct config *config)
1017 struct platform_powerpc *platform = to_platform_powerpc(p);
1020 rc = parse_nvram(platform);
1024 populate_config(platform, config);
1026 if (platform->get_ipmi_bootdev) {
1027 bool bootdev_persistent;
1029 rc = platform->get_ipmi_bootdev(platform, &bootdev,
1030 &bootdev_persistent);
1031 if (!rc && ipmi_bootdev_is_valid(bootdev)) {
1032 set_ipmi_bootdev(config, bootdev, bootdev_persistent);
1039 static int save_config(struct platform *p, struct config *config)
1041 struct platform_powerpc *platform = to_platform_powerpc(p);
1042 struct config *defaults;
1045 defaults = talloc_zero(platform, struct config);
1046 config_set_defaults(defaults);
1048 rc = update_config(platform, config, defaults);
1050 talloc_free(defaults);
1054 static void pre_boot(struct platform *p, const struct config *config)
1056 struct platform_powerpc *platform = to_platform_powerpc(p);
1058 if (!config->ipmi_bootdev_persistent && platform->clear_ipmi_bootdev)
1059 platform->clear_ipmi_bootdev(platform, false);
1061 if (platform->set_os_boot_sensor)
1062 platform->set_os_boot_sensor(platform);
1065 static int get_sysinfo(struct platform *p, struct system_info *sysinfo)
1067 struct platform_powerpc *platform = p->platform_data;
1068 char *buf, *filename;
1071 filename = talloc_asprintf(platform, "%smodel", devtree_dir);
1072 rc = read_file(platform, filename, &buf, &len);
1074 sysinfo->type = talloc_steal(sysinfo, buf);
1075 talloc_free(filename);
1077 filename = talloc_asprintf(platform, "%ssystem-id", devtree_dir);
1078 rc = read_file(platform, filename, &buf, &len);
1080 sysinfo->identifier = talloc_steal(sysinfo, buf);
1081 talloc_free(filename);
1083 sysinfo->bmc_mac = talloc_zero_size(sysinfo, HWADDR_SIZE);
1085 get_ipmi_bmc_mac(p, sysinfo->bmc_mac);
1090 static bool probe(struct platform *p, void *ctx)
1092 struct platform_powerpc *platform;
1093 struct stat statbuf;
1096 /* we need a device tree */
1097 rc = stat("/proc/device-tree", &statbuf);
1101 if (!S_ISDIR(statbuf.st_mode))
1104 platform = talloc_zero(ctx, struct platform_powerpc);
1105 list_init(&platform->params);
1107 p->platform_data = platform;
1109 if (ipmi_present()) {
1110 pb_debug("platform: using direct IPMI for IPMI paramters\n");
1111 platform->ipmi = ipmi_open(platform);
1112 platform->get_ipmi_bootdev = get_ipmi_bootdev_ipmi;
1113 platform->clear_ipmi_bootdev = clear_ipmi_bootdev_ipmi;
1114 platform->set_os_boot_sensor = set_ipmi_os_boot_sensor;
1115 } else if (!stat(sysparams_dir, &statbuf)) {
1116 pb_debug("platform: using sysparams for IPMI paramters\n");
1117 platform->get_ipmi_bootdev = get_ipmi_bootdev_sysparams;
1118 platform->clear_ipmi_bootdev = clear_ipmi_bootdev_sysparams;
1121 pb_log("platform: no IPMI parameter support\n");
1128 static struct platform platform_powerpc = {
1130 .dhcp_arch_id = 0x000e,
1132 .load_config = load_config,
1133 .save_config = save_config,
1134 .pre_boot = pre_boot,
1135 .get_sysinfo = get_sysinfo,
1138 register_platform(platform_powerpc);