From nobody Tue Jan 23 17:45:57 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 4TKDys65mBz57mT2; Tue, 23 Jan 2024 17:45:57 +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 4TKDys4pJcz47M4; Tue, 23 Jan 2024 17:45:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706031957; 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=HWMLzpdOzLdmQpht4Y6hLByhpByve2qLito6xZX13Lw=; b=kbYio/9//dge64XYSFD/v6TTEzNIoIrHa2zOrWy+7zvMxr+5mBylhLJaDGsM2jMghnWkmt aTseydknypfLzFHac9/xRM50GStPCxvjANVL7mPzaNRCvVRs03kkZmp6rzotHADw7zWjAw wMm3maD2Er4dhicH/iJ9sBxp4Rdkm0mKM5CNtSqQzYIRJJ3HM2ek2eoRiy0Y0q7NfnKF93 dPmjp6Ghaq/aFQzFXHel0sE/JFt+A4XVA1X0eQGUM0UPPjyxGltjpkPtTknCp4EWpyfuCO MtGr7XugLF3DXGULIEreRjYbS07TaMeeOS5+IpWpVqKiA7DeB++LeuZ2M2Jpcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706031957; 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=HWMLzpdOzLdmQpht4Y6hLByhpByve2qLito6xZX13Lw=; b=UYtbXFrxTLgFK+6s6DHNP29ufWBUXVzfp71DvlA0p7x0cwvwheVxImXJ0Uu+jJTvveWMnD o783PjFhwxhZhO519OSkRAdZ9UCknPGunDVdt2ftWzhhA1eCgPVOR0Yt0lGXPWqNja3ICU gLEJH69C/qcdRr8Lc/aBE2Mci3At6K4eBeqbVwytT1kRKzXhu++Qjcxg+LWdtzhAATrIV1 21sQD5wxqO7hxpHQ6Il9TUd4G7GNsieoBE/To3JitN5SJ4EG0pc4UQrBE2ng7eH5/wkbHT v2c5NGrK3q1dffzBwWvyv6rw1N0bRKpM1NTr7sfoX86xpnbmP22EEICk7aDVog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706031957; a=rsa-sha256; cv=none; b=sq4YAO+QQas6jrYrDwqlT61p1x8a8VyF3wfmWfZA2UGssNRd7rV26aNb909M9TXtITys4W XFCcJ2OvBMgg5nwwLHjJomYcj2tlkEQAb4J1JNeNGoVY4//YlE3NnLrMKo/4b0YXBu0TFe trlInomS668QtQRgIHEglLkIPv5iHEARwGAgUrS5yI76+PHCU326EjcmNawpdN2nXrM2qY BVTxmPMhsCyIMGINZhbF/uv0AUAJ0XNJpsgHzE8KbW6uH4oZki29x5LYrZSbcJclTh/b04 RWpnT2yO2mHYlQ+UtdgSKRnzbrygk4wejvY/DgRXWbP3923Igt8BSjquF6T+cA== 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 4TKDys3YxPzg0k; Tue, 23 Jan 2024 17:45:57 +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 40NHjvxt075877; Tue, 23 Jan 2024 17:45:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40NHjvRR075874; Tue, 23 Jan 2024 17:45:57 GMT (envelope-from git) Date: Tue, 23 Jan 2024 17:45:57 GMT Message-Id: <202401231745.40NHjvRR075874@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: af081ec6f7cf - main - powerpc powermac: Use bus_generic_rman_* 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: af081ec6f7cf4b764a1b417135440cf05cf1a174 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=af081ec6f7cf4b764a1b417135440cf05cf1a174 commit af081ec6f7cf4b764a1b417135440cf05cf1a174 Author: John Baldwin AuthorDate: 2024-01-23 17:36:49 +0000 Commit: John Baldwin CommitDate: 2024-01-23 17:36:49 +0000 powerpc powermac: Use bus_generic_rman_* Implement bus_map/unmap_resource and add bus_get_rman for use by bus_generic_rman_*. Reviewed by: imp, jhibbits Differential Revision: https://reviews.freebsd.org/D43435 --- sys/powerpc/powermac/macio.c | 197 ++++++++++++++++++++++++++------------- sys/powerpc/powermac/uninorth.c | 200 ++++++++++++++++++++++++++-------------- 2 files changed, 264 insertions(+), 133 deletions(-) diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c index 76ae844e50fe..f6ad815064e8 100644 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -80,15 +80,23 @@ static int macio_probe(device_t); static int macio_attach(device_t); static int macio_print_child(device_t dev, device_t child); static void macio_probe_nomatch(device_t, device_t); +static struct rman *macio_get_rman(device_t, int, u_int); static struct resource *macio_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); +static int macio_adjust_resource(device_t, device_t, int, struct resource *, + rman_res_t, rman_res_t); static int macio_activate_resource(device_t, device_t, int, int, struct resource *); static int macio_deactivate_resource(device_t, device_t, int, int, struct resource *); static int macio_release_resource(device_t, device_t, int, int, struct resource *); +static int macio_map_resource(device_t, device_t, int, struct resource *, + struct resource_map_request *, + struct resource_map *); +static int macio_unmap_resource(device_t, device_t, int, struct resource *, + struct resource_map *); static struct resource_list *macio_get_resource_list (device_t, device_t); static ofw_bus_get_devinfo_t macio_get_devinfo; #if !defined(__powerpc64__) && defined(SMP) @@ -113,10 +121,14 @@ static device_method_t macio_methods[] = { DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + DEVMETHOD(bus_get_rman, macio_get_rman), DEVMETHOD(bus_alloc_resource, macio_alloc_resource), + DEVMETHOD(bus_adjust_resource, macio_adjust_resource), DEVMETHOD(bus_release_resource, macio_release_resource), DEVMETHOD(bus_activate_resource, macio_activate_resource), DEVMETHOD(bus_deactivate_resource, macio_deactivate_resource), + DEVMETHOD(bus_map_resource, macio_map_resource), + DEVMETHOD(bus_unmap_resource, macio_unmap_resource), DEVMETHOD(bus_get_resource_list, macio_get_resource_list), DEVMETHOD(bus_child_pnpinfo, ofw_bus_gen_child_pnpinfo), @@ -495,25 +507,32 @@ macio_probe_nomatch(device_t dev, device_t child) } } +static struct rman * +macio_get_rman(device_t bus, int type, u_int flags) +{ + struct macio_softc *sc; + + sc = device_get_softc(bus); + switch (type) { + case SYS_RES_MEMORY: + case SYS_RES_IOPORT: + return (&sc->sc_mem_rman); + default: + return (NULL); + } +} + static struct resource * macio_alloc_resource(device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) { - struct macio_softc *sc; - int needactivate; - struct resource *rv; - struct rman *rm; - u_long adjstart, adjend, adjcount; + rman_res_t adjstart, adjend, adjcount; struct macio_devinfo *dinfo; struct resource_list_entry *rle; - sc = device_get_softc(bus); dinfo = device_get_ivars(child); - needactivate = flags & RF_ACTIVE; - flags &= ~RF_ACTIVE; - switch (type) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: @@ -541,8 +560,8 @@ macio_alloc_resource(device_t bus, device_t child, int type, int *rid, adjcount = adjend - adjstart; - rm = &sc->sc_mem_rman; - break; + return (bus_generic_rman_alloc_resource(bus, child, type, rid, + adjstart, adjend, adjcount, flags)); case SYS_RES_IRQ: /* Check for passthrough from subattachments like macgpio */ @@ -574,84 +593,134 @@ macio_alloc_resource(device_t bus, device_t child, int type, int *rid, device_get_nameunit(child)); return (NULL); } +} - rv = rman_reserve_resource(rm, adjstart, adjend, adjcount, flags, - child); - if (rv == NULL) { - device_printf(bus, - "failed to reserve resource %#lx - %#lx (%#lx) for %s\n", - adjstart, adjend, adjcount, device_get_nameunit(child)); - return (NULL); +static int +macio_adjust_resource(device_t bus, device_t child, int type, + struct resource *r, rman_res_t start, rman_res_t end) +{ + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + return (bus_generic_rman_adjust_resource(bus, child, type, r, + start, end)); + case SYS_RES_IRQ: + return (bus_generic_adjust_resource(bus, child, type, r, start, + end)); + default: + return (EINVAL); } - - rman_set_rid(rv, *rid); - - if (needactivate) { - if (bus_activate_resource(child, type, *rid, rv) != 0) { - device_printf(bus, - "failed to activate resource for %s\n", - device_get_nameunit(child)); - rman_release_resource(rv); - return (NULL); - } - } - - return (rv); } static int macio_release_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { - if (rman_get_flags(res) & RF_ACTIVE) { - int error = bus_deactivate_resource(child, type, rid, res); - if (error) - return error; + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + return (bus_generic_rman_release_resource(bus, child, type, rid, + res)); + case SYS_RES_IRQ: + return (bus_generic_rl_release_resource(bus, child, type, rid, + res)); + default: + return (EINVAL); } - - return (rman_release_resource(res)); } static int macio_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { - struct macio_softc *sc; - void *p; - - sc = device_get_softc(bus); - - if (type == SYS_RES_IRQ) - return (bus_activate_resource(bus, type, rid, res)); - - if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { - p = pmap_mapdev((vm_paddr_t)rman_get_start(res) + sc->sc_base, - (vm_size_t)rman_get_size(res)); - if (p == NULL) - return (ENOMEM); - rman_set_virtual(res, p); - rman_set_bustag(res, &bs_le_tag); - rman_set_bushandle(res, (u_long)p); + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + return (bus_generic_rman_activate_resource(bus, child, type, + rid, res)); + case SYS_RES_IRQ: + return (bus_generic_activate_resource(bus, child, type, rid, + res)); + default: + return (EINVAL); } - - return (rman_activate_resource(res)); } static int macio_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { - /* - * If this is a memory resource, unmap it. - */ - if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { - u_int32_t psize; + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + return (bus_generic_rman_deactivate_resource(bus, child, type, + rid, res)); + case SYS_RES_IRQ: + return (bus_generic_deactivate_resource(bus, child, type, rid, + res)); + default: + return (EINVAL); + } +} + +static int +macio_map_resource(device_t bus, device_t child, int type, + struct resource *r, struct resource_map_request *argsp, + struct resource_map *map) +{ + struct resource_map_request args; + struct macio_softc *sc; + rman_res_t length, start; + int error; + + /* Resources must be active to be mapped. */ + if (!(rman_get_flags(r) & RF_ACTIVE)) + return (ENXIO); - psize = rman_get_size(res); - pmap_unmapdev(rman_get_virtual(res), psize); + /* Mappings are only supported on I/O and memory resources. */ + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + break; + default: + return (EINVAL); } - return (rman_deactivate_resource(res)); + resource_init_map_request(&args); + error = resource_validate_map_request(r, argsp, &args, &start, &length); + if (error) + return (error); + + if (bootverbose) + printf("nexus mapdev: start %jx, len %jd\n", + (uintmax_t)start, (uintmax_t)length); + + sc = device_get_softc(bus); + map->r_vaddr = pmap_mapdev_attr((vm_paddr_t)start + sc->sc_base, + length, args.memattr); + if (map->r_vaddr == NULL) + return (ENOMEM); + map->r_bustag = &bs_le_tag; + map->r_bushandle = (bus_space_handle_t)map->r_vaddr; + return (0); +} + +static int +macio_unmap_resource(device_t bus, device_t child, int type, + struct resource *r, struct resource_map *map) +{ + /* + * If this is a memory resource, unmap it. + */ + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + pmap_unmapdev(map->r_vaddr, map->r_size); + break; + default: + return (EINVAL); + } + return (0); } static struct resource_list * diff --git a/sys/powerpc/powermac/uninorth.c b/sys/powerpc/powermac/uninorth.c index 1e22e0f92855..b64bbc8ade62 100644 --- a/sys/powerpc/powermac/uninorth.c +++ b/sys/powerpc/powermac/uninorth.c @@ -71,13 +71,22 @@ static int unin_chip_attach(device_t); */ static int unin_chip_print_child(device_t dev, device_t child); static void unin_chip_probe_nomatch(device_t, device_t); +static struct rman *unin_chip_get_rman(device_t, int, u_int); static struct resource *unin_chip_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); +static int unin_chip_adjust_resource(device_t, device_t, int, + struct resource *, rman_res_t, + rman_res_t); static int unin_chip_activate_resource(device_t, device_t, int, int, struct resource *); static int unin_chip_deactivate_resource(device_t, device_t, int, int, struct resource *); +static int unin_chip_map_resource(device_t, device_t, int, struct resource *, + struct resource_map_request *, + struct resource_map *); +static int unin_chip_unmap_resource(device_t, device_t, int, struct resource *, + struct resource_map *); static int unin_chip_release_resource(device_t, device_t, int, int, struct resource *); static struct resource_list *unin_chip_get_resource_list (device_t, device_t); @@ -109,10 +118,14 @@ static device_method_t unin_chip_methods[] = { DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + DEVMETHOD(bus_get_rman, unin_chip_get_rman), DEVMETHOD(bus_alloc_resource, unin_chip_alloc_resource), + DEVMETHOD(bus_adjust_resource, unin_chip_adjust_resource), DEVMETHOD(bus_release_resource, unin_chip_release_resource), DEVMETHOD(bus_activate_resource, unin_chip_activate_resource), DEVMETHOD(bus_deactivate_resource, unin_chip_deactivate_resource), + DEVMETHOD(bus_map_resource, unin_chip_map_resource), + DEVMETHOD(bus_unmap_resource, unin_chip_unmap_resource), DEVMETHOD(bus_get_resource_list, unin_chip_get_resource_list), DEVMETHOD(bus_child_pnpinfo, ofw_bus_gen_child_pnpinfo), @@ -449,25 +462,32 @@ unin_chip_probe_nomatch(device_t dev, device_t child) } } +static struct rman * +unin_chip_get_rman(device_t bus, int type, u_int flags) +{ + struct unin_chip_softc *sc; + + sc = device_get_softc(bus); + switch (type) { + case SYS_RES_MEMORY: + case SYS_RES_IOPORT: + return (&sc->sc_mem_rman); + default: + return (NULL); + } +} + static struct resource * unin_chip_alloc_resource(device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) { - struct unin_chip_softc *sc; - int needactivate; - struct resource *rv; - struct rman *rm; - u_long adjstart, adjend, adjcount; + rman_res_t adjstart, adjend, adjcount; struct unin_chip_devinfo *dinfo; struct resource_list_entry *rle; - sc = device_get_softc(bus); dinfo = device_get_ivars(child); - needactivate = flags & RF_ACTIVE; - flags &= ~RF_ACTIVE; - switch (type) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: @@ -497,9 +517,8 @@ unin_chip_alloc_resource(device_t bus, device_t child, int type, int *rid, adjcount = adjend - adjstart; - rm = &sc->sc_mem_rman; - break; - + return (bus_generic_rman_alloc_resource(bus, child, + SYS_RES_MEMORY, rid, adjstart, adjend, adjcount, flags)); case SYS_RES_IRQ: /* Check for passthrough from subattachments. */ if (device_get_parent(child) != bus) @@ -532,89 +551,132 @@ unin_chip_alloc_resource(device_t bus, device_t child, int type, int *rid, device_get_nameunit(child)); return (NULL); } +} - rv = rman_reserve_resource(rm, adjstart, adjend, adjcount, flags, - child); - if (rv == NULL) { - device_printf(bus, - "failed to reserve resource %#lx - %#lx (%#lx)" - " for %s\n", adjstart, adjend, adjcount, - device_get_nameunit(child)); - return (NULL); +static int +unin_chip_adjust_resource(device_t bus, device_t child, int type, + struct resource *r, rman_res_t start, rman_res_t end) +{ + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + return (bus_generic_rman_adjust_resource(bus, child, type, r, + start, end)); + case SYS_RES_IRQ: + return (bus_generic_adjust_resource(bus, child, type, r, start, + end)); + default: + return (EINVAL); } - - rman_set_rid(rv, *rid); - - if (needactivate) { - if (bus_activate_resource(child, type, *rid, rv) != 0) { - device_printf(bus, - "failed to activate resource for %s\n", - device_get_nameunit(child)); - rman_release_resource(rv); - return (NULL); - } - } - - return (rv); } static int unin_chip_release_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { - if (rman_get_flags(res) & RF_ACTIVE) { - int error = bus_deactivate_resource(child, type, rid, res); - if (error) - return error; + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + return (bus_generic_rman_release_resource(bus, child, type, rid, + res)); + case SYS_RES_IRQ: + return (bus_generic_rl_release_resource(bus, child, type, rid, + res)); + default: + return (EINVAL); } - - return (rman_release_resource(res)); } static int unin_chip_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { - void *p; - - if (type == SYS_RES_IRQ) - return (bus_activate_resource(bus, type, rid, res)); + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + return (bus_generic_rman_activate_resource(bus, child, type, + rid, res)); + case SYS_RES_IRQ: + return (bus_generic_activate_resource(bus, child, type, rid, + res)); + default: + return (EINVAL); + } +} - if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { - vm_offset_t start; +static int +unin_chip_deactivate_resource(device_t bus, device_t child, int type, int rid, + struct resource *res) +{ + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + return (bus_generic_rman_deactivate_resource(bus, child, type, + rid, res)); + case SYS_RES_IRQ: + return (bus_generic_deactivate_resource(bus, child, type, rid, + res)); + default: + return (EINVAL); + } +} - start = (vm_offset_t) rman_get_start(res); +static int +unin_chip_map_resource(device_t bus, device_t child, int type, + struct resource *r, struct resource_map_request *argsp, + struct resource_map *map) +{ + struct resource_map_request args; + rman_res_t length, start; + int error; - if (bootverbose) - printf("unin mapdev: start %zx, len %jd\n", start, - rman_get_size(res)); + /* Resources must be active to be mapped. */ + if (!(rman_get_flags(r) & RF_ACTIVE)) + return (ENXIO); - p = pmap_mapdev(start, (vm_size_t) rman_get_size(res)); - if (p == NULL) - return (ENOMEM); - rman_set_virtual(res, p); - rman_set_bustag(res, &bs_be_tag); - rman_set_bushandle(res, (u_long)p); + /* Mappings are only supported on I/O and memory resources. */ + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + break; + default: + return (EINVAL); } - return (rman_activate_resource(res)); + resource_init_map_request(&args); + error = resource_validate_map_request(r, argsp, &args, &start, &length); + if (error) + return (error); + + if (bootverbose) + printf("nexus mapdev: start %jx, len %jd\n", + (uintmax_t)start, (uintmax_t)length); + + map->r_vaddr = pmap_mapdev_attr(start, length, args.memattr); + if (map->r_vaddr == NULL) + return (ENOMEM); + map->r_bustag = &bs_be_tag; + map->r_size = length; + map->r_bushandle = (bus_space_handle_t)map->r_vaddr; + return (0); } static int -unin_chip_deactivate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) +unin_chip_unmap_resource(device_t bus, device_t child, int type, + struct resource *r, struct resource_map *map) { - /* - * If this is a memory resource, unmap it. - */ - if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { - u_int32_t psize; - - psize = rman_get_size(res); - pmap_unmapdev(rman_get_virtual(res), psize); + /* + * If this is a memory resource, unmap it. + */ + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + pmap_unmapdev(map->r_vaddr, map->r_size); + break; + default: + return (EINVAL); } - - return (rman_deactivate_resource(res)); + return (0); } static struct resource_list *