PCI Driver Help required

I am writing a QNX driver for PCI device. I am using QNX 6.2.1A OS

my main function works as follows:

  1. attach pci server
  2. Detect and attach the device using pci_attach_device()
  3. Read the BAR0 offset using pci_read_config into a variable addr
  4. map the memory address addr to process address space . I tried allocation
    using both mmap and mmap_device_memory. The handle for address is stored in
    mem_hndl (pointer to void).
  5. try to read and write at various offsets from mem_hndl
  6. Unmap device memory
  7. detach device
  8. detach pci server

my problem is
when i read the device as in step 5:
I get 0xffffffff at any offset irrespective of what i read or write if
memory has been mapped using mmap_devicce_memory
if i use mmap to map memory of device, i am able to read and write
but the problem is that I perform soft reset of device by writing to a bit
of request register (mapped into memory) and this value stays same after
reset.
I am not sure whether my map is correct when i using mmap and
I want to know what is the problem with mmap_device_memory return base
because I cannot write to this map nor read from it? I use
PROT_WRITE|PROT_READ|PROT_NOCACHE for protection pqrameter

Please help me in this regard

Regards
Moreshwar

Please post the output from ‘pci -v’ and also let us know which device you
are trying to attach to.

“Moreshwar Salpekar” <moreshwars@hotmail.com> wrote in message
news:cgmo3u$998$3@inn.qnx.com

I am writing a QNX driver for PCI device. I am using QNX 6.2.1A OS

my main function works as follows:

  1. attach pci server
  2. Detect and attach the device using pci_attach_device()
  3. Read the BAR0 offset using pci_read_config into a variable addr
  4. map the memory address addr to process address space . I tried
    allocation
    using both mmap and mmap_device_memory. The handle for address is stored
    in
    mem_hndl (pointer to void).
  5. try to read and write at various offsets from mem_hndl
  6. Unmap device memory
  7. detach device
  8. detach pci server

my problem is
when i read the device as in step 5:
I get 0xffffffff at any offset irrespective of what i read or write if
memory has been mapped using mmap_devicce_memory
if i use mmap to map memory of device, i am able to read and write
but the problem is that I perform soft reset of device by writing to a bit
of request register (mapped into memory) and this value stays same after
reset.
I am not sure whether my map is correct when i using mmap and
I want to know what is the problem with mmap_device_memory return base
because I cannot write to this map nor read from it? I use
PROT_WRITE|PROT_READ|PROT_NOCACHE for protection pqrameter

Please help me in this regard

Regards
Moreshwar

Hello,

here is an example how to handle the addresses provided by the base
address registers … it’s from the QNX4 documentation :slight_smile:

http://www.pjwstk.edu.pl/~jms/qnx/help/watcom/clibref/qnx/_ca_pci_find_device.html

Regards

Armin Steinhoff


Moreshwar Salpekar wrote:

I am writing a QNX driver for PCI device. I am using QNX 6.2.1A OS

my main function works as follows:

  1. attach pci server
  2. Detect and attach the device using pci_attach_device()
  3. Read the BAR0 offset using pci_read_config into a variable addr
  4. map the memory address addr to process address space . I tried allocation
    using both mmap and mmap_device_memory. The handle for address is stored in
    mem_hndl (pointer to void).
  5. try to read and write at various offsets from mem_hndl
  6. Unmap device memory
  7. detach device
  8. detach pci server

my problem is
when i read the device as in step 5:
I get 0xffffffff at any offset irrespective of what i read or write if
memory has been mapped using mmap_devicce_memory
if i use mmap to map memory of device, i am able to read and write
but the problem is that I perform soft reset of device by writing to a bit
of request register (mapped into memory) and this value stays same after
reset.
I am not sure whether my map is correct when i using mmap and
I want to know what is the problem with mmap_device_memory return base
because I cannot write to this map nor read from it? I use
PROT_WRITE|PROT_READ|PROT_NOCACHE for protection pqrameter

Please help me in this regard

Regards
Moreshwar

I am attaching my code Hope this helps in understanding the code more easily
… (the c source and output as text in zip attachment).
Hope it works in solving my problem. The code was written using ped and
Workspace editor and compiled with qcc (or cc)
The outputs are two different. One for mmap_device_memory
and another for mmap.
for mmap_device_memory variable flgs is set to 0 and for mmap it is
MAP_ANON|MAP_PHYS
when using mmap unmapping is using munmap and with mmap_device_memory is it
using munmap_device_memory
The following files are attached:

  1. pcitest.c the intended file
  2. pcitest_mmap.c file using mmap function
  3. pcitest_mmap_device_memory.c using mmap_device_memory function
  4. pciinfo.txt: relevant output of pci -vvv
  5. mmap.txt output
  6. mmap_device.txt using mmap_device_memory function

Regards
Moreshwar
“Hugh Brown” <hsbrown@qnx.com> wrote in message
news:cgv2ss$k44$1@inn.qnx.com

Please post the output from ‘pci -v’ and also let us know which device you
are trying to attach to.

“Moreshwar Salpekar” <> moreshwars@hotmail.com> > wrote in message
news:cgmo3u$998$> 3@inn.qnx.com> …

I am writing a QNX driver for PCI device. I am using QNX 6.2.1A OS

my main function works as follows:

  1. attach pci server
  2. Detect and attach the device using pci_attach_device()
  3. Read the BAR0 offset using pci_read_config into a variable addr
  4. map the memory address addr to process address space . I tried
    allocation
    using both mmap and mmap_device_memory. The handle for address is stored
    in
    mem_hndl (pointer to void).
  5. try to read and write at various offsets from mem_hndl
  6. Unmap device memory
  7. detach device
  8. detach pci server

my problem is
when i read the device as in step 5:
I get 0xffffffff at any offset irrespective of what i read or write if
memory has been mapped using mmap_devicce_memory
if i use mmap to map memory of device, i am able to read and write
but the problem is that I perform soft reset of device by writing to a
bit
of request register (mapped into memory) and this value stays same
after
reset.
I am not sure whether my map is correct when i using mmap and
I want to know what is the problem with mmap_device_memory return base
because I cannot write to this map nor read from it? I use
PROT_WRITE|PROT_READ|PROT_NOCACHE for protection pqrameter

Please help me in this regard

Regards
Moreshwar


\

begin 666 tosend.zip
M4$L#!!0(`.!T'S$EWQ3W!P$```(#```/=&]S96YD+VUM87 N='AT
MC9%-;L,@$(7WG&(.4$5@X\9=L&@.T$47W58$L(448VKL+'KZ#E Y3?RC>H/
MS7MO9H# :0IO4W<V@V $M+E:9:"9G!IM[X@/#YG?'R9N9@96BYH?:P(?
MQND^C+>8,YNGZC_9>HB0Q!%32F]90Y?HB+@E3W+8$!J/9@00)B*IH '0_V
MVPBV5J%;%B8>2;$@Y8+P!:DB@<%(;5T+JG>-;2%XB4M0.+V^TZ<D!7LW_8JP
M^+>ND_ZFK2EODA3O"M5=)YW&<5H;1H,+\J:;Q1[#Z0L0L[I)WB%CDYQ3[3 M7+O*RX0+C_ H8E@O#@N<1\('QN*.-X:7.XW+_<; 5[VY,=_VTA]02P,$% M@X'0?,7T+=!@&0'P,!4!T;W-E;F0O;6UA<&1E=FEC92YT>'2- MD<UR@R 4A?<\Q7V 3@80&[M@T3Q %UUTVR'\.,Q$I*)9].D+8DT332H;QN\< M#N<B@L,0WH;FJ#M.$"A]ME*#&9SL;>O^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FX?,2 0D9&8`@``+0P``!(
M0@+:!;0(``'1O<V5N9"]P8VEI;F9O+G1X=%!+0(4!0````((MP’S$ MO:=1N 8``($7```0``````````$( "V@34%!T;W-E;F0O<&-I=&5S="YC M4$L!`A0`% ````@`\6T?,;?F_ D_!@B!8!4``````````0`@`+:!&PP` M`'1O<V5N9"]P8VET97-T7VUM87 N8U!+`0(4`!0````(`"=N'S'OD9A.0 8` M`(@6```C``````````$`( "V@8T2!T;W-E;F0O<&-I=&5S=%]M;6%P7V1E
M=FEC95]M96UO<GDN8U!+0(4``H``````(MP'S$````````````````'```` K````````$ #_00X9``!T;W-E;F0O4$L%!@`````'``<QP$``#,9````````
`
end

Sorry I forgot, I am trying to attach CN8478 HDLC controller from Mindspeed
“Hugh Brown” <hsbrown@qnx.com> wrote in message
news:cgv2ss$k44$1@inn.qnx.com

Please post the output from ‘pci -v’ and also let us know which device you
are trying to attach to.

“Moreshwar Salpekar” <> moreshwars@hotmail.com> > wrote in message
news:cgmo3u$998$> 3@inn.qnx.com> …

I am writing a QNX driver for PCI device. I am using QNX 6.2.1A OS

my main function works as follows:

  1. attach pci server
  2. Detect and attach the device using pci_attach_device()
  3. Read the BAR0 offset using pci_read_config into a variable addr
  4. map the memory address addr to process address space . I tried
    allocation
    using both mmap and mmap_device_memory. The handle for address is stored
    in
    mem_hndl (pointer to void).
  5. try to read and write at various offsets from mem_hndl
  6. Unmap device memory
  7. detach device
  8. detach pci server

my problem is
when i read the device as in step 5:
I get 0xffffffff at any offset irrespective of what i read or write if
memory has been mapped using mmap_devicce_memory
if i use mmap to map memory of device, i am able to read and write
but the problem is that I perform soft reset of device by writing to a
bit
of request register (mapped into memory) and this value stays same
after
reset.
I am not sure whether my map is correct when i using mmap and
I want to know what is the problem with mmap_device_memory return base
because I cannot write to this map nor read from it? I use
PROT_WRITE|PROT_READ|PROT_NOCACHE for protection pqrameter

Please help me in this regard

Regards
Moreshwar

\

Just do the following for the mmap_device_memory:

mem_hndl = mmap_device_memory (NULL, inf.BaseAddressSize [0], PROT_READ |
PROT_WRITE | PROT_NOCACHE, MAP_SHARED, addr_hndl);

This should work for you.

“Moreshwar Salpekar” <moreshwars@hotmail.com> wrote in message
news:ch6vkl$n3k$3@inn.qnx.com

I am attaching my code Hope this helps in understanding the code more
easily
. (the c source and output as text in zip attachment).
Hope it works in solving my problem. The code was written using ped and
Workspace editor and compiled with qcc (or cc)
The outputs are two different. One for mmap_device_memory
and another for mmap.
for mmap_device_memory variable flgs is set to 0 and for mmap it is
MAP_ANON|MAP_PHYS
when using mmap unmapping is using munmap and with mmap_device_memory is
it
using munmap_device_memory
The following files are attached:

  1. pcitest.c the intended file
  2. pcitest_mmap.c file using mmap function
  3. pcitest_mmap_device_memory.c using mmap_device_memory function
  4. pciinfo.txt: relevant output of pci -vvv
  5. mmap.txt output
  6. mmap_device.txt using mmap_device_memory function

Regards
Moreshwar
“Hugh Brown” <> hsbrown@qnx.com> > wrote in message
news:cgv2ss$k44$> 1@inn.qnx.com> …
Please post the output from ‘pci -v’ and also let us know which device
you
are trying to attach to.

“Moreshwar Salpekar” <> moreshwars@hotmail.com> > wrote in message
news:cgmo3u$998$> 3@inn.qnx.com> …

I am writing a QNX driver for PCI device. I am using QNX 6.2.1A OS

my main function works as follows:

  1. attach pci server
  2. Detect and attach the device using pci_attach_device()
  3. Read the BAR0 offset using pci_read_config into a variable addr
  4. map the memory address addr to process address space . I tried
    allocation
    using both mmap and mmap_device_memory. The handle for address is
    stored
    in
    mem_hndl (pointer to void).
  5. try to read and write at various offsets from mem_hndl
  6. Unmap device memory
  7. detach device
  8. detach pci server

my problem is
when i read the device as in step 5:
I get 0xffffffff at any offset irrespective of what i read or write if
memory has been mapped using mmap_devicce_memory
if i use mmap to map memory of device, i am able to read and write
but the problem is that I perform soft reset of device by writing to a
bit
of request register (mapped into memory) and this value stays same
after
reset.
I am not sure whether my map is correct when i using mmap and
I want to know what is the problem with mmap_device_memory return base
because I cannot write to this map nor read from it? I use
PROT_WRITE|PROT_READ|PROT_NOCACHE for protection pqrameter

Please help me in this regard

Regards
Moreshwar




\

This is not working getting all f’s from any addresses. value read is
0xffffffff
“Hugh Brown” <hsbrown@qnx.com> wrote in message
news:ch70n5$nsq$1@inn.qnx.com

Just do the following for the mmap_device_memory:

mem_hndl = mmap_device_memory (NULL, inf.BaseAddressSize [0], PROT_READ |
PROT_WRITE | PROT_NOCACHE, MAP_SHARED, addr_hndl);

This should work for you.

“Moreshwar Salpekar” <> moreshwars@hotmail.com> > wrote in message
news:ch6vkl$n3k$> 3@inn.qnx.com> …
I am attaching my code Hope this helps in understanding the code more
easily
. (the c source and output as text in zip attachment).
Hope it works in solving my problem. The code was written using ped and
Workspace editor and compiled with qcc (or cc)
The outputs are two different. One for mmap_device_memory
and another for mmap.
for mmap_device_memory variable flgs is set to 0 and for mmap it is
MAP_ANON|MAP_PHYS
when using mmap unmapping is using munmap and with mmap_device_memory is
it
using munmap_device_memory
The following files are attached:

  1. pcitest.c the intended file
  2. pcitest_mmap.c file using mmap function
  3. pcitest_mmap_device_memory.c using mmap_device_memory function
  4. pciinfo.txt: relevant output of pci -vvv
  5. mmap.txt output
  6. mmap_device.txt using mmap_device_memory function

Regards
Moreshwar
“Hugh Brown” <> hsbrown@qnx.com> > wrote in message
news:cgv2ss$k44$> 1@inn.qnx.com> …
Please post the output from ‘pci -v’ and also let us know which device
you
are trying to attach to.

“Moreshwar Salpekar” <> moreshwars@hotmail.com> > wrote in message
news:cgmo3u$998$> 3@inn.qnx.com> …

I am writing a QNX driver for PCI device. I am using QNX 6.2.1A OS

my main function works as follows:

  1. attach pci server
  2. Detect and attach the device using pci_attach_device()
  3. Read the BAR0 offset using pci_read_config into a variable addr
  4. map the memory address addr to process address space . I tried
    allocation
    using both mmap and mmap_device_memory. The handle for address is
    stored
    in
    mem_hndl (pointer to void).
  5. try to read and write at various offsets from mem_hndl
  6. Unmap device memory
  7. detach device
  8. detach pci server

my problem is
when i read the device as in step 5:
I get 0xffffffff at any offset irrespective of what i read or write
if
memory has been mapped using mmap_devicce_memory
if i use mmap to map memory of device, i am able to read and write
but the problem is that I perform soft reset of device by writing to
a
bit
of request register (mapped into memory) and this value stays same
after
reset.
I am not sure whether my map is correct when i using mmap and
I want to know what is the problem with mmap_device_memory return
base
because I cannot write to this map nor read from it? I use
PROT_WRITE|PROT_READ|PROT_NOCACHE for protection pqrameter

Please help me in this regard

Regards
Moreshwar






\

Well if this is the case, then there is something else wrong. I don’t have
the specs for your chip, so there is not much more I can do. What you were
doing in your program is correct, just the mmap_device_memory had to be
changed.

“Moreshwar Salpekar” <moreshwars@hotmail.com> wrote in message
news:ch732o$pmm$3@inn.qnx.com

This is not working getting all f’s from any addresses. value read is
0xffffffff
“Hugh Brown” <> hsbrown@qnx.com> > wrote in message
news:ch70n5$nsq$> 1@inn.qnx.com> …
Just do the following for the mmap_device_memory:

mem_hndl = mmap_device_memory (NULL, inf.BaseAddressSize [0], PROT_READ
|
PROT_WRITE | PROT_NOCACHE, MAP_SHARED, addr_hndl);

This should work for you.

“Moreshwar Salpekar” <> moreshwars@hotmail.com> > wrote in message
news:ch6vkl$n3k$> 3@inn.qnx.com> …
I am attaching my code Hope this helps in understanding the code more
easily
. (the c source and output as text in zip attachment).
Hope it works in solving my problem. The code was written using ped
and
Workspace editor and compiled with qcc (or cc)
The outputs are two different. One for mmap_device_memory
and another for mmap.
for mmap_device_memory variable flgs is set to 0 and for mmap it is
MAP_ANON|MAP_PHYS
when using mmap unmapping is using munmap and with mmap_device_memory
is
it
using munmap_device_memory
The following files are attached:

  1. pcitest.c the intended file
  2. pcitest_mmap.c file using mmap function
  3. pcitest_mmap_device_memory.c using mmap_device_memory function
  4. pciinfo.txt: relevant output of pci -vvv
  5. mmap.txt output
  6. mmap_device.txt using mmap_device_memory function

Regards
Moreshwar
“Hugh Brown” <> hsbrown@qnx.com> > wrote in message
news:cgv2ss$k44$> 1@inn.qnx.com> …
Please post the output from ‘pci -v’ and also let us know which
device
you
are trying to attach to.

“Moreshwar Salpekar” <> moreshwars@hotmail.com> > wrote in message
news:cgmo3u$998$> 3@inn.qnx.com> …

I am writing a QNX driver for PCI device. I am using QNX 6.2.1A OS

my main function works as follows:

  1. attach pci server
  2. Detect and attach the device using pci_attach_device()
  3. Read the BAR0 offset using pci_read_config into a variable addr
  4. map the memory address addr to process address space . I tried
    allocation
    using both mmap and mmap_device_memory. The handle for address is
    stored
    in
    mem_hndl (pointer to void).
  5. try to read and write at various offsets from mem_hndl
  6. Unmap device memory
  7. detach device
  8. detach pci server

my problem is
when i read the device as in step 5:
I get 0xffffffff at any offset irrespective of what i read or
write
if
memory has been mapped using mmap_devicce_memory
if i use mmap to map memory of device, i am able to read and write
but the problem is that I perform soft reset of device by writing
to
a
bit
of request register (mapped into memory) and this value stays
same
after
reset.
I am not sure whether my map is correct when i using mmap and
I want to know what is the problem with mmap_device_memory return
base
because I cannot write to this map nor read from it? I use
PROT_WRITE|PROT_READ|PROT_NOCACHE for protection pqrameter

Please help me in this regard

Regards
Moreshwar








\

Moreshwar Salpekar wrote:

This is not working getting all f’s from any addresses. value read is
0xffffffff

Your pci_read_config call for reading the base address register values
is probably wrong.

The values of the base address registers
are available as e.g. ‘inf.PciBaseAdress[0]’ a.s.o.
(inf will be initialized by the pci_attach_device call … )

Regards

Armin Steinhoff




“Hugh Brown” <> hsbrown@qnx.com> > wrote in message
news:ch70n5$nsq$> 1@inn.qnx.com> …

Just do the following for the mmap_device_memory:

mem_hndl = mmap_device_memory (NULL, inf.BaseAddressSize [0], PROT_READ |
PROT_WRITE | PROT_NOCACHE, MAP_SHARED, addr_hndl);

This should work for you.

“Moreshwar Salpekar” <> moreshwars@hotmail.com> > wrote in message
news:ch6vkl$n3k$> 3@inn.qnx.com> …

I am attaching my code Hope this helps in understanding the code more

easily

. (the c source and output as text in zip attachment).
Hope it works in solving my problem. The code was written using ped and
Workspace editor and compiled with qcc (or cc)
The outputs are two different. One for mmap_device_memory
and another for mmap.
for mmap_device_memory variable flgs is set to 0 and for mmap it is
MAP_ANON|MAP_PHYS
when using mmap unmapping is using munmap and with mmap_device_memory is

it

using munmap_device_memory
The following files are attached:

  1. pcitest.c the intended file
  2. pcitest_mmap.c file using mmap function
  3. pcitest_mmap_device_memory.c using mmap_device_memory function
  4. pciinfo.txt: relevant output of pci -vvv
  5. mmap.txt output
  6. mmap_device.txt using mmap_device_memory function

Regards
Moreshwar
“Hugh Brown” <> hsbrown@qnx.com> > wrote in message
news:cgv2ss$k44$> 1@inn.qnx.com> …

Please post the output from ‘pci -v’ and also let us know which device

you

are trying to attach to.

“Moreshwar Salpekar” <> moreshwars@hotmail.com> > wrote in message
news:cgmo3u$998$> 3@inn.qnx.com> …

I am writing a QNX driver for PCI device. I am using QNX 6.2.1A OS

my main function works as follows:

  1. attach pci server
  2. Detect and attach the device using pci_attach_device()
  3. Read the BAR0 offset using pci_read_config into a variable addr
  4. map the memory address addr to process address space . I tried

allocation

using both mmap and mmap_device_memory. The handle for address is

stored

in

mem_hndl (pointer to void).
5. try to read and write at various offsets from mem_hndl
6. Unmap device memory
7. detach device
8. detach pci server

my problem is
when i read the device as in step 5:
I get 0xffffffff at any offset irrespective of what i read or write

if

memory has been mapped using mmap_devicce_memory
if i use mmap to map memory of device, i am able to read and write
but the problem is that I perform soft reset of device by writing to

a

bit

of request register (mapped into memory) and this value stays same

after

reset.
I am not sure whether my map is correct when i using mmap and
I want to know what is the problem with mmap_device_memory return

base

because I cannot write to this map nor read from it? I use
PROT_WRITE|PROT_READ|PROT_NOCACHE for protection pqrameter

Please help me in this regard

Regards
Moreshwar






\