From nobody Sun Jan 14 21:22:40 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TCpC50TPjz57957; Sun, 14 Jan 2024 21:22:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TCpC42sxfz47gB; Sun, 14 Jan 2024 21:22:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705267360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DLJ77iT6I5lCw+arIi02tyk53NSJLtV0RioUu3NMdlU=; b=BrHP+SZQDFCir4rSlfpPP3sVmZMeKZD1yUzVlM1h6YaVI+4cGh8w7MuHEkyRABZAXOSKvm R5A9YamVUtheSGKfDelojh7InH4uhC1KxEOO/HTxtloEA1qNzN1TbN46rrIF+50kI+7zAI IOL3nonhq3FmyY4R/VaBfvSRO3wlo6HKuL7B+tFeyc5jdwWw6q6WFF+NsqW92kSIBxT7EB vFZMfuuXc1n20A66GnS3KdG3ggbeEabrBcScNdVLXZihmQWnCD8nS8ysBnIwWXjDfr0xKH LpXLFDlT7OC0TONC+5AP3wiVo4tFmJcje5iWmwIooTmPFI3hwcfU5esUU987bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705267360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DLJ77iT6I5lCw+arIi02tyk53NSJLtV0RioUu3NMdlU=; b=lf45VUM2q8LP5tf6iAJgPSF35GsdC3HD6JsvDCAORHbyzXrH4094cc3Zp6OVH4LirTFX7O JCxjnpbDar4AypNE2C8i8lfO/67zRpvsO0V50v9rQgCZf/4q5Hda20YXN84dzUxXdsaRn6 NyVgR4T9ffbOLATGRa0tStDyZ4tToxNkklcUIyXhEtHtTCZOjPLZkOiFV8Glszf7orDOL4 MNoBLfMSf6jH/rkg88xO9aZPF3TQXVj/kjMFa2a4Sa6kVPHEoOH8mOjmob0rVdbiDVb9b2 4VaRug2kflfSxYhyiO5TU4FQTQW09EtAVeJxEYBFQO0a1/CZR5lt/6taVeVF+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705267360; a=rsa-sha256; cv=none; b=H5vpJryaFf/boFb8qBb9seDR4xZmn3Kycb6N/d3UKPUrKAnlPeTQjAYzKP91yyI5swsfkV f3qUPHtlUI2BC2irWXBGRu5yuKUhTnwcUQn1S42cjqaaVQdCG9A1TvBi9wAK8pFT32wNoH T4njVXDEwNVscSFi2g3GsdCsGdt/19GAzGxh6Sd3u37ufi437vEJQin9abq+m8bc6SAm44 eqwHyVuop9VxCzOpaQLdzRgBNmj1L/TF7H5Cj4MGWJ/ZtBdcUGy7YZiTTQBFGWpautDxb3 l0IzephoOFHJJdIcJ09EkxUSozJ0LEA4ep3JXHgtwsVvEHtPQekhndVChdzpAA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TCpC41wJ4zVTQ; Sun, 14 Jan 2024 21:22:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40ELMedb091133; Sun, 14 Jan 2024 21:22:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40ELMemB091130; Sun, 14 Jan 2024 21:22:40 GMT (envelope-from git) Date: Sun, 14 Jan 2024 21:22:40 GMT Message-Id: <202401142122.40ELMemB091130@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marius Strobl Subject: git: 53df7e58cca7 - main - geom_redboot(4): Garbage collect disconnected driver List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: marius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 53df7e58cca7e6726b44f447f10ddc3451cfa851 Auto-Submitted: auto-generated The branch main has been updated by marius: URL: https://cgit.FreeBSD.org/src/commit/?id=53df7e58cca7e6726b44f447f10ddc3451cfa851 commit 53df7e58cca7e6726b44f447f10ddc3451cfa851 Author: Marius Strobl AuthorDate: 2024-01-14 08:39:56 +0000 Commit: Marius Strobl CommitDate: 2024-01-14 21:22:21 +0000 geom_redboot(4): Garbage collect disconnected driver The last MIPS user has been removed in c09981f1 2 years ago, the last ARM one in ff945277 even 5.5 years ago. --- sys/conf/files | 1 - sys/geom/geom_redboot.c | 342 ------------------------------------------------ 2 files changed, 343 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index 1069079b162a..484ec90beb00 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3618,7 +3618,6 @@ geom/geom_event.c standard geom/geom_flashmap.c optional fdt cfi | fdt mx25l | mmcsd | fdt n25q | fdt at45d geom/geom_io.c standard geom/geom_kern.c standard -geom/geom_redboot.c optional geom_redboot geom/geom_slice.c standard geom/geom_subr.c standard geom/geom_vfs.c standard diff --git a/sys/geom/geom_redboot.c b/sys/geom/geom_redboot.c deleted file mode 100644 index aeb8f1e4e525..000000000000 --- a/sys/geom/geom_redboot.c +++ /dev/null @@ -1,342 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2009 Sam Leffler, Errno Consulting - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any - * redistribution must be conditioned upon including a substantially - * similar Disclaimer requirement for further binary redistribution. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, - * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGES. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define REDBOOT_CLASS_NAME "REDBOOT" - -struct fis_image_desc { - uint8_t name[16]; /* null-terminated name */ - uint32_t offset; /* offset in flash */ - uint32_t addr; /* address in memory */ - uint32_t size; /* image size in bytes */ - uint32_t entry; /* offset in image for entry point */ - uint32_t dsize; /* data size in bytes */ - uint8_t pad[256-(16+7*sizeof(uint32_t)+sizeof(void*))]; - struct fis_image_desc *next; /* linked list (in memory) */ - uint32_t dsum; /* descriptor checksum */ - uint32_t fsum; /* checksum over image data */ -}; - -#define FISDIR_NAME "FIS directory" -#define REDBCFG_NAME "RedBoot config" -#define REDBOOT_NAME "RedBoot" - -#define REDBOOT_MAXSLICE 64 -#define REDBOOT_MAXOFF \ - (REDBOOT_MAXSLICE*sizeof(struct fis_image_desc)) - -struct g_redboot_softc { - uint32_t entry[REDBOOT_MAXSLICE]; - uint32_t dsize[REDBOOT_MAXSLICE]; - uint8_t readonly[REDBOOT_MAXSLICE]; - g_access_t *parent_access; -}; - -static void -g_redboot_print(int i, struct fis_image_desc *fd) -{ - - printf("[%2d] \"%-15.15s\" %08x:%08x", i, fd->name, - fd->offset, fd->size); - printf(" addr %08x entry %08x\n", fd->addr, fd->entry); - printf(" dsize 0x%x dsum 0x%x fsum 0x%x\n", fd->dsize, - fd->dsum, fd->fsum); -} - -static int -g_redboot_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td) -{ - return (ENOIOCTL); -} - -static int -g_redboot_access(struct g_provider *pp, int dread, int dwrite, int dexcl) -{ - struct g_geom *gp = pp->geom; - struct g_slicer *gsp = gp->softc; - struct g_redboot_softc *sc = gsp->softc; - - if (dwrite > 0 && sc->readonly[pp->index]) - return (EPERM); - return (sc->parent_access(pp, dread, dwrite, dexcl)); -} - -static int -g_redboot_start(struct bio *bp) -{ - struct g_provider *pp; - struct g_geom *gp; - struct g_redboot_softc *sc; - struct g_slicer *gsp; - int idx; - - pp = bp->bio_to; - idx = pp->index; - gp = pp->geom; - gsp = gp->softc; - sc = gsp->softc; - if (bp->bio_cmd == BIO_GETATTR) { - if (g_handleattr_int(bp, REDBOOT_CLASS_NAME "::entry", - sc->entry[idx])) - return (1); - if (g_handleattr_int(bp, REDBOOT_CLASS_NAME "::dsize", - sc->dsize[idx])) - return (1); - } - - return (0); -} - -static void -g_redboot_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, - struct g_consumer *cp __unused, struct g_provider *pp) -{ - struct g_redboot_softc *sc; - struct g_slicer *gsp; - - gsp = gp->softc; - sc = gsp->softc; - g_slice_dumpconf(sb, indent, gp, cp, pp); - if (pp != NULL) { - if (indent == NULL) { - sbuf_printf(sb, " entry %d", sc->entry[pp->index]); - sbuf_printf(sb, " dsize %d", sc->dsize[pp->index]); - } else { - sbuf_printf(sb, "%s%d\n", indent, - sc->entry[pp->index]); - sbuf_printf(sb, "%s%d\n", indent, - sc->dsize[pp->index]); - } - } -} - -#include - -static int -nameok(const char name[16]) -{ - int i; - - /* descriptor names are null-terminated printable ascii */ - for (i = 0; i < 15; i++) - if (!isprint(name[i])) - break; - return (name[i] == '\0'); -} - -static struct fis_image_desc * -parse_fis_directory(u_char *buf, size_t bufsize, off_t offset, uint32_t offmask) -{ -#define match(a,b) (bcmp(a, b, sizeof(b)-1) == 0) - struct fis_image_desc *fd, *efd; - struct fis_image_desc *fisdir, *redbcfg; - struct fis_image_desc *head, **tail; - int i; - - fd = (struct fis_image_desc *)buf; - efd = fd + (bufsize / sizeof(struct fis_image_desc)); -#if 0 - /* - * Find the start of the FIS table. - */ - while (fd < efd && fd->name[0] != 0xff) - fd++; - if (fd == efd) - return (NULL); - if (bootverbose) - printf("RedBoot FIS table starts at 0x%jx\n", - offset + fd - (struct fis_image_desc *) buf); -#endif - /* - * Scan forward collecting entries in a list. - */ - fisdir = redbcfg = NULL; - *(tail = &head) = NULL; - for (i = 0; fd < efd; i++, fd++) { - if (fd->name[0] == 0xff) - continue; - if (match(fd->name, FISDIR_NAME)) - fisdir = fd; - else if (match(fd->name, REDBCFG_NAME)) - redbcfg = fd; - if (nameok(fd->name)) { - /* - * NB: flash address includes platform mapping; - * strip it so we have only a flash offset. - */ - fd->offset &= offmask; - if (bootverbose) - g_redboot_print(i, fd); - *tail = fd; - *(tail = &fd->next) = NULL; - } - } - if (fisdir == NULL) { - if (bootverbose) - printf("No RedBoot FIS table located at %lu\n", - (long) offset); - return (NULL); - } - if (redbcfg != NULL && - fisdir->offset + fisdir->size == redbcfg->offset) { - /* - * Merged FIS/RedBoot config directory. - */ - if (bootverbose) - printf("FIS/RedBoot merged at 0x%jx (not yet)\n", - offset + fisdir->offset); - /* XXX */ - } - return head; -#undef match -} - -static struct g_geom * -g_redboot_taste(struct g_class *mp, struct g_provider *pp, int insist) -{ - struct g_geom *gp; - struct g_consumer *cp; - struct g_redboot_softc *sc; - int error, sectorsize, i; - struct fis_image_desc *fd, *head; - uint32_t offmask; - off_t blksize; /* NB: flash block size stored as stripesize */ - u_char *buf; - off_t offset; - const char *value; - char *op; - - offset = 0; - if (resource_string_value("redboot", 0, "fisoffset", &value) == 0) { - offset = strtouq(value, &op, 0); - if (*op != '\0') { - offset = 0; - } - } - - g_trace(G_T_TOPOLOGY, "redboot_taste(%s,%s)", mp->name, pp->name); - g_topology_assert(); - if (!strcmp(pp->geom->class->name, REDBOOT_CLASS_NAME)) - return (NULL); - /* XXX only taste flash providers */ - if (strncmp(pp->name, "cfi", 3) && - strncmp(pp->name, "flash/spi", 9)) - return (NULL); - gp = g_slice_new(mp, REDBOOT_MAXSLICE, pp, &cp, &sc, sizeof(*sc), - g_redboot_start); - if (gp == NULL) - return (NULL); - /* interpose our access method */ - sc->parent_access = gp->access; - gp->access = g_redboot_access; - - sectorsize = cp->provider->sectorsize; - blksize = cp->provider->stripesize; - if (powerof2(cp->provider->mediasize)) - offmask = cp->provider->mediasize-1; - else - offmask = 0xffffffff; /* XXX */ - if (bootverbose) - printf("%s: mediasize %ld secsize %d blksize %ju offmask 0x%x\n", - __func__, (long) cp->provider->mediasize, sectorsize, - (uintmax_t)blksize, offmask); - if (sectorsize < sizeof(struct fis_image_desc) || - (sectorsize % sizeof(struct fis_image_desc))) - return (NULL); - g_topology_unlock(); - head = NULL; - if(offset == 0) - offset = cp->provider->mediasize - blksize; -again: - buf = g_read_data(cp, offset, blksize, NULL); - if (buf != NULL) - head = parse_fis_directory(buf, blksize, offset, offmask); - if (head == NULL && offset != 0) { - g_free(buf); - offset = 0; /* check the front */ - goto again; - } - g_topology_lock(); - if (head == NULL) { - g_free(buf); - return NULL; - } - /* - * Craft a slice for each entry. - */ - for (fd = head, i = 0; fd != NULL; fd = fd->next) { - if (fd->name[0] == '\0') - continue; - error = g_slice_config(gp, i, G_SLICE_CONFIG_SET, - fd->offset, fd->size, sectorsize, "redboot/%s", fd->name); - if (error) - printf("%s: g_slice_config returns %d for \"%s\"\n", - __func__, error, fd->name); - sc->entry[i] = fd->entry; - sc->dsize[i] = fd->dsize; - /* disallow writing hard-to-recover entries */ - sc->readonly[i] = (strcmp(fd->name, FISDIR_NAME) == 0) || - (strcmp(fd->name, REDBOOT_NAME) == 0); - i++; - } - g_free(buf); - g_access(cp, -1, 0, 0); - if (LIST_EMPTY(&gp->provider)) { - g_slice_spoiled(cp); - return (NULL); - } - return (gp); -} - -static struct g_class g_redboot_class = { - .name = REDBOOT_CLASS_NAME, - .version = G_VERSION, - .taste = g_redboot_taste, - .dumpconf = g_redboot_dumpconf, - .ioctl = g_redboot_ioctl, -}; -DECLARE_GEOM_CLASS(g_redboot_class, g_redboot); -MODULE_VERSION(geom_redboot, 0);