Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the base address of a pci device in register programming?

Hello Everyone
 I am making a register program to pci-7344.
 At this link http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/15f094f65a17e3af8625660d0018a20a?O... I find a method that finds the correct address in the register programming a pci device,but I am confused with some details.
It says BAR0 is assigned to the miniMITE ASIC,while BAR1 is used to program the PCI device itself.So the address mapped from BAR0 is
supposed to be the base-address of the registers on the miniMITE,but why 0x300 is added to the base-address? What 0x300 means?
I wonder if the address mapped from the BAR1 is not the valid baseadress for the pci board and a initial offset should be added to
it.If so what is the initial offset?
Thank you!!
0 Kudos
Message 1 of 5
(15,274 Views)
BAR0 is the base address of the miniMITE. The PCI configuration register map is mapped to offset 0x300 in BAR0. The first 16-bits are the vendor ID of the PCI devices which, for NI, is 0x1093. That is why the example code add an offset of 0x300. BAR1 is the base address of the device's registers.


However, you need to configure BAR1 as specified on the page you referenced before it is accessible.


geoff

--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 2 of 5
(15,257 Views)

Thank you for your reply !!

 I am developing pci-7344`s driver under venturecom`s rtx,now I have found the baseadresses[0] and baseadresses[1] . baseaddresses[0] is the base-address of the miniMITE and I can get the vendor ID, device ID by directly reading from baseaddresses[0] +offset,but  baseaddresses[1]  does not like to be the base address of the 7344 registers,because I can not get the correct status information when I read from the csr(baseaddresses[1]+0x04)(all the value read back is 1).According to your advice I add the following codes to the program.

 window_data_value = ( (0xffffff00 & (ULONG)BAR1.LowPart) | (0x00000080) );
        *((PLONG)(vMemAddr[0]+0xc0)) = window_data_value;

  vMemAddr[0] is the virtual address that is mapped from BAR0 into the user`s program ,which gives us access to physical memory locations on the system.

  After adding these codes I still can read the correct information from BAR0,but I still can not read back the correct value from BAR1(all the value read back is 0).

 It says in ddk that the csr(a read-only register) is located at cardlogicaddress+4(8byte offset),so I wonder what  the cardlogicaddress is . What is relationship between baseaddresses[1] and cardlogicaddress?

Thank you!!!!!

0 Kudos
Message 3 of 5
(15,253 Views)
I'm not very familiar with our motion control products, but, if from a PCI initialization perspective, they are similar to our DAQ products, the above code should have worked with the following assumptions:


1. BAR1.LowPart is the physical address of BAR1


2. vMemAddr[0] is of type ULONG or PCHAR such that the addition of the offset is correct


3. vMemAddr[0] the same as baseaddresses[0]



As I said, I'm not familiar with the Motion products or their DDK, but I would expect that cardlogicaddress should be the same as baseaddresses[1] if baseaddresses[1] is the mapped address of BAR1.


Hope this helps.


geoff

--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 4 of 5
(15,243 Views)
geoff
Thank you for your advice!!
  As you say the baseaddresses[1] is really the cardlogicaladdress of the card. Now I have read back the correct information of the card!
The problem is my code.It says in ddk that you can write to or read  from the card by directly writing to or reading from an unsigned short pointer(16-bits).However in my previous codes I have used a 8-bits pointer.
Thank you for your help!! 
0 Kudos
Message 5 of 5
(15,243 Views)