Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1600611/?format=api
{ "id": 1600611, "url": "http://patchwork.ozlabs.org/api/patches/1600611/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20220303204400.2787389-12-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-12-sean.anderson@seco.com>", "list_archive_url": null, "date": "2022-03-03T20:43:54", "name": "[11/17] fs: Add semihosting filesystem", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a193affcb6c344b293d8d3461c0a0b3af11a8a26", "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-12-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/1600611/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1600611/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=qS2HD8WZ;\n\tdkim-atps=neutral", "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=\"qS2HD8WZ\";\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\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\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 4K8jhS2b9lz9sG1\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 4 Mar 2022 07:46:48 +1100 (AEDT)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id A588B83D1F;\n\tThu, 3 Mar 2022 21:45:14 +0100 (CET)", "by phobos.denx.de (Postfix, from userid 109)\n id A8C1883C88; Thu, 3 Mar 2022 21:44:46 +0100 (CET)", "from EUR03-AM5-obe.outbound.protection.outlook.com\n (mail-am5eur03on061d.outbound.protection.outlook.com\n [IPv6:2a01:111:f400:fe08::61d])\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 6574583BAE\n for <u-boot@lists.denx.de>; Thu, 3 Mar 2022 21:44:32 +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:31 +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:31 +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=TebUcKyts4TpfmukjX9fIINieK1ydnWFI3YmXSm6z4kHUu2UGnKUlO5MM3gAwLwA+D+fWlrBvAZyAx0loisDn44HNVdTPSHByUIA7BUrASgx+cug/yTG8+4V6WJSckEB1bDNTzKx6u02mshZhqzDksg3Tzw5n5CpQagR9sgbCnJpUuhGLEaK1hW8WtxLRmI8qO7fkTLLAqIasAMA7RuzQpKo3eZNN1TTLadSbFlixgovpznZdF8QLk9ONC15qlPcccFnQy1wdaZVXO1sHiUdJ28Ru2P/b//oGVVGRHe/47tPvfwpMxcLBISIQYzSvpX8d0cLGLLxAPz4vQKWp1ahSQ==", "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=/zY0nTMq5ZCYca7rj98c1SAqGh5ddBviuLKqDkt8Y3k=;\n b=CWI/bbKCeREnSf/M+VTE5w8W3erTxq1muZHIt4SdWL7AmIwdJNHXkqqiiz9Ixh66shfkF5TkCqNbVWLEkE9ffgSZV/ki3DCRK+kG9UI+BoBa65p59qFCHi7CgZ7Tytace7EiVTv1iikuJ9Tw9KWEo4D7gK/OsN8ZMdUuhkYTt0JBZ/zbOaiUHwB++GT/i93x43tXehwU4yqb2IeEDN8owzPNGO/AR4ytmR1l8XMzo9szjD5X0wrxnmNjBqQJ4FXWakK4+Q1+qWEy3JE6EItDpgBgWDwHWKpTp+Jr8itjaYTDSYsFLX1HSd/nn5ZIp3rMgQ4xMVd1+a3rFEt8zEVU+A==", "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=/zY0nTMq5ZCYca7rj98c1SAqGh5ddBviuLKqDkt8Y3k=;\n b=qS2HD8WZPUjIL0KxaZLnvKPSkMvnDhQaLQqdnJuGwMsxPhC0/92GgKT5vxUOCWZNpQzWNzGcnU2YQcChn1XcPKJx9uUdMVyoqFxn/jzdah2fkRNzESNEIck+q7YoZ/r2VkzdvdWzwi8zGpAhiqcenyyLj5ilStI6aQv5ZekMyQSMBlmUB426smuPZq3Ya3wGy7GNWynvv+w9IvodxHaOsW0k8YdTQHTjni1vr6N2KeBvae/E+jcpZvQvfO2eeN4TZH2BDUisakUorvcELiOrsN+faK3HkqH71ekwi/sOzBqvDMGntOzmQSD+Wva3d6pHKgq3Q01ZKkT2u4UDcG7ouA==", "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 11/17] fs: Add semihosting filesystem", "Date": "Thu, 3 Mar 2022 15:43:54 -0500", "Message-Id": "<20220303204400.2787389-12-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": "e9a45c4a-ef1c-44d0-186f-08d9fd569e09", "X-MS-TrafficTypeDiagnostic": "VI1PR03MB4893:EE_", "X-Microsoft-Antispam-PRVS": "\n <VI1PR03MB4893BA4E8FF799C93EF6F18796049@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 RvXvweUMPOz44fmSd1wgqB71Qks/apcnCumTWxt5kUeh+QQcjA7t5mHLwJtwNKHyP3jVsi89RfaIdz+BADI8cX88f8rN3sminiGEpzXaxRq6Vy/wd9r7x6j9ltlZEcNl+gATbb4Mdomfma8bqXu/Lq15YPwtF7d6NbNuloNyy/BsC/Zjn1FDvyCGdbInqCrML/QtgTZRtpKBgFHRVDmc1sUCytG0GKzrjZKB4O94A1aoMYg5T3nu3zpP6xQLFDPpc90dKNuyTXdHsVPApNEna+a+CSWGVHqowN4GI/7hq7puqTq0xGYyIqK5nLfikZOB+aU+1vrSO8Gyn7X523u1uhL/aF4N5+Qzcv7Whtod8X094RT649rK7Y8eVQlxt23P4TMLUsg0udra7ASOcigxNcR9gdN2pG5jh9uabuCKseQL8csRwHo/tNF0aRS6W22Fqqot1MVv60u9wz33p7gzv/RqwUpm87S47BwJ6nPZ3bfffWh1o/HL79t75C12ojBCwjNQwHYI/RYTx6vrPO7Y3odM6BdJdQNlQ0aN7iL6RnGVFT+0IeLw3C+L43mNuLJi7tpHdIlxf3VReS5mI4Zdp9jDEDpdjSpBuQo/MMK/sWM6EfaxBf617a5eMNATWi1RvfbE9tIaevzIYZl7VrxKM9Hh5FzM4fjbZSttyGvOPAp4K+6OU2DYSLlFyTYcM0VzGy64jOTfoHGvzrwYyVJ6sVqOPTH6pq8Z7HvVaPb74Nw=", "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)(309714004);\n DIR:OUT; SFP:1101;", "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1", "X-MS-Exchange-AntiSpam-MessageData-0": "\n nIzr1GS7gScAcvx6r5aKD5yH71Bxm0oDBDIhId/1NXWqU+epEULzj+LdQerfF8TkQQlbw2PN2408FhgXeiFG3IfEH+p1Aecqb++NQm2tavsp7zDJcg8yjP2Taw2x3tOGg4tz891cUdD9677zYG8CIwJXuII0x78ASrXFeS9Pp+Fbp4y0iWHa1GLE974WNFA46vBu6MS51D2jlYr1g3WR0ZOuxNnj0nJNrXL/IeOq0/yJDbHgm+3hhBA0DZ0+tjYbE+RDvHW1PJh4ZmfsOxPe+VX6XAKJ2v3pUXe+Td0coqIY5A2gq4ud2EMQ9EYlbdEYR9SosveFyWOhjystnEv0VgON8Y31oHz0xekjauCrdw2gfpR+qPkxq0dkftCjeOIFLe480EdIfdzqVkzAeK7s2yuO2G3ljUSVG9BANvv1ZDmPtHKa9r8rKpwUfPOhU1XNbEBVEIkqKJ+5VsnSsHv1OWTidcyriN9tlbJc3Q/xaRKKwQeHnRq84HdUPpGIB/D1XMNY0/tDt6yn+tm+MiqzZFkbCLyw6/diaz7Ye646j1DHvB97UZjncO5IxozbvSG/pHF5q3Q0lqotxy/TW4SfkOfDU1Hl4oUaoHvrW8/rwQO2mJrO4nZrk2u8NRVt/lZGd/lezafuiSR4ArGMGk/IYzIH8WD2rM23e0ElarqyDNgnX28M7KyntS98R9/bXy3mg/Cpl4HMfJbtydqw7tQ1Tj+FbDa7eqKxxqWaH2suziD7hNWyS77lloCX+5yVxW/pXPxgZ2g4DnN5honwv3z8aSe9EOmSRZiueO257b0nDXJrJzEbwDCd1QyyStz9vvSek434YTGqMYZgBtoHxYMsvZ3N+5i1oVwfnkmm8Zzf8UK1bIrVkXKtzQS6dOZFZkheqhQ4sOwELgmzYN5OCrWVz0BjBUJgrbDJbLhpV6BG7yqnN6ZzFym7e8iV/131mbuoJwU9PIEi2QKMkQr22gup1mpeDYkvG0D/ivFG7BehdShDy5gYYeeNCnUQsxdbab+BY4MdQv32EfCg5gFBzWLBMpITH3tiW7BM7Oebb9PeGExfgoEIiXX4dDfeY1aYDSKP2AP6vgtyAw7B+RZB+gpah9tYJ9r4j1xkwfrB9na6L2z39ZcpXv4r3WwRpOswWNY0ay85+sm51xGEfv7Mg35qDA0vFF3SqNEAq+cRvv1zoTiJ29hzBxiq0owKGtC+5hYYg7UcBcyI9OsyKfdEVMx5q0kxJR7uw0UvkRYxtfEfov7NXypHOUPFC4Oa/xCJEFF3ky98+1mlkW/2H/2kXkEhnYgWS2+ZOveWRYTrF+l2xjrxdRxxIWRZVGMBgvjUg4+rntiQ6Vmrw2DzJ9GUYsA9aedudMmK8hWG9WdvXrj3cpntf7WtI70EgR4bPDr6qxk7Is9gkpkKU1ye3yJMbBVkm53qpoPl3unIBK/i+INMvgr+B+lpNAX1xhz+bsp8nn7GNqmRcXkUekeWmhAO5XJH3/yT/vczpHag1gbmOayK3GqFcDh78fGwza11A039r9D6VbXtTELWBeyizS4hixf8SqSfKFkocNvlaQlHdZ2OpvjHowl/f9Zryc5joIjiLDota/3xd5shNbHRmpJ7zk2on2YTKP472A84p2vJunSN0AU=", "X-OriginatorOrg": "seco.com", "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n e9a45c4a-ef1c-44d0-186f-08d9fd569e09", "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:31.1296 (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 Xc9UGkbgcrSMvIR8JDAWXP0LMy0ojL9ePO0z4nRnSmo20rhNBwJ3Mn/Ca5/d5nH1/XoDDphNJ5y5RThfsYSUPg==", "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 filesystem which is backed by the host's filesystem. It is\nmodeled off of sandboxfs, which has very similar aims. Semihosting\ndoesn't support listing directories (except with SYS_SYSTEM), so neither\ndo we. it's possible to optimize a bit for the common case of reading a\nwhole file by omitting a call to smh_seek, but this is left as a future\noptimization.\n\nSigned-off-by: Sean Anderson <sean.anderson@seco.com>\n---\n\n disk/part.c | 4 +-\n fs/Makefile | 1 +\n fs/fs.c | 20 +++++++\n fs/semihostingfs.c | 115 ++++++++++++++++++++++++++++++++++++++++\n include/fs.h | 1 +\n include/semihostingfs.h | 21 ++++++++\n 6 files changed, 160 insertions(+), 2 deletions(-)\n create mode 100644 fs/semihostingfs.c\n create mode 100644 include/semihostingfs.h", "diff": "diff --git a/disk/part.c b/disk/part.c\nindex 49e39a24e8..b95405bb49 100644\n--- a/disk/part.c\n+++ b/disk/part.c\n@@ -455,7 +455,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,\n \tint part;\n \tstruct disk_partition tmpinfo;\n \n-#ifdef CONFIG_SANDBOX\n+#if IS_ENABLED(CONFIG_SANDBOX) || IS_ENABLED(CONFIG_SEMIHOSTING)\n \t/*\n \t * Special-case a pseudo block device \"hostfs\", to allow access to the\n \t * host's own filesystem.\n@@ -467,7 +467,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,\n \t\tinfo->blksz = 0;\n \t\tinfo->bootable = 0;\n \t\tstrcpy((char *)info->type, BOOT_PART_TYPE);\n-\t\tstrcpy((char *)info->name, \"Sandbox host\");\n+\t\tstrcpy((char *)info->name, \"Host filesystem\");\n #if CONFIG_IS_ENABLED(PARTITION_UUIDS)\n \t\tinfo->uuid[0] = 0;\n #endif\ndiff --git a/fs/Makefile b/fs/Makefile\nindex 937cbcf6e8..c25d022946 100644\n--- a/fs/Makefile\n+++ b/fs/Makefile\n@@ -21,6 +21,7 @@ obj-$(CONFIG_FS_FAT) += fat/\n obj-$(CONFIG_FS_JFFS2) += jffs2/\n obj-$(CONFIG_CMD_REISER) += reiserfs/\n obj-$(CONFIG_SANDBOX) += sandbox/\n+obj-$(CONFIG_SEMIHOSTING) += semihostingfs.o\n obj-$(CONFIG_CMD_UBIFS) += ubifs/\n obj-$(CONFIG_YAFFS2) += yaffs2/\n obj-$(CONFIG_CMD_ZFS) += zfs/\ndiff --git a/fs/fs.c b/fs/fs.c\nindex 023f89cafe..bba010ea99 100644\n--- a/fs/fs.c\n+++ b/fs/fs.c\n@@ -18,6 +18,7 @@\n #include <fat.h>\n #include <fs.h>\n #include <sandboxfs.h>\n+#include <semihostingfs.h>\n #include <ubifs_uboot.h>\n #include <btrfs.h>\n #include <asm/global_data.h>\n@@ -246,6 +247,25 @@ static struct fstype_info fstypes[] = {\n \t\t.ln = fs_ln_unsupported,\n \t},\n #endif\n+#ifdef CONFIG_SEMIHOSTING\n+\t{\n+\t\t.fstype = FS_TYPE_SEMIHOSTING,\n+\t\t.name = \"semihosting\",\n+\t\t.null_dev_desc_ok = true,\n+\t\t.probe = smh_fs_set_blk_dev,\n+\t\t.close = fs_close_unsupported,\n+\t\t.ls = fs_ls_unsupported,\n+\t\t.exists = fs_exists_unsupported,\n+\t\t.size = smh_fs_size,\n+\t\t.read = smh_fs_read,\n+\t\t.write = smh_fs_write,\n+\t\t.uuid = fs_uuid_unsupported,\n+\t\t.opendir = fs_opendir_unsupported,\n+\t\t.unlink = fs_unlink_unsupported,\n+\t\t.mkdir = fs_mkdir_unsupported,\n+\t\t.ln = fs_ln_unsupported,\n+\t},\n+#endif\n #ifdef CONFIG_CMD_UBIFS\n \t{\n \t\t.fstype = FS_TYPE_UBIFS,\ndiff --git a/fs/semihostingfs.c b/fs/semihostingfs.c\nnew file mode 100644\nindex 0000000000..96eb3349a2\n--- /dev/null\n+++ b/fs/semihostingfs.c\n@@ -0,0 +1,115 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * Copyright (C) 2022, Sean Anderson <sean.anderson@seco.com>\n+ * Copyright (c) 2012, Google Inc.\n+ */\n+\n+#include <common.h>\n+#include <fs.h>\n+#include <malloc.h>\n+#include <os.h>\n+#include <semihosting.h>\n+#include <semihostingfs.h>\n+\n+int smh_fs_set_blk_dev(struct blk_desc *rbdd, struct disk_partition *info)\n+{\n+\t/*\n+\t * Only accept a NULL struct blk_desc for the semihosting, which is when\n+\t * hostfs interface is used\n+\t */\n+\treturn !!rbdd;\n+}\n+\n+static int smh_fs_read_at(const char *filename, loff_t pos, void *buffer,\n+\t\t\t loff_t maxsize, loff_t *actread)\n+{\n+\tlong fd, size, ret;\n+\n+\tfd = smh_open(filename, MODE_READ | MODE_BINARY);\n+\tif (fd < 0)\n+\t\treturn fd;\n+\tret = smh_seek(fd, pos);\n+\tif (ret < 0) {\n+\t\tsmh_close(fd);\n+\t\treturn ret;\n+\t}\n+\tif (!maxsize) {\n+\t\tsize = smh_flen(fd);\n+\t\tif (ret < 0) {\n+\t\t\tsmh_close(fd);\n+\t\t\treturn size;\n+\t\t}\n+\n+\t\tmaxsize = size;\n+\t}\n+\n+\tsize = smh_read(fd, buffer, maxsize);\n+\tsmh_close(fd);\n+\tif (size < 0)\n+\t\treturn size;\n+\n+\t*actread = size;\n+\treturn 0;\n+}\n+\n+static int smh_fs_write_at(const char *filename, loff_t pos, void *buffer,\n+\t\t\t loff_t towrite, loff_t *actwrite)\n+{\n+\tlong fd, size, ret;\n+\n+\tfd = smh_open(filename, MODE_READ | MODE_BINARY | MODE_PLUS);\n+\tif (fd < 0)\n+\t\treturn fd;\n+\tret = smh_seek(fd, pos);\n+\tif (ret < 0) {\n+\t\tsmh_close(fd);\n+\t\treturn ret;\n+\t}\n+\n+\tret = smh_write(fd, buffer, towrite, &size);\n+\tsmh_close(fd);\n+\t*actwrite = size;\n+\treturn ret;\n+}\n+\n+int smh_fs_size(const char *filename, loff_t *result)\n+{\n+\tlong fd, size;\n+\n+\tfd = smh_open(filename, MODE_READ | MODE_BINARY);\n+\tif (fd < 0)\n+\t\treturn fd;\n+\n+\tsize = smh_flen(fd);\n+\tsmh_close(fd);\n+\n+\tif (size < 0)\n+\t\treturn size;\n+\n+\t*result = size;\n+\treturn 0;\n+}\n+\n+int smh_fs_read(const char *filename, void *buf, loff_t offset, loff_t len,\n+\t\tloff_t *actread)\n+{\n+\tint ret;\n+\n+\tret = smh_fs_read_at(filename, offset, buf, len, actread);\n+\tif (ret)\n+\t\tprintf(\"** Unable to read file %s **\\n\", filename);\n+\n+\treturn ret;\n+}\n+\n+int smh_fs_write(const char *filename, void *buf, loff_t offset,\n+\t\t loff_t len, loff_t *actwrite)\n+{\n+\tint ret;\n+\n+\tret = smh_fs_write_at(filename, offset, buf, len, actwrite);\n+\tif (ret)\n+\t\tprintf(\"** Unable to write file %s **\\n\", filename);\n+\n+\treturn ret;\n+}\ndiff --git a/include/fs.h b/include/fs.h\nindex c8df3886ac..2f631624b5 100644\n--- a/include/fs.h\n+++ b/include/fs.h\n@@ -17,6 +17,7 @@ struct cmd_tbl;\n #define FS_TYPE_UBIFS\t4\n #define FS_TYPE_BTRFS\t5\n #define FS_TYPE_SQUASHFS 6\n+#define FS_TYPE_SEMIHOSTING 7\n \n struct blk_desc;\n \ndiff --git a/include/semihostingfs.h b/include/semihostingfs.h\nnew file mode 100644\nindex 0000000000..25ebdbbeff\n--- /dev/null\n+++ b/include/semihostingfs.h\n@@ -0,0 +1,21 @@\n+/* SPDX-License-Identifier: GPL-2.0+ */\n+/*\n+ * Copyright (C) 2022, Sean Anderson <sean.anderson@seco.com>\n+ * Copyright (c) 2012, Google Inc.\n+ */\n+\n+#ifndef __SEMIHOSTING_FS__\n+#define __SEMIHOSTING_FS__\n+\n+struct blk_desc;\n+struct disk_partition;\n+\n+int smh_fs_set_blk_dev(struct blk_desc *rbdd, struct disk_partition *info);\n+void smh_fs_close(void);\n+int smh_fs_size(const char *filename, loff_t *size);\n+int smh_fs_read(const char *filename, void *buf, loff_t offset, loff_t len,\n+\t\tloff_t *actread);\n+int smh_fs_write(const char *filename, void *buf, loff_t offset,\n+\t\t loff_t len, loff_t *actwrite);\n+\n+#endif\n", "prefixes": [ "11/17" ] }