PCI Address space?

How do you find a block of PCI memory that is not allocated to other either
physical memory, or another PCI device?
I have I VME bridge identifies it’s self to the PCI for the registers map,
but require the developer to setup the VME to PCI addressing. Right now I
am hard coding a VME bridge card to use PCI address space at E0000000 for a
64K length. And it works, but if I add another card to the system I don’t
know that I won’t get a address space conflict. How do I grab an unused
block of addresses intellegently once the system comes up and I run my
driver?

Pete

EZK <peter.w.eddy@lmco.com> wrote:

How do you find a block of PCI memory that is not allocated to other either
physical memory, or another PCI device?
I have I VME bridge identifies it’s self to the PCI for the registers map,
but require the developer to setup the VME to PCI addressing. Right now I
am hard coding a VME bridge card to use PCI address space at E0000000 for a
64K length. And it works, but if I add another card to the system I don’t
know that I won’t get a address space conflict. How do I grab an unused
block of addresses intellegently once the system comes up and I run my
driver?

If you’re developing under QNX 6.1, you should have a pci-server running
for you target. That being the case you can use the pci_* series of
functions to communicate with your PCI device. Check out the docs for
pci_attach_device() at:

http://qdn.qnx.com/support/docs/neutrino/lib_ref/p/pci_attach_device.html

At the bottom are links to the related calls for pci_*

-Adam
amallory@qnx.com

The pci_attach_device call seems to just gives me resources that are already
allocated to a device I need to allocate, PCI space that is NOT already
allocated to the card. Is there some special combination of flags needed to
add another block of memory to the device? I’ve been beating my head off of
this one for a while, non of the pci_ functions seem to do what I need. The
VME chip vendor says, “your OS should provide a function for that.” PLEASE
help.

Thanks
-Pete

If you’re developing under QNX 6.1, you should have a pci-server running
for you target. That being the case you can use the pci_* series of
functions to communicate with your PCI device. Check out the docs for
pci_attach_device() at:

http://qdn.qnx.com/support/docs/neutrino/lib_ref/p/pci_attach_device.html

At the bottom are links to the related calls for pci_*

-Adam
amallory@qnx.com

Take a look at the rsrcdbmgr… range of functions that will allow you to
allocate unused memory, I/O or IRQs from procnto. These functions together
with the pci_write_config() functions should give you what you need to
program your VME device.

Previously, EZK wrote in qdn.public.qnxrtp.os:

The pci_attach_device call seems to just gives me resources that are already
allocated to a device I need to allocate, PCI space that is NOT already
allocated to the card. Is there some special combination of flags needed to
add another block of memory to the device? I’ve been beating my head off of
this one for a while, non of the pci_ functions seem to do what I need. The
VME chip vendor says, “your OS should provide a function for that.” PLEASE
help.

Thanks
-Pete


If you’re developing under QNX 6.1, you should have a pci-server running
for you target. That being the case you can use the pci_* series of
functions to communicate with your PCI device. Check out the docs for
pci_attach_device() at:

http://qdn.qnx.com/support/docs/neutrino/lib_ref/p/pci_attach_device.html

At the bottom are links to the related calls for pci_*

-Adam
amallory@qnx.com

I tried the example from the online help, and it doesn’t link when I compile
it as a CPP file, but links fine when I compile it as a .C file. Why does
that happen? Is there a different library I need to link in C++?
The target app was being done in C++.

Pete

“Hugh Brown” <hsbrown@qnx.com> wrote in message
news:Voyager.010828080826.22888C@node90.ott.qnx.com

Take a look at the rsrcdbmgr… range of functions that will allow you to
allocate unused memory, I/O or IRQs from procnto. These functions together
with the pci_write_config() functions should give you what you need to
program your VME device.

Thanks.
I think it should help. The only problem is I am using C++, and those calls
don’t seem to link in C++. I copyed the example strait from the HTML page,
and pasted it into a .CPP file to try it out, and it fails to link. If I
change the name to a .C file it links fine. What causes this and how can I
fix it?

Pete.

“Hugh Brown” <hsbrown@qnx.com> wrote in message
news:Voyager.010828080826.22888C@node90.ott.qnx.com

Take a look at the rsrcdbmgr… range of functions that will allow you to
allocate unused memory, I/O or IRQs from procnto. These functions together
with the pci_write_config() functions should give you what you need to
program your VME device.

Sounds like a possible name mangling problem. Are you calling any C functions
from your C++ code? Are they protected from name mangling (extern “C”)?

EZK wrote:

Thanks.
I think it should help. The only problem is I am using C++, and those calls
don’t seem to link in C++. I copyed the example strait from the HTML page,
and pasted it into a .CPP file to try it out, and it fails to link. If I
change the name to a .C file it links fine. What causes this and how can I
fix it?

Pete.

“Hugh Brown” <> hsbrown@qnx.com> > wrote in message
news:> Voyager.010828080826.22888C@node90.ott.qnx.com> …
Take a look at the rsrcdbmgr… range of functions that will allow you to
allocate unused memory, I/O or IRQs from procnto. These functions together
with the pci_write_config() functions should give you what you need to
program your VME device.

“Dean Douthat” <ddouthat@faac.com> wrote in message
news:3B8E578B.6B5D7DE2@faac.com

Sounds like a possible name mangling problem. Are you calling any C
functions
from your C++ code? Are they protected from name mangling (extern “C”)?

It’s the OS calls that are giving me compiler errors. If I just add a

extern “C” int rsrcdbmgr(…), I get redeclairation errors. How do I
compile library calls without modifying the header files myself?

Pete

EZK <peter.w.eddy@lmco.com> wrote:

Sounds like a possible name mangling problem. Are you calling any C
functions
from your C++ code? Are they protected from name mangling (extern “C”)?

It’s the OS calls that are giving me compiler errors. If I just add a
extern “C” int rsrcdbmgr(…), I get redeclairation errors. How do I
compile library calls without modifying the header files myself?

I took the sample from the help system, and made some modifications to
get it to compile and link for C++.

Note the use of extern “C” around the includes, so you don’t need to modify
headers yourself. If the file is names test.cc, you can compile it
using “QCC ./test.cc -o test” and it should build fine.

-Adam
amallory@qnx.com


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef __cplusplus
extern “C” {
#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>
}
#endif

int main(int argc, char **argv) {
int count;
rsrc_request_t req;

memset(&req, 0, sizeof(req));
req.length = 1;
req.flags = RSRCDBMGR_DMA_CHANNEL;
count = 1;

if (rsrcdbmgr_attach( &req, count) == -1) {
perror("Problem attaching to resource ");
exit(1);
}

printf(“You can use DMA channel 0x%llx \n”,
req.start);

/* Do something with the acquired resource */

/* To return the resource to the database: */
if (rsrcdbmgr_detach( &req, count) == -1) {
perror(“Problem detaching resource \n”);
exit(1);
}

return(0);
}