sunndi.h revision f41150baf74bdaf964ddfe42d865d3c2380b3623
/*
* 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
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SUNNDI_H
#define _SYS_SUNNDI_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Sun Specific NDI definitions
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* Property functions: See also, ddipropdefs.h.
* In general, the underlying driver MUST be held
* to call it's property functions.
*/
/*
* Used to create boolean properties
*/
int
/*
* Used to create, modify, and lookup integer properties
*/
int
int
int
int
/*
* Used to create, modify, and lookup string properties
*/
int
char *data);
int
/*
* Used to create, modify, and lookup byte properties
*/
int
/*
* Used to remove properties
*/
int
void
/*
* Nexus Driver Functions
*/
/*
* Allocate and initialize a new dev_info structure.
* This routine will often be called at interrupt time by a nexus in
* response to a hotplug event, therefore memory allocations are
* not allowed to sleep.
*/
int
dev_info_t **ret_dip);
void
dev_info_t **ret_dip);
/*
* Remove an initialized (but not yet attached) dev_info
* node from it's parent.
*/
int
/* devinfo locking: use DEVI_BUSY_OWNED in ASSERTs to verify */
/* devinfo ref counting */
/* driver ref counting */
/*
* Change the node name
*/
int
/*
* Place the devinfo in the DS_BOUND state,
* binding a driver to the device
*
* Flags:
* all flags are ignored.
*/
int
/*
* Asynchronous version of ndi_devi_bind_driver, callable from
* interrupt context. The dip must be a persistent node.
*/
int
/*
* Return devctl state of the child addressed by "name@addr".
* For use by a driver's DEVCTL_DEVICE_GETSTATE handler.
*/
int
/*
* Transition the child addressed by "name@addr" to the online state.
* For use by a driver's DEVCTL_DEVICE_ONLINE handler.
*/
int
/*
* Transition the child addressed by "name@addr" to the offline state.
* For use by a driver's DEVCTL_DEVICE_OFFLINE handler.
*/
int
/*
* Remove the child addressed by name@addr.
* For use by a driver's DEVCTL_DEVICE_REMOVE handler.
*/
int
/*
* Bus get state
* For use by a driver's DEVCTL_BUS_GETSTATE handler.
*/
int
/*
* Place the devinfo in the ONLINE state
*/
int
/*
* Generic devctl ioctl handler
*/
int
/*
* Asynchronous version of ndi_devi_online, callable from interrupt
* context. The dip must be a persistent node.
*/
int
/*
* Configure children of a nexus node.
*
* Flags:
* NDI_ONLINE_ATTACH - Attach driver to devinfo node when placing
* the device Online.
* NDI_CONFIG - Recursively configure children if child is nexus node
*/
int
int
int
/*
* Unconfigure children of a nexus node.
*
* Flags:
* NDI_DEVI_REMOVE - Remove child devinfo nodes
*
* NDI_UNCONFIG - Put child devinfo nodes to uninitialized state,
* release resources held by child nodes.
*/
int
int
int
int flags);
int
void
void *data);
void *
/*
* Take a device node "Offline".
*
* Offline means to detach the device instance from the bound
* driver and setting the devinfo state to prevent deferred attach
* from re-attaching the device instance.
*
* Flags:
* NDI_DEVI_REMOVE - Remove the node from the devinfo tree after
* first taking it Offline.
*/
/* ndi interface flag values */
#define NDI_SLEEP 0x000000
#define NDI_NOSLEEP 0x100000
int
/*
* Find the child dev_info node of parent nexus 'p' whose name
* matches "cname"@"caddr". Use ndi_devi_findchild() instead.
*/
/*
* Find the child dev_info node of parent nexus 'p' whose name
* matches device name "name"@"addr".
*/
/*
* generate debug msg via NDI_DEVI_DEBUG flag
*/
/*
* Copy in the devctl IOCTL data structure and the strings referenced
* by the structure.
*
* Convenience functions for use by nexus drivers as part of the
* implementation of devctl IOCTL handling.
*/
int
void
char *
char *
char *
nvlist_t *
char *
int
int
int
int
dev_info_t **rdip);
int
int
/*
* Post an event notification up the device tree hierarchy to the
* parent nexus, until claimed by a bus nexus driver or the top
* of the dev_info tree is reached.
*/
int
void *impl_data);
/*
* Called by the NDI Event Framework to deliver a registration request to the
* appropriate bus nexus driver.
*/
int
/*
* Called by the NDI Event Framework to deliver an unregister request to the
* appropriate bus nexus driver.
*/
int
/*
* implementation of the (*bus_get_eventcookie)() interface up the device tree
* hierarchy, until claimed by a bus nexus driver or the top of the dev_info
* tree is reached. The NDI Event Framework will skip nexus drivers which are
* not configured to handle NDI events.
*/
int
/*
* ndi event callback support routines:
*
* these functions require an opaque ndi event handle
*/
typedef struct ndi_event_hdl *ndi_event_hdl_t;
/*
* structure for maintaining each registered callback
*/
typedef struct ndi_event_callbacks {
struct ndi_event_callbacks *ndi_evtcb_next;
struct ndi_event_callbacks *ndi_evtcb_prev;
char *devname; /* name of device defining this callback */
void (*ndi_evtcb_callback)();
void *ndi_evtcb_arg;
/*
* a nexus driver defines events that it can support using the
* following structure
*/
typedef struct ndi_event_definition {
int ndi_event_tag;
char *ndi_event_name;
typedef struct ndi_event_cookie {
#define NDI_EVENT_ATTRIBUTES(cookie) \
#define NDI_EVENT_PLEVEL(cookie) \
/* ndi_event_attributes */
typedef struct ndi_event_set {
#define NDI_EVENTS_REV0 0
#define NDI_EVENTS_REV1 1
/*
* allocate an ndi event handle
*/
int
/*
* free the ndi event handle
*/
int
/*
*/
int
int
/*
* get an event cookie
*/
int
char *eventname,
/*
* add an event callback info to the ndi event handle
*/
int
void (*event_callback)
(dev_info_t *,
void *arg,
void *impldata),
void *arg,
/*
* remove an event callback registration from the ndi event handle
*/
int
/*
* perform callbacks for a specified cookie
*/
int
/*
* do callback for just one child_dip, regardless of attributes
*/
/*
* ndi_event_tag_to_cookie: utility function to find an event cookie
* given an event tag
*/
/*
* ndi_event_cookie_to_tag: utility function to find an event tag
* given an event_cookie
*/
int
/*
* ndi_event_cookie_to_name: utility function to find an event
* name given an event_cookie
*/
char *
/*
* ndi_event_tag_to_name: utility function to find an event
* name given an event_tag
*/
char *
ndi_devi_config_vhci(char *, int);
#ifdef DEBUG
/*
* ndi_event_dump_hdl: debug functionality used to display event handle
*/
void
#endif
/*
* Default busop bus_config helper functions
*/
int
int
void *arg);
/*
* Bus Resource allocation structures and function prototypes exported
* by busra module
*/
/* structure for specifying a request */
typedef struct ndi_ra_request {
/* see bit definitions below */
/* the allocated resource to be */
/* restricted to */
/* from ra_boundbase, for the */
/* allocated resource to be */
/* restricted to. */
/* allocated base address */
/* ra_flags bit definitions */
/* allocated resource address */
/* according to the ra_len */
/* value (alignment mask will */
/* be (ra_len - 1)). Value of */
/* ra_len has to be power of 2. */
/* If this flag is set, value of */
/* ra_align_mask will be ignored. */
/* should be restricted to the */
/* area specified by ra_boundbase */
/* and ra_boundlen */
/* address (ra_addr value) is */
/* requested. */
/* (ra_len) chunk is not available */
/* then allocate as big chunk as */
/* possible which is less than or */
/* equal to ra_len size. */
/* return values specific to bus resource allocator */
#define NDI_RA_PARTIAL_REQ -7
/* Predefined types for generic type of resources */
#define NDI_RA_TYPE_MEM "memory"
#define NDI_RA_TYPE_IO "io"
#define NDI_RA_TYPE_PCI_BUSNUM "pci_bus_number"
#define NDI_RA_TYPE_PCI_PREFETCH_MEM "pci_prefetchable_memory"
#define NDI_RA_TYPE_INTR "interrupt"
/* flag bit definition */
/*
* Prototype definitions for functions exported
*/
int
int
int
int
/*
* ndi_dev_is_prom_node: Return non-zero if the node is a prom node
*/
int ndi_dev_is_prom_node(dev_info_t *);
/*
* ndi_dev_is_pseudo_node: Return non-zero if the node is a pseudo node.
* NB: all non-prom nodes are pseudo nodes.
* c.f. ndi_dev_is_persistent_node
*/
int ndi_dev_is_pseudo_node(dev_info_t *);
/*
* ndi_dev_is_persistent_node: Return non-zero if the node has the
* property of persistence.
*/
int ndi_dev_is_persistent_node(dev_info_t *);
/*
* Event posted when a fault is reported
*/
#define DDI_DEVI_FAULT_EVENT "DDI:DEVI_FAULT"
struct ddi_fault_event_data {
const char *f_message;
};
/*
*/
/* Driver.conf property merging */
void ndi_merge_wildcard_node(dev_info_t *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SUNNDI_H */