Obtaining physical memory addresses

I’m building an interface between 2 QNX4.25 machines that uses the
dataBLIZZARD PCI card from SBS Technologies. This card maps PCI resources
between the machines for very low latency data transfers.

In QNX4, how do I malloc a small (say 8K bytes) chunk of non-page-able
memory and then obtain the physical address of it? I need the physical
address to initialize the dataBLIZZARD card so that the other machine can
make accesses to this memory.

Thanks in advance…

Jay Marchetti
Pittsburgh Firmware, Inc.

“Jay Marchetti” <marchetti@pittsburghfirmware.com> wrote in message
news:aa9mfl$t8$1@inn.qnx.com

I’m building an interface between 2 QNX4.25 machines that uses the
dataBLIZZARD PCI card from SBS Technologies. This card maps PCI resources
between the machines for very low latency data transfers.

In QNX4, how do I malloc a small (say 8K bytes) chunk of non-page-able
memory and then obtain the physical address of it? I need the physical
address to initialize the dataBLIZZARD card so that the other machine can
make accesses to this memory.

Look in to mmap and shm_open. I don’t recall the function the get
the physical memory but it should be in the mmap and shm_open doc (i hope).

If not look at the file /etc/readme/technotes/shmem.txt

Thanks in advance…

Jay Marchetti
Pittsburgh Firmware, Inc.

Mario Charest <goto@nothingness.com> wrote:

“Jay Marchetti” <> marchetti@pittsburghfirmware.com> > wrote in message
news:aa9mfl$t8$> 1@inn.qnx.com> …
I’m building an interface between 2 QNX4.25 machines that uses the
dataBLIZZARD PCI card from SBS Technologies. This card maps PCI resources
between the machines for very low latency data transfers.

In QNX4, how do I malloc a small (say 8K bytes) chunk of non-page-able
memory and then obtain the physical address of it? I need the physical
address to initialize the dataBLIZZARD card so that the other machine can
make accesses to this memory.

Look in to mmap and shm_open. I don’t recall the function the get
the physical memory but it should be in the mmap and shm_open doc (i hope).

Under QNX6 – yes. Under QNX4, you need to use
qnx_segment_alloc_flags() to allocate the memory.

If not look at the file /etc/readme/technotes/shmem.txt

Yup, that is the place to look – it should already be on your dev
system, you want, if I recall correctly, example 3.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Here’s a small example from a real project. Even if you don’t use
DMA, use _PMF_DMA_SAFE flag to tell the OS you need a
contiguos chunk of memory. Good luck.

typedef struct
{
int segno; /* segment number /
int seglen; /
segment length /
paddr_t phys_addr; /
physical address /
caddr_t bufp; /
logical address */
} dmabuf_t;

int alloc_dmabuf(dmabuf_t *p, int nbytes)
{
struct _seginfo sbuf;
int selector;
int fd;

/* allocate memory */

if ((selector = qnx_segment_alloc_flags(nbytes,
_PMF_DMA_SAFE | _PMF_DMA_HIGH | _PMF_NOCACHE)) == -1)
return -1;

/* get physical address */

if (qnx_segment_info(PROC_PID, 0, selector, &sbuf) == -1)


qnx_segment_free(selector);
return -1;
}

p->phys_addr = sbuf.addr;
p->segno = selector;
p->seglen = nbytes;


/* map to the buffer */

if ((fd=shm_open(“Physical”,O_RDWR,0)) == -1)


qnx_segment_free(selector);
return -1;
}

p->bufp = (caddr_t)mmap(0,nbytes,
PROT_READ|PROT_WRITE|PROT_NOCACHE,
MAP_SHARED,fd, p->phys_addr);

close(fd);

if (p->phys_addr == (paddr_t)-1)


qnx_segment_free(selector);
return -1;
}


return 0;

}

int free_dmabuf(dmabuf_t *p)
{
munmap(p->bufp,p->seglen);
qnx_segment_free(p->segno);

return 0;
}

Enjoy :wink:


“Jay Marchetti” <marchetti@pittsburghfirmware.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ ×
ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:aa9mfl$t8$1@inn.qnx.com

I’m building an interface between 2 QNX4.25 machines that uses the
dataBLIZZARD PCI card from SBS Technologies. This card maps PCI resources
between the machines for very low latency data transfers.

In QNX4, how do I malloc a small (say 8K bytes) chunk of non-page-able
memory and then obtain the physical address of it? I need the physical
address to initialize the dataBLIZZARD card so that the other machine can
make accesses to this memory.

Thanks in advance…

Jay Marchetti
Pittsburgh Firmware, Inc.