Subject: Re: PCI_MAPREG_TYPE_ROM... or the lack of it
To: Garrett D'Amore <garrett_damore@tadpole.com>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: tech-kern
Date: 02/26/2006 21:16:40
Garrett D'Amore wrote:
> Allen Briggs wrote:
>   
>> On Fri, Feb 24, 2006 at 07:43:01PM -0800, Garrett D'Amore wrote:
>>   
>>     
>>> Actually, it occurs to me that there is an easier way:
>>>
>>> PCI_MAPREG_TYPE_ROM could be defined the same as PCI_MAPREG_TYPE_MEM,
>>> and the PCI register mapping code could look at the offset of the register.
>>>
>>> PCI_MAPREG_ROM is *always* 0x30.  That's probably a better way to do it.
>>>     
>>>       
>> I agree.  I think it should be noted in the man page that
>> PCI_MAPREG_TYPE_ROM is only valid for PCI_MAPREG_ROM.
>>
>> -allen
>>
>>   
>>     
> Okay, I'm going to take that as the "official" word then.  Expect diffs
> early next week. :-)
>
>     - Garrett
>
>   
My diffs are attached, please review.  These diffs add support for
PCI_MAPREG_TYPE_ROM as an argument to pci_mapreg_map().

A consequence of these changes is that now pci_configure_bus() properly
setups up the PCI expansion ROM BAR at 0x30, whereas before it still
wasn't getting it right (due to an incorrect check against
PCI_CONF_ENABLE_ROM that should only have been PCI_CONF_MAP_ROM.

This means that on *most* systems that use PCI_NETBSD_CONFIGURE, you
will now see Expansion ROMs get allocated address space *and* have that
address written to the ROM BAR, but it will *not* be enabled.

pci_mapreg_map() will *enable* the expansion rom address decoder if not
already done.  As this can have detrimental effects for some devices, it
should only be done in target device drivers that really need this
access to ROMs.  Note that there is *no* standard API for *disabling* an
enabled ROM address decoder.  If you need to do that, just turn off the
enable bit in the ROM address decoder.  (This will not normally be a
problem, since those devices with drivers that need an expansion rom
usually will have a separate address decoder for the expansion rom.)

If none of this makes any sense, rest assured that your devices/drivers
will continue to operate as before.

These diffs do not include the necessary changes to the man pages
(primarily to indicate that PCI_MAPREG_TYPE_ROM is only allowed when reg
is PCI_MAPREG_ROM), but I'll do that as well, assuming that the
technical content of these diffs is acceptable.

    -- Garrett

-- 
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134  Fax: 951 325-2191