CrossCore XA
Revision: 1.0
Programmers Guide
Date: Jul 1, 10
5.3.5.
ioctl
Description
The ioctl function calls are used for accessing the I/O device at different offsets. The available ioctl
operations are summarized in the table below.
Define
Description
CROSS_PWR_IOC_GET_PWRFAIL_STATUS Get low power – pin state
CROSS_PWR_IOC_GET_OVERVOLTAGE_
STATUS
Get over voltage – pin state
CROSS_PWR_IOC_GET_SIGNAL
Get source what caused signal
CROSS_PWR_IOC_SET_SIGNAL
Register signal handler. Only one process can register
signal handler. Note! Before closing the driver, remove
handler by setting both pid and signal number to zero.
CROSS_PWR_IOC_GET_PWR_STATE
Get power state of specific subsystem
CROSS_PWR_IOC_SET_PWR_STATE
Set power state of specific subsystem
Include files
#include <sys/ioctl.h>
#include “pwr-io.h”
Syntax
int ioctl(
int fd,
int request,
void *argp
)
Parameters
fd
The file descriptor
request
The code of the request
argp
Used for transferring data in the ioctl call.
Return value
Returns a positive value on success. In case of errors, -1 is returned and errno is set appropriately.
Example
This example shows a range of different configuration settings by calling ioctl(). All possible errors
are not handled, since the purpose of the example is to explain how the calls are made.
int
fd, result;
/* Open device */
fd = open(
“/dev/cross_pwr_io”
, O_RDWR | O_NONBLOCK);
/* Read from device - Get power state for Eth */
result = ioctl(fd, CROSS_PWR_IOC_GET_PWR_STATE, PWR_PIN_ETH);
/* Write to device – Set power state for Wlan */
data = (PWR_PIN_WLAN << 8) | 0;
result = ioctl(fd, CROSS_PWR_IOC_SET_PWR_STATE, data);
www.crosscontrol.com
33