/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
#ifndef _SYS_DEVOPS_H
#define _SYS_DEVOPS_H
#include <sys/dditypes.h>
#include <sys/ddidmareq.h>
#include <sys/ddimapreq.h>
#include <sys/ddipropdefs.h>
#include <sys/ddidevmap.h>
#include <sys/nexusdefs.h>
#include <sys/ddi_intr.h>
#include <sys/ddi_hp_impl.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* cb_ops: Leaf device drivers or bus nexus drivers supporting
*
* This is an OR of cdevsw and bdevsw fields for drivers that
* support both character and block entry points.
*
*
*
* b XXdump DDI(Sun)
* c XXdevmap DDI(Sun)
* c XXmmap DKI(Obsolete)
* c XXsegmap DKI
* c XXprop_op DDI(Sun)
* c XXaread DDI(Sun)
* c XXawrite DDI(Sun)
*/
struct cb_ops {
/*
* The cb_flag fields are here to tell the system a
* bit about the device. The bit definitions are
*/
};
/*
* bus_ops: bus nexus drivers only.
*
* These functions are used to implement the Sun DDI functions
* described elsewhere.
*
* Only nexus drivers support these entry points.
*
* The following bus nexus functions are provided in the bus nexus
* driver operations structure. Note that all functions take both
* their dip and the requesters dip except for the child functions since
* they will be called from outside the ddi.
*
* bus_get_intrspec - obsolete, not called
* bus_add_intrspec - obsolete, not called
* bus_remove_intrspec - obsolete, not called
* bus_map_fault - bus fault handler
* bus_dma_map - obsolete, not called
* bus_dma_allochdl - allocate a DMA handle
* bus_dma_freehdl - free a DMA handle
* bus_dma_bindhdl - bind a DMA handle to physical mapping
* bus_dma_unbindhdl - unbind a DMA handle to physical mapping
* bus_dma_flush - flush DMA caches
* bus_dma_win - access DMA windows
* bus_dma_ctl - control dma mapping (legacy use only)
* bus_ctl - generic control operations
* bus_prop_op - request for property
* bus_get_eventcookie - get an event cookie
* bus_add_eventcall - event call management
* bus_remove_eventcall - event call management
* bus_post_event - post an event
* bus_config - child node configuration
* bus_unconfig - child node unconfiguration
* bus_fm_init - FMA support
* bus_fm_fini - FMA support
* bus_fm_access_enter - FMA support
* bus_fm_access_exit - FMA support
* bus_power - power management
* bus_intr_op - control interrupt mappings
* bus_hp_op - hotplug support
*/
struct bus_ops {
/*
* NOTE: the following 3 busops entrypoints are obsoleted with
* version 9 or greater. Use bus_intr_op interface in place of
* these obsolete interfaces.
*/
struct ddi_dma_req *dmareq,
ddi_dma_cookie_t *, uint_t *);
int *length);
/*
* NOTE: the following 4 busops entrypoints are only available
* with version 3 or greater. Due to interface modifications, these
* entrypoints can only be used with version 6 or greater.
*/
void *bus_impldata), void *arg,
/*
* NOTE: the following bus_intr_ctl entrypoint is obsoleted with
* version 9 or greater. Use bus_intr_op interface in place of
* this obsolete interface.
*/
/*
* NOTE: the following busop entrypoints are available with version
* 5 or greater.
*/
dev_info_t **childp);
/*
* NOTE: the following busop entrypoints are available with version
* 6 or greater.
*/
/*
* NOTE: the following busop entrypoint is available with version
* 7 or greater.
*/
/*
* NOTE: the following busop entrypoint is available with version
* 9 or greater.
*/
void *result);
/*
* NOTE: the following busop entrypoint is available with version
* 10 or greater.
*/
};
/*
* REV 1 bus ops structure
*/
struct bus_ops_rev1 {
struct ddi_dma_req *dmareq,
int *length);
};
/*
* dev_ops: Contains driver common fields and pointers
*
* Drivers should set devo_rev to DEVO_REV at compile time.
* All drivers should support these entry points.
*
* the following device functions are provided in the device operations
* structure.
*
* devo_getinfo - Device handle conversion
* devo_identify - Obsolete, set to nulldev
* devo_probe - Probe for device's existence
* devo_attach - Attach driver to dev_info
* devo_reset - Reset device
* devo_quiesce - Quiesce device
*/
/*
* Return from driver's devo_probe function:
*/
/*
* Typedefs for the info, attach, detach and reset routines.
* These are mostly placeholders for now.
*
* NOTE: DDI_INFO_DEVT2DEVINFO is deprecated
*/
typedef enum {
typedef enum {
DDI_ATTACH = 0,
typedef enum {
DDI_DETACH = 0,
typedef enum {
DDI_RESET_FORCE = 0
struct dev_ops {
int level);
};
/*
* Create a dev_ops suitable for a streams driver:
*
* XXX: Note: Since this is a macro, it is NOT supported as
* XXX: part of the Sun DDI. It is not a documented Sun DDI interface.
*
* STR_OPS(name, identify, probe, attach, detach, reset,
* info, flag, stream_tab);
*
* XXname is the name of the dev_ops structure.
* XXidentify must be set to nulldev
* XXprobe is the name of the probe routine, or nulldev
* XXattach is the name of the attach routine
* XXdetach is the name of the detach routine, or nodev
* XXreset is the name of the reset routine, or nodev
* XXinfo is the name of the info routine
* XXflag is driver flag (cb_flag) in cb_ops,
* XXstream_tab is the obvious.
* XXquiesce is the name of the quiesce routine. It must be implemented
* for fast reboot to succeed.
* cb_##XXname is the name of the internally defined cb_ops struct.
*
* uses cb_XXname as name of static cb_ops structure.
*/
/*
* This file is included by genassym.c now and I couldn't get it to take the
* next line if it was broken into two lines joined by a '\'. So, don't try
* to reformat it to satisfy Cstyle because genassym.c won't compile.
*/
/* CSTYLED */
#define DDI_DEFINE_STREAM_OPS(XXname, XXidentify, XXprobe, XXattach, XXdetach, XXreset, XXgetinfo, XXflag, XXstream_tab, XXquiesce) \
nulldev, /* cb_open */ \
nulldev, /* cb_close */ \
nodev, /* cb_strategy */ \
nodev, /* cb_print */ \
nodev, /* cb_dump */ \
nodev, /* cb_read */ \
nodev, /* cb_write */ \
nodev, /* cb_ioctl */ \
nodev, /* cb_devmap */ \
nodev, /* cb_mmap */ \
nodev, /* cb_segmap */ \
nochpoll, /* cb_chpoll */ \
ddi_prop_op, /* cb_prop_op */ \
(XXstream_tab), /* cb_stream */ \
(int)(XXflag), /* cb_flag */ \
CB_REV, /* cb_rev */ \
nodev, /* cb_aread */ \
nodev, /* cb_awrite */ \
}; \
\
DEVO_REV, /* devo_rev */ \
0, /* devo_refcnt */ \
(XXgetinfo), /* devo_getinfo */ \
(XXidentify), /* devo_identify */ \
(XXprobe), /* devo_probe */ \
(XXattach), /* devo_attach */ \
(XXdetach), /* devo_detach */ \
(XXreset), /* devo_reset */ \
NULL, /* devo_power */ \
(XXquiesce) /* devo_quiesce */ \
}
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_DEVOPS_H */