create a segment that overlays memory, specifying options
#include <sys/seginfo.h> unsigned qnx_segment_overlay_flags( long address, long nbytes, unsigned flags );
The qnx_segment_overlay_flags() function allows you to create a segment nbytes long that overlays memory at physical address address. This function is identical to qnx_segment_overlay() except it allows you to specify some option flags on the allocated segment.
The following special flags are supported. Note that _PMF_MODIFY is always set for you. You can remove it using qnx_segment_flags().
This flag may need to be set if you pass an address as returned from qnx_segment_info(), since it returns a virtual address (unless the _PMF_DMA_SAFE flag is set).
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. |
A segment number on success. On error, it returns -1 and errno is set.
#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_flags( 0xb8000, 32786, _PMF_GLOBAL ); /* Create a selector for monochrome video memory */ mono_base = qnx_segment_overlay_flags( 0xb0000, 32786, _PMF_GLOBAL ); /* 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 ); /* * The cp and mp pointers can now be passed to any * process that wants to be able to write to * either color or monochrome text video memory. */ }
QNX
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
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(), qnx_segment_put(), qnx_segment_raw_alloc(), qnx_segment_raw_free(), qnx_segment_realloc()