From patchwork Wed Jun 8 06:28:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 631981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rPdmp1WSdz9sCg for ; Wed, 8 Jun 2016 16:28:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=ZSSbnzn+; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rPdmp058wzDqGc for ; Wed, 8 Jun 2016 16:28:42 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=ZSSbnzn+; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from mendozajonas.com (mendozajonas.com [188.166.185.233]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rPdmX5X2czDq5v for ; Wed, 8 Jun 2016 16:28:28 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=ZSSbnzn+; dkim-atps=neutral Received: from skellige.ozlabs.ibm.com (unknown [122.99.82.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: sam@mendozajonas.com) by mendozajonas.com (Postfix) with ESMTPSA id 71F3B143F73 for ; Wed, 8 Jun 2016 14:28:25 +0800 (SGT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mendozajonas.com; s=mail; t=1465367305; bh=5kHRIxdzrpf8DEsz3rpqmRh1nooS50vQHrwizRccfIU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZSSbnzn+/+qxxzbX7h99Irgz5bCoM6zCqZZeFAYGvHp624kHyGOJTVNLBDg9AzG6c OwGGobk/l4yvPVWFfL3kxny4tcbboF8ppAj8t4R6FbqvvaTuU5VGeTRvZBkRyNDqEL 4b0AugvUhWxuHtzcWkyI9tzg3hHWj2XpC+dpznWo= From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH 2/6] discover: Add petitboot, tty and track available consoles Date: Wed, 8 Jun 2016 16:28:08 +1000 Message-Id: <20160608062812.14480-3-sam@mendozajonas.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160608062812.14480-1-sam@mendozajonas.com> References: <20160608062812.14480-1-sam@mendozajonas.com> X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Add the NVRAM parameter petitboot,tty which sets the default console to use when booting a kernel. In load_config() construct a list of available consoles depending on the current platform. A future patch depending on firmware changes will allow this list to be constructed dynamically. Signed-off-by: Samuel Mendoza-Jonas --- discover/platform-powerpc.c | 43 +++++++++++++++++++++++++++++++++++++++++++ discover/platform.c | 10 ++++++++++ 2 files changed, 53 insertions(+) diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 1961304..3956a7e 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); @@ -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, + "IPMI: /dev/hvc0"); + config->tty_list[1] = talloc_asprintf(config->tty_list, + "VGA: /dev/tty1"); + + 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, + "Serial: /dev/hvc1"); + } + + 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); @@ -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; } diff --git a/discover/platform.c b/discover/platform.c index fc0930d..254da97 100644 --- a/discover/platform.c +++ b/discover/platform.c @@ -79,6 +79,12 @@ static void dump_config(struct config *config) pb_log(" IPMI boot device 0x%02x%s\n", config->ipmi_bootdev, config->ipmi_bootdev_persistent ? " (persistent)" : ""); + pb_log(" Modifications allowed to disks: %s\n", + config->allow_writes ? "yes" : "no"); + + pb_log(" Default UI to boot on: %s\n", + config->boot_tty ?: "none set"); + pb_log(" language: %s\n", config->lang ?: ""); } @@ -117,6 +123,10 @@ void config_set_defaults(struct config *config) config->allow_writes = true; config->disable_snapshots = false; + config->n_tty = 0; + config->tty_list = NULL; + config->boot_tty = NULL; + config->n_autoboot_opts = 2; config->autoboot_opts = talloc_array(config, struct autoboot_option, config->n_autoboot_opts);