X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fplatform-powerpc.c;h=57618c3592bc5922c395de72e0fb6b9a411a5cf6;hp=0e3a10b29d0de2247bb7593fb90844365bad42f1;hb=9f42e56fc5968fcb34edfad017adb73960c2bb61;hpb=11284780b9aa525dd659bd85d6374040630db008 diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 0e3a10b..57618c3 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_console = talloc_strdup(config, val); } static char *iface_config_str(void *ctx, struct interface_config *config) @@ -630,6 +635,15 @@ static void update_network_config(struct platform_powerpc *platform, unsigned int i; char *val; + /* + * Don't store IPMI overrides to NVRAM. If this was a persistent + * override it was already stored in NVRAM by + * get_ipmi_network_override() + */ + if (config->network.n_interfaces && + config->network.interfaces[0]->override) + return; + val = talloc_strdup(platform, ""); for (i = 0; i < config->network.n_interfaces; i++) { @@ -732,6 +746,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_console ?: ""; + update_string_config(platform, "petitboot,tty", val); + update_network_config(platform, config); update_bootdev_config(platform, config); @@ -956,7 +973,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; @@ -1066,7 +1083,7 @@ static void get_ipmi_bmc_versions(struct platform *p, struct system_info *info) bcd += 10 * (resp[4] >> 4); memcpy(&aux_version, &resp[12], sizeof(aux_version)); info->bmc_current[2] = talloc_asprintf(info, - "Firmware version: %u.%02u.%u", + "Firmware version: %u.%02u.%05u", resp[3], bcd, aux_version); bcd = resp[5] & 0x0f; bcd += 10 * (resp[5] >> 4); @@ -1121,6 +1138,7 @@ static void get_ipmi_network_override(struct platform_powerpc *platform, const uint32_t magic_value = 0x21706221; uint8_t resp[resp_len]; uint32_t cookie; + bool persistent; int i, rc; uint8_t req[] = { 0x61, /* parameter selector: OEM section (network) */ @@ -1169,18 +1187,21 @@ static void get_ipmi_network_override(struct platform_powerpc *platform, return; } - /* Check for valid parameters. For now ignore the persistent flag */ + /* Check that the parameters are valid */ if (resp[2] & 0x80) { pb_debug("platform: network override is invalid/locked\n"); return; } - /* Check for valid parameters in the boot flags section, ignoring the - * persistent bit */ + /* Check for valid parameters in the boot flags section */ if (!(resp[3] & 0x80)) { pb_debug("platform: network override valid flag not set\n"); return; } + /* Read the persistent flag; if it is set we need to save this config */ + persistent = resp[3] & 0x40; + if (persistent) + pb_debug("platform: network override is persistent\n"); /* Check 4-byte cookie value */ i = 4; @@ -1202,7 +1223,48 @@ static void get_ipmi_network_override(struct platform_powerpc *platform, } /* Interpret the rest of the interface config */ - parse_ipmi_interface_override(config, &resp[i], resp_len - i); + rc = parse_ipmi_interface_override(config, &resp[i], resp_len - i); + + if (!rc && persistent) { + /* Write this new config to NVRAM */ + update_network_config(platform, config); + rc = write_nvram(platform); + if (rc) + pb_log("platform: Failed to save persistent interface override\n"); + } +} + +static void get_active_consoles(struct config *config) +{ + struct stat sbuf; + char *fsp_prop = NULL; + + config->n_consoles = 2; + config->consoles = talloc_array(config, char *, config->n_consoles); + if (!config->consoles) + goto err; + + config->consoles[0] = talloc_asprintf(config->consoles, + "/dev/hvc0 [IPMI / Serial]"); + config->consoles[1] = talloc_asprintf(config->consoles, + "/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->consoles = talloc_realloc(config, config->consoles, + char *, config->n_consoles + 1); + if (!config->consoles) + goto err; + config->consoles[config->n_consoles++] = talloc_asprintf( + config->consoles, + "/dev/hvc1 [Serial]"); + } + + return; +err: + config->n_consoles = 0; + pb_log("Failed to allocate memory for consoles\n"); } static int load_config(struct platform *p, struct config *config) @@ -1218,7 +1280,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)) { @@ -1229,6 +1291,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; } @@ -1293,6 +1357,7 @@ static bool probe(struct platform *p, void *ctx) { struct platform_powerpc *platform; struct stat statbuf; + bool bmc_present; int rc; /* we need a device tree */ @@ -1308,7 +1373,9 @@ static bool probe(struct platform *p, void *ctx) p->platform_data = platform; - if (ipmi_present()) { + bmc_present = stat("/proc/device-tree/bmc", &statbuf) == 0; + + if (ipmi_present() && bmc_present) { pb_debug("platform: using direct IPMI for IPMI paramters\n"); platform->ipmi = ipmi_open(platform); platform->get_ipmi_bootdev = get_ipmi_bootdev_ipmi; @@ -1323,8 +1390,7 @@ static bool probe(struct platform *p, void *ctx) pb_log("platform: no IPMI parameter support\n"); } - rc = stat("/proc/device-tree/bmc", &statbuf); - if (!rc) + if (bmc_present) platform->get_platform_versions = hostboot_load_versions; return true;