10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_DDI_INTR_IMPL_H 280Sstevel@tonic-gate #define _SYS_DDI_INTR_IMPL_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate /* 330Sstevel@tonic-gate * Sun DDI interrupt implementation specific definitions 340Sstevel@tonic-gate */ 350Sstevel@tonic-gate 360Sstevel@tonic-gate #ifdef __cplusplus 370Sstevel@tonic-gate extern "C" { 380Sstevel@tonic-gate #endif 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef _KERNEL 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * Typedef for interrupt ops 440Sstevel@tonic-gate */ 450Sstevel@tonic-gate typedef enum { 460Sstevel@tonic-gate DDI_INTROP_SUPPORTED_TYPES = 1, /* 1 get supported interrupts types */ 470Sstevel@tonic-gate DDI_INTROP_NINTRS, /* 2 get num of interrupts supported */ 480Sstevel@tonic-gate DDI_INTROP_ALLOC, /* 3 allocate interrupt handle */ 490Sstevel@tonic-gate DDI_INTROP_GETPRI, /* 4 get priority */ 500Sstevel@tonic-gate DDI_INTROP_SETPRI, /* 5 set priority */ 510Sstevel@tonic-gate DDI_INTROP_ADDISR, /* 6 add interrupt handler */ 520Sstevel@tonic-gate DDI_INTROP_DUPVEC, /* 7 duplicate interrupt handler */ 530Sstevel@tonic-gate DDI_INTROP_ENABLE, /* 8 enable interrupt */ 540Sstevel@tonic-gate DDI_INTROP_BLOCKENABLE, /* 9 block enable interrupts */ 550Sstevel@tonic-gate DDI_INTROP_BLOCKDISABLE, /* 10 block disable interrupts */ 560Sstevel@tonic-gate DDI_INTROP_DISABLE, /* 11 disable interrupt */ 570Sstevel@tonic-gate DDI_INTROP_REMISR, /* 12 remove interrupt handler */ 580Sstevel@tonic-gate DDI_INTROP_FREE, /* 13 free interrupt handle */ 590Sstevel@tonic-gate DDI_INTROP_GETCAP, /* 14 get capacity */ 600Sstevel@tonic-gate DDI_INTROP_SETCAP, /* 15 set capacity */ 610Sstevel@tonic-gate DDI_INTROP_SETMASK, /* 16 set mask */ 620Sstevel@tonic-gate DDI_INTROP_CLRMASK, /* 17 clear mask */ 630Sstevel@tonic-gate DDI_INTROP_GETPENDING, /* 18 get pending interrupt */ 640Sstevel@tonic-gate DDI_INTROP_NAVAIL /* 19 get num of available interrupts */ 650Sstevel@tonic-gate } ddi_intr_op_t; 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* Version number used in the handles */ 680Sstevel@tonic-gate #define DDI_INTR_VERSION_1 1 690Sstevel@tonic-gate #define DDI_INTR_VERSION DDI_INTR_VERSION_1 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* 720Sstevel@tonic-gate * One such data structure is allocated per ddi_intr_handle_t 730Sstevel@tonic-gate * This is the incore copy of the regular interrupt info. 740Sstevel@tonic-gate */ 750Sstevel@tonic-gate typedef struct ddi_intr_handle_impl { 760Sstevel@tonic-gate dev_info_t *ih_dip; /* dip associated with handle */ 770Sstevel@tonic-gate uint16_t ih_type; /* interrupt type being used */ 780Sstevel@tonic-gate ushort_t ih_inum; /* interrupt number */ 79693Sgovinda uint32_t ih_vector; /* vector number */ 800Sstevel@tonic-gate uint16_t ih_ver; /* Version */ 810Sstevel@tonic-gate uint_t ih_state; /* interrupt handle state */ 820Sstevel@tonic-gate uint_t ih_cap; /* interrupt capabilities */ 830Sstevel@tonic-gate uint_t ih_pri; /* priority - bus dependent */ 840Sstevel@tonic-gate krwlock_t ih_rwlock; /* read/write lock per handle */ 850Sstevel@tonic-gate 860Sstevel@tonic-gate uint_t (*ih_cb_func)(caddr_t, caddr_t); 870Sstevel@tonic-gate void *ih_cb_arg1; 880Sstevel@tonic-gate void *ih_cb_arg2; 890Sstevel@tonic-gate 900Sstevel@tonic-gate /* 910Sstevel@tonic-gate * The next set of members are for 'scratch' purpose only. 920Sstevel@tonic-gate * The DDI interrupt framework uses them internally and their 930Sstevel@tonic-gate * interpretation is left to the framework. For now, 940Sstevel@tonic-gate * scratch1 - used to send NINTRs information 950Sstevel@tonic-gate * to various nexus drivers. 960Sstevel@tonic-gate * scratch2 - used to send 'behavior' flag 970Sstevel@tonic-gate * information to the nexus drivers 980Sstevel@tonic-gate * from ddi_intr_alloc() 99916Sschwartz * private - On X86 it usually carries a pointer to 100916Sschwartz * ihdl_plat_t. Not used on SPARC platforms. 1010Sstevel@tonic-gate */ 1020Sstevel@tonic-gate void *ih_private; /* Platform specific data */ 1030Sstevel@tonic-gate uint_t ih_scratch1; /* Scratch1: #interrupts */ 1040Sstevel@tonic-gate uint_t ih_scratch2; /* Scratch2: flag */ 1050Sstevel@tonic-gate } ddi_intr_handle_impl_t; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate /* values for ih_state (strictly for interrupt handle) */ 1080Sstevel@tonic-gate #define DDI_IHDL_STATE_ALLOC 0x01 /* Allocated. ddi_intr_alloc() called */ 1090Sstevel@tonic-gate #define DDI_IHDL_STATE_ADDED 0x02 /* Added interrupt handler */ 1100Sstevel@tonic-gate /* ddi_intr_add_handler() called */ 1110Sstevel@tonic-gate #define DDI_IHDL_STATE_ENABLE 0x04 /* Enabled. ddi_intr_enable() called */ 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate #define DDI_INTR_IS_MSI_OR_MSIX(type) \ 1140Sstevel@tonic-gate ((type) == DDI_INTR_TYPE_MSI || (type) == DDI_INTR_TYPE_MSIX) 1150Sstevel@tonic-gate 116693Sgovinda #define DDI_INTR_SUP_TYPES DDI_INTR_TYPE_FIXED|DDI_INTR_TYPE_MSI|\ 117693Sgovinda DDI_INTR_TYPE_MSIX 118693Sgovinda 119*999Slq150181 struct av_softinfo; 120*999Slq150181 1210Sstevel@tonic-gate /* 1220Sstevel@tonic-gate * One such data structure is allocated per ddi_soft_intr_handle 1230Sstevel@tonic-gate * This is the incore copy of the softint info. 1240Sstevel@tonic-gate */ 1250Sstevel@tonic-gate typedef struct ddi_softint_hdl_impl { 1260Sstevel@tonic-gate dev_info_t *ih_dip; /* dip associated with handle */ 1270Sstevel@tonic-gate uint_t ih_pri; /* priority - bus dependent */ 1280Sstevel@tonic-gate krwlock_t ih_rwlock; /* read/write lock per handle */ 129*999Slq150181 struct av_softinfo *ih_pending; /* whether softint is pending */ 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate uint_t (*ih_cb_func)(caddr_t, caddr_t); 1320Sstevel@tonic-gate /* cb function for soft ints */ 1330Sstevel@tonic-gate void *ih_cb_arg1; /* arg1 of callback function */ 1340Sstevel@tonic-gate void *ih_cb_arg2; /* arg2 passed to "trigger" */ 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate /* 1370Sstevel@tonic-gate * The next member is for 'scratch' purpose only. 1380Sstevel@tonic-gate * The DDI interrupt framework uses it internally and its 1390Sstevel@tonic-gate * interpretation is left to the framework. 1400Sstevel@tonic-gate * private - used by the DDI framework to pass back 1410Sstevel@tonic-gate * and forth 'softid' information on SPARC 1420Sstevel@tonic-gate * side only. Not used on X86 platform. 1430Sstevel@tonic-gate */ 1440Sstevel@tonic-gate void *ih_private; /* Platform specific data */ 1450Sstevel@tonic-gate } ddi_softint_hdl_impl_t; 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* Softint internal implementation defines */ 1480Sstevel@tonic-gate #define DDI_SOFT_INTR_PRI_M 4 1490Sstevel@tonic-gate #define DDI_SOFT_INTR_PRI_H 6 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * One such data structure is allocated for MSI-X enabled 1530Sstevel@tonic-gate * device. If no MSI-X is enabled then it is NULL 1540Sstevel@tonic-gate */ 1550Sstevel@tonic-gate typedef struct ddi_intr_msix { 1560Sstevel@tonic-gate uint_t msix_intrs_in_use; /* MSI-X intrs in use */ 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate /* MSI-X Table related information */ 1590Sstevel@tonic-gate ddi_acc_handle_t msix_tbl_hdl; /* MSI-X table handle */ 160965Sgovinda uint32_t *msix_tbl_addr; /* MSI-X table addr */ 161965Sgovinda uint32_t msix_tbl_offset; /* MSI-X table offset */ 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* MSI-X PBA Table related information */ 1640Sstevel@tonic-gate ddi_acc_handle_t msix_pba_hdl; /* MSI-X PBA handle */ 165965Sgovinda uint32_t *msix_pba_addr; /* MSI-X PBA addr */ 166965Sgovinda uint32_t msix_pba_offset; /* MSI-X PBA offset */ 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate ddi_device_acc_attr_t msix_dev_attr; /* MSI-X device attr */ 1690Sstevel@tonic-gate } ddi_intr_msix_t; 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate /* 1730Sstevel@tonic-gate * One such data structure is allocated for each dip. 1740Sstevel@tonic-gate * It has interrupt related information that can be 1750Sstevel@tonic-gate * stored/retrieved for convenience. 1760Sstevel@tonic-gate */ 1770Sstevel@tonic-gate typedef struct devinfo_intr { 1780Sstevel@tonic-gate /* These three fields show what the device is capable of */ 1790Sstevel@tonic-gate uint_t devi_intr_sup_types; /* Intrs supported by device */ 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate ddi_intr_msix_t *devi_msix_p; /* MSI-X info, if supported */ 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* Next three fields show current status for the device */ 1840Sstevel@tonic-gate uint_t devi_intr_curr_type; /* Interrupt type being used */ 1850Sstevel@tonic-gate uint_t devi_intr_sup_nintrs; /* #intr supported */ 1860Sstevel@tonic-gate uint_t devi_intr_curr_nintrs; /* #intr currently being used */ 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate ddi_intr_handle_t **devi_intr_handle_p; /* Hdl for legacy intr APIs */ 1890Sstevel@tonic-gate } devinfo_intr_t; 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate #define NEXUS_HAS_INTR_OP(dip) \ 1920Sstevel@tonic-gate ((DEVI(dip)->devi_ops->devo_bus_ops) && \ 1930Sstevel@tonic-gate (DEVI(dip)->devi_ops->devo_bus_ops->busops_rev >= BUSO_REV_9) && \ 1940Sstevel@tonic-gate (DEVI(dip)->devi_ops->devo_bus_ops->bus_intr_op)) 1950Sstevel@tonic-gate 1960Sstevel@tonic-gate int i_ddi_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t op, 1970Sstevel@tonic-gate ddi_intr_handle_impl_t *hdlp, void *result); 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate int i_ddi_add_softint(ddi_softint_hdl_impl_t *); 2000Sstevel@tonic-gate void i_ddi_remove_softint(ddi_softint_hdl_impl_t *); 201278Sgovinda int i_ddi_trigger_softint(ddi_softint_hdl_impl_t *, void *); 2020Sstevel@tonic-gate int i_ddi_set_softint_pri(ddi_softint_hdl_impl_t *, uint_t); 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate void i_ddi_intr_devi_init(dev_info_t *dip); 2050Sstevel@tonic-gate void i_ddi_intr_devi_fini(dev_info_t *dip); 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate uint_t i_ddi_intr_get_supported_types(dev_info_t *dip); 2080Sstevel@tonic-gate void i_ddi_intr_set_supported_types(dev_info_t *dip, int sup_type); 2090Sstevel@tonic-gate uint_t i_ddi_intr_get_current_type(dev_info_t *dip); 2100Sstevel@tonic-gate void i_ddi_intr_set_current_type(dev_info_t *dip, int intr_type); 2110Sstevel@tonic-gate uint_t i_ddi_intr_get_supported_nintrs(dev_info_t *dip, int intr_type); 2120Sstevel@tonic-gate void i_ddi_intr_set_supported_nintrs(dev_info_t *dip, int nintrs); 2130Sstevel@tonic-gate uint_t i_ddi_intr_get_current_nintrs(dev_info_t *dip); 2140Sstevel@tonic-gate void i_ddi_intr_set_current_nintrs(dev_info_t *dip, int nintrs); 2150Sstevel@tonic-gate 216693Sgovinda ddi_intr_handle_t *i_ddi_get_intr_handle(dev_info_t *dip, int inum); 2170Sstevel@tonic-gate void i_ddi_set_intr_handle(dev_info_t *dip, int inum, 2180Sstevel@tonic-gate ddi_intr_handle_t *hdlp); 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate ddi_intr_msix_t *i_ddi_get_msix(dev_info_t *dip); 2210Sstevel@tonic-gate void i_ddi_set_msix(dev_info_t *dip, ddi_intr_msix_t *msix_p); 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate int32_t i_ddi_get_intr_weight(dev_info_t *); 2240Sstevel@tonic-gate int32_t i_ddi_set_intr_weight(dev_info_t *, int32_t); 2250Sstevel@tonic-gate 226916Sschwartz void i_ddi_alloc_intr_phdl(ddi_intr_handle_impl_t *); 227916Sschwartz void i_ddi_free_intr_phdl(ddi_intr_handle_impl_t *); 228916Sschwartz 2290Sstevel@tonic-gate #define DDI_INTR_ASSIGN_HDLR_N_ARGS(hdlp, func, arg1, arg2) \ 2300Sstevel@tonic-gate hdlp->ih_cb_func = func; \ 2310Sstevel@tonic-gate hdlp->ih_cb_arg1 = arg1; \ 2320Sstevel@tonic-gate hdlp->ih_cb_arg2 = arg2; 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate #else /* _KERNEL */ 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate typedef struct devinfo_intr devinfo_intr_t; 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate #endif /* _KERNEL */ 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate /* 2410Sstevel@tonic-gate * Used only by old DDI interrupt interfaces. 2420Sstevel@tonic-gate */ 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate /* 2450Sstevel@tonic-gate * This structure represents one interrupt possible from the given 2460Sstevel@tonic-gate * device. It is used in an array for devices with multiple interrupts. 2470Sstevel@tonic-gate */ 2480Sstevel@tonic-gate struct intrspec { 2490Sstevel@tonic-gate uint_t intrspec_pri; /* interrupt priority */ 2500Sstevel@tonic-gate uint_t intrspec_vec; /* vector # (0 if none) */ 2510Sstevel@tonic-gate uint_t (*intrspec_func)(); /* function to call for interrupt, */ 2520Sstevel@tonic-gate /* If (uint_t (*)()) 0, none. */ 2530Sstevel@tonic-gate /* If (uint_t (*)()) 1, then */ 2540Sstevel@tonic-gate }; 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate #ifdef _KERNEL 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate /* 2590Sstevel@tonic-gate * NOTE: 2600Sstevel@tonic-gate * The following 4 busops entry points are obsoleted with version 2610Sstevel@tonic-gate * 9 or greater. Use i_ddi_intr_op interface in place of these 2620Sstevel@tonic-gate * obsolete interfaces. 2630Sstevel@tonic-gate * 2640Sstevel@tonic-gate * Remove these busops entry points and all related data structures 2650Sstevel@tonic-gate * in future minor/major solaris release. 2660Sstevel@tonic-gate */ 2670Sstevel@tonic-gate typedef enum {DDI_INTR_CTLOPS_NONE} ddi_intr_ctlop_t; 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate /* The following are the obsolete interfaces */ 2700Sstevel@tonic-gate ddi_intrspec_t i_ddi_get_intrspec(dev_info_t *dip, dev_info_t *rdip, 2710Sstevel@tonic-gate uint_t inumber); 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate int i_ddi_add_intrspec(dev_info_t *dip, dev_info_t *rdip, 2740Sstevel@tonic-gate ddi_intrspec_t intrspec, ddi_iblock_cookie_t *iblock_cookiep, 2750Sstevel@tonic-gate ddi_idevice_cookie_t *idevice_cookiep, 2760Sstevel@tonic-gate uint_t (*int_handler)(caddr_t int_handler_arg), 2770Sstevel@tonic-gate caddr_t int_handler_arg, int kind); 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate void i_ddi_remove_intrspec(dev_info_t *dip, dev_info_t *rdip, 2800Sstevel@tonic-gate ddi_intrspec_t intrspec, ddi_iblock_cookie_t iblock_cookie); 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate int i_ddi_intr_ctlops(dev_info_t *dip, dev_info_t *rdip, 2830Sstevel@tonic-gate ddi_intr_ctlop_t op, void *arg, void *val); 2840Sstevel@tonic-gate 2850Sstevel@tonic-gate #endif /* _KERNEL */ 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate #ifdef __cplusplus 2880Sstevel@tonic-gate } 2890Sstevel@tonic-gate #endif 2900Sstevel@tonic-gate 2910Sstevel@tonic-gate #endif /* _SYS_DDI_INTR_IMPL_H */ 292