![]() |
![]() |
| |||||||||||
Check Changed Arguments of DDI FunctionsSome DDI function argument data types have been changed. These routines are listed below. getrbuf() Argument Changes
In previous releases, sleepflag was defined as a type long. drv_getparm() Argument Changes
In previous releases, value_p was defined as type unsigned long. In the 64-bit kernel, drv_getparm(9F) can be used to fetch both 32-bit and 64-bit quantities, yet the interface does not define the data types of these quantities, which encourages simple programming errors. The following new routines offer a safer alternative:
Driver writers are strongly urged to use these routines instead of drv_getparm(9F). delay() and timeout () Argument Changes
The ticks argument to the delay(9F) and timeout(9F) routines has been changed from long to clock_t. rmallocmap() and rmallocmap_wait() Argument Changes
The mapsize argument to thermallocmap(9F) and rmallocmap_wait(9F) routines has been changed from ulong_t to size_t. scsi_alloc_consistent_buf() Argument Changes
In previous releases, datalen was defined as an int and bflags was defined as a ulong. uiomove() Argument Changes
The nbytes argument was defined as a type long, but because it represents a size in bytes, size_t is more appropriate. cv_timedwait() and cv_timedwait_sig() Argument Changes
In previous releases, the timeout argument to the cv_timedwait(9F) and cv_timedwait_sig(9F) routines was defined to be of type long. Because they represent time in ticks, clock_t is more appropriate. ddi_device_copy() Argument Changes
The src_advcnt, dest_advcnt, dev_datasz arguments have changed type. These were previously defined as long, long, and ulong_t respectively. ddi_device_zero() Argument Changes
In previous releases, dev_advcnt was defined as a type long and dev_datasz as a ulong_t. ddi_dma_mem_alloc() Argument Changes
In previous releases, length, flags, and real_length were defined with types uint_t, ulong_t, and uint_t *. Modify Routines That Handle Data SharingIf a device driver shares data structures that contain longs or pointers with a 32-bit application using ioctl(9E), devmap(9E), or mmap(9E), and the driver is recompiled for a 64-bit kernel, the binary layout of data structures will be incompatible. If a field is currently defined in terms of type long, and there is no actual need for 64-bit data items, change the data structure to use data types that remain as 32-bit quantities (int and unsigned int). Otherwise, the driver needs to be aware of the different structure shapes for ILP32 and LP64 and determine whether there is a model mismatch between the application and the kernel. To handle potential data model differences, the ioctl(), devmap(), and mmap() driver entry points, which interact directly with user applications, need to be written to determine whether the argument came from an application using the same data model as the kernel. Data Sharing in ioctl()To determine whether there is a model mismatch between the application and the driver, the driver uses the FMODELS mask to determine the model type from the ioctl() mode argument. The following values are OR-ed into mode to identify the application data model: The code examples in I/O Control Support for 64-Bit Capable Device Drivers show how this can be handled using ddi_model_convert_from(9F). Data Sharing in devmap()To enable a 64-bit driver and a 32-bit application to share memory, the binary layout generated by the 64-bit driver must be the same as consumed by the 32-bit application. The mapped memory being exported to the application might need to contain data-model-dependent data structures. Few memory mapped devices face this problem because the device registers do not change size when the kernel data model changes. However, some pseudo-devices that export mappings to the user address space might want to export different data structures to ILP32 or LP64 applications. To determine whether there is a data model mismatch, devmap(9E) uses the model parameter to describe the data model expected by the application. The model parameter is set to one of the following: The model parameter can be passed untranslated to the ddi_model_convert_from(9F) routine or to STRUCT_INIT(). See 32-bit and 64-bit Data Structure Macros. Data Sharing in mmap()Because mmap(9E) does not have a parameter that can be used to pass data model information, the driver's mmap(9E) entry point can be written to use the new DDI function ddi_model_convert_from(9F). This function returns one of the following values to indicate the application's data type model:
As with ioctl() and devmap(), the model bits can be passed to ddi_model_convert_from(9F) to determine whether data conversion is necessary, or the model can be handed to STRUCT_INIT(). Alternatively, migrate the device driver to support the devmap(9E) entry point. | |||||||||||
| |||||||||||