Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1600621/?format=api
{ "id": 1600621, "url": "http://patchwork.ozlabs.org/api/patches/1600621/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20220303204400.2787389-16-sean.anderson@seco.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20220303204400.2787389-16-sean.anderson@seco.com>", "list_archive_url": null, "date": "2022-03-03T20:43:58", "name": "[15/17] serial: Add semihosting driver", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "14fd077eb0b5534623cdc58138a26a5058cc1b05", "submitter": { "id": 80860, "url": "http://patchwork.ozlabs.org/api/people/80860/?format=api", "name": "Sean Anderson", "email": "sean.anderson@seco.com" }, "delegate": { "id": 3651, "url": "http://patchwork.ozlabs.org/api/users/3651/?format=api", "username": "trini", "first_name": "Tom", "last_name": "Rini", "email": "trini@ti.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20220303204400.2787389-16-sean.anderson@seco.com/mbox/", "series": [ { "id": 288836, "url": "http://patchwork.ozlabs.org/api/series/288836/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=288836", "date": "2022-03-03T20:43:44", "name": "arm: semihosting: Cleanups and new features", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/288836/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1600621/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1600621/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "bilbo.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256\n header.s=selector1 header.b=rXQePz5B;\n\tdkim-atps=neutral", "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)", "phobos.denx.de;\n dmarc=pass (p=reject dis=none) header.from=seco.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=seco.com header.i=@seco.com header.b=\"rXQePz5B\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=pass (p=reject dis=none) header.from=seco.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=sean.anderson@seco.com", "dkim=none (message not signed)\n header.d=none;dmarc=none action=none header.from=seco.com;" ], "Received": [ "from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits))\n\t(No client certificate requested)\n\tby bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8jjm178xz9sG1\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 4 Mar 2022 07:47:56 +1100 (AEDT)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id B666983CEE;\n\tThu, 3 Mar 2022 21:45:36 +0100 (CET)", "by phobos.denx.de (Postfix, from userid 109)\n id C3A9E83CB4; Thu, 3 Mar 2022 21:44:58 +0100 (CET)", "from EUR03-AM5-obe.outbound.protection.outlook.com\n (mail-am5eur03on0613.outbound.protection.outlook.com\n [IPv6:2a01:111:f400:fe08::613])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id C6CEF83D29\n for <u-boot@lists.denx.de>; Thu, 3 Mar 2022 21:44:37 +0100 (CET)", "from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27)\n by VI1PR03MB4893.eurprd03.prod.outlook.com (2603:10a6:803:ba::33) with\n Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.25; Thu, 3 Mar\n 2022 20:44:36 +0000", "from DB7PR03MB4523.eurprd03.prod.outlook.com\n ([fe80::9130:93ae:6e27:e9a]) by DB7PR03MB4523.eurprd03.prod.outlook.com\n ([fe80::9130:93ae:6e27:e9a%4]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022\n 20:44:35 +0000" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS,\n T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2", "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n b=nMgLP7zUUCQRY6AWYyPPV8+crTPDxaqNfCpz8gpJeTYPF7qqPH8TvMr1nISA7w3Ce/5s8uyi3p/oOulSMemjXeu4LEx9ChvvnzdDyDqC3jkHDLSDsxy3ur6e2b+zMnin225dhjT0Ti25DxM3t09/dK4IS3S6YJPGs3z8247faEDuCH3GiR76K5XRn+nFYaZjKDvc3Z5Nbm8OgGMVF4z38kn7Uw9jZ6c2aMQA1QlA6DbEcAsCUDscX1ZaKb6/YJMo3k+Ry8rTAb1uLlzO2WtMTAqIHzfppiotJmXlEIO0nLDLALpO0pYK6oV57oML+oeA5qJP8T5kR6+J2gnoUTK84w==", "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector9901;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=QqNAf3eNqX3h2KwiRu7YiG5A6yxNq1+cF4f1MJy8ZGA=;\n b=aZVGiXI5xiFdkrOL/LfB5YTYtynHxI52Ppzh04BSc1hTyd8auC0cggiifTNnP4CT2BRV6K5YqrhbEnZKIrDjju/mAAjy4Ponc5n8klBc76uc5bgRViemIz169pcvbRzXNz5hawNbEkwWD+2JnmUdBKTpmS6O+1bjdslPt8IOxRITk5J3hLM/J/nKwpLT8uCuLejLWq+obgvPWM+zRF/pgnPSTj3dCZny2xUy8GDKRHabB1tPPLC6K0m7xtOD08SamAjtLMMCWEFFmDxZ528zfAZwzrEgNAtLOSv9h2BaCm3e/BnhUlkThmBo0Ggyctw2lQButEv5oyoTCMoTvB8nUA==", "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass\n smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com;\n dkim=pass header.d=seco.com; arc=none", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=QqNAf3eNqX3h2KwiRu7YiG5A6yxNq1+cF4f1MJy8ZGA=;\n b=rXQePz5BEK1uU7NeSLM23ybhLPYfkOcNRmUMxBU0mFP/9mBxQe8V1DOE+Yj769hhgju4b3M/+ZxYQgtbkW5/+49n9Xrt6ibEMCcg1OCNUvrrRNol8fHgijrC1aIys4pdBPD0vBI5mveFpguivB7PNLMqNN6NMFLWyLrXybSQXDQImXTNPL4oZJi5CMY5TaNIEpntHmv4gFDL+YaoZfYfJC9Rx/gW9ZVSmTW0Dwofd/ibetTIMRgaqcXernengLVR8lhtJRndsgpkITyQi+3T8RoU7obeVXqsYKuM/ab+NmgzP1bS7Oko8e12TDvTrrvkYMD/Mf2/qCqhSHe3nzL5CA==", "From": "Sean Anderson <sean.anderson@seco.com>", "To": "Simon Glass <sjg@chromium.org>", "Cc": "Linus Walleij <linus.walleij@linaro.org>, Tom Rini <trini@konsulko.com>,\n u-boot@lists.denx.de, Sean Anderson <sean.anderson@seco.com>", "Subject": "[PATCH 15/17] serial: Add semihosting driver", "Date": "Thu, 3 Mar 2022 15:43:58 -0500", "Message-Id": "<20220303204400.2787389-16-sean.anderson@seco.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220303204400.2787389-1-sean.anderson@seco.com>", "References": "<20220303204400.2787389-1-sean.anderson@seco.com>", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain", "X-ClientProxiedBy": "MN2PR16CA0013.namprd16.prod.outlook.com\n (2603:10b6:208:134::26) To DB7PR03MB4523.eurprd03.prod.outlook.com\n (2603:10a6:10:19::27)", "MIME-Version": "1.0", "X-MS-PublicTrafficType": "Email", "X-MS-Office365-Filtering-Correlation-Id": "9218c72b-7bd3-44d5-fe3f-08d9fd56a0e4", "X-MS-TrafficTypeDiagnostic": "VI1PR03MB4893:EE_", "X-Microsoft-Antispam-PRVS": "\n <VI1PR03MB48936E20C553C311910E339496049@VI1PR03MB4893.eurprd03.prod.outlook.com>", "X-MS-Exchange-SenderADCheck": "1", "X-MS-Exchange-AntiSpam-Relay": "0", "X-Microsoft-Antispam": "BCL:0;", "X-Microsoft-Antispam-Message-Info": "\n Lgoe201I8zdL0sNQ7qghyyJrZWBhFcZuklNMoXPUKKhX5HmGAJxoixDudjmXmeTH8dFkEfRbiExfe91aGpUKrkIJrTrUUEBFvMHIy4K21Pk4n3zcX0/921fUCIdYzYFjtLg+I9d7ntwNXn9EM7G+TG4aH6z/zbE1Ug7vBIBTX2DnJUiaoUkjkM273Uzyb+cLJwQnWgVlaB2QVQdSIl2qNh5LEFgV9Egx9usvRa8Dw+W0daMbFmybUMSWrLok+ZjjDAH+wu2kBKXR3wHdCZHFc33TxeWmxEG3G4JFGFvsAXwiIsa6/XggRmFlNIT89h+if/m57cjRFp1G1iKcVJi0e+jWbSygRvW0pZncXGSQcExzuZsqLXW0L3GOgziqr9y98wCFIYISZkAmOaIxXRdk/3MSsbfGgIBnbHll2WfU3DMv24tt6ZjICVngl2qyiVeUbv2nJJoyOp2w8/irEEzbj/4v1e/wMLqrJpMiuZOqlT6cWPgFdlwzoSxsvtO534WFHQh3RuNRBxN5Cg4dp61mc3GUGHTDnMOgKzB1L0SDLSVrW25BnCzsDsUzzTfFgrH33Z56r7v//7AZegP18iznY2N90/cUX8TCzM1JcMixTu9Ktxn4hwjTazUMyqIiQGq0wHGl8YmMv59WD+4l/aq2mXCC52tP3FhpIzAk2NHmi3xiE3IerYUFdSQVsFc9cFv6YcHGQfYpUec8r/x5lbgg5A==", "X-Forefront-Antispam-Report": "CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE;\n SFS:(13230001)(366004)(38350700002)(38100700002)(44832011)(36756003)(2906002)(186003)(8936002)(26005)(5660300002)(508600001)(2616005)(8676002)(4326008)(107886003)(1076003)(83380400001)(52116002)(66946007)(66556008)(86362001)(66476007)(316002)(54906003)(6916009)(6506007)(6512007)(6666004)(6486002);\n DIR:OUT; SFP:1101;", "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1", "X-MS-Exchange-AntiSpam-MessageData-0": "\n 7lFdG9r1N/dPyuN+PR2UiIUPCRazOjyKpn5WyB2RQmUkgo+914Xc26ft1dLUNOJY7t5G014hv5PFNBFe/V32tFr1xTaLDiperJVBtIxiA7RV/mZG8DFvs3bNHQYiodN6zKxMLl54+ZBQIginldwBtjXt52m6QZRWlTM4jcbWX00/pMvdoZ204cvPkHktbM3xwS/idv8Yt9ewv923UEYqeGJENBTvdpPG9QTPt+xnOm7zkhu2bIulhOMenVZYmulfJx0faH/VxYvJ9yIZY1849W5U3tQsNEaCNkSadykV9ANbbLAu+yZtUMAtb+Vx5hEwBPH12Ut7ZU1nhC6Qhxh6Wg7/4wUvvOfyW7gTo5aT4P7G/76PubuyKA5rp1A5PGUQ5694X8nebiMEqlGKYtB35dUvOqM2v8Fc/LoqvtypUo6f065j2dBqfT7lPUBVPhY0A/8SkuMsHXN7Ueztvwm1I8vrkGY2dE2zU1FVit+3prkbHuk6PPZaAmRkrLL7KnNGdjJNK3wCFqB+Tv3Va2kLA0f4wIkY9FwD7WL/4TOmnbvBYc2/sDF5OBPAol7gpVhHJqFqX6pg6IJRe8CQalloFQB7QMI6OsUOwe7JdE71VnekBe3fgP9b+Nrz5cB1g4JEaA5R6pn+F6hKFRY8fHSIiRwv63tWOqVCqSrfsQTR0dqwOg/Izum3XKUSexP3t/3UCk9WTdW3uJZsZGebvVaq2M0qdJim17ZY5Ydqcg92OqQqFsTztRDJeP2z02x4MQ6E00Mb80FhFN2X0+R0Y0zHSdsAWoR1oXsKm0L1yXlMxUKpFQDvolZJoJNM0QiWyfmJHUhjgj4NK+dyPIuekCSiabP5L+EsUEdJ/GnzUNzNsbFZp3bKgLr59s8xhYOQHydy5CqfEyer55v17omZtPCNbAaYkfE4Ui2TL9gctl8A0TNG+1B4m6GROcLZt4QVtPMEsiNrtxAeLjBOeEYpS3jJ4X9Gn6tRHHfdY2YLj5kk9qb/iGQRnJRPuBObwR0jNOVCOKa7wYaGKgi+ovmzdlN5afyhvyPEzWaRyYl7fTOSotx0r5P37E7sKkwSfOTvTLhY4M5bX115HgfjePhDSeN00XHeCfzOKWLTWSgz3uAsy04zwjFY8rspWEraMkgNtDfTKSemIlzuHiTlOTGFKB3wVloaVU2apz2piB7ZIpEMeNTU3zLQhGQbQOvKhcAN4YJvhPoeH9naPAGEDGQ0p7jx8+GovaFSMMln41YAoOTaVNKMuGnOsC8RmNEv/8OzlgWniA74v5zjBZ8C7xS7tjr9BCRTy3vc/+TuOKhA9BsSG/jw9B5QFAmCzHMRfINFq5P5cHSHpWiDjWTS9bhm29fVfz2dcr+kyhXN2okgac0wg2ee7inZf1kHQeI6zK7zCtHdGnHH/iSolzwaWrF15+j22oib3TB1rH3Zgbi5VLq28YWCnS/0m0wwkog4L3v0eMYozToJU9+qAQRk2oGKyWom9JI5AxYuB5ilnXjHfbTFD/PiACJcdD6NhXqPLa52mGLiHl7bb0iwvxvzM5DqHMp4tKfIP1agkB+soE3Y0Bs2bVQyyVVYjIrV6XcIYE/FfWpScGUDGCKNWEutBYJoiuex9y0p7KdIWZ52KJlR/emu2aw=", "X-OriginatorOrg": "seco.com", "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 9218c72b-7bd3-44d5-fe3f-08d9fd56a0e4", "X-MS-Exchange-CrossTenant-AuthSource": "DB7PR03MB4523.eurprd03.prod.outlook.com", "X-MS-Exchange-CrossTenant-AuthAs": "Internal", "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "03 Mar 2022 20:44:35.9574 (UTC)", "X-MS-Exchange-CrossTenant-FromEntityHeader": "Hosted", "X-MS-Exchange-CrossTenant-Id": "bebe97c3-6438-442e-ade3-ff17aa50e733", "X-MS-Exchange-CrossTenant-MailboxType": "HOSTED", "X-MS-Exchange-CrossTenant-UserPrincipalName": "\n vejrm9HE7iOs5uQdk3+1gqs/krxutf0Z5iFxo+OtegrgUkjheIJ9WOdL+7q2K9ZgZ1+sIC6eoqm+91f/CEOJdg==", "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "VI1PR03MB4893", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.5 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "This adds a serial driver which uses semihosting calls to read and write\nto the host's console. For convenience, if CONFIG_DM_SERIAL is enabled,\nwe will instantiate a serial driver. This allows users to enable this\ndriver (which has no physical device) without modifying their device\ntrees or board files. We also implement a non-DM driver for SPL, or for\nmuch faster output in U-Boot proper.\n\nThere are three ways to print to the console:\n\nMethod Baud\n================== ====\nsmh_putc in a loop 17\nsmh_puts 160\nsmh_write with :tt 2000\n================== ====\n\nThese speeds were mesured using a 175 character message with a J-Link\nadapter. For reference, U-Boot typically prints around 2700 characters\nduring boot on this board. There are two major factors affecting the\nspeed of these functions. First, each breakpoint incurs a delay. Second,\neach debugger memory transaction incurs a delay. smh_putc has a\nbreakpoint and memory transaction for every character. smh_puts has one\nbreakpoint, but still has to use a transaction for every character. This\nis because we don't know the length up front, so OpenOCD has to check if\neach character is nul. smh_write has only one breakpoint and one memory\ntransfer.\n\nDM serial drivers can only implement a putc interface, so we are stuck\nwith the slowest API. Non-DM drivers can implement puts, which is vastly\nmore efficient. When the driver starts up, we try to open :tt. Since\nthis is an extension, this may fail. If it does, we fall back to\nsmh_puts. We don't check :semihosting-features, since there are\nnonconforming imlementations (OpenOCD) which don't implement it (but\n*do* implement :tt).\n\nThere is no non-blocking I/O available, so we don't implement pending.\nThis will cause __serial_tstc to always return true. If\nCONFIG_SERIAL_RX_BUFFER is enabled, _serial_tstc will try and read\ncharacters forever. To avoid this, we depend on this config being\ndisabled.\n\nSigned-off-by: Sean Anderson <sean.anderson@seco.com>\n---\n\n drivers/serial/Kconfig | 22 ++++++\n drivers/serial/Makefile | 1 +\n drivers/serial/serial.c | 2 +\n drivers/serial/serial_semihosting.c | 108 ++++++++++++++++++++++++++++\n 4 files changed, 133 insertions(+)\n create mode 100644 drivers/serial/serial_semihosting.c", "diff": "diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig\nindex 345d1881f5..cc20759505 100644\n--- a/drivers/serial/Kconfig\n+++ b/drivers/serial/Kconfig\n@@ -399,6 +399,15 @@ config DEBUG_UART_SANDBOX\n \t start up driver model. The driver will be available until the real\n \t driver model serial is running.\n \n+config DEBUG_UART_SEMIHOSTING\n+\tbool \"semihosting\"\n+\tdepends on SEMIHOSTING_SERIAL\n+\thelp\n+\t Select this to enable the debug UART using the semihosting driver.\n+\t This provides basic serial output from the console without needing to\n+\t start up driver model. The driver will be available until the real\n+\t driver model serial is running.\n+\n config DEBUG_UART_SIFIVE\n \tbool \"SiFive UART\"\n \tdepends on SIFIVE_SERIAL\n@@ -778,6 +787,19 @@ config SCIF_CONSOLE\n \t on systems with RCar or SH SoCs, say Y to this option. If unsure,\n \t say N.\n \n+config SEMIHOSTING_SERIAL\n+\tbool \"Semihosting UART support\"\n+\tdepends on SEMIHOSTING && !SERIAL_RX_BUFFER\n+\thelp\n+\t Select this to enable a serial UART using semihosting. Special halt\n+\t instructions will be issued which an external debugger (such as a\n+\t JTAG emulator) may interpret. The debugger will display U-Boot's\n+\t console output on the host system.\n+\n+\t Enable this option only if you are using a debugger which supports\n+\t semihosting. If you are not using a debugger, this driver will halt\n+\t the boot.\n+\n config UNIPHIER_SERIAL\n \tbool \"Support for UniPhier on-chip UART\"\n \tdepends on ARCH_UNIPHIER\ndiff --git a/drivers/serial/Makefile b/drivers/serial/Makefile\nindex 52e70aa191..b68b5e7b2b 100644\n--- a/drivers/serial/Makefile\n+++ b/drivers/serial/Makefile\n@@ -52,6 +52,7 @@ endif\n obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o\n obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o\n obj-$(CONFIG_SCIF_CONSOLE) += serial_sh.o\n+obj-$(CONFIG_SEMIHOSTING_SERIAL) += serial_semihosting.o\n obj-$(CONFIG_ZYNQ_SERIAL) += serial_zynq.o\n obj-$(CONFIG_FSL_LPUART) += serial_lpuart.o\n obj-$(CONFIG_FSL_LINFLEXUART) += serial_linflexuart.o\ndiff --git a/drivers/serial/serial.c b/drivers/serial/serial.c\nindex ebbd21916d..6cdbb89841 100644\n--- a/drivers/serial/serial.c\n+++ b/drivers/serial/serial.c\n@@ -126,6 +126,7 @@ serial_initfunc(mxc_serial_initialize);\n serial_initfunc(ns16550_serial_initialize);\n serial_initfunc(pl01x_serial_initialize);\n serial_initfunc(pxa_serial_initialize);\n+serial_initfunc(smh_serial_initialize);\n serial_initfunc(sh_serial_initialize);\n serial_initfunc(mtk_serial_initialize);\n \n@@ -180,6 +181,7 @@ int serial_initialize(void)\n \tns16550_serial_initialize();\n \tpl01x_serial_initialize();\n \tpxa_serial_initialize();\n+\tsmh_serial_initialize();\n \tsh_serial_initialize();\n \tmtk_serial_initialize();\n \ndiff --git a/drivers/serial/serial_semihosting.c b/drivers/serial/serial_semihosting.c\nnew file mode 100644\nindex 0000000000..44a67c5cb6\n--- /dev/null\n+++ b/drivers/serial/serial_semihosting.c\n@@ -0,0 +1,108 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * Copyright (C) 2022 Sean Anderson <sean.anderson@seco.com>\n+ */\n+\n+#include <common.h>\n+#include <dm.h>\n+#include <serial.h>\n+#include <semihosting.h>\n+\n+#if CONFIG_IS_ENABLED(DM_SERIAL)\n+static int smh_serial_getc(struct udevice *dev)\n+{\n+\treturn smh_getc();\n+}\n+\n+static int smh_serial_putc(struct udevice *dev, const char ch)\n+{\n+\tsmh_putc(ch);\n+\treturn 0;\n+}\n+\n+static const struct dm_serial_ops smh_serial_ops = {\n+\t.putc = smh_serial_putc,\n+\t.getc = smh_serial_getc,\n+};\n+\n+U_BOOT_DRIVER(smh_serial) = {\n+\t.name\t= \"serial_semihosting\",\n+\t.id\t= UCLASS_SERIAL,\n+\t.ops\t= &smh_serial_ops,\n+\t.flags\t= DM_FLAG_PRE_RELOC,\n+};\n+\n+U_BOOT_DRVINFO(smh_serial) = {\n+\t.name = \"serial_semihosting\",\n+};\n+#else /* DM_SERIAL */\n+static int outfd = -ENODEV;\n+\n+static int smh_serial_start(void)\n+{\n+\toutfd = smh_open(\":tt\", MODE_WRITE);\n+\treturn 0;\n+}\n+\n+static int smh_serial_stop(void)\n+{\n+\tif (outfd >= 0)\n+\t\tsmh_close(outfd);\n+\treturn 0;\n+}\n+\n+static void smh_serial_setbrg(void)\n+{\n+}\n+\n+static int smh_serial_tstc(void)\n+{\n+\treturn 1;\n+}\n+\n+static void smh_serial_puts(const char *s)\n+{\n+\tulong unused;\n+\n+\tif (outfd < 0)\n+\t\tsmh_puts(s);\n+\telse\n+\t\tsmh_write(outfd, s, strlen(s), &unused);\n+}\n+\n+static struct serial_device smh_serial_drv = {\n+\t.name\t= \"serial_smh\",\n+\t.start\t= smh_serial_start,\n+\t.stop\t= smh_serial_stop,\n+\t.setbrg\t= smh_serial_setbrg,\n+\t.getc\t= smh_getc,\n+\t.tstc\t= smh_serial_tstc,\n+\t.putc\t= smh_putc,\n+\t.puts\t= smh_serial_puts,\n+};\n+\n+void smh_serial_initialize(void)\n+{\n+\tserial_register(&smh_serial_drv);\n+}\n+\n+struct serial_device *default_serial_console(void)\n+{\n+\treturn &smh_serial_drv;\n+}\n+#endif\n+\n+#ifdef CONFIG_DEBUG_UART_SEMIHOSTING\n+#include <debug_uart.h>\n+\n+static inline void _debug_uart_init(void)\n+{\n+}\n+\n+static inline void _debug_uart_putc(int c)\n+{\n+\tsmh_putc(c);\n+}\n+\n+DEBUG_UART_FUNCS\n+#endif\n", "prefixes": [ "15/17" ] }