Writing Device Drivers

Introduction

This appendix discusses the interfaces provided by the Solaris 9 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 man pages section 9F: DDI and DKI Kernel Functions for more detailed information. The categories are:

This appendix does not discuss STREAMS interfaces; to learn more about network drivers, see the STREAMS Programming Guide.

Module Functions

Table B–1 Module Functions

Function Name 

Description 

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

Table B–2 Device Information Tree Node (dev_info_t) Functions

Function Name 

Description 

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

Table B–3 Device (dev_t) Functions

Function Name 

Description 

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

Table B–4 Property Functions

Function Name 

Description 

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–5 Deprecated Property Functions

Deprecated Functions 

Replacements 

ddi_getlongprop

see ddi_prop_lookup 

ddi_getlongprop_buf 

see ddi_prop_lookup 

ddi_getprop 

ddi_prop_get_int 

ddi_getproplen 

see ddi_prop_lookup 

ddi_prop_create 

see ddi_prop_lookup 

ddi_prop_modify 

see ddi_prop_lookup 

ddi_prop_op 

see ddi_prop_lookup 

Device Software State Functions

Table B–6 Device Software State Functions

Function Name 

Description 

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

Table B–7 Memory Allocation and Deallocation Functions

Function Name 

Description 

kmem_alloc

allocate kernel memory 

kmem_free 

free kernel memory 

kmem_zalloc 

allocate zero-filled kernel memory 

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

Table B–8

Function Name 

Description 

ddi_dma_mem_alloc

allocate memory for DMA transfer 

ddi_dma_mem_free 

free previously allocated DMA memory 

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

Table B–9

Function Name 

Description 

ddi_umem_alloc 

allocate page-aligned kernel memory 

ddi_umem_free 

free page-aligned kernel memory 

Table B–10 Deprecated Memory Allocation and Deallocation Functions

Deprecated Functions 

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

Table B–11 Kernel Thread Control and Synchronization Functions

Function Name 

Description 

cv_broadcast

wakeup all waiting threads 

cv_destroy 

free an allocated condition variable 

cv_init 

allocate a condition variable 

cv_signal 

wakeup 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_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 if 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 

Interrupt Functions

Table B–12 Interrupt Functions

Function Name 

Description 

ddi_add_intr

register a hardware interrupt handler 

ddi_add_softintr 

register a software interrupt handler 

ddi_dev_nintrs 

return the number of interrupt specifications a device has 

ddi_get_iblock_cookie 

get a hardware interrupt block cookie 

ddi_get_soft_iblock_cookie 

get a software interrupt block cookie 

ddi_intr_hilevel 

indicate interrupt type 

ddi_remove_intr 

unregister a hardware interrupt handler 

ddi_remove_softintr 

unregister a software interrupt handler 

ddi_trigger_softintr 

trigger a software interrupt 

Programmed I/O Functions

Table B–13 Programmed I/O Functions

Function Name 

Description 

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 above can always be used rather than the mem, io, and pci_config functions below. However, the below functions may be used as alternatives in cases where the type of access is known at compile time.

Table B–14 Alternate Access Mechanisms

Function Name 

Description 

ddi_io_get8

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

ddi_io_get16 

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

ddi_io_get32 

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

ddi_io_put8 

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

ddi_io_put16 

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

ddi_io_put32 

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

ddi_io_rep_get8 

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

ddi_io_rep_get16 

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

ddi_io_rep_get32 

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

ddi_io_rep_put8 

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

ddi_io_rep_put16 

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

ddi_io_rep_put32 

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

ddi_mem_get8 

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

ddi_mem_get16 

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

ddi_mem_get32 

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

ddi_mem_get64 

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

ddi_mem_put8 

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

ddi_mem_put16 

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

ddi_mem_put32 

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

ddi_mem_put64 

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

ddi_mem_rep_get8 

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

ddi_mem_rep_get16 

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

ddi_mem_rep_get32 

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

ddi_mem_rep_get64 

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

ddi_mem_rep_put8 

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

ddi_mem_rep_put16 

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

ddi_mem_rep_put32 

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

ddi_mem_rep_put64 

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

pci_config_setup 

setup 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–15 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

Table B–16 Direct Memory Access (DMA) Functions

Function Name 

Description 

ddi_dma_alloc_handle

allocate a DMA handle 

ddi_dma_free_handle 

free DMA handle 

ddi_dma_mem_alloc 

allocate memory for 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 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 DMA handle 

ddi_dma_set_sbus64 

allow 64-bit transfers on SBus 

ddi_slaveonly 

tell if a device is installed in a slave access only location 

ddi_iomin 

find 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 DMA engine attributes 

ddi_dmae_prog 

program a DMA channel 

ddi_dmae_stop 

terminate DMA engine operation 

ddi_dmae_disable 

disable a DMA channel 

ddi_dmae_enable 

enable a DMA channel 

ddi_dmae_getcnt 

get DMA engine count remaining 

ddi_dmae_1stparty 

configure DMA channel cascade mode 

ddi_dma_coff 

convert a DMA cookie to an offset within a DMA handle 

Table B–17 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

Table B–18 User Space Access Functions

Function Name 

Description 

ddi_copyin 

copy data to a driver buffer 

ddi_copyout 

copy data from a driver 

uiomove 

copy kernel data using uio structure  

ureadc 

add character to a uio structure 

uwritec 

remove a character from a uio structure 

ddi_getiminor 

get kernel internal minor number from an external dev_t  

ddi_model_convert_from 

determine data model type mismatch 

IOC_CONVERT_FROM 

determine if there is a need to translate M_IOCTL contents 

STRUCT_DECL 

establish handle to application data in possibly differing data model 

STRUCT_HANDLE 

establish handle to application data in possibly differing data model 

STRUCT_INIT 

establish handle to application data in possibly differing data model 

STRUCT_SET_HANDLE 

establish handle to application data in possibly differing data model 

SIZEOF_PTR 

return size of pointer in specified data model 

SIZEOF_STRUCT 

return size of structure in specified data model 

STRUCT_SIZE 

return size of structure in 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 specified field of a structure in application data model 

STRUCT_FGETP 

return specified pointer field of a structure in application data model 

STRUCT_FSET 

set specified field of a structure in application data model 

STRUCT_FSETP 

set specified pointer field of a structure in application data model 

Table B–19 Deprecated User Space Access Functions

Deprecated Functions 

Replacement 

copyin

ddi_copyin 

copyout 

ddi_copyout 

User Process Event Functions

Table B–20 User Process Event Functions

Function Name 

Description 

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

Table B–21 User Process Information Functions

Function Name 

Description 

ddi_get_cred

returns a pointer to the credential structure of the caller 

drv_priv 

determine process credentials privilege 

ddi_get_pid 

return the process ID 

Table B–22 Deprecated User Process Information Functions

Deprecated Functions 

Replacement 

drv_getparm

ddi_get_pid, ddi_get_cred  

User Application Kernel and Device Access Functions

Table B–23 User Application Kernel and Device Access Functions

Function Name 

Description 

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 

set up a user mapping to device memory 

devmap_setup 

set up a user mapping to device memory 

devmap_devmem_setup 

export device memory to user space 

devmap_load 

control validation of memory address translations 

devmap_unload 

control validation of 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–24 Deprecated User Application Kernel and Device Access Functions

Deprecated Functions 

Replacement 

ddi_mapdev

devmap_setup 

ddi_mapdev_intercept 

devmap_load 

ddi_mapdev_nointercept 

devmap_unload 

ddi_mapdev_set_device_acc_attr 

see devmap(9e) 

ddi_segmap 

see devmap(9e) 

ddi_segmap_setup 

devmap_setup 

hat_getkpfnum 

see devmap(9e) 

ddi_mmap_get_model 

see devmap(9e) 

Time-Related Functions

Table B–25 Time-Related Functions

Function Name 

Description 

ddi_get_lbolt

returns clock ticks since reboot 

ddi_get_time 

return the current time in seconds 

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 previous timeout function call 

drv_getparm 

ddi_get_lbolt, ddi_get_time  

Table B–26 Deprecated Time-Related Functions

Deprecated Function 

Replacement 

drv_getparm

ddi_get_lbolt, ddi_get_time  

Power Management Functions

Table B–27 Power Management Functions

Function Name 

Description 

ddi_removing_power

check if device loses power with DDI_SUSPEND 

pci_report_pmcap 

report power management capability of a PCI device 

pm_busy_component 

mark component as busy 

pm_idle_component 

mark 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 power management framework of autonomous power level change 

pm_trans_check 

device power cycle advisory check 

Table B–28 Deprecated Power Management Functions

Function Name 

Description 

ddi_dev_is_needed

inform the system that a device's component is required  

pm_create_components 

see pm-components(9P)

pm_destroy_components 

see pm-components(9P)

pm_get_normal_power 

see pm-components(9P)

pm_set_normal_power 

see pm-components(9P)

Kernel Statistics Functions

Table B–29 Kernel Statistics Functions

Function Name 

Description 

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 transaction migration from run queue to wait queue 

kstat_runq_enter 

record transaction add to run queue 

kstat_runq_exit 

record transaction removal from run queue 

kstat_waitq_enter 

record transaction add to wait queue 

kstat_waitq_exit 

record transaction removal from wait queue 

kstat_waitq_to_runq 

record transaction migration from wait queue to run queue 

Kernel Logging and Printing Functions

Table B–30 Kernel Logging and Printing Functions

Function Name 

Description 

cmn_err

display an error message 

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

Table B–31 Buffered I/O Functions

Function Name 

Description 

physio

perform physical I/O 

aphysio 

perform asynchronous physical I/O 

anocancel 

prevent cancellation of asynchronous I/O request  

minphys 

limit physio buffer size 

biowait 

suspend processes pending completion of block I/O 

biodone 

release buffer after buffer I/O transfer and notify blocked threads 

bioerror 

indicate error in buffer header 

geterror 

return I/O error 

bp_mapin 

allocate virtual address space 

bp_mapout 

deallocate virtual address space 

disksort 

single direction elevator seek sort for buffers 

getrbuf 

get a raw buffer header  

freerbuf 

free a raw buffer header 

biosize 

returns 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 if a buffer is modified 

clrbuf 

erase the contents of a buffer 

Virtual Memory Functions

Table B–32 Virtual Memory Functions

Function Name 

Description 

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–33 Deprecated Virtual Memory Functions

Deprecated Functions 

Replacement 

hat_getkpfnum

see devmap(9e), ddi_dma_*_bind_handle, ddi_dma_nextcookie  

Device ID Functions

Table B–34 Device ID Functions

Function Name 

Description 

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

Table B–35 SCSI Functions

Function Name 

Description 

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 

setup 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 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 index matching capability string 

Table B–36 Deprecated SCSI Functions

Deprecated Functions 

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

Table B–37 Resource Map Management Functions

Function Name 

Description 

rmallocmap

allocate resource map 

rmallocmap_wait 

allocate resource map, wait if necessary 

rmfreemap 

free 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

Table B–38 System Global State

Function Name 

Description 

ddi_in_panic

determine if system is in panic state 

Utility Functions

Table B–39 Utility Functions

Function Name 

Description 

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 first bit set in a long integer 

ddi_fls 

find 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 

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 

format characters in memory 

vsprintf 

format characters in memory 

numtos 

convert integer to decimal string 

stoi 

convert decimal string to an integer 

max 

return the larger of two integers 

min 

return the lesser of two integers 

va_arg 

handle variable argument list 

va_copy 

handle variable argument list 

va_end 

handle variable argument list 

va_start 

handle variable argument list