PCI Driver Server.

I’m writing a pci driver server which I need to be able to attach an ISR in
a
client. The problem I’m having is when I run the driver standalone
everything
work fine, Interrupts and all. As soon as I move the ISR to the client and
map
the pci address I get no interrupts. Any suggestions?

Tom.

Tom <pwc@ag-signs.com> wrote:
T > I’m writing a pci driver server which I need to be able to attach an ISR in
T > a
T > client. The problem I’m having is when I run the driver standalone
T > everything
T > work fine, Interrupts and all. As soon as I move the ISR to the client and
T > map
T > the pci address I get no interrupts. Any suggestions?

T > Tom.

Is your client also run as root and linked with -T1 ?

Bill,

Yes. Could it have something to do with the mmap?

Tom.

“Bill Caroselli” <qtps@earthlink.net> wrote in message
news:c8srn1$jh8$1@inn.qnx.com

Tom <> pwc@ag-signs.com> > wrote:
T > I’m writing a pci driver server which I need to be able to attach an
ISR in
T > a
T > client. The problem I’m having is when I run the driver standalone
T > everything
T > work fine, Interrupts and all. As soon as I move the ISR to the
client and
T > map
T > the pci address I get no interrupts. Any suggestions?

T > Tom.

Is your client also run as root and linked with -T1 ?

Perhaps you could explain a little more about what you mean when you say it
runs as a stand-alone driver but not as a client. What are you calling a
driver and what are you calling a client?


Tom <pwc@ag-signs.com> wrote:
T > Bill,

T > Yes. Could it have something to do with the mmap?

T > Tom.

T > “Bill Caroselli” <qtps@earthlink.net> wrote in message
T > news:c8srn1$jh8$1@inn.qnx.com

Tom <> pwc@ag-signs.com> > wrote:
T > I’m writing a pci driver server which I need to be able to attach an
T > ISR in
T > a
T > client. The problem I’m having is when I run the driver standalone
T > everything
T > work fine, Interrupts and all. As soon as I move the ISR to the
T > client and
T > map
T > the pci address I get no interrupts. Any suggestions?

T > Tom.

Is your client also run as root and linked with -T1 ?

For the stand-alone drive I have the ISR as part of the driver, for testing.
This
way everything works fine. As soon as I move the ISR to the client, ISR no
longer works. The only thing I’m doing different is moving the ISR to the
client and calling the PCI-init routines to get access to the bus address.
Everything
else works fine through send/receive. I call openDevice in server and then
again
in client to get address.

int openDevice()
{
struct _pci_config_regs creg;
unsigned int lastbus, version, hardware, busnum, device;

int fd;
char *page_ptr;
char *mem_base;

if (openedDevice) {
return 1;
}

/* Find all PCI-units /
if (_CA_PCI_BIOS_Present(&lastbus, &version, &hardware) == PCI_SUCCESS) {
// All bus and units
for (busnum = 0; busnum <= lastbus; busnum++) {
for (device = 0; device < 32; device++) {
/
Obtain PCI information */
_CA_PCI_Read_Config_DWord(busnum, device << 3, 0, 16, (char
*)&creg);

if ((creg.Device_ID == PCI_DEVICE_ID_1) || (creg.Device_ID ==
PCI_DEVICE_ID_2)) {
pci_bar_0 = PCI_MEM_ADDR(creg.Base_Address_Regs[0]);

// you might want to map in the memory area
fd = shm_open( “Physical”, O_RDWR, 0777 );
if ( fd == -1 ) {
perror(“Error shm_open:”);
exit (-1);
}
page_ptr = mmap (0, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
PCI_MEM_ADDR(creg.Base_Address_Regs[0]) & ~0xfff);

if (page_ptr == (char *) -1) {
perror(“Error mmap:”);
exit (-1);
}
mem_base = page_ptr + (pci_bar_0 & 0xfff);
close(fd);

isystem.board[0].base = (DWORD)mem_base;
isystem.board[0].irqline = creg.Interrupt_Line;
irq = creg.Interrupt_Line;

fprintf(stderr, “\nVendor %x, DeviceId %x, Base Addr %x, Device
Number %d, Int %d\n”,
creg.Vendor_ID, creg.Device_ID, pci_bar_3, device, irq);

openedDevice = 1;

return 1;
}
}
}
} else {
fprintf(stderr, “NO BIOS32 found\n”);
}
fprintf(stderr, “PCI device not found\n”);

return 0;
}

Tom.


“Bill Caroselli” <qtps@earthlink.net> wrote in message
news:c8tm10$a9d$1@inn.qnx.com

Perhaps you could explain a little more about what you mean when you say
it
runs as a stand-alone driver but not as a client. What are you calling a
driver and what are you calling a client?


Tom <> pwc@ag-signs.com> > wrote:
T > Bill,

T > Yes. Could it have something to do with the mmap?

T > Tom.

T > “Bill Caroselli” <> qtps@earthlink.net> > wrote in message
T > news:c8srn1$jh8$> 1@inn.qnx.com> …
Tom <> pwc@ag-signs.com> > wrote:
T > I’m writing a pci driver server which I need to be able to attach
an
T > ISR in
T > a
T > client. The problem I’m having is when I run the driver standalone
T > everything
T > work fine, Interrupts and all. As soon as I move the ISR to the
T > client and
T > map
T > the pci address I get no interrupts. Any suggestions?

T > Tom.

Is your client also run as root and linked with -T1 ?

Tom <pwc@ag-signs.com> wrote:

For the stand-alone drive I have the ISR as part of the driver, for testing.
This
way everything works fine. As soon as I move the ISR to the client, ISR no
longer works. The only thing I’m doing different is moving the ISR to the
client and calling the PCI-init routines to get access to the bus address.
Everything
else works fine through send/receive. I call openDevice in server and then
again
in client to get address.

What error do you get? Do all the _CA_PCI calls complete properly?

Note, it is unusual to have both client & server (driver) attach to the
interrupt – usually only the driver does so, and it handles the interrupts
and passes the data back to the client.

When you move the ISR to the client, do you compile it the same way?

-David

int openDevice()
{
struct _pci_config_regs creg;
unsigned int lastbus, version, hardware, busnum, device;

int fd;
char *page_ptr;
char *mem_base;

if (openedDevice) {
return 1;
}

/* Find all PCI-units /
if (_CA_PCI_BIOS_Present(&lastbus, &version, &hardware) == PCI_SUCCESS) {
// All bus and units
for (busnum = 0; busnum <= lastbus; busnum++) {
for (device = 0; device < 32; device++) {
/
Obtain PCI information */
_CA_PCI_Read_Config_DWord(busnum, device << 3, 0, 16, (char
*)&creg);

if ((creg.Device_ID == PCI_DEVICE_ID_1) || (creg.Device_ID ==
PCI_DEVICE_ID_2)) {
pci_bar_0 = PCI_MEM_ADDR(creg.Base_Address_Regs[0]);

// you might want to map in the memory area
fd = shm_open( “Physical”, O_RDWR, 0777 );
if ( fd == -1 ) {
perror(“Error shm_open:”);
exit (-1);
}
page_ptr = mmap (0, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
PCI_MEM_ADDR(creg.Base_Address_Regs[0]) & ~0xfff);

if (page_ptr == (char *) -1) {
perror(“Error mmap:”);
exit (-1);
}
mem_base = page_ptr + (pci_bar_0 & 0xfff);
close(fd);

isystem.board[0].base = (DWORD)mem_base;
isystem.board[0].irqline = creg.Interrupt_Line;
irq = creg.Interrupt_Line;

fprintf(stderr, “\nVendor %x, DeviceId %x, Base Addr %x, Device
Number %d, Int %d\n”,
creg.Vendor_ID, creg.Device_ID, pci_bar_3, device, irq);

openedDevice = 1;

return 1;
}
}
}
} else {
fprintf(stderr, “NO BIOS32 found\n”);
}
fprintf(stderr, “PCI device not found\n”);

return 0;
}

Tom.



“Bill Caroselli” <> qtps@earthlink.net> > wrote in message
news:c8tm10$a9d$> 1@inn.qnx.com> …
Perhaps you could explain a little more about what you mean when you say
it
runs as a stand-alone driver but not as a client. What are you calling a
driver and what are you calling a client?


Tom <> pwc@ag-signs.com> > wrote:
T > Bill,

T > Yes. Could it have something to do with the mmap?

T > Tom.

T > “Bill Caroselli” <> qtps@earthlink.net> > wrote in message
T > news:c8srn1$jh8$> 1@inn.qnx.com> …
Tom <> pwc@ag-signs.com> > wrote:
T > I’m writing a pci driver server which I need to be able to attach
an
T > ISR in
T > a
T > client. The problem I’m having is when I run the driver standalone
T > everything
T > work fine, Interrupts and all. As soon as I move the ISR to the
T > client and
T > map
T > the pci address I get no interrupts. Any suggestions?

T > Tom.

Is your client also run as root and linked with -T1 ?


Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com