Skip navigation.
Home
The QNX Community Portal

View topic - Dual port memory problem

Dual port memory problem

Read-only archive of qnx.qnx4 (General QNX4 Discussion Group) at inn.qnx.com

Dual port memory problem

Postby Guest » Mon Jun 25, 2007 7:58 am

Hi,

I am working with a piece of hardware that requires me to map to two regions of dual-port
[shared] memory. The PCI provides me with two addresses and lengths that I subsequently use with
mmap() to obtain two pointer references.

Region0 is 4096 bytes long and region1 is 16384 bytes long. The problem I am having is in
regards to region1 - region0 is fine.

This device has two ASIC's: the first is at the address of region1 (say 0x00018000) and the
second ASIC is 4096 bytes above that (0x00019000). The problem is that even though the length
argument to mmap is 16384, a valid address is returned, and errno is EOK, all memory beyond
region1 + 4096 (0x1000) (being the 2nd ASIC) is -1 (0xff). I note that this equates to the 2nd
page of memory and am not sure if this is coincidental or not. The first ASIC is fine.

I know that the card is working properly as a Linux based test utility works fine (in teh same
machine) with both ASICS. The problem I have occurs with both QNX4 and QNX6. While I have tried
to replicate the Linux code, it uses ioremap() so I can't do an exact translation.

The QNX4 mmap() routine is as follows:

char *allocBuf(int addr, unsigned long nbytes)
{
int fd;
char *ptr;

if ((fd = shm_open("Physical", O_RDWR, 0777)) == -1)
return((char *) -1);

ptr = (char *) mmap(0, nbytes, PROT_READ | PROT_WRITE | PROT_NOCACHE, MAP_SHARED, fd, addr);

close(fd);

return (ptr);
}

Is there something I'm missing with the way I am using mmap()? Are there any issues regarding
access to dual port memory areas greater than one page in both QNX4 and QNX6?

Thanks,

Geoff Roberts
Guest
 

Re: Dual port memory problem

Postby Augie » Tue Jun 26, 2007 12:40 pm

Geoff,

I would suggest taking out the PROT_NOCACHE.

I don't see it in the docs... I'm not sure if it's supported by QNX4.

Also how are you getting the addr?

There are some issues in QNX4 with BIOS access to PCI card... which you must
address.

Augie

<user@domain.invalid> wrote in message news:f5ns12$qpe$1@inn.qnx.com...
Hi,

I am working with a piece of hardware that requires me to map to two
regions of dual-port [shared] memory. The PCI provides me with two
addresses and lengths that I subsequently use with mmap() to obtain two
pointer references.

Region0 is 4096 bytes long and region1 is 16384 bytes long. The problem I
am having is in regards to region1 - region0 is fine.

This device has two ASIC's: the first is at the address of region1 (say
0x00018000) and the second ASIC is 4096 bytes above that (0x00019000). The
problem is that even though the length argument to mmap is 16384, a valid
address is returned, and errno is EOK, all memory beyond region1 + 4096
(0x1000) (being the 2nd ASIC) is -1 (0xff). I note that this equates to
the 2nd page of memory and am not sure if this is coincidental or not. The
first ASIC is fine.

I know that the card is working properly as a Linux based test utility
works fine (in teh same machine) with both ASICS. The problem I have
occurs with both QNX4 and QNX6. While I have tried to replicate the Linux
code, it uses ioremap() so I can't do an exact translation.

The QNX4 mmap() routine is as follows:

char *allocBuf(int addr, unsigned long nbytes)
{
int fd;
char *ptr;

if ((fd = shm_open("Physical", O_RDWR, 0777)) == -1)
return((char *) -1);

ptr = (char *) mmap(0, nbytes, PROT_READ | PROT_WRITE | PROT_NOCACHE,
MAP_SHARED, fd, addr);

close(fd);

return (ptr);
}

Is there something I'm missing with the way I am using mmap()? Are there
any issues regarding access to dual port memory areas greater than one
page in both QNX4 and QNX6?

Thanks,

Geoff Roberts
Augie
 

RE: Re: Dual port memory problem

Postby maschoen » Tue Jun 26, 2007 4:14 pm

I'm quite sure PROT_NOCACHE is required for QNX 4 at least. Otherwise, the processor might cache values saved to the dual ported memory, and return them on a read, not what you would ever want.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm


Return to qnx.qnx4

Who is online

Users browsing this forum: No registered users and 1 guest

cron