From owner-freebsd-hackers Sun Sep 17 19:19:40 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from astart2.astart.com (astart2.astart.com [64.63.58.122]) by hub.freebsd.org (Postfix) with ESMTP id 1637A37B422 for ; Sun, 17 Sep 2000 19:19:35 -0700 (PDT) Received: from h4.private (papowell@h4.private [10.0.0.4]) by astart2.astart.com (8.9.3/8.9.3) with ESMTP id MAA20778 for ; Sun, 17 Sep 2000 12:18:44 -0700 (PDT) (envelope-from papowell@astart.com) Received: (from papowell@localhost) by h4.private (8.9.3/8.9.3) id TAA12263 for freebsd-hackers@freebsd.org; Sun, 17 Sep 2000 19:20:43 -0700 (PDT) Date: Sun, 17 Sep 2000 19:20:43 -0700 (PDT) From: papowell@astart.com Message-Id: <200009180220.TAA12263@h4.private> To: freebsd-hackers@freebsd.org Subject: Device driver, memory map failing, and it is probably obvious Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I am making a driver for a VERY old PCI device. I decided to try using the new 'bus_resource' facilities, and came up with the oddest error. First, here is my 'probe' routine: > static int > digic_probe(device_t dev) > { > static struct digic_type *t; > int vendor = pci_get_vendor(dev); > int did = pci_get_device(dev); > DPRINTF(("myprobe: vendor 0x%x, device 0x%x\n", > vendor, did )); > for( t = digic_devs; t->vid; ++t ){ > if( (t->vid == vendor) && (t->did == did) ){ > DPRINTF(("found '%s'\n", t->name ); > device_set_desc(dev,t->name)); > return(0); > } > } > return( ENXIO ); > } And here is the output it puts out (from dmesg): > Copyright (c) 1992-2000 The FreeBSD Project. > .... > myprobe: vendor 0x1106, device 0x597 > pcib2: at device 1.0 on pci0 > pci1: on pcib2 > myprobe: vendor 0x1002, device 0x4742 Yes it is seeing things... > pci1: at 0.0 irq 11 > isab0: at device 7.0 on pci0 > isa0: on isab0 .... > found 'Digi International PCI Classic 8 Serial Adapter' > my0: \ port 0xdc00-0xdcff,0xd800-0xd87f mem 0xea400000-0xea4000ff,0xea402000-0xea40207f \ irq 12 at device 10.0 on pci0 > digic_attach: unit 0, irq 12, slot 10, progif 0x0, iobase 0xd801, membase 0xea402000, irqline 0x10c > my0: couldn't map memory > device_probe_and_attach: my0 attach returned 6 So it found the card, discovered the vintage hardware id, and printed it out. The we call the attach routine: > static int > digic_attach( device_t dev ) > { > struct digic_softc *digic; > int unit; > int irq, slot, progif, iobase, membase, irqline; > int error = 0; > void *ih = 0; > > /* get the sc structure */ > digic = device_get_softc(dev); > bzero(digic,sizeof(digic[0])); > unit = device_get_unit(dev); > irq = pci_get_irq(dev); > slot = pci_get_slot(dev); > progif = pci_get_progif(dev); > > #define WB_PCI_LOMEM 0x10 > #define WB_PCI_LOIO 0x14 > #define WB_PCI_INTLINE 0x3c > iobase = pci_read_config(dev, WB_PCI_LOIO, 4); > membase = pci_read_config(dev, WB_PCI_LOMEM, 4); > irqline = pci_read_config(dev, WB_PCI_INTLINE, 4); > > DPRINTF(("digic_attach: unit %d, irq %d, slot %d, progif 0x%x, iobase 0x%x, membase 0x%x, irqline 0x%x\n", > unit, irq, slot, progif, iobase, membase, irqline )); > > > switch( pci_get_device(dev) ){ > case PCI_CLASSIC_4: digic->digic_ports = 4; break; > case PCI_CLASSIC_8: digic->digic_ports = 8; break; > default: > device_printf(dev,"digic_attach: bad device id! %d", pci_get_device(dev)); > goto fail; > } > > /* now get the memory resources */ > digic->digic_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, > &digic->digic_mem_rid, > 0, ~0, 256, RF_ACTIVE|RF_SHAREABLE); > if (!digic->digic_mem_res) { > device_printf(dev, "couldn't map memory\n"); > goto fail; > } Now, I am SURE that I must be doing something stupid here - but I snipped this code right out of the code for another driver, and this one works. The only puzzle is: > my0: \ port 0xdc00-0xdcff,0xd800-0xd87f mem 0xea400000-0xea4000ff,0xea402000-0xea40207f \ irq 12 at device 10.0 on pci0 Note that the diagnostic output indicates some VERY strange ranges. Could this be the problem? Patrick Powell Patrick Powell Astart Technologies, papowell@astart.com 9475 Chesapeake Drive, Suite D, Network and System San Diego, CA 92123 Consulting 858-874-6543 FAX 858-279-8424 LPRng - Print Spooler (http://www.astart.com) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message