sunddi.h revision 15e1afcd5e908ae29b1e6018838638befdc225a2
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#ifndef _SYS_SUNDDI_H
#define _SYS_SUNDDI_H
/*
* Sun Specific DDI definitions
*/
#include <sys/isa_defs.h>
#include <sys/dditypes.h>
#include <sys/ddipropdefs.h>
#include <sys/ddidevmap.h>
#include <sys/ddi_impldefs.h>
#include <sys/ddi_implfuncs.h>
#include <sys/dma_engine.h>
#endif
#include <sys/sysevent.h>
#endif
#ifdef _KERNEL
#include <sys/ddi_obsolete.h>
#endif
#include <sys/u8_textprep.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Generic Sun DDI definitions.
*/
#define DDI_SUCCESS (0) /* successful return */
/*
* General-purpose DDI error return value definitions
*/
/*
*/
#define DDI_SLEEP 0
#define DDI_NOSLEEP 1
/*
* The following special nodeid values are reserved for use when creating
* nodes ONLY. They specify the attributes of the DDI_NC_PSEUDO class node
* being created:
*
* o DEVI_PSEUDO_NODEID specifics a node without persistence.
* o DEVI_SID_NODEID specifies a node with persistence.
* o DEVI_SID_HIDDEN_NODEID specifies a hidden node with persistence.
*
* A node with the 'hidden' attribute will not show up in devinfo snapshots
* or in /devices file system.
*
* A node with the 'persistent' attribute will not be automatically removed by
* the framework in the current implementation - driver.conf nodes are without
* persistence.
*
* The actual nodeid value may be assigned by the framework and may be
* different than these special values. Drivers may not make assumptions
* about the nodeid value that is actually assigned to the node.
*/
#define DEVI_PSEUDO_NODEID ((int)-1)
#define DEVI_SID_NODEID ((int)-2)
#define DEVI_SID_HIDDEN_NODEID ((int)-3)
#define DEVI_SID_HP_NODEID ((int)-4)
#define DEVI_SID_HP_HIDDEN_NODEID ((int)-5)
#define DEVI_PSEUDO_NEXNAME "pseudo"
#define DEVI_ISA_NEXNAME "isa"
#define DEVI_EISA_NEXNAME "eisa"
/*
* ddi_create_minor_node flags
*/
/*
* Historical values used for the flag field in ddi_create_minor_node.
* Future use of flag bits should avoid these fields to keep binary
* compatibility
* #define GLOBAL_DEV 0x2
* #define NODEBOUND_DEV 0x4
* #define NODESPECIFIC_DEV 0x6
* #define ENUMERATED_DEV 0x8
*/
/*
* Device type defines which are used by the 'node_type' element of the
* ddi_minor_data structure
*/
/* ports (the old ttya, b */
/* (,c ,d)) */
/* ports */
/*
* *_CHAN disk type devices have channel numbers or target numbers.
* (i.e. ipi and scsi devices)
*/
/*
* The next define is for block type devices that can possible exist on
* a sub-bus like the scsi bus or the ipi channel. The 'disks' program
* will pick up on this and create logical names like c0t0d0s0 instead of
* c0d0s0
*/
#define DDI_NT_BLOCK_CHAN "ddi_block:channel"
#define DDI_NT_BLOCK_WWN "ddi_block:wwn"
#define DDI_NT_ENCLOSURE "ddi_enclosure"
#define DDI_NT_SCSI_ENCLOSURE "ddi_enclosure:scsi"
#define DDI_NT_BLOCK_SAS "ddi_block:sas"
/*
* xVM virtual block devices
*/
#define DDI_NT_BLOCK_XVMD "ddi_block:xvmd"
#define DDI_NT_CD_XVMD "ddi_block:cdrom:xvmd"
#define DDI_NT_SCSI_ATTACHMENT_POINT "ddi_ctl:attachment_point:scsi"
/* scsi attachment pt */
#define DDI_NT_SATA_ATTACHMENT_POINT "ddi_ctl:attachment_point:sata"
/* sata attachment pt */
#define DDI_NT_SDCARD_ATTACHMENT_POINT "ddi_ctl:attachment_point:sdcard"
/* sdcard attachment pt */
#define DDI_NT_PCI_ATTACHMENT_POINT "ddi_ctl:attachment_point:pci"
/* PCI attachment pt */
#define DDI_NT_SBD_ATTACHMENT_POINT "ddi_ctl:attachment_point:sbd"
/* generic bd attachment pt */
#define DDI_NT_FC_ATTACHMENT_POINT "ddi_ctl:attachment_point:fc"
/* FC attachment pt */
#define DDI_NT_USB_ATTACHMENT_POINT "ddi_ctl:attachment_point:usb"
/* USB devices */
#define DDI_NT_BLOCK_FABRIC "ddi_block:fabric"
/* Fabric Devices */
#define DDI_NT_IB_ATTACHMENT_POINT "ddi_ctl:attachment_point:ib"
/* IB devices */
/* Device types used for agpgart driver related devices */
/*
* DDI event definitions
*/
/* Class devfs subclasses */
#define ESC_DEVFS_MINOR_CREATE "ESC_devfs_minor_create"
#define ESC_DEVFS_MINOR_REMOVE "ESC_devfs_minor_remove"
#define ESC_DEVFS_DEVI_ADD "ESC_devfs_devi_add"
#define ESC_DEVFS_DEVI_REMOVE "ESC_devfs_devi_remove"
#define ESC_DEVFS_INSTANCE_MOD "ESC_devfs_instance_mod"
#define ESC_DEVFS_BRANCH_ADD "ESC_devfs_branch_add"
#define ESC_DEVFS_BRANCH_REMOVE "ESC_devfs_branch_remove"
#define ESC_DEVFS_START "ESC_devfs_start"
/* Class ddi subclasses */
#define ESC_DDI_INITIATOR_REGISTER "ESC_ddi_initiator_register"
#define ESC_DDI_INITIATOR_UNREGISTER "ESC_ddi_initiator_unregister"
/*
* devfs event class attributes
*
* The following attributes are private to EC_DEVFS event data.
*/
#define DEVFS_DRIVER_NAME "di.driver"
#define DEVFS_INSTANCE "di.instance"
#define DEVFS_PATHNAME "di.path"
#define DEVFS_DEVI_CLASS "di.devi_class"
#define DEVFS_BRANCH_EVENT "di.branch_event"
#define DEVFS_MINOR_NAME "mi.name"
#define DEVFS_MINOR_NODETYPE "mi.nodetype"
#define DEVFS_MINOR_ISCLONE "mi.isclone"
#define DEVFS_MINOR_MAJNUM "mi.majorno"
#define DEVFS_MINOR_MINORNUM "mi.minorno"
/*
* ddi event class payload
*
* The following attributes are private to EC_DDI event data.
*/
#define DDI_DRIVER_NAME "ddi.driver"
#define DDI_DRIVER_MAJOR "ddi.major"
#define DDI_INSTANCE "ddi.instance"
#define DDI_PATHNAME "ddi.path"
/*
* Fault-related definitions
*
* The specific numeric values have been chosen to be ordered, but
* not consecutive, to allow for future interpolation if required.
*/
typedef enum {
DDI_SERVICE_LOST = -32,
DDI_SERVICE_DEGRADED = -16,
DDI_SERVICE_RESTORED = 16
typedef enum {
DDI_DATAPATH_FAULT = -32,
DDI_DEVICE_FAULT = -16,
typedef enum {
DDI_DEVSTATE_OFFLINE = -32,
DDI_DEVSTATE_DOWN = -16,
DDI_DEVSTATE_DEGRADED = 16,
DDI_DEVSTATE_UP = 32
#ifdef _KERNEL
/*
* Common property definitions
*/
#define DDI_FORCEATTACH "ddi-forceattach"
#define DDI_NO_AUTODETACH "ddi-no-autodetach"
#define DDI_VHCI_CLASS "ddi-vhci-class"
#define DDI_NO_ROOT_SUPPORT "ddi-no-root-support"
#define DDI_OPEN_RETURNS_EINTR "ddi-open-returns-eintr"
#define DDI_DEVID_REGISTRANT "ddi-devid-registrant"
/*
* Values that the function supplied to the dev_info
* tree traversal functions defined below must return.
*/
/*
* Continue search, if appropriate.
*/
#define DDI_WALK_CONTINUE 0
/*
* Terminate current depth of traversal. That is, terminate
* the current traversal of children nodes, but continue
* traversing sibling nodes and their children (if any).
*/
#define DDI_WALK_PRUNECHILD -1
/*
* Terminate current width of traversal. That is, terminate
* the current traversal of sibling nodes, but continue with
* traversing children nodes and their siblings (if appropriate).
*/
#define DDI_WALK_PRUNESIB -2
/*
* Terminate the entire search.
*/
#define DDI_WALK_TERMINATE -3
/*
* Terminate the entire search because an error occurred in function
*/
#define DDI_WALK_ERROR -4
/*
* Drivers that are prepared to support full driver layering
* should create and export a null-valued property of the following
* name.
*
* Such drivers should be prepared to be called with FKLYR in
* the 'flag' argument of their open(9E), close(9E) routines, and
* with FKIOCTL in the 'mode' argument of their ioctl(9E) routines.
*
* See ioctl(9E) and ddi_copyin(9F) for details.
*/
#define DDI_KERNEL_IOCTL "ddi-kernel-ioctl"
/*
* Model definitions for ddi_mmap_get_model(9F) and ddi_model_convert_from(9F).
*/
#define DDI_MODEL_ILP32 DATAMODEL_ILP32
#define DDI_MODEL_LP64 DATAMODEL_LP64
#define DDI_MODEL_NATIVE DATAMODEL_NATIVE
#define DDI_MODEL_NONE DATAMODEL_NONE
/* if set to B_TRUE is DER_MODE is equivalent to DERE_PANIC */
extern boolean_t ddi_err_panic;
/*
* Defines for ddi_err().
*/
typedef enum {
DER_INVALID = 0, /* must be 0 */
DER_CONT = 1,
} ddi_err_t;
/*
*/
extern int maxphys;
extern char *strcpy(char *, const char *);
/* Need to be consistent with <string.h> C++ definition for strchr() */
#if __cplusplus >= 199711L
extern const char *strchr(const char *, int);
#ifndef _STRCHR_INLINE
#define _STRCHR_INLINE
extern "C++" {
}
}
#endif /* _STRCHR_INLINE */
#else
extern char *strchr(const char *, int);
#endif /* __cplusplus >= 199711L */
extern int stoi(char **);
/* Need to be consistent with <string.h> C++ definition for memchr() */
#if __cplusplus >= 199711L
#ifndef _MEMCHR_INLINE
#define _MEMCHR_INLINE
extern "C++" {
}
}
#endif /* _MEMCHR_INLINE */
#else
#endif /* __cplusplus >= 199711L */
extern int ddi_strtol(const char *, char **, int, long *);
extern int ddi_strtoul(const char *, char **, int, unsigned long *);
extern int ddi_strtoll(const char *, char **, int, longlong_t *);
extern int ddi_strtoull(const char *, char **, int, u_longlong_t *);
/*
* kiconv functions and their macros.
*/
#define KICONV_IGNORE_NULL (0x0001)
#define KICONV_REPLACE_INVALID (0x0002)
extern kiconv_t kiconv_open(const char *, const char *);
extern int kiconv_close(kiconv_t);
size_t *, int, int *);
/*
* ddi_map_regs
*
* Map in the register set given by rnumber.
* The register number determine which register
* set will be mapped if more than one exists.
* The parent driver gets the information
* from parent private data and sets up the
* appropriate mappings and returns the kernel
* virtual address of the register set in *kaddrp.
* The offset specifies an offset into the register
* space to start from and len indicates the size
* of the area to map. If len and offset are 0 then
* the entire space is mapped. It returns DDI_SUCCESS on
* success or DDI_FAILURE otherwise.
*
*/
int
/*
* ddi_unmap_regs
*
* Undo mappings set up by ddi_map_regs.
* The register number determines which register
* set will be unmapped if more than one exists.
* This is provided for drivers preparing
* to detach themselves from the system to
* allow them to release allocated mappings.
*
* The kaddrp and len specify the area to be
* unmapped. *kaddrp was returned from ddi_map_regs
* and len should match what ddi_map_regs was called
* with.
*/
void
int
int
/*
* ddi_rnumber_to_regspec: Not for use by leaf drivers.
*/
struct regspec *
int
int
/*
* Peek and poke to and from a uio structure in xfersize pieces,
* using the parent nexi.
*/
/*
* Pagesize conversions using the parent nexi
*/
/*
* There are no more "block" interrupt functions, per se.
*
* However, there are certain times in which a driver needs
* absolutely a critical guaranteed non-preemptable time
* in which to execute a few instructions.
*
* The following pair of functions attempt to guarantee this,
* but they are dangerous to use. That is, use them with
* extreme care. They do not guarantee to stop other processors
* from executing, but they do guarantee that the caller
* of ddi_enter_critical will continue to run until the
* caller calls ddi_exit_critical. No intervening DDI functions
* may be called between an entry and an exit from a critical
* region.
*
* ddi_enter_critical returns an integer identifier which must
* be passed to ddi_exit_critical.
*
* Be very sparing in the use of these functions since it is
* likely that absolutely nothing else can occur in the system
* whilst in the critical region.
*/
unsigned int
ddi_enter_critical(void);
void
ddi_exit_critical(unsigned int);
/*
* devmap functions
*/
int
int
int
int
int
struct devmap_callback_ctl *callback_ops,
int
struct devmap_callback_ctl *callback_ops,
int
int
void
int
int
/*
* Functions to lock user memory and do repeated I/O or do devmap_umem_setup
*/
int
void
struct buf *
/*
* Mapping functions
*/
int
int
int
int
/*
* Property functions: See also, ddipropdefs.h.
* In general, the underlying driver MUST be held
* to call it's property functions.
*/
/*
* Used to create, modify, and lookup integer properties
*/
/*
* Used to create, modify, and lookup string properties
*/
/*
* Used to create, modify, and lookup byte properties
*/
/*
* Used to verify the existence of a property or to see if a boolean
* property exists.
*/
/*
* Used to free the data returned by the above property routines.
*/
void ddi_prop_free(void *data);
/*
* nopropop: For internal use in `dummy' cb_prop_op functions only
*/
int
/*
* ddi_prop_op: The basic property operator for drivers.
*
* In ddi_prop_op, the type of valuep is interpreted based on prop_op:
*
* prop_op valuep
* ------ ------
*
* PROP_LEN <unused>
*
* PROP_LEN_AND_VAL_BUF Pointer to callers buffer
*
* PROP_LEN_AND_VAL_ALLOC Address of callers pointer (will be set to
* address of allocated buffer, if successful)
*/
int
/* ddi_prop_op_size: for drivers that implement size in bytes */
int
/* ddi_prop_op_size_blksize: like ddi_prop_op_size, in blksize blocks */
int
/* ddi_prop_op_nblocks: for drivers that implement size in DEV_BSIZE blocks */
int
/* ddi_prop_op_nblocks_blksize: like ddi_prop_op_nblocks, in blksize blocks */
int
/*
* Variable length props...
*/
/*
* ddi_getlongprop: Get variable length property len+val into a buffer
* allocated by property provider via kmem_alloc. Requester
* is responsible for freeing returned property via kmem_free.
*
* Arguments:
*
* dev: Input: dev_t of property.
* dip: Input: dev_info_t pointer of child.
* flags: Input: Possible flag modifiers are:
* DDI_PROP_DONTPASS: Don't pass to parent if prop not found.
* DDI_PROP_CANSLEEP: Memory allocation may sleep.
* name: Input: name of property.
* valuep: Output: Addr of callers buffer pointer.
* lengthp:Output: *lengthp will contain prop length on exit.
*
* Possible Returns:
*
* DDI_PROP_SUCCESS: Prop found and returned.
* DDI_PROP_NOT_FOUND: Prop not found
* DDI_PROP_UNDEFINED: Prop explicitly undefined.
* DDI_PROP_NO_MEMORY: Prop found, but unable to alloc mem.
*/
int
/*
*
* ddi_getlongprop_buf: Get long prop into pre-allocated callers
* buffer. (no memory allocation by provider).
*
* dev: Input: dev_t of property.
* dip: Input: dev_info_t pointer of child.
* flags: Input: DDI_PROP_DONTPASS or NULL
* name: Input: name of property
* valuep: Input: ptr to callers buffer.
* lengthp:I/O: ptr to length of callers buffer on entry,
* actual length of property on exit.
*
* Possible returns:
*
* DDI_PROP_SUCCESS Prop found and returned
* DDI_PROP_NOT_FOUND Prop not found
* DDI_PROP_UNDEFINED Prop explicitly undefined.
* DDI_PROP_BUF_TOO_SMALL Prop found, callers buf too small,
* no value returned, but actual prop
* length returned in *lengthp
*
*/
int
/*
*
* Call is value only... returns found boolean or int sized prop value or
* defvalue if prop not found or is wrong length or is explicitly undefined.
* Only flag is DDI_PROP_DONTPASS...
*
* By convention, this interface returns boolean (0) sized properties
* as value (int)1.
*/
int
/*
* Get prop length interface: flags are 0 or DDI_PROP_DONTPASS
* if returns DDI_PROP_SUCCESS, length returned in *lengthp.
*/
int
/*
* Only flag is DDI_PROP_CANSLEEP to allow memory allocation to sleep
* if no memory available for internal prop structure. Long property
* (non integer sized) value references are not copied.
*
* Define property with DDI_DEV_T_NONE dev_t for properties not associated
* with any particular dev_t. Use the same dev_t when modifying or undefining
* a property.
*
* No guarantee on order of property search, so don't mix the same
* property name with wildcard and non-wildcard dev_t's.
*/
/*
* ddi_prop_create: Define a managed property:
*/
int
/*
* ddi_prop_modify: Modify a managed property value
*/
int
/*
* ddi_prop_remove: Undefine a managed property:
*/
int
/*
* ddi_prop_remove_all: Used before unloading a driver to remove
* all properties. (undefines all dev_t's props.)
* Also removes `undefined' prop defs.
*/
void
/*
* ddi_prop_undefine: Explicitly undefine a property. Property
* searches which match this property return
* the error code DDI_PROP_UNDEFINED.
*
* Use ddi_prop_remove to negate effect of
* ddi_prop_undefine
*/
int
/*
* ddi_prop_cache_invalidate
* Invalidate a property in the current cached
* devinfo snapshot - next cached snapshot will
* return the latest property value available.
*/
void
/*
* The default ddi_bus_prop_op wrapper...
*/
int
/*
* Routines to traverse the tree of dev_info nodes.
* The general idea of these functions is to provide
* various tree traversal utilities. For each node
* that the tree traversal function finds, a caller
* supplied function is called with arguments of
* the current node and a caller supplied argument.
* The caller supplied function should return one
* of the integer values defined below which will
* indicate to the tree traversal function whether
* the traversal should be continued, and if so, how,
* or whether the traversal should terminate.
*/
/*
* This general-purpose routine traverses the tree of dev_info nodes,
* starting from the given node, and calls the given function for each
* node that it finds with the current node and the pointer arg (which
* can point to a structure of information that the function
* needs) as arguments.
*
* It does the walk a layer at a time, not depth-first.
*
* The given function must return one of the values defined above.
*
*/
void
/*
* Routines to get at elements of the dev_info structure
*/
/*
* ddi_node_name gets the device's 'name' from the device node.
*
* ddi_binding_name gets the string the OS used to bind the node to a driver,
* in certain cases, the binding name may be different from the node name,
* if the node name does not name a specific device driver.
*
* ddi_get_name is a synonym for ddi_binding_name().
*/
char *
char *
const char *
char *
int
int
struct dev_ops *
void
void
void *
/*
* ddi_dev_is_needed tells system that a device is about to use a
* component. Returns when component is ready.
*/
int
/*
* check if DDI_SUSPEND may result in power being removed from a device.
*/
int
/*
* (Obsolete) power entry point
*/
int
/*
* ddi_get_parent requires that the branch of the tree with the
* node be held (ddi_hold_installed_driver) or that the devinfo tree
* lock be held
*/
/*
* ddi_get_child and ddi_get_next_sibling require that the devinfo
* tree lock be held
*/
void
/*
* dev_info manipulation functions
*/
/*
* Add and remove child devices. These are part of the system framework.
*
* ddi_add_child creates a dev_info structure with the passed name,
* nodeid and instance arguments and makes it a child of pdip. Devices
* that are known directly by the hardware have real nodeids; devices
* that are software constructs use the defined DEVI_PSEUDO_NODEID
* for the node id.
*
* ddi_remove_node removes the node from the tree. This fails if this
* child has children. Parent and driver private data should already
* be released (freed) prior to calling this function. If flag is
* non-zero, the child is removed from it's linked list of instances.
*/
int
/*
* Given the major number for a driver, make sure that dev_info nodes
* are created form the driver's hwconf file, the driver for the named
* device is loaded and attached, as well as any drivers for parent devices.
* Return a pointer to the driver's dev_ops struct with the dev_ops held.
* Note - Callers must release the dev_ops with ddi_rele_driver.
*
* When a driver is held, the branch of the devinfo tree from any of the
* drivers devinfos to the root node are automatically held. This only
* applies to tree traversals up (and back down) the tree following the
* parent pointers.
*
* Use of this interface is discouraged, it may be removed in a future release.
*/
struct dev_ops *
void
/*
* Attach and hold the specified instance of a driver. The flags argument
* should be zero.
*/
void
/*
* Associate a streams queue with a devinfo node
*/
void
/*
* Given the identifier string passed, make sure that dev_info nodes
* are created form the driver's hwconf file, the driver for the named
* device is loaded and attached, as well as any drivers for parent devices.
*
* Note that the driver is not held and is subject to being removed the instant
* this call completes. You probably really want ddi_hold_installed_driver.
*/
int
ddi_install_driver(char *idstring);
/*
* Routines that return specific nodes
*/
ddi_root_node(void);
/*
* Given a name and an instance number, find and return the
* dev_info from the current state of the device tree.
*
* If instance number is -1, return the first named instance.
*
* If attached is 1, exclude all nodes that are < DS_ATTACHED
*
* Requires that the devinfo tree be locked.
* If attached is 1, the driver must be held.
*/
/*
* Synchronization of I/O with respect to various
* caches and system write buffers.
*
* Done at varying points during an I/O transfer (including at the
* removal of an I/O mapping).
*
* Due to the support of systems with write buffers which may
* not be able to be turned off, this function *must* used at
* any point in which data consistency might be required.
*
* Generally this means that if a memory object has multiple mappings
* (both for I/O, as described by the handle, and the IU, via, e.g.
* a call to ddi_dma_kvaddrp), and one mapping may have been
* used to modify the memory object, this function must be called
* to ensure that the modification of the memory object is
* complete, as well as possibly to inform other mappings of
* the object that any cached references to the object are
* now stale (and flush or invalidate these stale cache references
* as necessary).
*
* The function ddi_dma_sync() provides the general interface with
* respect to this capability. Generally, ddi_dma_free() (below) may
* be used in preference to ddi_dma_sync() as ddi_dma_free() calls
* ddi_dma_sync().
*
* Returns 0 if all caches that exist and are specified by cache_flags
* are successfully operated on, else -1.
*
* The argument offset specifies an offset into the mapping of the mapped
* object in which to perform the synchronization. It will be silently
* truncated to the granularity of underlying cache line sizes as
* appropriate.
*
* The argument len specifies a length starting from offset in which to
* perform the synchronization. A value of (uint_t) -1 means that the length
* proceeds from offset to the end of the mapping. The length argument
* will silently rounded up to the granularity of underlying cache line
* sizes as appropriate.
*
* The argument flags specifies what to synchronize (the device's view of
* the object or the cpu's view of the object).
*
* Inquiring minds want to know when ddi_dma_sync should be used:
*
* + When an object is mapped for dma, assume that an
* implicit ddi_dma_sync() is done for you.
*
* + When an object is unmapped (ddi_dma_free()), assume
* that an implicit ddi_dma_sync() is done for you.
*
* + At any time between the two times above that the
* memory object may have been modified by either
* the DMA device or a processor and you wish that
* the change be noticed by the master that didn't
* do the modifying.
*
* Clearly, only the third case above requires the use of ddi_dma_sync.
*
* Inquiring minds also want to know which flag to use:
*
* + If you *modify* with a cpu the object, you use
* ddi_dma_sync(...DDI_DMA_SYNC_FORDEV) (you are making sure
* that the DMA device sees the changes you made).
*
* + If you are checking, with the processor, an area
* of the object that the DMA device *may* have modified,
* you use ddi_dma_sync(....DDI_DMA_SYNC_FORCPU) (you are
* making sure that the processor(s) will see the changes
* that the DMA device may have made).
*/
int
/*
* Return the allowable DMA burst size for the object mapped by handle.
* The burst sizes will returned in an integer that encodes power
* of two burst sizes that are allowed in bit encoded format. For
* example, a transfer that could allow 1, 2, 4, 8 and 32 byte bursts
* would be encoded as 0x2f. A transfer that could be allowed as solely
* a halfword (2 byte) transfers would be returned as 0x2.
*/
int
/*
* Merge DMA attributes
*/
void
/*
* Allocate a DMA handle
*/
int
/*
* Free DMA handle
*/
void
/*
* Allocate memory for DMA transfers
*/
int
/*
* Free DMA memory
*/
void
/*
* bind address to a DMA handle
*/
int
/*
* bind buffer to DMA handle
*/
int
/*
* unbind mapping object to handle
*/
int
/*
* get next DMA cookie
*/
void
/*
* get number of DMA windows
*/
int
/*
* get specific DMA window
*/
int
/*
* activate 64 bit SBus support
*/
int
/*
* Miscellaneous functions
*/
/*
* ddi_report_dev: Report a successful attach.
*/
void
/*
* ddi_dev_regsize
*
* If the device has h/w register(s), report
* the size, in bytes, of the specified one into *resultp.
*
* Returns DDI_FAILURE if there are not registers,
* or the specified register doesn't exist.
*/
int
/*
* ddi_dev_nregs
*
* If the device has h/w register(s), report
* how many of them that there are into resultp.
* Return DDI_FAILURE if the device has no registers.
*/
int
/*
* ddi_dev_is_sid
*
* If the device is self-identifying, i.e.,
* has already been probed by a smart PROM
* (and thus registers are known to be valid)
* return DDI_SUCCESS, else DDI_FAILURE.
*/
int
/*
* ddi_slaveonly
*
* If the device is on a bus that precludes
* the device from being either a dma master or
* a dma slave, return DDI_SUCCESS.
*/
int
/*
* ddi_dev_affinity
*
* Report, via DDI_SUCCESS, whether there exists
* an 'affinity' between two dev_info_t's. An
* affinity is defined to be either a parent-child,
* or a sibling relationship such that the siblings
* or in the same part of the bus they happen to be
* on.
*/
int
/*
* ddi_set_callback
*
* by listid. *listid must always initially start out as zero.
*/
void
/*
* ddi_run_callback
*
* Run the callback list identified by listid.
*/
void
/*
* More miscellaneous
*/
int
int
int
int
int
int
int
int
int
int
int
int
void
ddivoid();
cred_t *
ddi_get_cred(void);
ddi_get_time(void);
ddi_get_pid(void);
ddi_get_kt_did(void);
ddi_can_receive_sig(void);
void
int
int
void
int
ddi_in_panic(void);
int
/*
* DDI wrappers for ffs and fls
*/
int
int
/*
* The ddi_soft_state* routines comprise generic storage management utilities
* for driver soft state structures. Two types of soft_state indexes are
* supported: 'integer index', and 'string index'.
*/
typedef struct __ddi_soft_state_bystr ddi_soft_state_bystr;
/*
* Initialize a soft_state set, establishing the 'size' of soft state objects
* in the set.
*
* For an 'integer indexed' soft_state set, the initial set will accommodate
* 'n_items' objects - 'n_items' is a hint (i.e. zero is allowed), allocations
* that exceed 'n_items' have additional overhead.
*
* For a 'string indexed' soft_state set, 'n_items' should be the typical
* number of soft state objects in the set - 'n_items' is a hint, there may
* be additional overhead if the hint is too small (and wasted memory if the
* hint is too big).
*/
int
int
/*
* Allocate a soft state object associated with either 'integer index' or
* 'string index' from a soft_state set.
*/
int
int
/*
* Get the pointer to the allocated soft state object associated with
* either 'integer index' or 'string index'.
*/
void *
void *
/*
* Free the soft state object associated with either 'integer index'
* or 'string index'.
*/
void
void
/*
* Free the soft state set and any associated soft state objects.
*/
void
ddi_soft_state_fini(void **state_p);
void
/*
* The ddi_strid_* routines provide string-to-index management utilities.
*/
typedef struct __ddi_strid ddi_strid;
int
char *
void
void
/*
* Set the addr field of the name in dip to name
*/
void
/*
* Get the address part of the name.
*/
char *
void
void *
int
int
ddi_name_to_major(char *name);
char *
char *
char *
char *
char *
int
int
ddi_pathname_to_dev_t(char *pathname);
/*
* High resolution system timer functions.
*
* The ddi supports the notion of a hrtime_t type and the
* functions gethrtime, hrtadd, hrtsub and hrtcmp.
*/
/*
* Nexus wrapper functions
*
* These functions are for entries in a bus nexus driver's bus_ops
* structure for when the driver doesn't have such a function and
* doesn't wish to prohibit such a function from existing. They
* may also be called to start passing a request up the dev_info
* tree.
*/
/*
* bus_ctl wrapper
*/
int
/*
* bus_dma_map wrapper
*/
int
int
int
int
int
int
int
/*
* bus_dma_ctl wrapper
*/
int
/*
* dvma support for networking drivers
*/
unsigned long
int
void
void
void
void
/*
* Layered driver support
*/
extern int ddi_copyin(const void *, void *, size_t, int);
extern int ddi_copyout(const void *, void *, size_t, int);
/*
* Send signals to processes
*/
extern void *proc_ref(void);
extern void proc_unref(void *pref);
/* I/O port access routines */
/*
* Console bell routines
*/
/*
* Fault-related functions
*/
extern int ddi_check_acc_handle(ddi_acc_handle_t);
extern int ddi_check_dma_handle(ddi_dma_handle_t);
ddi_fault_location_t, const char *);
/*
* Miscellaneous redefines
*/
/*
* utilities - "reg" mapping and all common portable data access functions
*/
/*
* error code from ddi_regs_map_setup
*/
#define DDI_REGS_ACC_CONFLICT (-10)
/*
* Device address advance flags
*/
#define DDI_DEV_NO_AUTOINCR 0x0000
#define DDI_DEV_AUTOINCR 0x0001
int
void
/*
* these are the prototypes for the common portable data access functions
*/
void
void
void
void
void
void
void
void
void
void
void
void
/*
* these are special device handling functions
*/
int
int
/*
* these are software byte swapping functions
*/
/*
* these are the prototypes for PCI local bus functions
*/
/*
* PCI power management capabilities reporting in addition to those
* provided by the PCI Power Management Specification.
*/
int
void
void
void
void
void
int
int
int
void
void
void
int
#endif
void
void
pci_targetq_init(void);
int
int
/*
* the prototype for the C Language Type Model inquiry.
*/
model_t ddi_mmap_get_model(void);
/*
* these are the prototypes for device id functions.
*/
int
int
void
int
int
void
int
int
int
char
void
ddi_devid_free_guid(char *guid);
int
int
int
void
char *
int
void
ddi_devid_str_free(char *devidstr);
int
/*
* Event to post to when a devinfo node is removed.
*/
#define DDI_DEVI_REMOVE_EVENT "DDI:DEVI_REMOVE"
#define DDI_DEVI_INSERT_EVENT "DDI:DEVI_INSERT"
#define DDI_DEVI_BUS_RESET_EVENT "DDI:DEVI_BUS_RESET"
#define DDI_DEVI_DEVICE_RESET_EVENT "DDI:DEVI_DEVICE_RESET"
/*
* Invoke bus nexus driver's implementation of the
* (*bus_remove_eventcall)() interface to remove a registered
* callback handler for "event".
*/
int
/*
* Invoke bus nexus driver's implementation of the
* (*bus_add_eventcall)() interface to register a callback handler
* for "event".
*/
int
/*
* Return a handle for event "name" by calling up the device tree
* hierarchy via (*bus_get_eventcookie)() interface until claimed
* by a bus nexus or top of dev_info tree is reached.
*/
int
/*
* log a system event
*/
int
int sleep_flag);
/*
* ddi_log_sysevent() vendors
*/
#define DDI_VENDOR_SUNW "SUNW"
/*
* Opaque task queue handle.
*/
typedef struct ddi_taskq ddi_taskq_t;
/*
* Use default system priority.
*/
#define TASKQ_DEFAULTPRI -1
/*
* Create a task queue
*/
/*
* destroy a task queue
*/
/*
* Dispatch a task to a task queue
*/
/*
* Wait for all previously scheduled tasks to complete.
*/
/*
* Suspend all task execution.
*/
/*
* Resume task execution.
*/
/*
* Is task queue suspended?
*/
/*
* Parse an interface name of the form <alphanumeric>##<numeric> where
* <numeric> is maximal.
*/
/*
* DDI interrupt priority level
*/
#define DDI_IPL_0 (0) /* kernel context */
/*
* DDI periodic timeout interface
*/
/*
* Default quiesce(9E) implementation for drivers that don't need to do
* anything.
*/
int ddi_quiesce_not_needed(dev_info_t *);
/*
* Default quiesce(9E) initialization function for drivers that should
* implement quiesce but haven't yet.
*/
int ddi_quiesce_not_supported(dev_info_t *);
/*
* DDI generic callback interface
*/
typedef struct __ddi_cb **ddi_cb_handle_t;
/* Notify DDI of memory added */
/* Path alias interfaces */
typedef struct plat_alias {
char *pali_current;
char **pali_aliases;
} plat_alias_t;
typedef struct alias_pair {
char *pair_alias;
char *pair_curr;
} alias_pair_t;
extern boolean_t ddi_aliases_present;
typedef struct ddi_alias {
int dali_num_pairs;
} ddi_alias_t;
extern ddi_alias_t ddi_aliases;
char *ddi_curr_redirect(char *curr);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SUNDDI_H */