From patchwork Thu Mar 10 20:50:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1604140 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=qhVOXIUo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KF1X10X5zz9sGB for ; Fri, 11 Mar 2022 07:54:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5088783B40; Thu, 10 Mar 2022 21:53:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="qhVOXIUo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E4A0D83B08; Thu, 10 Mar 2022 21:51:56 +0100 (CET) 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, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03on0600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe09::600]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CC53683ADB for ; Thu, 10 Mar 2022 21:51:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=My2xD7Jjra9WDrcyqhn7sVlnITzy+dMxN54VF9Hv2OWcJEsbSt+wy7GV5AU9BVn4mf64yKyqtefh5VUzFsqpBA5QPnwWjceo57Nq82cISwJuLBRCmLfP3nM+d+S4PuXSDuDhGWDeflhgB7WijgXNgqXFG/NtYeQ+N/wJYYq7ayzOPAj3BGtxwegUup+4iF2D++48NX+hLmhw3vO1ppKejXoQrpRbn9kTh14QyttXPt67hTynGTcxl16CJI8t8pX0yPWcPGXhIDAp2eTXdGyjhr+bwjfcAa5B788yltb/ig5+lbYExfF+R5Jk4Dv9Y6PspSkj+xq+iZGBLONsYE6XaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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; bh=n1gaTfxYw5HTylMHf4vLWUzAIorK4Rcf3P3GecncYXE=; b=C4xAiYGWJ/prC8c9+Z3gHSHlch5GSG6oAfDC2cB+Hu7o/2iQDTzc1+FKO7dN7U4Yp3uQxg/Rz8MXaGdUJaW2GKl571kuZRsm5GYZbmk5e0FCaFNAX00G/TRkGvKKdLCu1ybintxnVVBLJIpohnO1cxdRV+a9ckeyBhxoiOYMCKUtXwb6svBZlFW1u60irncfq/OBKLwI7vsFO27Zgg2+O/FSbvAG0LJApLWvR3UxH7Srt7xsi/O8cUueVkijAg9YAWOrswdgL7Aos+51wIuP4Rh4R+Lu/RMUG9069uG/BaulJ5zNo8lves+CoCtpDTyPHFp3In3vnjyRgna5mdEsvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n1gaTfxYw5HTylMHf4vLWUzAIorK4Rcf3P3GecncYXE=; b=qhVOXIUoMgEoafoxAVDjcuFK3hx1D4CE9Royf6+t1DQpMlPuW+9KiROa19IFtwJ2en7/AC8VhbbLHfm4r8E+xH9rQLWqdD4CqhlLfKtwc71FSFzhMbziNnkmArCm2IeqtvXLBdYtbMaJajJxCwAgh1uJUDz2Qt28H4GOdXer/Dpg1hScLUqbgYtACNHR4pXWnE2rNwQLJZHg+v98J9VJMu6xslNqVz/FRQV3iPpagk4r3sR4YOg2xOBwRqtqncHVSbkd5JXo3CppU/Iu5PLPYQ5igenO3O8D4kDHlPfgLnXaEqxh+sHmeRozScyIiuTTqk/kNivV8NYrYDvRvyxghw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB6PR0301MB2439.eurprd03.prod.outlook.com (2603:10a6:4:5b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Thu, 10 Mar 2022 20:51:38 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::9860:b15b:f166:5896]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::9860:b15b:f166:5896%3]) with mapi id 15.20.5061.022; Thu, 10 Mar 2022 20:51:38 +0000 From: Sean Anderson To: Tom Rini Cc: Liviu Dudau , u-boot@lists.denx.de, Simon Glass , Linus Walleij , Andre Przywara , Sean Anderson Subject: [PATCH v2 15/28] arm: smh: Add some functions for working with the host console Date: Thu, 10 Mar 2022 15:50:45 -0500 Message-Id: <20220310205059.499269-16-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220310205059.499269-1-sean.anderson@seco.com> References: <20220310205059.499269-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0433.namprd13.prod.outlook.com (2603:10b6:208:2c3::18) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76a2052f-e3dc-496a-0f86-08da02d7c559 X-MS-TrafficTypeDiagnostic: DB6PR0301MB2439:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eVm5okTIeFJ/Hbx1sx4l/Iy6hbObGis1IlgGgdSEB2LtMXDANprh6OI8mHb8+9rtwXUiXe54sX10oMUcls7DAEySgUJLzdwICzwNYj7ufA3SaynaWFon4bkvk0BwcVhNh2vnBlc4plW/c7hARgPdmSNC0FEUMkYmLZgkd+Dqcrx1vVYTEMD6PZpDLLVicDACdWCKqtd86mYqXNl7RI/l2sPf9qWQN29nj5II/HZ60nX6le4bYrE+6H+uCpY3vN/Sg8NiohbUqkkrmWHQkJoeJr1nXIfZB/WttCj+sFsJ2HXvLTZriIUpyQq0C2OvdC338eSf7BoAzB/73R2DUqJveomqFfZmm65SohB2hrKuMkqOruMvyCDMYhfI179HpsqhGrFzn5QpMULKYpRoJBaVmngw8fMyJ2V17gyrBJspKnZsn94dKUVDmW1SWckFGY1DeCUiP3Ta710vY90I9U6oQQ121VFYguggO8NSZC+B5zswpMGldfTg3UYGNC5zz31V+8n1kAbFyelYaFCzHY2RqwIuUAt8Ckrz3Bt+NgiILvxm1uPyQePziXCLyMcTM5zFffvbSHQp32mRGE83mVtFFOIQOgIj1AQ9oCaTOtiPja3rl5+AKxz46nrIKuT+PxlmxGlSk9AVPEwWWH9Tciw5AEqCXvxSyehenzOG3jjFkv5oYBiAx/K0pclefVLUNcM6vOuCilsc4SZ4MW0dLtuYlw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(54906003)(66476007)(316002)(4326008)(66556008)(6916009)(8676002)(66946007)(44832011)(36756003)(86362001)(2906002)(38350700002)(38100700002)(5660300002)(8936002)(6512007)(52116002)(6666004)(6486002)(6506007)(508600001)(186003)(26005)(2616005)(107886003)(1076003)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5RDswduU/MQMrFyhoAu2rnsP8K2FNJvfng/zkeeOVPrxGnrWqhpbYHdsgJbBK+f2Zayi0gZIfwMayfccAuIH7NtY9Pr/2Nyo0/OtjbD/D2bCwLfVJQC/Jn6n63AjxWdk4+emtgVK/HuQuoDBsFRHdAZXNU3okc5HN5TeUNzUvWjdfyrCdtOiUWL1lStWZcggB69XG9n8E9cfbtNZ2Ln5KmPH007E/RpeC4CBf2cq5iygGbpEotBJrUQ8Ma6QqDTIlVewnCed57FJA43iBkxDVb20OMRAhotQ2SeYggHRK7Ye0iBzYg9SQgNG0ljSJUPPGh/P21rm99AX35wovkXA7QvwQRMUXESO/HXCCLAXf6Ktiw9Xl3TijVrp6/B+9UlwNBB3zuoL9Om4NpPhWJqEGh0aW/N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byQvgvvGBC/Nom5sX/nYIak0RuXhWeRNpWjArcMyOSLKtKyZJHxawikNEizPk4e3CI91wqAxJNV++QNz758DPyY5gSHcGD40i/fugtoO6R4ztmOccsHjN1FuL6g7SUdD6Ocf+xC81SIoI4V07g0= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76a2052f-e3dc-496a-0f86-08da02d7c559 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2022 20:51:37.9925 (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: ZywgvtUsXKJdTUXOZGsUyJHdifOfh7ow8IcBdpCSMFac4+IqE+RM2eFJMvO8CEyd50qhROHd5Rh5jmORSppkJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0301MB2439 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean This adds three wrappers around the semihosting commands for reading and writing to the host console. We use the more standard getc/putc/puts names instead of readc/writec/write0 for familiarity. Signed-off-by: Sean Anderson --- (no changes since v1) arch/arm/lib/semihosting.c | 18 ++++++++++++++++++ include/semihosting.h | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/arch/arm/lib/semihosting.c b/arch/arm/lib/semihosting.c index 57ab25294f..7595dbc4a9 100644 --- a/arch/arm/lib/semihosting.c +++ b/arch/arm/lib/semihosting.c @@ -15,8 +15,11 @@ #define SYSOPEN 0x01 #define SYSCLOSE 0x02 +#define SYSWRITEC 0x03 +#define SYSWRITE0 0x04 #define SYSWRITE 0x05 #define SYSREAD 0x06 +#define SYSREADC 0x07 #define SYSSEEK 0x0A #define SYSFLEN 0x0C #define SYSERRNO 0x13 @@ -167,3 +170,18 @@ long smh_seek(long fd, long pos) return smh_errno(); return 0; } + +int smh_getc(void) +{ + return smh_trap(SYSREADC, NULL); +} + +void smh_putc(char ch) +{ + smh_trap(SYSWRITEC, &ch); +} + +void smh_puts(const char *s) +{ + smh_trap(SYSWRITE0, (char *)s); +} diff --git a/include/semihosting.h b/include/semihosting.h index b53c650444..6f3c29786c 100644 --- a/include/semihosting.h +++ b/include/semihosting.h @@ -86,4 +86,23 @@ long smh_flen(long fd); */ long smh_seek(long fd, long pos); +/** + * smh_getc() - Read a character from stdin + * + * Return: The character read, or a negative error on failure + */ +int smh_getc(void); + +/** + * smh_putc() - Print a character on stdout + * @ch: The character to print + */ +void smh_putc(char ch); + +/** + * smh_write0() - Print a nul-terminated string on stdout + * @s: The string to print + */ +void smh_puts(const char *s); + #endif /* _SEMIHOSTING_H */