Date: Wed, 2 Sep 1998 19:34:00 +0200 (CEST) From: Wilko Bulte <wilko@yedi.iaf.nl> To: wpaul@skynet.ctr.columbia.edu (Bill Paul) Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: pci memory mapping Message-ID: <199809021734.TAA10258@yedi.iaf.nl> In-Reply-To: <199809021322.JAA08429@skynet.ctr.columbia.edu> from Bill Paul at "Sep 2, 98 09:22:48 am"
next in thread | previous in thread | raw e-mail | index | archive | help
As Bill Paul wrote... > Of all the gin joints in all the towns in all the world, Wilko Bulte had > to walk into mine and say: > > > Hi there, > > > > I'm trying to get a Mylex DAC960PD to work with a driver skeleton Ulf > > wrote. As I have a different Mylex board than Ulf (a PD iso a PG) I need > > to make some changes. > > > > For some reason the followin code in attach() fails: > > > > if (!pci_map_mem(config_id, PCI_MAP_REG_START, &mp->vbase, > > &mp->pbase)) { > > printf("myx%d: couldn't map memory\n", unit); > > goto fail; > > } > > > > From a previous post by Bill Paul I get the impression (...) that I might need > > to enable memory mapping by doing a pci_conf_write(). But what params > > do I feed pci_conf_write()? > > Given that you learned this from a posting by Bill Paul, would it not then > make sense to read the driver code that Bill Paul has recently written to > see how he did it? :) "Guilty your Honor" %-) > > This is all new to me, I could really use some advise here. > > First of all, bear in mind that not every PCI device supports memory > mapping of its registers. To find out if yours does or not, you need > to check the device's manual or datasheet. Right.... manual...... I'm still trying to convince Mylex that handing me a copy of the DAC960 V2.xx programming manual will not wipe all life from Planet Earth. Sigh. Sample code from Linux and Ulf's driver are based on firmware V4.xx which is different in it's interface to the OS. > It's also possible that the device does support memory mapped access > but the 'memory map enable' bit in the command register is off. To turn > it on, you need to do something like the following: > > u_int32_t command; > > /* read the PCI command register */ > command = pci_conf_read(config_id, PCI_COMMAND_STATUS_REG); > /* set the memory map enable bit */ > command |= PCIM_CMD_MEMEN; > /* write it back to the register */ > pci_conf_write(config_id, PCI_COMMAND_STATUS_REG, command); > /* check that it worked */ > command = pci_conf_read(config_id, PCI_COMMAND_STATUS_REG); > if (!(command & PCIM_CMD_MEMEN)) > printf("failed to enable memory mapped access!\n"); > > Note that this is for -current. The constant PCIM_CMD_MEMEN has a > different name in 2.2.x. If you compare the XL driver from 3.0 and > 2.2.x, you can see the differences. The constants are defined in > /sys/pci/pcireg.h. OK, I followed your advise, and unfortunately still no-go. It is quite possible that the DAC960 old firmware does not do memory mapped access. > If the bit doesn't come on after you write to the command register, it > probably means the device doesn't actually support memory mapped access. Well, the bit comes on because the printf() is not triggered. But still I get the 'cannot map memory' from the code sample at the top of this mail. > In this case, the driver must use PIO access (inb/outb). For this, you > must make sure the PCIM_CMD_PORTEN bit is set. Lastly, if the device is > a bus master (and being a disk controller I suppose it would make sense > that it would be) you should check that the PCIM_CMD_BUSMASTEREN bit is > set too. I'll check, maybe some kind soul at Mylex can at least tell me if V2.x firmware supports memory mapping or not. > I'm not certain why these bits are not always on, however I've heard > nebulous statements that this has something to do with Windows turning > them off and the PCI BIOS leaving that way. I decided to always try > forcing them on just to cover myself. Sounds like a reasonable idea ;-) Wilko _ ______________________________________________________________________ | / o / / _ Bulte email: wilko@yedi.iaf.nl |/|/ / / /( (_) Arnhem, The Netherlands WWW : http://www.tcja.nl ______________________________________________ Powered by FreeBSD __________ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809021734.TAA10258>