There are two differences that you need to be aware of when writing registry functions for your device driver.
When accessing the device using UNIX function calls, you must perform these additional tasks:
When attaching to the interrupt handler, which processes the SIGIO
signal, you must perform these additional tasks:
In the init() function, the UNIX function structure pointer must be retrieved from the device tree (see "Retrieving UNIX Function Addresses").
The specific part of the init() function of the UNIX function structure pointer is retrieved from the device tree as follows:
device->fd = unixFct->open("/dev/tty0", UNIX_O_RDWR, 0); if (device->fd == -1) { DKI_ERR(("%s: /dev/tty0 open failed (%d)\n", path, unixFct->geterrno())); return; } /* Open SIGIO Parent Class */ res = sigioOps->open((BusId)busId, myNode, eventHandler, NULL, device, &device->busDevId); if (res != K_OK) { DKI_ERR(("%s: parent bus open() failed (%d)\n", path, res)); return; } /* Connect Interrupt Handler based on file descriptor */ res = sigioOps->intr_attach(device->busDevId, (void *)device->fd, (BusIntrHandler)intrHandler, device, &device->busIntrOps, &device->busIntrId); if (res != K_OK) { DKI_ERR(("%s: intr_attach failed (%d)\n", path, res)); return; }
In the init() function, a device must be opened by calling the open() UNIX function.
The interrupt number parameter is replaced by the file descriptor when calling the intr_attach() function.