Real physical address of an array in the DATA segment of my

Hi,

I am writing a driver for a SYM53C875 SCSI chip and I need to be able to
find out the physical memory address of an array in my DATA segment.

If I have the following declaration:

char my_array [10];

I would like to be able to say:

typedef unsigned long int uquad;

uquad my_array_addr;

my_array_addr = getPhysAddr(my_array);

Now, my_array_addr contains the real physical address where my_array is
located in physical memory.



Under Borland C++ 4.5 (DOS), I saw this function:

/* This function returns the physical 20-bit addres to a far pointer that is

  • passed. This is needed because the c875 only understands true addresses,
  • not segment:offset. */
    uquad
    getPhysAddr(void far * addr)
    {
    return (((uquad)FP_SEG(addr) << 4) + FP_OFF(addr));
    }



    Is there anything in Neutrino equivalent to the FP_SEG and FP_OFF macros?

Thank you!
Alain Achkar
aachkar@storagequest.com

On Wed, 16 May 2001 02:07:25 -0400, “Alain Achkar”
<aachkar@storagequest.com> wrote:

Hi,

I am writing a driver for a SYM53C875 SCSI chip and I need to be able to
find out the physical memory address of an array in my DATA segment.

If I have the following declaration:

char my_array [10];

I would like to be able to say:

typedef unsigned long int uquad;

uquad my_array_addr;

my_array_addr = getPhysAddr(my_array);

Now, my_array_addr contains the real physical address where my_array is
located in physical memory.

Is it safe to assume that the data segment stays at

a fixed physical address? There are some hints in the Memory-mapped
I/O and Memory for DMA sections of the QNX4->NTO Migration doc
under Programming Issues, using mmap() and memory_offset().

ako

Under Borland C++ 4.5 (DOS), I saw this function:

/* This function returns the physical 20-bit addres to a far pointer that is

  • passed. This is needed because the c875 only understands true addresses,
  • not segment:offset. */
    uquad
    getPhysAddr(void far * addr)
    {
    return (((uquad)FP_SEG(addr) << 4) + FP_OFF(addr));
    }



    Is there anything in Neutrino equivalent to the FP_SEG and FP_OFF macros?

Thank you!
Alain Achkar
aachkar@storagequest.com

“Andrzej Kocon” <ako@box43.gnet.pl> wrote in message
news:3b024b93.14569630@inn.qnx.com

On Wed, 16 May 2001 02:07:25 -0400, “Alain Achkar”
aachkar@storagequest.com> > wrote:

Hi,

I am writing a driver for a SYM53C875 SCSI chip and I need to be able to
find out the physical memory address of an array in my DATA segment.

If I have the following declaration:

char my_array [10];

I would like to be able to say:

typedef unsigned long int uquad;

uquad my_array_addr;

my_array_addr = getPhysAddr(my_array);

Now, my_array_addr contains the real physical address where my_array is
located in physical memory.

Is it safe to assume that the data segment stays at
a fixed physical address? There are some hints in the Memory-mapped
I/O and Memory for DMA sections of the QNX4->NTO Migration doc
under Programming Issues, using mmap() and memory_offset().

Indeed that is not really the way to go, you should allocate
my_array with mmap. Depending on the hardware the my_array
may no be accessible , or worse it may not be contigous.

ako



Under Borland C++ 4.5 (DOS), I saw this function:

/* This function returns the physical 20-bit addres to a far pointer that
is

  • passed. This is needed because the c875 only understands true
    addresses,
  • not segment:offset. */
    uquad
    getPhysAddr(void far * addr)
    {
    return (((uquad)FP_SEG(addr) << 4) + FP_OFF(addr));
    }



    Is there anything in Neutrino equivalent to the FP_SEG and FP_OFF macros?

Thank you!
Alain Achkar
aachkar@storagequest.com
\

Alain Achkar <aachkar@storagequest.com> wrote:

Hi,

Posted a long followup in the other newsgroup where you posted this
question. Please try to post to one place only – that way the
various responses can all be kept together.

-David

QNX Training Services
dagibbs@qnx.com