[Previous]
[Contents]
[Next]

qnx_segment_overlay()

create a segment that overlays memory at a given physical address

Synopsis:

#include <sys/seginfo.h>
unsigned qnx_segment_overlay( long address,
                              long nbytes );

Description:

The qnx_segment_overlay() function allows you to create a segment nbytes long that overlays memory at physical address address. This is often required to address dual-ported memory or system ROM.

The address is a 32-bit long byte address that points to the start of the segment. For example the EGA/VGA graphics memory is located at segment A000, which is byte address 0xA0000. In real mode, there's a restriction that the address must lie on a 16-byte boundary (8086 segmentation).

In the 32-bit version of QNX with paging, the address must start on a 4096 page boundary, and the size must be a multiple of 4096, unless the overlaid memory lies in the range 0xA0000 to 0xFFFFF (system ROM and adapter memory between 640K and 1 meg).


Note: Although this function is available in both the 16-bit and 32-bit libraries, the qnx_segment_... family of calls is primarily intended for the 16-bit segmented version of QNX. To allocate and share memory in the 32-bit version, you should look at using the POSIX shm_open() and mmap() functions.

Returns:

A segment number on success. On error, -1 is returned, and errno is set.

Errors:

EINVAL
The parameter nbytes is 0.
ENOMEM
Insufficient local process manager memory to manage the segment.

Examples:

#include <stdio.h>
#include <i86.h>
#include <sys/seginfo.h>

void main()
  {
    unsigned color_base, mono_base;
    char __far *cp, __far *mp;

    /* Create a selector for color video memory */
    color_base = qnx_segment_overlay( 0xb8000, 32786 );
    /* Create a selector for monochrome video memory */
    mono_base = qnx_segment_overlay( 0xb0000, 32786 );

    /* Point at byte 100 in the display */
    cp = MK_FP( color_base, 100 );
    mp = MK_FP( mono_base, 100 );

    putchar( '\014' );
    fflush( stdout );

    /* Set the byte and read it back */
    *cp = 'a';
    *mp = 'a';
    printf( "color_base = %x, cp = %08lx\n",
         color_base, cp );
    printf( "mono_base = %x, mp = %08lx\n",
         mono_base, mp );
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, qnx_segment_alloc(), qnx_segment_alloc_flags(), qnx_segment_arm(), qnx_segment_flags(), qnx_segment_free(), qnx_segment_get(), qnx_segment_huge(), qnx_segment_index(), qnx_segment_info(), qnx_segment_overlay_flags(), qnx_segment_put(), qnx_segment_raw_alloc(), qnx_segment_raw_free(), qnx_segment_realloc()


[Previous]
[Contents]
[Next]