Writing Device Drivers

Appendix B Summary of Oracle Solaris DDI/DKI Services

This appendix discusses the interfaces provided by the Oracle Solaris DDI/DKI. These descriptions should not be considered complete or definitive, nor do they provide a thorough guide to usage. The descriptions are intended to describe what the functions do in general terms. See physio(9F) for more detailed information. The categories are:

Module Functions

The module functions are:

mod_info

Query a loadable module

mod_install

Add a loadable module

mod_remove

Remove a loadable module

Device Information Tree Node (dev_info_t) Functions

The device information tree node functions are:

ddi_binding_name()

Return driver binding name

ddi_dev_is_sid()

Tell whether a device is self-identifying

ddi_driver_major()

Return driver major device number

ddi_driver_name()

Return normalized driver name

ddi_node_name()

Return the devinfo node name

ddi_get_devstate()

Check device state

ddi_get_instance()

Get device instance number

ddi_get_name()

Return driver binding name

ddi_get_parent()

Find the parent of a device information structure

ddi_root_node()

Get the root of the dev_info tree

Device (dev_t) Functions

The device functions are:

ddi_create_minor_node()

Create a minor node for a device

ddi_getiminor()

Get kernel internal minor number from an external dev_t

ddi_remove_minor_node()

Remove a minor mode for a device

getmajor()

Get major device number

getminor()

Get minor device number

makedevice()

Make device number from major and minor numbers

Property Functions

The property functions are:

ddi_prop_exists()

Check for the existence of a property

ddi_prop_free()

Free resources consumed by property lookup

ddi_prop_get_int()

Look up integer property

ddi_prop_get_int64()

Look up 64-bit integer property

ddi_prop_lookup_byte_array()

Look up byte array property

ddi_prop_lookup_int_array()

Look up integer array property

ddi_prop_lookup_int64_array()

Look up 64-bit integer array property

ddi_prop_lookup_string()

Look up string property

ddi_prop_lookup_string_array()

Look up string array property

ddi_prop_remove()

Remove a property of a device

ddi_prop_remove_all()

Remove all properties of a device

ddi_prop_undefine()

Hide a property of a device

ddi_prop_update_byte_array()

Create or update byte array property

ddi_prop_update_int()

Create or update integer property

ddi_prop_update_int64()

Create or update 64-bit integer property

ddi_prop_update_int_array()

Create or update integer array property

ddi_prop_update_int64_array()

Create or update 64-bit integer array property

ddi_prop_update_string()

Create or update string property

ddi_prop_update_string_array()

Create or update string array property

Table B–1 Deprecated Property Functions

Deprecated Functions 

Replacements 

ddi_getlongprop()

see ddi_prop_lookup()

ddi_getlongprop_buf()

ddi_prop_lookup()

ddi_getprop()

ddi_prop_get_int()

ddi_getproplen()

ddi_prop_lookup()

ddi_prop_create()

ddi_prop_lookup()

ddi_prop_modify()

ddi_prop_lookup()

ddi_prop_op()

ddi_prop_lookup()

Device Software State Functions

The device software state functions are:

ddi_get_driver_private()

Get the address of the device's private data area

ddi_get_soft_state()

Get pointer to instance soft-state structure

ddi_set_driver_private()

Set the address of the device's private data area

ddi_soft_state_fini()

Destroy driver soft-state structure

ddi_soft_state_free()

Free instance soft-state structure

ddi_soft_state_init()

Initialize driver soft-state structure

ddi_soft_state_zalloc()

Allocate instance soft-state structure

Memory Allocation and Deallocation Functions

The memory allocation and deallocation functions are:

kmem_alloc()

Allocate kernel memory

kmem_free()

Free kernel memory

kmem_zalloc()

Allocate zero-filled kernel memory

The following functions allocate and free memory intended to be used for DMA. See Direct Memory Access (DMA) Functions.

ddi_dma_mem_alloc()

Allocate memory for DMA transfer

ddi_dma_mem_free()

Free previously allocated DMA memory

The following functions allocate and free memory intended to be exported to user space. See User Space Access Functions.

ddi_umem_alloc()

Allocate page-aligned kernel memory

ddi_umem_free()

Free page-aligned kernel memory

Table B–2 Deprecated Memory Allocation and Deallocation Functions

Deprecated Function 

Replacement 

ddi_iopb_alloc()

ddi_dma_mem_alloc()

ddi_iopb_free()

ddi_dma_mem_free()

ddi_mem_alloc()

ddi_dma_mem_alloc()

ddi_mem_free()

ddi_dma_mem_free()

Kernel Thread Control and Synchronization Functions

The kernel thread control and synchronization functions are:

cv_broadcast()

Wake up all waiting threads

cv_destroy()

Free an allocated condition variable

cv_init()

Allocate a condition variable

cv_signal()

Wake up one waiting thread

cv_timedwait()

Await an event with timeout

cv_timedwait_sig()

Await an event or signal with timeout

cv_wait()

Await an event

cv_wait_sig()

Await an event or signal

ddi_can_receive_sig()

Determine whether the current thread can receive a signal

ddi_enter_critical()

Enter a critical region of control

ddi_exit_critical()

Exit a critical region of control

mutex_destroy()

Destroy mutual exclusion lock

mutex_enter()

Acquire mutual exclusion lock

mutex_exit()

Release mutual exclusion lock

mutex_init()

Initialize mutual exclusion lock

mutex_owned()

Determine whether current thread is holding mutual exclusion lock

mutex_tryenter()

Attempt to acquire mutual exclusion lock without waiting

rw_destroy()

Destroy a readers/writer lock

rw_downgrade()

Downgrade a readers/writer lock holding from writer to reader

rw_enter()

Acquire a readers/writer lock

rw_exit()

Release a readers/writer lock

rw_init()

Initialize a readers/writer lock

rw_read_locked()

Determine whether readers/writer lock is held for read or write

rw_tryenter()

Attempt to acquire a readers/writer lock without waiting

rw_tryupgrade()

Attempt to upgrade readers/writer lock holding from reader to writer

sema_destroy()

Destroy a semaphore

sema_init()

Initialize a semaphore

sema_p()

Decrement semaphore and possibly block

sema_p_sig()

Decrement semaphore but do not block if signal is pending

sema_tryp()

Attempt to decrement semaphore but do not block

sema_v()

Increment semaphore and possibly unblock waiter

Task Queue Management Functions

The task queue management functions are listed below. See the taskq(9F) man page for more information about these interfaces.

ddi_taskq_create()

Create a task queue

ddi_taskq_destroy()

Destroy a task queue

ddi_taskq_dispatch()

Add a task to a task queue

ddi_taskq_wait()

Wait for pending tasks to complete

ddi_taskq_suspend()

Suspend a task queue

ddi_taskq_suspended()

Check whether a task queue is suspended

ddi_taskq_resume()

Resume a suspended task queue

Interrupt Functions

The interrupt functions are:

ddi_intr_add_handler(9F)

Adds an interrupt handler.

ddi_intr_add_softint(9F)

Adds a soft interrupt handler.

ddi_intr_alloc(9F)

Allocates system resources and interrupt vectors for the specified type of interrupt.

ddi_intr_block_disable(9F)

Disables the specified range of interrupts. For MSI only.

ddi_intr_block_enable(9F)

Enables the specified range of interrupts. For MSI only.

ddi_intr_clr_mask(9F)

Clears an interrupt mask if the specified interrupt is enabled.

ddi_intr_disable(9F)

Disables the specified interrupt.

ddi_intr_dup_handler(9F)

Use with MSI-X only. Copies an address and data pair for an allocated interrupt vector to an unused interrupt vector on the same device.

ddi_intr_enable(9F)

Enables the specified interrupt.

ddi_intr_free(9F)

Releases the system resources and interrupt vectors for a specified interrupt handle.

ddi_intr_get_cap(9F)

Returns interrupt capability flags for the specified interrupt.

ddi_intr_get_hilevel_pri(9F)

Returns the minimum priority level for a high-level interrupt.

ddi_intr_get_navail(9F)

Returns the number of interrupts available for a particular hardware device and given interrupt type.

ddi_intr_get_nintrs(9F)

Get the number of interrupts that the device supports for the given interrupt type.

ddi_intr_get_pending(9F)

Read the interrupt pending bit if one is supported by either the host bridge or the device.

ddi_intr_get_pri(9F)

Returns the current software priority setting for the specified interrupt.

ddi_intr_get_softint_pri(9F)

Returns the soft interrupt priority for the specified interrupt.

ddi_intr_get_supported_types(9F)

Returns the hardware interrupt types that are supported by both the device and the host.

ddi_intr_remove_handler(9F)

Removes the specified interrupt handler.

ddi_intr_remove_softint(9F)

Remove the specified soft interrupt handler.

ddi_intr_set_cap(9F)

Sets the DDI_INTR_FLAG_LEVEL or DDI_INTR_FLAG_EDGE flag for the specified interrupt.

ddi_intr_set_mask(9F)

Sets an interrupt mask if the specified interrupt is enabled.

ddi_intr_set_pri(9F)

Sets the interrupt priority level for the specified interrupt.

ddi_intr_set_softint_pri(9F)

Changes the relative soft interrupt priority for the specified soft interrupt.

ddi_intr_trigger_softint(9F)

Trigger the specified soft interrupt.

To take advantage of the features of the new framework, use the above interfaces. Do not use the deprecated interfaces that are listed in the following table. These deprecated interfaces are retained for compatibility purposes only.

Table B–3 Deprecated Interrupt Functions

Deprecated Interrupt Functions 

Replacements 

ddi_add_intr(9F)

Three-step process: 

  1. ddi_intr_alloc(9F)

  2. ddi_intr_add_handler(9F)

  3. ddi_intr_enable(9F)

ddi_add_softintr(9F)

ddi_intr_add_softint(9F)

ddi_dev_nintrs(9F)

ddi_intr_get_nintrs(9F)

ddi_get_iblock_cookie(9F)

Three-step process: 

  1. ddi_intr_alloc(9F)

  2. ddi_intr_get_pri(9F)

  3. ddi_intr_free(9F)

ddi_get_soft_iblock_cookie(9F)

Three-step process: 

  1. ddi_intr_add_softint(9F)

  2. ddi_intr_get_softint_pri(9F)

  3. ddi_intr_remove_softint(9F)

ddi_intr_hilevel(9F)

Three-step process: 

  1. ddi_intr_alloc(9F)

  2. ddi_intr_get_hilevel_pri(9F)

  3. ddi_intr_free(9F)

ddi_remove_intr(9F)

Three-step process: 

  1. ddi_intr_disable(9F)

  2. ddi_intr_remove_handler(9F)

  3. ddi_intr_free(9F)

ddi_remove_softintr(9F)

ddi_intr_remove_softint(9F)

ddi_trigger_softintr(9F)

ddi_intr_trigger_softint(9F)

Programmed I/O Functions

The programmed I/O functions are:

ddi_dev_nregs()

Return the number of register sets a device has

ddi_dev_regsize()

Return the size of a device's register

ddi_regs_map_setup()

Set up a mapping for a register address space

ddi_regs_map_free()

Free a previously mapped register address space

ddi_device_copy()

Copy data from one device register to another device register

ddi_device_zero()

Zero fill the device

ddi_check_acc_handle()

Check data access handle

ddi_get8()

Read 8-bit data from mapped memory, device register, or DMA memory

ddi_get16()

Read 16-bit data from mapped memory, device register, or DMA memory

ddi_get32()

Read 32-bit data from mapped memory, device register, or DMA memory

ddi_get64()

Read 64-bit data from mapped memory, device register, or DMA memory

ddi_put8()

Write 8-bit data to mapped memory, device register, or DMA memory

ddi_put16()

Write 16-bit data to mapped memory, device register, or DMA memory

ddi_put32()

Write 32-bit data to mapped memory, device register, or DMA memory

ddi_put64()

Write 64-bit data to mapped memory, device register, or DMA memory

ddi_rep_get8()

Read multiple 8-bit data from mapped memory, device register, or DMA memory

ddi_rep_get16()

Read multiple 16-bit data from mapped memory, device register, or DMA memory

ddi_rep_get32()

Read multiple 32-bit data from mapped memory, device register, or DMA memory

ddi_rep_get64()

Read multiple 64-bit data from mapped memory, device register, or DMA memory

ddi_rep_put8()

Write multiple 8-bit data to mapped memory, device register, or DMA memory

ddi_rep_put16()

Write multiple 16-bit data to mapped memory, device register, or DMA memory

ddi_rep_put32()

Write multiple 32-bit data to mapped memory, device register, or DMA memory

ddi_rep_put64()

Write multiple 64-bit data to mapped memory, device register, or DMA memory

ddi_peek8()

Cautiously read an 8-bit value from a location

ddi_peek16()

Cautiously read a 16-bit value from a location

ddi_peek32()

Cautiously read a 32-bit value from a location

ddi_peek64()

Cautiously read a 64-bit value from a location

ddi_poke8()

Cautiously write an 8-bit value to a location

ddi_poke16()

Cautiously write a 16-bit value to a location

ddi_poke32()

Cautiously write a 32-bit value to a location

ddi_poke64()

Cautiously write a 64-bit value to a location

The general programmed I/O functions listed above can always be used rather than the mem, io, and pci_config functions that follow. However, the following functions can be used as alternatives in cases where the type of access is known at compile time.

ddi_io_get8()

Read 8-bit data from a mapped device register in I/O space

ddi_io_get16()

Read 16-bit data from a mapped device register in I/O space

ddi_io_get32()

Read 32-bit data from a mapped device register in I/O space

ddi_io_put8()

Write 8-bit data to a mapped device register in I/O space

ddi_io_put16()

Write 16-bit data to a mapped device register in I/O space

ddi_io_put32()

Write 32-bit data to a mapped device register in I/O space

ddi_io_rep_get8()

Read multiple 8-bit data from a mapped device register in I/O space

ddi_io_rep_get16()

Read multiple 16-bit data from a mapped device register in I/O space

ddi_io_rep_get32()

Read multiple 32-bit data from a mapped device register in I/O space

ddi_io_rep_put8()

Write multiple 8-bit data to a mapped device register in I/O space

ddi_io_rep_put16()

Write multiple 16-bit data to a mapped device register in I/O space

ddi_io_rep_put32()

Write multiple 32-bit data to a mapped device register in I/O space

ddi_mem_get8()

Read 8-bit data from a mapped device in memory space or DMA memory

ddi_mem_get16()

Read 16-bit data from a mapped device in memory space or DMA memory

ddi_mem_get32()

Read 32-bit data from a mapped device in memory space or DMA memory

ddi_mem_get64()

Read 64-bit data from a mapped device in memory space or DMA memory

ddi_mem_put8()

Write 8-bit data to a mapped device in memory space or DMA memory

ddi_mem_put16()

Write 16-bit data to a mapped device in memory space or DMA memory

ddi_mem_put32()

Write 32-bit data to a mapped device in memory space or DMA memory

ddi_mem_put64()

Write 64-bit data to a mapped device in memory space or DMA memory

ddi_mem_rep_get8()

Read multiple 8-bit data from a mapped device in memory space or DMA memory

ddi_mem_rep_get16()

Read multiple 16-bit data from a mapped device in memory space or DMA memory

ddi_mem_rep_get32()

Read multiple 32-bit data from a mapped device in memory space or DMA memory

ddi_mem_rep_get64()

Read multiple 64-bit data from a mapped device in memory space or DMA memory

ddi_mem_rep_put8()

Write multiple 8-bit data to a mapped device in memory space or DMA memory

ddi_mem_rep_put16()

Write multiple 16-bit data to a mapped device in memory space or DMA memory

ddi_mem_rep_put32()

Write multiple 32-bit data to a mapped device in memory space or DMA memory

ddi_mem_rep_put64()

Write multiple 64-bit data to a mapped device in memory space or DMA memory

pci_config_setup()

Set up access to PCI Local Bus Configuration space

pci_config_teardown()

Tear down access to PCI Local Bus Configuration space

pci_config_get8()

Read 8-bit data from the PCI Local Bus Configuration space

pci_config_get16()

Read 16-bit data from the PCI Local Bus Configuration space

pci_config_get32()

Read 32-bit data from the PCI Local Bus Configuration space

pci_config_get64()

Read 64-bit data from the PCI Local Bus Configuration space

pci_config_put8()

Write 8-bit data to the PCI Local Bus Configuration space

pci_config_put16()

Write 16-bit data to the PCI Local Bus Configuration space

pci_config_put32()

Write 32-bit data to the PCI Local Bus Configuration space

pci_config_put64()

Write 64-bit data to the PCI Local Bus Configuration space

Table B–4 Deprecated Programmed I/O Functions

Deprecated Function 

Replacement 

ddi_getb()

ddi_get8()

ddi_getl()

ddi_get32()

ddi_getll()

ddi_get64()

ddi_getw()

ddi_get16()

ddi_io_getb()

ddi_io_get8()

ddi_io_getl()

ddi_io_get32()

ddi_io_getw()

ddi_io_get16()

ddi_io_putb()

ddi_io_put8()

ddi_io_putl()

ddi_io_put32()

ddi_io_putw()

ddi_io_put16()

ddi_io_rep_getb()

ddi_io_rep_get8()

ddi_io_rep_getl()

ddi_io_rep_get32()

ddi_io_rep_getw()

ddi_io_rep_get16()

ddi_io_rep_putb()

ddi_io_rep_put8()

ddi_io_rep_putl()

ddi_io_rep_put32()

ddi_io_rep_putw()

ddi_io_rep_put16()

ddi_map_regs()

ddi_regs_map_setup()

ddi_mem_getb()

ddi_mem_get8()

ddi_mem_getl()

ddi_mem_get32()

ddi_mem_getll()

ddi_mem_get64()

ddi_mem_getw()

ddi_mem_get16()

ddi_mem_putb()

ddi_mem_put8()

ddi_mem_putl()

ddi_mem_put32()

ddi_mem_putll()

ddi_mem_put64()

ddi_mem_putw()

ddi_mem_put16()

ddi_mem_rep_getb()

ddi_mem_rep_get8()

ddi_mem_rep_getl()

ddi_mem_rep_get32()

ddi_mem_rep_getll()

ddi_mem_rep_get64()

ddi_mem_rep_getw()

ddi_mem_rep_get16()

ddi_mem_rep_putb()

ddi_mem_rep_put8()

ddi_mem_rep_putl()

ddi_mem_rep_put32()

ddi_mem_rep_putll()

ddi_mem_rep_put64()

ddi_mem_rep_putw()

ddi_mem_rep_put16()

ddi_peekc()

ddi_peek8()

ddi_peekd()

ddi_peek64()

ddi_peekl()

ddi_peek32()

ddi_peeks()

ddi_peek16()

ddi_pokec()

ddi_poke8()

ddi_poked()

ddi_poke64()

ddi_pokel()

ddi_poke32()

ddi_pokes()

ddi_poke16()

ddi_putb()

ddi_put8()

ddi_putl()

ddi_put32()

ddi_putll()

ddi_put64()

ddi_putw()

ddi_put16()

ddi_rep_getb()

ddi_rep_get8()

ddi_rep_getl()

ddi_rep_get32()

ddi_rep_getll()

ddi_rep_get64()

ddi_rep_getw()

ddi_rep_get16()

ddi_rep_putb()

ddi_rep_put8()

ddi_rep_putl()

ddi_rep_put32()

ddi_rep_putll()

ddi_rep_put64()

ddi_rep_putw()

ddi_rep_put16()

ddi_unmap_regs()

ddi_regs_map_free()

inb()

ddi_io_get8()

inl()

ddi_io_get32()

inw()

ddi_io_get16()

outb()

ddi_io_put8()

outl()

ddi_io_put32()

outw()

ddi_io_put16()

pci_config_getb()

pci_config_get8()

pci_config_getl()

pci_config_get32()

pci_config_getll()

pci_config_get64()

pci_config_getw()

pci_config_get16()

pci_config_putb()

pci_config_put8()

pci_config_putl()

pci_config_put32()

pci_config_putll()

pci_config_put64()

pci_config_putw()

pci_config_put16()

repinsb()

ddi_io_rep_get8()

repinsd()

ddi_io_rep_get32()

repinsw()

ddi_io_rep_get16()

repoutsb()

ddi_io_rep_put8()

repoutsd()

ddi_io_rep_put32()

repoutsw()

ddi_io_rep_put16()

Direct Memory Access (DMA) Functions

The DMA functions are:

ddi_dma_alloc_handle()

Allocate a DMA handle

ddi_dma_free_handle()

Free a DMA handle

ddi_dma_mem_alloc()

Allocate memory for a DMA transfer

ddi_dma_mem_free()

Free previously allocated DMA memory

ddi_dma_addr_bind_handle()

Bind an address to a DMA handle

ddi_dma_buf_bind_handle()

Bind a system buffer to a DMA handle

ddi_dma_unbind_handle()

Unbind the address in a DMA handle

ddi_dma_nextcookie()

Retrieve the subsequent DMA cookie

ddi_dma_getwin()

Activate a new DMA window

ddi_dma_numwin()

Retrieve number of DMA windows

ddi_dma_sync()

Synchronize CPU and I/O views of memory

ddi_check_dma_handle()

Check a DMA handle

ddi_dma_set_sbus64()

Allow 64-bit transfers on SBus

ddi_slaveonly()

Report whether a device is installed in a slave access-only location

ddi_iomin()

Find the minimum alignment and transfer size for DMA

ddi_dma_burstsizes()

Find out the allowed burst sizes for a DMA mapping

ddi_dma_devalign()

Find DMA mapping alignment and minimum transfer size

ddi_dmae_alloc()

Acquire a DMA channel

ddi_dmae_release()

Release a DMA channel

ddi_dmae_getattr()

Get the DMA engine attributes

ddi_dmae_prog()

Program a DMA channel

ddi_dmae_stop()

Terminate a DMA engine operation

ddi_dmae_disable()

Disable a DMA channel

ddi_dmae_enable()

Enable a DMA channel

ddi_dmae_getcnt()

Get the remaining DMA engine count

ddi_dmae_1stparty()

Configure the DMA channel cascade mode

ddi_dma_coff()

Convert a DMA cookie to an offset within a DMA handle

Table B–5 Deprecated Direct Memory Access (DMA) Functions

Deprecated Function 

Replacement 

ddi_dma_addr_setup()

ddi_dma_alloc_handle(), ddi_dma_addr_bind_handle()

ddi_dma_buf_setup()

ddi_dma_alloc_handle(), ddi_dma_buf_bind_handle()

ddi_dma_curwin()

ddi_dma_getwin()

ddi_dma_free()

ddi_dma_free_handle()

ddi_dma_htoc()

ddi_dma_addr_bind_handle(), ddi_dma_buf_bind_handle()

ddi_dma_movwin()

ddi_dma_getwin()

ddi_dma_nextseg()

ddi_dma_nextcookie()

ddi_dma_segtocookie()

ddi_dma_nextcookie()

ddi_dma_setup()

ddi_dma_alloc_handle(), ddi_dma_addr_bind_handle(), ddi_dma_buf_bind_handle()

ddi_dmae_getlim()

ddi_dmae_getattr()

ddi_iopb_alloc()

ddi_dma_mem_alloc()

ddi_iopb_free()

ddi_dma_mem_free()

ddi_mem_alloc()

ddi_dma_mem_alloc()

ddi_mem_free()

ddi_dma_mem_free()

hat_getkpfnum()

ddi_dma_addr_bind_handle(), ddi_dma_buf_bind_handle(), ddi_dma_nextcookie()

User Space Access Functions

The user space access functions are:

ddi_copyin()

Copy data to a driver buffer

ddi_copyout()

Copy data from a driver

uiomove()

Copy kernel data using a uio structure

ureadc()

Add character to a uio structure

uwritec()

Remove a character from a uio structure

getminor()

Get minor device number.

ddi_model_convert_from()

Determine a data model type mismatch

IOC_CONVERT_FROM()

Determine whether there is a need to translate M_IOCTL contents

STRUCT_DECL()

Establish the handle to application data in a possibly differing data model

STRUCT_HANDLE()

Establish the handle to application data in a possibly differing data model

STRUCT_INIT()

Establish the handle to application data in a possibly differing data model

STRUCT_SET_HANDLE()

Establish the handle to application data in a possibly differing data model

SIZEOF_PTR()

Return the size of pointer in specified data model

SIZEOF_STRUCT()

Return the size of a structure in the specified data model

STRUCT_SIZE()

Return the size of a structure in the application data model

STRUCT_BUF()

Return a pointer to the native mode instance of the structure

STRUCT_FADDR()

Return a pointer to the specified field of a structure

STRUCT_FGET()

Return the specified field of a structure in the application data model

STRUCT_FGETP()

Return the specified pointer field of a structure in the application data model

STRUCT_FSET()

Set a specified field of a structure in the application data model

STRUCT_FSETP()

Set a specified pointer field of a structure in the application data model

Table B–6 Deprecated User Space Access Functions

Deprecated Function 

Replacement 

copyin()

ddi_copyin()

copyout()

ddi_copyout()

ddi_getminor()

getminor()

User Process Event Functions

The user process event functions are:

pollwakeup()

Inform a process that an event has occurred

proc_ref()

Get a handle on a process to signal

proc_unref()

Release a handle on a process to signal

proc_signal()

Send a signal to a process

User Process Information Functions

The user process information functions are:

ddi_get_cred()

Return a pointer to the credential structure of the caller

drv_priv()

Determine process credentials privilege

ddi_get_pid()

Return the process ID

Table B–7 Deprecated User Process Information Functions

Deprecated Functions 

Replacement 

drv_getparm()

ddi_get_pid(), ddi_get_cred()

User Application Kernel and Device Access Functions

The user application kernel and device access functions are:

ddi_dev_nregs()

Return the number of register sets a device has

ddi_dev_regsize()

Return the size of a device's register

ddi_devmap_segmap(), devmap_setup()

Set up a user mapping to device memory using the devmap framework

devmap_devmem_setup()

Export device memory to user space

devmap_load()

Validate memory address translations

devmap_unload()

Invalidate memory address translations

devmap_do_ctxmgt()

Perform device context switching on a mapping

devmap_set_ctx_timeout()

Set the timeout value for the context management callback

devmap_default_access()

Default driver memory access function

ddi_umem_alloc()

Allocate page-aligned kernel memory

ddi_umem_free()

Free page-aligned kernel memory

ddi_umem_lock()

Lock memory pages

ddi_umem_unlock()

Unlock memory pages

ddi_umem_iosetup()

Setup I/O requests to application memory

devmap_umem_setup()

Export kernel memory to user space

ddi_model_convert_from()

Determine data model type mismatch

Table B–8 Deprecated User Application Kernel and Device Access Functions

Deprecated Function 

Replacement 

ddi_mapdev()

devmap_setup()

ddi_mapdev_intercept()

devmap_load()

ddi_mapdev_nointercept()

devmap_unload()

ddi_mapdev_set_device_acc_attr()

devmap()

ddi_segmap()

devmap()

ddi_segmap_setup()

devmap_setup()

hat_getkpfnum()

devmap()

ddi_mmap_get_model()

devmap()

Time-Related Functions

The time-related functions are:

ddi_get_lbolt()

Return the number of clock ticks since reboot

ddi_get_time()

Return the current time in seconds

ddi_periodic_add()

Issue nanosecond periodic timeout requests

ddi_periodic_delete()

Cancel nanosecond periodic timeout requests

delay()

Delay execution for a specified number of clock ticks

drv_hztousec()

Convert clock ticks to microseconds

drv_usectohz()

Convert microseconds to clock ticks

drv_usecwait()

Busy-wait for specified interval

gethrtime()

Get high-resolution time

gethrvtime()

Get high-resolution LWP virtual time

timeout()

Execute a function after a specified length of time

untimeout()

Cancel the previous time out function call

drv_getparm()

ddi_get_lbolt(), ddi_get_time()

Table B–9 Deprecated Time-Related Functions

Deprecated Function 

Replacement 

drv_getparm()

ddi_get_lbolt(), ddi_get_time()

Power Management Functions

The power management functions are:

ddi_removing_power()

Check if device loses power with DDI_SUSPEND

pci_report_pmcap()

Report the power management capability of a PCI device

pm_busy_component()

Mark a component as busy

pm_idle_component()

Mark a component as idle

pm_raise_power()

Raise the power level of a component

pm_lower_power()

Lower the power level of a component

pm_power_has_changed()

Notify the power management framework of an autonomous power level change

pm_trans_check()

Device power cycle advisory check

Table B–10 Deprecated Power Management Functions

Function Name 

Description 

ddi_dev_is_needed()

Inform the system that a device's component is required 

pm_create_components()

Create power-manageable components 

pm_destroy_components()

Destroy power-manageable components 

pm_get_normal_power()

Get the normal power level of a device component 

pm_set_normal_power()

Set the normal power level of a device component 

Fault Management Functions

The fault management functions are:

ddi_fm_init()

Allocates and initializes resources based on declared fault management capabilities

ddi_fm_fini()

Cleans up resources that were allocated for this device instance to support fault management capabilities declared to ddi_fm_init()

ddi_fm_capable()

Returns the capability bit mask currently set for this device instance

ddi_fm_handler_register()

Registers an error handler callback routine with the IO Fault Management framework

ddi_fm_handler_unregister()

Removes an error handler callback routine that was registered with ddi_fm_handler_register()

ddi_fm_acc_err_get()

Returns the error status for an access handle

ddi_fm_dma_err_get()

Returns the error status for a DMA handle

ddi_fm_acc_err_clear()

Clears the error status for an access handle

ddi_fm_dma_err_clear()

Clears the error status for a DMA handle

ddi_fm_ereport_post()

Queues an encoded fault management error report name-value pair list for delivery to the Fault Manager daemon, fmd(1M)

ddi_fm_service_impact()

Reports the impact of an error

pci_ereport_setup()

Initializes support for error report generation and sets up the resources for subsequent accesses to PCI, PCI/X, or PCI Express configuration space

pci_ereport_teardown()

Releases any resources allocated and setup by pci_ereport_setup() for this device instance

pci_ereport_post()

Scans for and posts any PCI, PCI/X, or PCI Express bus errors

Kernel Statistics Functions

The kernel statistics (kstats) functions are:

kstat_create()

Create and initialize a new kstat

kstat_delete()

Remove a kstat from the system

kstat_install()

Add a fully initialized kstat to the system

kstat_named_init()

Initialize a named kstat

kstat_runq_back_to_waitq()

Record a transaction migration from run queue to the wait queue

kstat_runq_enter()

Record a transaction addition to the run queue

kstat_runq_exit()

Record a transaction removal from the run queue

kstat_waitq_enter()

Record a transaction addition to the wait queue

kstat_waitq_exit()

Record a transaction removal from the wait queue

kstat_waitq_to_runq()

Record a transaction migration from the wait queue to the run queue

Kernel Logging and Printing Functions

The kernel logging and printing functions are:

cmn_err(), vcmn_err()

Display an error message

ddi_report_dev()

Announce a device

strlog()

Submit messages to the log driver

ddi_dev_report_fault()

Report a hardware failure

scsi_errmsg()

Display a SCSI request sense message

scsi_log()

Display a SCSI-device-related message

scsi_vu_errmsg()

Display a SCSI request sense message

Buffered I/O Functions

The buffered I/O functions are:

physio()

Perform physical I/O

aphysio()

Perform asynchronous physical I/O

anocancel()

Prevent cancellation of an asynchronous I/O request

minphys()

Limit the physio() buffer size

biowait()

Suspend processes pending completion of block I/O

biodone()

Release the buffer after buffer I/O transfer and notify blocked threads

bioerror()

Indicate the error in a buffer header

geterror()

Return an I/O error

bp_mapin()

Allocate virtual address space

bp_mapout()

Deallocate virtual address space

disksort()

Use a single-direction elevator seek strategy to sort for buffers

getrbuf()

Get a raw buffer header

freerbuf()

Free a raw buffer header

biosize()

Return the size of a buffer structure

bioinit()

Initialize a buffer structure

biofini()

Uninitialize a buffer structure

bioreset()

Reuse a private buffer header after I/O is complete

bioclone()

Clone another buffer

biomodified()

Check whether a buffer is modified

clrbuf()

Erase the contents of a buffer

Virtual Memory Functions

The virtual memory functions are:

ddi_btop()

Convert device bytes to pages (round down)

ddi_btopr()

Convert device bytes to pages (round up)

ddi_ptob()

Convert device pages to bytes

btop()

Convert size in bytes to size in pages (round down)

btopr()

Convert size in bytes to size in pages (round up)

ptob()

Convert size in pages to size in bytes

Table B–11 Deprecated Virtual Memory Functions

Deprecated Functions 

Replacement 

hat_getkpfnum()

devmap(), ddi_dma_*_bind_handle(), ddi_dma_nextcookie()

Device ID Functions

The device ID functions are:

ddi_devid_init()

Allocate a device ID structure

ddi_devid_free()

Free a device ID structure

ddi_devid_register()

Register a device ID

ddi_devid_unregister()

Unregister a device ID

ddi_devid_compare()

Compare two device IDs

ddi_devid_sizeof()

Return the size of a device ID

ddi_devid_valid()

Validate a device ID

ddi_devid_str_encode()

Encode a device ID and minor_name into a null-terminated ASCII string; return a pointer to that string

ddi_devid_str_decode()

Decode the device ID and minor_name from a previously encoded string; allocate and return pointers to the extracted parts

ddi_devid_str_free()

Free all strings returned by the ddi_devid_* functions

SCSI Functions

The SCSI functions are:

scsi_probe()

Probe a SCSI device

scsi_unprobe()

Free resources allocated during initial probing

scsi_alloc_consistent_buf()

Allocate an I/O buffer for SCSI DMA

scsi_free_consistent_buf()

Free a previously allocated SCSI DMA I/O buffer

scsi_init_pkt()

Prepare a complete SCSI packet

scsi_destroy_pkt()

Free an allocated SCSI packet and its DMA resource

scsi_setup_cdb()

Set up SCSI command descriptor block (CDB)

scsi_transport()

Start a SCSI command

scsi_poll()

Run a polled SCSI command

scsi_ifgetcap()

Get SCSI transport capability

scsi_ifsetcap()

Set SCSI transport capability

scsi_sync_pkt()

Synchronize CPU and I/O views of memory

scsi_abort()

Abort a SCSI command

scsi_reset()

Reset a SCSI bus or target

scsi_reset_notify()

Notify the target driver of bus resets

scsi_cname()

Decode a SCSI command

scsi_dname()

Decode a SCSI peripheral device type

scsi_mname()

Decode a SCSI message

scsi_rname()

Decode a SCSI packet completion reason

scsi_sname()

Decode a SCSI sense key

scsi_errmsg()

Display a SCSI request sense message

scsi_log()

Display a SCSI-device-related message

scsi_vu_errmsg()

Display a SCSI request sense message

scsi_hba_init()

SCSI HBA system initialization routine

scsi_hba_fini()

SCSI HBA system completion routine

scsi_hba_attach_setup()

SCSI HBA attach routine

scsi_hba_detach()

SCSI HBA detach routine

scsi_hba_probe()

Default SCSI HBA probe function

scsi_hba_tran_alloc()

Allocate a transport structure

scsi_hba_tran_free()

Free a transport structure

scsi_hba_pkt_alloc()

Allocate a scsi_pkt structure

scsi_hba_pkt_free()

Free a scsi_pkt structure

scsi_hba_lookup_capstr()

Return an index matching capability string

Table B–12 Deprecated SCSI Functions

Deprecated Function 

Replacement 

free_pktiopb()

scsi_free_consistent_buf()

get_pktiopb()

scsi_alloc_consistent_buf()

makecom_g0()

scsi_setup_cdb()

makecom_g0_s()

scsi_setup_cdb()

makecom_g1()

scsi_setup_cdb()

makecom_g5()

scsi_setup_cdb()

scsi_dmafree()

scsi_destroy_pkt()

scsi_dmaget()

scsi_init_pkt()

scsi_hba_attach()

scsi_hba_attach_setup()

scsi_pktalloc()

scsi_init_pkt()

scsi_pktfree()

scsi_destroy_pkt()

scsi_resalloc()

scsi_init_pkt()

scsi_resfree()

scsi_destroy_pkt()

scsi_slave()

scsi_probe()

scsi_unslave()

scsi_unprobe()

Resource Map Management Functions

The resource map management functions are:

rmallocmap()

Allocate a resource map

rmallocmap_wait()

Allocate a resource map, wait if necessary

rmfreemap()

Free a resource map

rmalloc()

Allocate space from a resource map

rmalloc_wait()

Allocate space from a resource map, wait if necessary

rmfree()

Free space back into a resource map

System Global State

ddi_in_panic()

Determine whether the system is in panic state

Utility Functions

The utility functions are:

nulldev()

Zero return function

nodev()

Error return function

nochpoll()

Error return function for non-pollable devices

ASSERT()

Expression verification

bcopy()

Copy data between address locations in the kernel

bzero()

Clear memory for a given number of bytes

bcmp()

Compare two byte arrays

ddi_ffs()

Find the first bit set in a long integer

ddi_fls()

Find the last bit set in a long integer

swab()

Swap bytes in 16-bit halfwords

strcmp()

Compare two null-terminated strings

strncmp()

Compare two null-terminated strings, with length limit

strlen()

Determine the number of non-null bytes in a string

strnlen()

(Available starting with SXCE build 88) Determine the number of non-null bytes in a string, with length limit

strcpy()

Copy a string from one location to another

strncpy()

Copy a string from one location to another, with length limit

strchr()

Find a character in a string

sprintf(), vsprintf()

Format characters in memory

numtos()

Convert an integer to a decimal string

stoi()

Convert a decimal string to an integer

max()

Return the larger of two integers

min()

Return the lesser of two integers

va_arg()

Finds the next value in a variable argument list

va_copy()

Copies the state of a variable argument list

va_end()

Deletes pointer to a variable argument list

va_start()

Finds the pointer to the start of a variable argument list