X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fplatform-powerpc.c;h=eb54c6dddf231d73a5f1f1965f76703f7967d471;hp=19613045f60a4d94e592a07c98a120a0e1a39bd4;hb=ce54f86;hpb=7b7c45a42d9a46e15109f1cbab460e0b97c53f57 diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 1961304..eb54c6d 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -59,6 +59,7 @@ static const char *known_params[] = { "petitboot,debug?", "petitboot,write?", "petitboot,snapshots?", + "petitboot,tty", NULL, }; @@ -565,6 +566,10 @@ static void populate_config(struct platform_powerpc *platform, val = get_param(platform, "petitboot,snapshots?"); if (val) config->disable_snapshots = !strcmp(val, "false"); + + val = get_param(platform, "petitboot,tty"); + if (val) + config->boot_tty = talloc_strdup(config, val); } static char *iface_config_str(void *ctx, struct interface_config *config) @@ -732,6 +737,9 @@ static int update_config(struct platform_powerpc *platform, val = config->allow_writes ? "true" : "false"; update_string_config(platform, "petitboot,write?", val); + val = config->boot_tty ?: ""; + update_string_config(platform, "petitboot,tty", val); + update_network_config(platform, config); update_bootdev_config(platform, config); @@ -956,7 +964,7 @@ static int get_ipmi_bootdev_ipmi(struct platform_powerpc *platform, /* check for valid flags */ if (!(resp[3] & 0x80)) { pb_debug("platform: boot flags are invalid, ignoring\n"); - return 0; + return -1; } *persistent = resp[3] & 0x40; @@ -1217,6 +1225,39 @@ static void get_ipmi_network_override(struct platform_powerpc *platform, } } +static void get_active_consoles(struct config *config) +{ + struct stat sbuf; + char *fsp_prop = NULL; + + config->n_tty = 2; + config->tty_list = talloc_array(config, char *, config->n_tty); + if (!config->tty_list) + goto err; + + config->tty_list[0] = talloc_asprintf(config->tty_list, + "/dev/hvc0 [IPMI / Serial]"); + config->tty_list[1] = talloc_asprintf(config->tty_list, + "/dev/tty1 [VGA]"); + + fsp_prop = talloc_asprintf(config, "%sfsps", devtree_dir); + if (stat(fsp_prop, &sbuf) == 0) { + /* FSP based machines also have a separate serial console */ + config->tty_list = talloc_realloc(config, config->tty_list, + char *, config->n_tty + 1); + if (!config->tty_list) + goto err; + config->tty_list[config->n_tty++] = talloc_asprintf( + config->tty_list, + "/dev/hvc1 [Serial]"); + } + + return; +err: + config->n_tty = 0; + pb_log("Failed to allocate memory for tty_list\n"); +} + static int load_config(struct platform *p, struct config *config) { struct platform_powerpc *platform = to_platform_powerpc(p); @@ -1230,7 +1271,7 @@ static int load_config(struct platform *p, struct config *config) if (platform->get_ipmi_bootdev) { bool bootdev_persistent; - uint8_t bootdev; + uint8_t bootdev = IPMI_BOOTDEV_INVALID; rc = platform->get_ipmi_bootdev(platform, &bootdev, &bootdev_persistent); if (!rc && ipmi_bootdev_is_valid(bootdev)) { @@ -1241,6 +1282,8 @@ static int load_config(struct platform *p, struct config *config) if (platform->ipmi) get_ipmi_network_override(platform, config); + get_active_consoles(config); + return 0; }