Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/631984/?format=api
{ "id": 631984, "url": "http://patchwork.ozlabs.org/api/patches/631984/?format=api", "web_url": "http://patchwork.ozlabs.org/project/petitboot/patch/20160608062812.14480-7-sam@mendozajonas.com/", "project": { "id": 53, "url": "http://patchwork.ozlabs.org/api/projects/53/?format=api", "name": "Petitboot development", "link_name": "petitboot", "list_id": "petitboot.lists.ozlabs.org", "list_email": "petitboot@lists.ozlabs.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20160608062812.14480-7-sam@mendozajonas.com>", "list_archive_url": null, "date": "2016-06-08T06:28:12", "name": "[6/6] utils/hooks: Set linux,stdout-path for primary console", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "5e57cfeccb23b2367bb56103a093a93825a0c8a2", "submitter": { "id": 68013, "url": "http://patchwork.ozlabs.org/api/people/68013/?format=api", "name": "Sam Mendoza-Jonas", "email": "sam@mendozajonas.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/petitboot/patch/20160608062812.14480-7-sam@mendozajonas.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/631984/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/631984/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "petitboot@lists.ozlabs.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "petitboot@lists.ozlabs.org" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3rPdn62rqwz9sCg\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 8 Jun 2016 16:28:58 +1000 (AEST)", "from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3rPdn61kq3zDqV3\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 8 Jun 2016 16:28:58 +1000 (AEST)", "from mendozajonas.com (mendozajonas.com [188.166.185.233])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3rPdmf6CHDzDq5m\n\tfor <petitboot@lists.ozlabs.org>;\n\tWed, 8 Jun 2016 16:28:33 +1000 (AEST)", "from skellige.ozlabs.ibm.com (unknown [122.99.82.10])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (Client did not present a certificate)\n\t(Authenticated sender: sam@mendozajonas.com)\n\tby mendozajonas.com (Postfix) with ESMTPSA id 020EA1442E9\n\tfor <petitboot@lists.ozlabs.org>;\n\tWed, 8 Jun 2016 14:28:28 +0800 (SGT)" ], "Authentication-Results": [ "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=mendozajonas.com header.i=@mendozajonas.com\n\theader.b=oqaCjET4; dkim-atps=neutral", "lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=mendozajonas.com header.i=@mendozajonas.com\n\theader.b=oqaCjET4; dkim-atps=neutral", "lists.ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=mendozajonas.com header.i=@mendozajonas.com\n\theader.b=oqaCjET4; dkim-atps=neutral" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=mendozajonas.com;\n\ts=mail; t=1465367309;\n\tbh=BT0fywc6Dscr27vvR7AxcIPqn2gyWvJiJikujPoj+iE=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=oqaCjET4Gs4NiWUUTYzM+ZepAStaQOF4cSaL60a2Tf2npHM5lgQ+PK29TDtKGVhq9\n\trflBhmSgBQPpVNF4Fo4S5r05tWFAZN3LG75xbVqvvSTylLFuQD4/5jZWfBt9KoROam\n\tomc66TxYbEBegk9DxAuSmrb1ccoUQ857/6ov8hMM=", "From": "Samuel Mendoza-Jonas <sam@mendozajonas.com>", "To": "petitboot@lists.ozlabs.org", "Subject": "[PATCH 6/6] utils/hooks: Set linux,stdout-path for primary console", "Date": "Wed, 8 Jun 2016 16:28:12 +1000", "Message-Id": "<20160608062812.14480-7-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 <petitboot.lists.ozlabs.org>", "List-Unsubscribe": "<https://lists.ozlabs.org/options/petitboot>,\n\t<mailto:petitboot-request@lists.ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://lists.ozlabs.org/pipermail/petitboot/>", "List-Post": "<mailto:petitboot@lists.ozlabs.org>", "List-Help": "<mailto:petitboot-request@lists.ozlabs.org?subject=help>", "List-Subscribe": "<https://lists.ozlabs.org/listinfo/petitboot>,\n\t<mailto:petitboot-request@lists.ozlabs.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org", "Sender": "\"Petitboot\"\n\t<petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>" }, "content": "If the boot_tty environment variable is set, determine which device path\nto set in the linux,stdout-path property, which will instruct the next\nkernel to use it as the primary console.\n\nSigned-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>\n---\n utils/hooks/30-add-offb.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 120 insertions(+)", "diff": "diff --git a/utils/hooks/30-add-offb.c b/utils/hooks/30-add-offb.c\nindex c635409..cc88922 100644\n--- a/utils/hooks/30-add-offb.c\n+++ b/utils/hooks/30-add-offb.c\n@@ -9,6 +9,7 @@\n #include <string.h>\n #include <stdbool.h>\n #include <inttypes.h>\n+#include <errno.h>\n \n #include <linux/fb.h>\n \n@@ -441,6 +442,121 @@ static int populate_devicetree(struct offb_ctx *ctx)\n \treturn 0;\n }\n \n+/*\n+ * Find the device tree path assoicated with a hvc device.\n+ * On OPAL all hvc consoles have a 'serial@X' node under ibm,opal/consoles,\n+ * so we make a simplifying assumption that a hvcX is associated with a\n+ * serial@X node.\n+ */\n+static char *get_hvc_path(struct offb_ctx *ctx, unsigned int termno)\n+{\n+\tchar *serial;\n+\tint node;\n+\n+\tserial = talloc_asprintf(ctx, \"serial@%u\", termno);\n+\tif (!serial)\n+\t\treturn NULL;\n+\n+\tnode = fdt_subnode_offset(ctx->dtb, 0, \"ibm,opal\");\n+\tif (node <= 0) {\n+\t\tfprintf(stderr, \"Couldn't find ibm,opal\\n\");\n+\t\treturn NULL;\n+\t}\n+\tnode = fdt_subnode_offset(ctx->dtb, node, \"consoles\");\n+\tif (node <= 0) {\n+\t\tfprintf(stderr, \"Couldn't find ibm,opal/consoles\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\tnode = fdt_subnode_offset(ctx->dtb, node, serial);\n+\tif (node <= 0) {\n+\t\tfprintf(stderr, \"Could not locate hvc%u\\n\", termno);\n+\t\treturn NULL;\n+\t}\n+\n+\treturn talloc_asprintf(ctx, \"ibm,opal/consoles/%s\", serial);\n+}\n+\n+/*\n+ * Find the device tree path of the vga device. On OPAL we assume there is only\n+ * one of these that represents any 'tty' console.\n+ */\n+static char *get_vga_path(struct offb_ctx *ctx)\n+{\n+\tchar *root, *vga_path;\n+\n+\troot = strstr(ctx->path, \"/pciex@\");\n+\tif (!root) {\n+\t\tfprintf(stderr, \"Can't find root path for vga device in below:\\n\");\n+\t\t\tfprintf(stderr, \"%s\\n\", ctx->path);\n+\t\treturn NULL;\n+\t}\n+\n+\tvga_path = talloc_strdup(ctx, root);\n+\tfprintf(stderr, \"VGA target at '%s'\\n\", vga_path);\n+\n+\treturn vga_path;\n+}\n+\n+static int set_stdout(struct offb_ctx *ctx)\n+{\n+\tconst char *boot_tty, *ptr;\n+\tlong unsigned int termno;\n+\tconst fdt32_t *prop;\n+\tint node, prop_len;\n+\tchar *stdout_path;\n+\n+\tboot_tty = getenv(\"boot_tty\");\n+\tif (!boot_tty) {\n+\t\tfprintf(stderr, \"boot_tty not set, using default stdout for boot\\n\");\n+\t\treturn 0;\n+\t}\n+\n+\tif (strstr(boot_tty, \"tty\") != NULL) {\n+\t\tfprintf(stderr, \"TTY recognised: %s\\n\", boot_tty);\n+\t\tstdout_path = get_vga_path(ctx);\n+\t} else {\n+\t\tptr = strstr(boot_tty, \"hvc\");\n+\t\tif (!ptr || strlen(ptr) <= strlen(\"hvc\")) {\n+\t\t\tfprintf(stderr, \"Unrecognised console: %s\\n\", boot_tty);\n+\t\t\treturn 0;\n+\t\t}\n+\t\tptr += strlen(\"hvc\");\n+\t\terrno = 0;\n+\t\ttermno = strtoul(ptr, NULL, 0);\n+\t\tif (errno) {\n+\t\t\tfprintf(stderr, \"Couldn't parse termno from %s\\n\", boot_tty);\n+\t\t\treturn 0;\n+\t\t}\n+\t\tfprintf(stderr, \"HVC recognised: %s\\n\", boot_tty);\n+\t\tstdout_path = get_hvc_path(ctx, termno);\n+\t}\n+\n+\tif (!stdout_path) {\n+\t\tfprintf(stderr, \"Couldn't parse %s into a path\", boot_tty);\n+\t\treturn -1;\n+\t}\n+\n+\tfprintf(stderr, \"stdout-path: %s\", stdout_path);\n+\n+\tnode = fdt_subnode_offset(ctx->dtb, 0, \"chosen\");\n+\tif (node <= 0) {\n+\t\tfprintf(stderr, \"Failed to find chosen\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tprop = fdt_getprop(ctx->dtb, node, \"linux,stdout-path\", &prop_len);\n+\tif (!prop) {\n+\t\tfprintf(stderr, \"Failed to find linux,stdout-path\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tfdt_set_check(ctx->dtb, node, fdt_setprop_string, \"linux,stdout-path\",\n+\t\t\tstdout_path);\n+\n+\treturn 0;\n+}\n+\n static int write_devicetree(struct offb_ctx *ctx)\n {\n \tint rc;\n@@ -484,6 +600,10 @@ int main(void)\n \tif (rc)\n \t\tgoto out;\n \n+\trc = set_stdout(ctx);\n+\tif (rc)\n+\t\tgoto out;\n+\n \trc = write_devicetree(ctx);\n \n out:\n", "prefixes": [ "6/6" ] }