in16(), inbe16(), inle16()

Updated: April 19, 2023

Read a 16-bit value from a port

Synopsis:

#include <hw/inout.h>

uint16_t in16( uintptr_t port );

#define inbe16 ( port ) ...

#define inle16 ( port ) ...

Arguments:

port
The port you want to read the value from.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The in16() function reads a 16-bit value from the specified port in native-endian format (there's no conversion required).

The inbe16() and inle16() macros read a 16-bit value that's in big-endian or little-endian format, respectively, from the specified port, and returns the value as native-endian.

CAUTION:
The inbe16() and inle16() macros access the specified port more than once if endian conversion is necessary. This could be a problem on some hardware.

The calling process must use mmap_device_io() to access the device's I/O registers.

On x86_64 targets, the process must have the PROCMGR_AID_IO ability enabled, and the calling thread must have I/O privileges, or else it will fault with a SIGSEGV; see procmgr_ability(), and the ThreadCtl() _NTO_TCTL_IO_LEVEL command.

Returns:

A 16-bit value in native-endian.

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes

Caveats:

Both inbe16() and inle16() are implemented as macros.