Umm, Yes, I'm sure it does. If you hard code a PCI device to the same  
address, it might not. However, if you let Linux auto-assign all the  
PCI addresses, it will do the job correctly. Otherwise computers would  
randomly not boot.

Ali

On Dec 2, 2008, at 4:20 AM, Gabe Black wrote:

> But Linux doesn't behave itself and make sure the PCI devices are  
> always
> at different addresses. That's unfortunate.
>
> Gabe
>
> Gabe Black wrote:
>> I don't disagree with anything you've said, but I think you're  
>> missing
>> my point. When you write 0xFFFFFFFF to a BAR which expects a 256 byte
>> large block of memory, you'd read back 0xFFFFFF00. If you wrote
>> 0x12345678, you would read back 0x12345600. There isn't anything  
>> magical
>> about 0xFFFFFFFF except that you can easily what bits you could  
>> actually
>> change. To quote the PCI spec, page 221 of the pdf, page 207 of the
>> document:
>>
>> The number of upper bits that a device actually implements depends on
>> how much of the
>> address space the device will respond to. A 32-bit register can be
>> implemented to support
>> a single memory size that is a power of 2 from 16 bytes to 2 GB. A
>> device that wants a
>> 1 MB memory address space (using a 32-bit base address register)  
>> would
>> build the top 12
>> bits of the address register, hardwiring the other bits to 0.
>>
>> Power-up software can determine how much address space the device
>> requires by writing
>> a value of all 1's to the register and then reading the value back.  
>> The
>> device will return
>> 0's in all don't-care address bits, effectively specifying the  
>> address
>> space required.
>> Unimplemented Base Address registers are hardwired to zero.
>>
>>
>> So we can stop treating 0xFFFFFFFF as a special case and also start
>> enforcing alignment correctly by combining the code.
>>
>> Ali Saidi wrote:
>>
>>> If you write the address to the BAR the kernel will normally accept
>>> that. If you don't the kernel sets up the address for that BAR
>>> automatically at boot.  If the kernel enforces the alignment
>>> requirement, then the problem is solved. If it doesn't I wouldn't
>>> worry about it because we're not going anything special with
>>> addressing such that we need to enforce it.
>>>
>>> Take a look at how the IGbE adapter sets up it's memory. In that  
>>> case
>>> it's memory space so the LSB of the bar is 0, and the size is 128kB.
>>> So BAR0 = 0 and BAR0Size = '128kB'. The kernel will come around when
>>> it does PCI configuration, write -1 to BAR0 and read back 128kB. It
>>> will then allocate the appropriate region of memory and write the
>>> address the BAR0. The write will preserve the lowest 2 or 3 bits of
>>> the address to indicate I/O, and cachability. In the case of I/O  
>>> space
>>> the exact same thing would happen, but the kernel would know to
>>> allocate the address from it's I/O space not from PCI memory space.
>>>
>>> In both cases it's up to the kernel (or the BIOS) to correctly  
>>> assign
>>> a base address to the BAR register and enforce whatever alignment
>>> constraints are required.
>>>
>>> Ali
>>>
>>>
>>>
>>> On Nov 25, 2008, at 11:22 PM, Gabe Black wrote:
>>>
>>>
>>>
>>>> Writing to BARs doesn't look quite right. According to what I read,
>>>> the
>>>> address you use also has to be aligned to the size of the region
>>>> you're
>>>> working with. You can just align it and set bit 1 all the time, and
>>>> 0xFFFFFFFF will be handled naturally. If you want a 1 MB region of
>>>> memory, you have to align your address on 1 MB which the current  
>>>> code
>>>> won't enforce. That's probably not a big deal, but slightly
>>>> incorrect I
>>>> think.
>>>>
>>>> Gabe
>>>>
>>>> [EMAIL PROTECTED] wrote:
>>>>
>>>>
>>>>> Ah, ok. I see where I was getting confused. There doesn't look  
>>>>> like
>>>>> there's any
>>>>> way to disable a BAR or force it to a particular value, correct?  
>>>>> In
>>>>> reality you
>>>>> wouldn't force a BAR to a particular value you'd just work without
>>>>> it, but that
>>>>> way the existing models won't have to be changed.
>>>>>
>>>>> Gabe
>>>>>
>>>>> Quoting Ali Saidi <[EMAIL PROTECTED]>:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> You should setup the BARs and the BAR sizes with the BARX and
>>>>>> BARSizeX
>>>>>> variables. If you set the BAR to 0x1 and the size to 1024, then  
>>>>>> you
>>>>>> would get an 1024 byte I/O space when Linux reads the bar type,
>>>>>> writes
>>>>>> -1 to read the bar size, and then properly configures the device.
>>>>>>
>>>>>> Ali
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Nov 24, 2008, at 9:50 PM, Gabe Black wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> I dug around in the lspci source a bit, and "[virtual]" means
>>>>>>> that the
>>>>>>> OS has assigned a resource to a device but it doesn't appear  
>>>>>>> in the
>>>>>>> BARs. It shows up as the memory type because bit 0 of an
>>>>>>> "unimplemented"
>>>>>>> BAR is 0, but the address it prints is what the OS reports which
>>>>>>> matches
>>>>>>> with the legacy addresses. "[disabled]" shows up because the
>>>>>>> command
>>>>>>> registers memory bit is 0, again because lspci is  
>>>>>>> misinterpreting
>>>>>>> the
>>>>>>> virtual regions as memory instead of IO. The final region of  
>>>>>>> IO I'm
>>>>>>> assuming is the BMI region in our controller model, and it -is-
>>>>>>> actually
>>>>>>> set up with its BAR.
>>>>>>>
>>>>>>> So the unresolved issue here is still how do I get M5 to do  
>>>>>>> this? I
>>>>>>> need
>>>>>>> to be able to set up an IO BAR and to disable any particular BAR
>>>>>>> and
>>>>>>> force an address in its place. If there's already a way to do  
>>>>>>> this
>>>>>>> then
>>>>>>> please let me know. If not, I'll go ahead and cook one up.
>>>>>>>
>>>>>>> Gabe
>>>>>>>
>>>>>>> Gabe Black wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>  I've been looking at the implementation of the PCI BAR
>>>>>>>> registers,
>>>>>>>> and I can't see how it's possible to set up an IO decoder. The
>>>>>>>> lowest
>>>>>>>> bit of the BAR is supposed to be a 1 for IO addresses, and the
>>>>>>>> BARs
>>>>>>>> are
>>>>>>>> memset to 0 in the constructor. The only way to set them that I
>>>>>>>> see
>>>>>>>> is
>>>>>>>> to write to the BARs, but that preserves what type it is so  
>>>>>>>> it can
>>>>>>>> never
>>>>>>>> change from memory to IO. Also, the thing that sets the range
>>>>>>>> for the
>>>>>>>> various devices just uses the address directly without masking
>>>>>>>> that
>>>>>>>> bit
>>>>>>>> out. What it should do is mask it out, and if it was a 1  
>>>>>>>> transform
>>>>>>>> the
>>>>>>>> rest to an IO address somehow. Also, there doesn't seem to be  
>>>>>>>> any
>>>>>>>> way to
>>>>>>>> disable BARs, or at least not that I see. I have the  
>>>>>>>> mindshare PCI
>>>>>>>> book,
>>>>>>>> and it says that for legacy IO decoders, like what I'm trying  
>>>>>>>> to
>>>>>>>> get to
>>>>>>>> work, the BAR is not implemented. I think that means reading it
>>>>>>>> returns
>>>>>>>> 0, but that part is a little fuzzy. The configuration  
>>>>>>>> software is
>>>>>>>> supposed to then recognize that this is a legacy device and  
>>>>>>>> turn
>>>>>>>> on
>>>>>>>> it's
>>>>>>>> IO decoders in the command register. There doesn't seem to be  
>>>>>>>> any
>>>>>>>> way to
>>>>>>>> set this sort of thing up in the IDE controller, although  
>>>>>>>> that's
>>>>>>>> pretty
>>>>>>>> understandable since Alpha probably doesn't expect devices to  
>>>>>>>> end
>>>>>>>> up in
>>>>>>>> fixed locations. On my system my IDE controller shows up under
>>>>>>>> lspci as
>>>>>>>> copied below. I'm not sure how to interpret all of it, but the
>>>>>>>> "Memory"
>>>>>>>> regions actually correspond to the IO locations the legacy
>>>>>>>> controllers
>>>>>>>> are supposed to be at. They're marked as "[disabled]" which
>>>>>>>> matches
>>>>>>>> the
>>>>>>>> description of the legacy devices, but I don't know how it
>>>>>>>> determined
>>>>>>>> that. They're also marked as "[virtual]" and I have no idea  
>>>>>>>> what
>>>>>>>> that
>>>>>>>> means either, unless it has something to do with an IO MMU.
>>>>>>>>
>>>>>>>> 00:0d.0 IDE interface: nVidia Corporation MCP55 IDE (rev a1)
>>>>>>>> (prog-
>>>>>>>> if 8a
>>>>>>>> [Master SecP PriP])
>>>>>>>>      Subsystem: nVidia Corporation Device c55e
>>>>>>>>      Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV-  
>>>>>>>> VGASnoop-
>>>>>>>> ParErr- Stepping- SERR- FastB2B- DisINTx-
>>>>>>>>      Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=fast
>>>>>>>>
>>>>>>>>
>>>>>>>>> TAbort-
>>>>>>>>>
>>>>>>>>>
>>>>>>>> <TAbort- <MAbort- >SERR- <PERR- INTx-
>>>>>>>>      Latency: 0 (750ns min, 250ns max)
>>>>>>>>      Region 0: [virtual] Memory at 000001f0 (32-bit,
>>>>>>>> non-prefetchable) [disabled] [size=8]
>>>>>>>>      Region 1: [virtual] Memory at 000003f0 (type 3,
>>>>>>>> non-prefetchable) [disabled] [size=1]
>>>>>>>>      Region 2: [virtual] Memory at 00000170 (32-bit,
>>>>>>>> non-prefetchable) [disabled] [size=8]
>>>>>>>>      Region 3: [virtual] Memory at 00000370 (type 3,
>>>>>>>> non-prefetchable) [disabled] [size=1]
>>>>>>>>      Region 4: I/O ports at ec00 [size=16]
>>>>>>>>      Capabilities: [44] Power Management version 2
>>>>>>>>              Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA
>>>>>>>> PME(D0-,D1-,D2-,D3hot-,D3cold-)
>>>>>>>>              Status: D0 PME-Enable- DSel=0 DScale=0 PME-
>>>>>>>>      Kernel driver in use: AMD_IDE
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> m5-dev mailing list
>>>>>>>> [email protected]
>>>>>>>> http://m5sim.org/mailman/listinfo/m5-dev
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> m5-dev mailing list
>>>>>>> [email protected]
>>>>>>> http://m5sim.org/mailman/listinfo/m5-dev
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> _______________________________________________
>>>>>> m5-dev mailing list
>>>>>> [email protected]
>>>>>> http://m5sim.org/mailman/listinfo/m5-dev
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> m5-dev mailing list
>>>>> [email protected]
>>>>> http://m5sim.org/mailman/listinfo/m5-dev
>>>>>
>>>>>
>>>>>
>>>> _______________________________________________
>>>> m5-dev mailing list
>>>> [email protected]
>>>> http://m5sim.org/mailman/listinfo/m5-dev
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> m5-dev mailing list
>>> [email protected]
>>> http://m5sim.org/mailman/listinfo/m5-dev
>>>
>>>
>>
>> _______________________________________________
>> m5-dev mailing list
>> [email protected]
>> http://m5sim.org/mailman/listinfo/m5-dev
>>
>
> _______________________________________________
> m5-dev mailing list
> [email protected]
> http://m5sim.org/mailman/listinfo/m5-dev
>

_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to