From owner-svn-src-head@FreeBSD.ORG Wed Feb 18 20:42:43 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89C9D106566B; Wed, 18 Feb 2009 20:42:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D0CC8FC15; Wed, 18 Feb 2009 20:42:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1IKghBB074156; Wed, 18 Feb 2009 20:42:43 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1IKghwU074155; Wed, 18 Feb 2009 20:42:43 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200902182042.n1IKghwU074155@svn.freebsd.org> From: Alexander Motin Date: Wed, 18 Feb 2009 20:42:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188762 - head/sys/dev/ata X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2009 20:42:44 -0000 Author: mav Date: Wed Feb 18 20:42:42 2009 New Revision: 188762 URL: http://svn.freebsd.org/changeset/base/188762 Log: Implement proper attach/detach routines for ISA driver. Modified: head/sys/dev/ata/ata-isa.c Modified: head/sys/dev/ata/ata-isa.c ============================================================================== --- head/sys/dev/ata/ata-isa.c Wed Feb 18 20:12:08 2009 (r188761) +++ head/sys/dev/ata/ata-isa.c Wed Feb 18 20:42:42 2009 (r188762) @@ -60,15 +60,49 @@ static struct isa_pnp_id ata_ids[] = { static int ata_isa_probe(device_t dev) { - struct ata_channel *ch = device_get_softc(dev); struct resource *io = NULL, *ctlio = NULL; u_long tmp; - int i, rid; + int rid; /* check isapnp ids */ if (ISA_PNP_PROBE(device_get_parent(dev), dev, ata_ids) == ENXIO) return ENXIO; - + + /* allocate the io port range */ + rid = ATA_IOADDR_RID; + if (!(io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, + ATA_IOSIZE, RF_ACTIVE))) + return ENXIO; + + /* set the altport range */ + if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, &tmp, &tmp)) { + bus_set_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, + rman_get_start(io) + ATA_CTLOFFSET, ATA_CTLIOSIZE); + } + + /* allocate the altport range */ + rid = ATA_CTLADDR_RID; + if (!(ctlio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, + ATA_CTLIOSIZE, RF_ACTIVE))) { + bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); + return ENXIO; + } + + /* Release resources to reallocate on attach. */ + bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlio); + bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); + + return (ata_probe(dev)); +} + +static int +ata_isa_attach(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + struct resource *io = NULL, *ctlio = NULL; + u_long tmp; + int i, rid; + /* allocate the io port range */ rid = ATA_IOADDR_RID; if (!(io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, @@ -103,13 +137,29 @@ ata_isa_probe(device_t dev) ch->unit = 0; ch->flags |= ATA_USE_16BIT; ata_generic_hw(dev); - return ata_probe(dev); + return ata_attach(dev); +} + +static int +ata_isa_detach(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + int error; + + error = ata_detach(dev); + + bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, + ch->r_io[ATA_CONTROL].res); + bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, + ch->r_io[ATA_IDX_ADDR].res); + return (error); } static device_method_t ata_isa_methods[] = { /* device interface */ DEVMETHOD(device_probe, ata_isa_probe), - DEVMETHOD(device_attach, ata_attach), + DEVMETHOD(device_attach, ata_isa_attach), + DEVMETHOD(device_detach, ata_isa_detach), DEVMETHOD(device_suspend, ata_suspend), DEVMETHOD(device_resume, ata_resume),