badaddr(2)
NAME
badaddr − probe location for bus error
SYNOPSIS
#include <sys/types.h>
int badaddr (vaddr, len, mode)
caddr_t vaddr;
int len;
int mode;
DESCRIPTION
The badaddr system service is used to determine whether a particular virtual address maps a valid physical memory location or device register. The service provides a user interface to the _badaddr internal routine used by device drivers in probing for the location of device registers.
Vaddr is the virtual address of the location to be tested. This location must lie in a memory locked (non-pageable) data or shared memory region. Len is the length, in bytes, of the test access. This length may be specified as 1, 2, or 4 bytes long. Mode specifies the type of access to be attempted. A mode value of zero will cause the service to attempt to read the specified location. A non-zero mode value will cause the service to attempt to write that value to the specified location.
To prevent the problems that will occur if the page containing vaddr is paged out, the region containing vaddr must be locked into physical memory. This can be accomplished for data regions by using the plock(2) system service and for shared memory regions by using the shmctl(2) system service. Shared memory regions that are bound to physical sections of memory by the shmbind(2) system service do not need to be explicitly locked into memory as they are implicitly made so by the binding operation.
badaddr will fail and no test of the given location performed if one or more of the following are true:
[EINVAL] Len has an illegal value.
[EFAULT] One or more of the bytes to be tested lies outside the virtual address space of the calling process.
[ENDATREG] Vaddr does not lie in either a data region or a shared memory region of the calling process.
[ENRLOCK] Vaddr does not lie in a locked region.
[EPAGNV] Vaddr lies in a page that is not resident.
RETURN VALUES
badaddr will return a value of 0 if the test access completed without causing a bus error, and a value 1 if a bus error did occur. A value of -1 will be returned if an error occurred, with errno set to indicate which error.
SEE ALSO
plock(2), shmbind(2), shmctl(2).
CX/UX Programmer’s Reference Manual