17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5144dfaa9Scth * Common Development and Distribution License (the "License"). 6144dfaa9Scth * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 2294c894bbSVikram Hegde * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. 23cd21e7c5SGarrett D'Amore * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. 241f0c5e61SRobert Mustacchi * Copyright 2016 Joyent, Inc. 2548bbca81SDaniel Hoffman * Copyright (c) 2016 by Delphix. All rights reserved. 26*b8f43eb6SHans Rosenfeld * Copyright 2022 Tintri by DDN, Inc. All rights reserved. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _SYS_DDI_IMPLDEFS_H 307c478bd9Sstevel@tonic-gate #define _SYS_DDI_IMPLDEFS_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate #include <sys/param.h> 347c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 357c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h> 367c478bd9Sstevel@tonic-gate #include <sys/devops.h> 377c478bd9Sstevel@tonic-gate #include <sys/autoconf.h> 387c478bd9Sstevel@tonic-gate #include <sys/mutex.h> 397c478bd9Sstevel@tonic-gate #include <vm/page.h> 407c478bd9Sstevel@tonic-gate #include <sys/dacf_impl.h> 417c478bd9Sstevel@tonic-gate #include <sys/ndifm.h> 427c478bd9Sstevel@tonic-gate #include <sys/epm.h> 437c478bd9Sstevel@tonic-gate #include <sys/ddidmareq.h> 447c478bd9Sstevel@tonic-gate #include <sys/ddi_intr.h> 4526947304SEvan Yan #include <sys/ddi_hp.h> 4626947304SEvan Yan #include <sys/ddi_hp_impl.h> 477c478bd9Sstevel@tonic-gate #include <sys/ddi_isa.h> 484c06356bSdh142964 #include <sys/id_space.h> 494c06356bSdh142964 #include <sys/modhash.h> 504c06356bSdh142964 #include <sys/bitset.h> 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate #ifdef __cplusplus 537c478bd9Sstevel@tonic-gate extern "C" { 547c478bd9Sstevel@tonic-gate #endif 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* 577c478bd9Sstevel@tonic-gate * The device id implementation has been switched to be based on properties. 587c478bd9Sstevel@tonic-gate * For compatibility with di_devid libdevinfo interface the following 597c478bd9Sstevel@tonic-gate * must be defined: 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate #define DEVID_COMPATIBILITY ((ddi_devid_t)-1) 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* 647c478bd9Sstevel@tonic-gate * Definitions for node class. 657c478bd9Sstevel@tonic-gate * DDI_NC_PROM: a node with a nodeid that may be used in a promif call. 667c478bd9Sstevel@tonic-gate * DDI_NC_PSEUDO: a software created node with a software assigned nodeid. 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate typedef enum { 697c478bd9Sstevel@tonic-gate DDI_NC_PROM = 0, 707c478bd9Sstevel@tonic-gate DDI_NC_PSEUDO 717c478bd9Sstevel@tonic-gate } ddi_node_class_t; 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate /* 745febcb4aSScott Carter, SD IOSW * Definitions for generic callback mechanism. 755febcb4aSScott Carter, SD IOSW */ 765febcb4aSScott Carter, SD IOSW typedef enum { 7726947304SEvan Yan DDI_CB_INTR_ADD, /* More available interrupts */ 7826947304SEvan Yan DDI_CB_INTR_REMOVE /* Fewer available interrupts */ 795febcb4aSScott Carter, SD IOSW } ddi_cb_action_t; 805febcb4aSScott Carter, SD IOSW 815febcb4aSScott Carter, SD IOSW typedef enum { 8226947304SEvan Yan DDI_CB_FLAG_INTR = 0x1 /* Driver is IRM aware */ 835febcb4aSScott Carter, SD IOSW } ddi_cb_flags_t; 845febcb4aSScott Carter, SD IOSW 855febcb4aSScott Carter, SD IOSW #define DDI_CB_FLAG_VALID(f) ((f) & DDI_CB_FLAG_INTR) 865febcb4aSScott Carter, SD IOSW 875febcb4aSScott Carter, SD IOSW typedef int (*ddi_cb_func_t)(dev_info_t *dip, ddi_cb_action_t action, 885febcb4aSScott Carter, SD IOSW void *cbarg, void *arg1, void *arg2); 895febcb4aSScott Carter, SD IOSW 905febcb4aSScott Carter, SD IOSW typedef struct ddi_cb { 915febcb4aSScott Carter, SD IOSW uint64_t cb_flags; 925febcb4aSScott Carter, SD IOSW dev_info_t *cb_dip; 935febcb4aSScott Carter, SD IOSW ddi_cb_func_t cb_func; 945febcb4aSScott Carter, SD IOSW void *cb_arg1; 955febcb4aSScott Carter, SD IOSW void *cb_arg2; 965febcb4aSScott Carter, SD IOSW } ddi_cb_t; 975febcb4aSScott Carter, SD IOSW 985febcb4aSScott Carter, SD IOSW /* 997c478bd9Sstevel@tonic-gate * dev_info: The main device information structure this is intended to be 1007c478bd9Sstevel@tonic-gate * opaque to drivers and drivers should use ddi functions to 1017c478bd9Sstevel@tonic-gate * access *all* driver accessible fields. 1027c478bd9Sstevel@tonic-gate * 1037c478bd9Sstevel@tonic-gate * devi_parent_data includes property lists (interrupts, registers, etc.) 1047c478bd9Sstevel@tonic-gate * devi_driver_data includes whatever the driver wants to place there. 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate struct devinfo_audit; 1077c478bd9Sstevel@tonic-gate 108eae2e508Skrishnae typedef struct devi_port { 109eae2e508Skrishnae union { 110eae2e508Skrishnae struct { 111eae2e508Skrishnae uint32_t type; 112eae2e508Skrishnae uint32_t pad; 113eae2e508Skrishnae } port; 114eae2e508Skrishnae uint64_t type64; 115eae2e508Skrishnae } info; 116eae2e508Skrishnae void *priv_p; 117eae2e508Skrishnae } devi_port_t; 118eae2e508Skrishnae 119eae2e508Skrishnae typedef struct devi_bus_priv { 120eae2e508Skrishnae devi_port_t port_up; 121eae2e508Skrishnae devi_port_t port_down; 122eae2e508Skrishnae } devi_bus_priv_t; 123eae2e508Skrishnae 12450200e77SFrank Van Der Linden #if defined(__x86) 12520906b23SVikram Hegde struct iommulib_unit; 12620906b23SVikram Hegde typedef struct iommulib_unit *iommulib_handle_t; 12750200e77SFrank Van Der Linden struct iommulib_nex; 12850200e77SFrank Van Der Linden typedef struct iommulib_nex *iommulib_nexhandle_t; 12950200e77SFrank Van Der Linden #endif 13050200e77SFrank Van Der Linden 131255a2d50SMatthew Jacob typedef uint8_t ndi_flavor_t; 13226947304SEvan Yan struct ddi_hp_cn_handle; 13320906b23SVikram Hegde 13494c894bbSVikram Hegde struct in_node; 13594c894bbSVikram Hegde 1367c478bd9Sstevel@tonic-gate struct dev_info { 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate struct dev_info *devi_parent; /* my parent node in tree */ 1397c478bd9Sstevel@tonic-gate struct dev_info *devi_child; /* my child list head */ 1407c478bd9Sstevel@tonic-gate struct dev_info *devi_sibling; /* next element on my level */ 1417c478bd9Sstevel@tonic-gate 142f4da9be0Scth char *devi_binding_name; /* name used to bind driver: */ 143f4da9be0Scth /* shared storage, points to */ 144f4da9be0Scth /* devi_node_name, devi_compat_names */ 145f4da9be0Scth /* or devi_rebinding_name */ 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate char *devi_addr; /* address part of name */ 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate int devi_nodeid; /* device nodeid */ 1507c478bd9Sstevel@tonic-gate int devi_instance; /* device instance number */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate struct dev_ops *devi_ops; /* driver operations */ 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate void *devi_parent_data; /* parent private data */ 1557c478bd9Sstevel@tonic-gate void *devi_driver_data; /* driver private data */ 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate ddi_prop_t *devi_drv_prop_ptr; /* head of driver prop list */ 1587c478bd9Sstevel@tonic-gate ddi_prop_t *devi_sys_prop_ptr; /* head of system prop list */ 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate struct ddi_minor_data *devi_minor; /* head of minor list */ 1617c478bd9Sstevel@tonic-gate struct dev_info *devi_next; /* Next instance of this device */ 1627c478bd9Sstevel@tonic-gate kmutex_t devi_lock; /* Protects per-devinfo data */ 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate /* logical parents for busop primitives */ 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate struct dev_info *devi_bus_map_fault; /* bus_map_fault parent */ 167cd21e7c5SGarrett D'Amore void *devi_obsolete; /* obsolete placeholder */ 1687c478bd9Sstevel@tonic-gate struct dev_info *devi_bus_dma_allochdl; /* bus_dma_newhdl parent */ 1697c478bd9Sstevel@tonic-gate struct dev_info *devi_bus_dma_freehdl; /* bus_dma_freehdl parent */ 1707c478bd9Sstevel@tonic-gate struct dev_info *devi_bus_dma_bindhdl; /* bus_dma_bindhdl parent */ 1717c478bd9Sstevel@tonic-gate struct dev_info *devi_bus_dma_unbindhdl; /* bus_dma_unbindhdl parent */ 1727c478bd9Sstevel@tonic-gate struct dev_info *devi_bus_dma_flush; /* bus_dma_flush parent */ 1737c478bd9Sstevel@tonic-gate struct dev_info *devi_bus_dma_win; /* bus_dma_win parent */ 1747c478bd9Sstevel@tonic-gate struct dev_info *devi_bus_dma_ctl; /* bus_dma_ctl parent */ 1757c478bd9Sstevel@tonic-gate struct dev_info *devi_bus_ctl; /* bus_ctl parent */ 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate ddi_prop_t *devi_hw_prop_ptr; /* head of hw prop list */ 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate char *devi_node_name; /* The 'name' of the node */ 1807c478bd9Sstevel@tonic-gate char *devi_compat_names; /* A list of driver names */ 1817c478bd9Sstevel@tonic-gate size_t devi_compat_length; /* Size of compat_names */ 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate int (*devi_bus_dma_bindfunc)(dev_info_t *, dev_info_t *, 1847c478bd9Sstevel@tonic-gate ddi_dma_handle_t, struct ddi_dma_req *, ddi_dma_cookie_t *, 1857c478bd9Sstevel@tonic-gate uint_t *); 1867c478bd9Sstevel@tonic-gate int (*devi_bus_dma_unbindfunc)(dev_info_t *, dev_info_t *, 1877c478bd9Sstevel@tonic-gate ddi_dma_handle_t); 1887c478bd9Sstevel@tonic-gate 189602ca9eaScth char *devi_devid_str; /* registered device id */ 190602ca9eaScth 1917c478bd9Sstevel@tonic-gate /* 1927c478bd9Sstevel@tonic-gate * power management entries 1937c478bd9Sstevel@tonic-gate * components exist even if the device is not currently power managed 1947c478bd9Sstevel@tonic-gate */ 1957c478bd9Sstevel@tonic-gate struct pm_info *devi_pm_info; /* 0 => dev not power managed */ 1967c478bd9Sstevel@tonic-gate uint_t devi_pm_flags; /* pm flags */ 1977c478bd9Sstevel@tonic-gate int devi_pm_num_components; /* number of components */ 1987c478bd9Sstevel@tonic-gate size_t devi_pm_comp_size; /* size of devi_components */ 1997c478bd9Sstevel@tonic-gate struct pm_component *devi_pm_components; /* array of pm components */ 2007c478bd9Sstevel@tonic-gate struct dev_info *devi_pm_ppm; /* ppm attached to this one */ 2017c478bd9Sstevel@tonic-gate void *devi_pm_ppm_private; /* for use by ppm driver */ 2027c478bd9Sstevel@tonic-gate int devi_pm_dev_thresh; /* "device" threshold */ 203f13856c4Scth uint_t devi_pm_kidsupcnt; /* # of kids powered up */ 2047c478bd9Sstevel@tonic-gate struct pm_scan *devi_pm_scan; /* pm scan info */ 2057c478bd9Sstevel@tonic-gate uint_t devi_pm_noinvolpm; /* # of descendents no-invol */ 2067c478bd9Sstevel@tonic-gate uint_t devi_pm_volpmd; /* # of voluntarily pm'ed */ 2077c478bd9Sstevel@tonic-gate kmutex_t devi_pm_lock; /* pm lock for state */ 2087c478bd9Sstevel@tonic-gate kmutex_t devi_pm_busy_lock; /* for component busy count */ 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate uint_t devi_state; /* device/bus state flags */ 2117c478bd9Sstevel@tonic-gate /* see below for definitions */ 2127c478bd9Sstevel@tonic-gate kcondvar_t devi_cv; /* cv */ 2137c478bd9Sstevel@tonic-gate int devi_ref; /* reference count */ 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate dacf_rsrvlist_t *devi_dacf_tasks; /* dacf reservation queue */ 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate ddi_node_class_t devi_node_class; /* Node class */ 2187c478bd9Sstevel@tonic-gate int devi_node_attributes; /* Node attributes: See below */ 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate char *devi_device_class; 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate /* 2237c478bd9Sstevel@tonic-gate * New mpxio kernel hooks entries 2247c478bd9Sstevel@tonic-gate */ 2257c478bd9Sstevel@tonic-gate int devi_mdi_component; /* mpxio component type */ 2267c478bd9Sstevel@tonic-gate void *devi_mdi_client; /* mpxio client information */ 2277c478bd9Sstevel@tonic-gate void *devi_mdi_xhci; /* vhci/phci info */ 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate ddi_prop_list_t *devi_global_prop_list; /* driver global properties */ 2307c478bd9Sstevel@tonic-gate major_t devi_major; /* driver major number */ 2317c478bd9Sstevel@tonic-gate ddi_node_state_t devi_node_state; /* state of node */ 2327c478bd9Sstevel@tonic-gate uint_t devi_flags; /* configuration flags */ 2337c478bd9Sstevel@tonic-gate int devi_circular; /* for recursive operations */ 2347c478bd9Sstevel@tonic-gate void *devi_busy_thread; /* thread operating on node */ 2357c478bd9Sstevel@tonic-gate void *devi_taskq; /* hotplug taskq */ 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate /* device driver statistical and audit info */ 2387c478bd9Sstevel@tonic-gate struct devinfo_audit *devi_audit; /* last state change */ 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate /* 2417c478bd9Sstevel@tonic-gate * FMA support for resource caches and error handlers 2427c478bd9Sstevel@tonic-gate */ 2437c478bd9Sstevel@tonic-gate struct i_ddi_fmhdl *devi_fmhdl; 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate uint_t devi_cpr_flags; 2467c478bd9Sstevel@tonic-gate 24726947304SEvan Yan /* Owned by DDI interrupt framework */ 2487c478bd9Sstevel@tonic-gate devinfo_intr_t *devi_intr_p; 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate void *devi_nex_pm; /* nexus PM private */ 251fe9fe9fbScth 252fe9fe9fbScth char *devi_addr_buf; /* buffer for devi_addr */ 253f4da9be0Scth 254f4da9be0Scth char *devi_rebinding_name; /* binding_name of rebind */ 255602ca9eaScth 25625e8c5aaSvikram /* For device contracts that have this dip's minor node as resource */ 25725e8c5aaSvikram kmutex_t devi_ct_lock; /* contract lock */ 25825e8c5aaSvikram kcondvar_t devi_ct_cv; /* contract cv */ 25925e8c5aaSvikram int devi_ct_count; /* # of outstanding responses */ 26025e8c5aaSvikram int devi_ct_neg; /* neg. occurred on dip */ 26125e8c5aaSvikram list_t devi_ct; 262eae2e508Skrishnae 263eae2e508Skrishnae /* owned by bus framework */ 264eae2e508Skrishnae devi_bus_priv_t devi_bus; /* bus private data */ 265b9ccdc5aScth 266b9ccdc5aScth /* Declarations of the pure dynamic properties to snapshot */ 267b9ccdc5aScth struct i_ddi_prop_dyn *devi_prop_dyn_driver; /* prop_op */ 268b9ccdc5aScth struct i_ddi_prop_dyn *devi_prop_dyn_parent; /* bus_prop_op */ 26986c1f4dcSVikram Hegde 27050200e77SFrank Van Der Linden #if defined(__x86) 2713a634bfcSVikram Hegde /* For x86 (Intel and AMD) IOMMU support */ 2723a634bfcSVikram Hegde void *devi_iommu; 27320906b23SVikram Hegde iommulib_handle_t devi_iommulib_handle; 27450200e77SFrank Van Der Linden iommulib_nexhandle_t devi_iommulib_nex_handle; 27550200e77SFrank Van Der Linden #endif 2765febcb4aSScott Carter, SD IOSW 2775febcb4aSScott Carter, SD IOSW /* Generic callback mechanism */ 2785febcb4aSScott Carter, SD IOSW ddi_cb_t *devi_cb_p; 279255a2d50SMatthew Jacob 280255a2d50SMatthew Jacob /* ndi 'flavors' */ 281255a2d50SMatthew Jacob ndi_flavor_t devi_flavor; /* flavor assigned by parent */ 282255a2d50SMatthew Jacob ndi_flavor_t devi_flavorv_n; /* number of child-flavors */ 283255a2d50SMatthew Jacob void **devi_flavorv; /* child-flavor specific data */ 28426947304SEvan Yan 28526947304SEvan Yan /* Owned by hotplug framework */ 28626947304SEvan Yan struct ddi_hp_cn_handle *devi_hp_hdlp; /* hotplug handle list */ 28794c894bbSVikram Hegde 28894c894bbSVikram Hegde struct in_node *devi_in_node; /* pointer to devinfo node's in_node_t */ 289779f1d69SMichael Bergknoff 290779f1d69SMichael Bergknoff /* detach event data */ 291779f1d69SMichael Bergknoff char *devi_ev_path; 292779f1d69SMichael Bergknoff int devi_ev_instance; 2933ce53722SRobert Mustacchi 2943ce53722SRobert Mustacchi /* 2953ce53722SRobert Mustacchi * Unbind callback data. 2963ce53722SRobert Mustacchi */ 2973ce53722SRobert Mustacchi kmutex_t devi_unbind_lock; 2983ce53722SRobert Mustacchi list_t devi_unbind_cbs; 2997c478bd9Sstevel@tonic-gate }; 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate #define DEVI(dev_info_type) ((struct dev_info *)(dev_info_type)) 3027c478bd9Sstevel@tonic-gate 3037c478bd9Sstevel@tonic-gate /* 3047c478bd9Sstevel@tonic-gate * NB: The 'name' field, for compatibility with old code (both existing 3057c478bd9Sstevel@tonic-gate * device drivers and userland code), is now defined as the name used 3067c478bd9Sstevel@tonic-gate * to bind the node to a device driver, and not the device node name. 3077c478bd9Sstevel@tonic-gate * If the device node name does not define a binding to a device driver, 3087c478bd9Sstevel@tonic-gate * and the framework uses a different algorithm to create the binding to 3097c478bd9Sstevel@tonic-gate * the driver, the node name and binding name will be different. 3107c478bd9Sstevel@tonic-gate * 3117c478bd9Sstevel@tonic-gate * Note that this implies that the node name plus instance number does 3127c478bd9Sstevel@tonic-gate * NOT create a unique driver id; only the binding name plus instance 3137c478bd9Sstevel@tonic-gate * number creates a unique driver id. 3147c478bd9Sstevel@tonic-gate * 3157c478bd9Sstevel@tonic-gate * New code should not use 'devi_name'; use 'devi_binding_name' or 3167c478bd9Sstevel@tonic-gate * 'devi_node_name' and/or the routines that access those fields. 3177c478bd9Sstevel@tonic-gate */ 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate #define devi_name devi_binding_name 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate /* 3227c478bd9Sstevel@tonic-gate * DDI_CF1, DDI_CF2 and DDI_DRV_UNLOADED are obsolete. They are kept 3237c478bd9Sstevel@tonic-gate * around to allow legacy drivers to to compile. 3247c478bd9Sstevel@tonic-gate */ 3257c478bd9Sstevel@tonic-gate #define DDI_CF1(devi) (DEVI(devi)->devi_addr != NULL) 3267c478bd9Sstevel@tonic-gate #define DDI_CF2(devi) (DEVI(devi)->devi_ops != NULL) 3277c478bd9Sstevel@tonic-gate #define DDI_DRV_UNLOADED(devi) (DEVI(devi)->devi_ops == &mod_nodev_ops) 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate /* 33016747f41Scth * The device state flags (devi_state) contains information regarding 3317c478bd9Sstevel@tonic-gate * the state of the device (Online/Offline/Down). For bus nexus 3327c478bd9Sstevel@tonic-gate * devices, the device state also contains state information regarding 3337c478bd9Sstevel@tonic-gate * the state of the bus represented by this nexus node. 3347c478bd9Sstevel@tonic-gate * 3357c478bd9Sstevel@tonic-gate * Device state information is stored in bits [0-7], bus state in bits 3367c478bd9Sstevel@tonic-gate * [8-15]. 3377c478bd9Sstevel@tonic-gate * 338b9ccdc5aScth * NOTE: all devi_state updates should be protected by devi_lock. 3397c478bd9Sstevel@tonic-gate */ 3407c478bd9Sstevel@tonic-gate #define DEVI_DEVICE_OFFLINE 0x00000001 3417c478bd9Sstevel@tonic-gate #define DEVI_DEVICE_DOWN 0x00000002 3427c478bd9Sstevel@tonic-gate #define DEVI_DEVICE_DEGRADED 0x00000004 3437c478bd9Sstevel@tonic-gate #define DEVI_DEVICE_REMOVED 0x00000008 /* hardware removed */ 34416747f41Scth 3457c478bd9Sstevel@tonic-gate #define DEVI_BUS_QUIESCED 0x00000100 3467c478bd9Sstevel@tonic-gate #define DEVI_BUS_DOWN 0x00000200 3477c478bd9Sstevel@tonic-gate #define DEVI_NDI_CONFIG 0x00000400 /* perform config when attaching */ 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate #define DEVI_S_ATTACHING 0x00010000 3507c478bd9Sstevel@tonic-gate #define DEVI_S_DETACHING 0x00020000 3517c478bd9Sstevel@tonic-gate #define DEVI_S_ONLINING 0x00040000 3527c478bd9Sstevel@tonic-gate #define DEVI_S_OFFLINING 0x00080000 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate #define DEVI_S_INVOKING_DACF 0x00100000 /* busy invoking a dacf task */ 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate #define DEVI_S_UNBOUND 0x00200000 3577c478bd9Sstevel@tonic-gate #define DEVI_S_REPORT 0x08000000 /* report status change */ 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate #define DEVI_S_EVADD 0x10000000 /* state of devfs event */ 3607c478bd9Sstevel@tonic-gate #define DEVI_S_EVREMOVE 0x20000000 /* state of devfs event */ 3617c478bd9Sstevel@tonic-gate #define DEVI_S_NEED_RESET 0x40000000 /* devo_reset should be called */ 3627c478bd9Sstevel@tonic-gate 36316747f41Scth /* 36416747f41Scth * Device state macros. 36516747f41Scth * o All SET/CLR/DONE users must protect context with devi_lock. 36648bbca81SDaniel Hoffman * o DEVI_SET_DEVICE_ONLINE users must do their own DEVI_SET_REPORT. 36716747f41Scth * o DEVI_SET_DEVICE_{DOWN|DEGRADED|UP} should only be used when !OFFLINE. 36816747f41Scth * o DEVI_SET_DEVICE_UP clears DOWN and DEGRADED. 36916747f41Scth */ 3707c478bd9Sstevel@tonic-gate #define DEVI_IS_DEVICE_OFFLINE(dip) \ 37116747f41Scth ((DEVI(dip)->devi_state & DEVI_DEVICE_OFFLINE) == DEVI_DEVICE_OFFLINE) 3727c478bd9Sstevel@tonic-gate 37316747f41Scth #define DEVI_SET_DEVICE_ONLINE(dip) { \ 37416747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 37525e8c5aaSvikram if (DEVI(dip)->devi_state & DEVI_DEVICE_DEGRADED) { \ 37625e8c5aaSvikram mutex_exit(&DEVI(dip)->devi_lock); \ 37725e8c5aaSvikram e_ddi_undegrade_finalize(dip); \ 37825e8c5aaSvikram mutex_enter(&DEVI(dip)->devi_lock); \ 37925e8c5aaSvikram } \ 38016747f41Scth /* setting ONLINE clears DOWN, DEGRADED, OFFLINE */ \ 38116747f41Scth DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DOWN | \ 38216747f41Scth DEVI_DEVICE_DEGRADED | DEVI_DEVICE_OFFLINE); \ 38316747f41Scth } 3847c478bd9Sstevel@tonic-gate 38516747f41Scth #define DEVI_SET_DEVICE_OFFLINE(dip) { \ 38616747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 38716747f41Scth DEVI(dip)->devi_state |= (DEVI_DEVICE_OFFLINE | DEVI_S_REPORT); \ 38816747f41Scth } 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate #define DEVI_IS_DEVICE_DOWN(dip) \ 39116747f41Scth ((DEVI(dip)->devi_state & DEVI_DEVICE_DOWN) == DEVI_DEVICE_DOWN) 3927c478bd9Sstevel@tonic-gate 39316747f41Scth #define DEVI_SET_DEVICE_DOWN(dip) { \ 39416747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 39516747f41Scth ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \ 39616747f41Scth DEVI(dip)->devi_state |= (DEVI_DEVICE_DOWN | DEVI_S_REPORT); \ 39716747f41Scth } 3987c478bd9Sstevel@tonic-gate 3997c478bd9Sstevel@tonic-gate #define DEVI_IS_DEVICE_DEGRADED(dip) \ 40016747f41Scth ((DEVI(dip)->devi_state & \ 40116747f41Scth (DEVI_DEVICE_DEGRADED|DEVI_DEVICE_DOWN)) == DEVI_DEVICE_DEGRADED) 4027c478bd9Sstevel@tonic-gate 40316747f41Scth #define DEVI_SET_DEVICE_DEGRADED(dip) { \ 40416747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 40516747f41Scth ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \ 40625e8c5aaSvikram mutex_exit(&DEVI(dip)->devi_lock); \ 40725e8c5aaSvikram e_ddi_degrade_finalize(dip); \ 40825e8c5aaSvikram mutex_enter(&DEVI(dip)->devi_lock); \ 40916747f41Scth DEVI(dip)->devi_state |= (DEVI_DEVICE_DEGRADED | DEVI_S_REPORT); \ 41016747f41Scth } 4117c478bd9Sstevel@tonic-gate 41216747f41Scth #define DEVI_SET_DEVICE_UP(dip) { \ 41316747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 41416747f41Scth ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \ 41525e8c5aaSvikram if (DEVI(dip)->devi_state & DEVI_DEVICE_DEGRADED) { \ 41625e8c5aaSvikram mutex_exit(&DEVI(dip)->devi_lock); \ 41725e8c5aaSvikram e_ddi_undegrade_finalize(dip); \ 41825e8c5aaSvikram mutex_enter(&DEVI(dip)->devi_lock); \ 41925e8c5aaSvikram } \ 42016747f41Scth DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DEGRADED | DEVI_DEVICE_DOWN); \ 42116747f41Scth DEVI(dip)->devi_state |= DEVI_S_REPORT; \ 42216747f41Scth } 4237c478bd9Sstevel@tonic-gate 42416747f41Scth /* Device removal and insertion */ 4257c478bd9Sstevel@tonic-gate #define DEVI_IS_DEVICE_REMOVED(dip) \ 42616747f41Scth ((DEVI(dip)->devi_state & DEVI_DEVICE_REMOVED) == DEVI_DEVICE_REMOVED) 4277c478bd9Sstevel@tonic-gate 42816747f41Scth #define DEVI_SET_DEVICE_REMOVED(dip) { \ 42916747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 4304c06356bSdh142964 DEVI(dip)->devi_state |= DEVI_DEVICE_REMOVED | DEVI_S_REPORT; \ 43116747f41Scth } 4327c478bd9Sstevel@tonic-gate 43316747f41Scth #define DEVI_SET_DEVICE_REINSERTED(dip) { \ 43416747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 43516747f41Scth DEVI(dip)->devi_state &= ~DEVI_DEVICE_REMOVED; \ 4364c06356bSdh142964 DEVI(dip)->devi_state |= DEVI_S_REPORT; \ 43716747f41Scth } 4387c478bd9Sstevel@tonic-gate 43916747f41Scth /* Bus state change macros */ 4407c478bd9Sstevel@tonic-gate #define DEVI_IS_BUS_QUIESCED(dip) \ 44116747f41Scth ((DEVI(dip)->devi_state & DEVI_BUS_QUIESCED) == DEVI_BUS_QUIESCED) 4427c478bd9Sstevel@tonic-gate 44316747f41Scth #define DEVI_SET_BUS_ACTIVE(dip) { \ 44416747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 44516747f41Scth DEVI(dip)->devi_state &= ~DEVI_BUS_QUIESCED; \ 44616747f41Scth DEVI(dip)->devi_state |= DEVI_S_REPORT; \ 44716747f41Scth } 4487c478bd9Sstevel@tonic-gate 44916747f41Scth #define DEVI_SET_BUS_QUIESCE(dip) { \ 45016747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 45116747f41Scth DEVI(dip)->devi_state |= (DEVI_BUS_QUIESCED | DEVI_S_REPORT); \ 45216747f41Scth } 4537c478bd9Sstevel@tonic-gate 4547c478bd9Sstevel@tonic-gate #define DEVI_IS_BUS_DOWN(dip) \ 45516747f41Scth ((DEVI(dip)->devi_state & DEVI_BUS_DOWN) == DEVI_BUS_DOWN) 4567c478bd9Sstevel@tonic-gate 45716747f41Scth #define DEVI_SET_BUS_UP(dip) { \ 45816747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 45916747f41Scth DEVI(dip)->devi_state &= ~DEVI_BUS_DOWN; \ 46016747f41Scth DEVI(dip)->devi_state |= DEVI_S_REPORT; \ 46116747f41Scth } 4627c478bd9Sstevel@tonic-gate 46316747f41Scth #define DEVI_SET_BUS_DOWN(dip) { \ 46416747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 46516747f41Scth DEVI(dip)->devi_state |= (DEVI_BUS_DOWN | DEVI_S_REPORT); \ 46616747f41Scth } 4677c478bd9Sstevel@tonic-gate 46816747f41Scth /* Status change report needed */ 4697c478bd9Sstevel@tonic-gate #define DEVI_NEED_REPORT(dip) \ 47016747f41Scth ((DEVI(dip)->devi_state & DEVI_S_REPORT) == DEVI_S_REPORT) 4717c478bd9Sstevel@tonic-gate 47216747f41Scth #define DEVI_SET_REPORT(dip) { \ 47316747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 47416747f41Scth DEVI(dip)->devi_state |= DEVI_S_REPORT; \ 47516747f41Scth } 4767c478bd9Sstevel@tonic-gate 47716747f41Scth #define DEVI_REPORT_DONE(dip) { \ 47816747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 47916747f41Scth DEVI(dip)->devi_state &= ~DEVI_S_REPORT; \ 48016747f41Scth } 48116747f41Scth 48216747f41Scth /* Do an NDI_CONFIG for its children */ 4837c478bd9Sstevel@tonic-gate #define DEVI_NEED_NDI_CONFIG(dip) \ 48416747f41Scth ((DEVI(dip)->devi_state & DEVI_NDI_CONFIG) == DEVI_NDI_CONFIG) 4857c478bd9Sstevel@tonic-gate 48616747f41Scth #define DEVI_SET_NDI_CONFIG(dip) { \ 48716747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 48816747f41Scth DEVI(dip)->devi_state |= DEVI_NDI_CONFIG; \ 48916747f41Scth } 4907c478bd9Sstevel@tonic-gate 49116747f41Scth #define DEVI_CLR_NDI_CONFIG(dip) { \ 49216747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 49316747f41Scth DEVI(dip)->devi_state &= ~DEVI_NDI_CONFIG; \ 49416747f41Scth } 4957c478bd9Sstevel@tonic-gate 49616747f41Scth /* Attaching or detaching state */ 4977c478bd9Sstevel@tonic-gate #define DEVI_IS_ATTACHING(dip) \ 49816747f41Scth ((DEVI(dip)->devi_state & DEVI_S_ATTACHING) == DEVI_S_ATTACHING) 4997c478bd9Sstevel@tonic-gate 50016747f41Scth #define DEVI_SET_ATTACHING(dip) { \ 50116747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 50216747f41Scth DEVI(dip)->devi_state |= DEVI_S_ATTACHING; \ 50316747f41Scth } 5047c478bd9Sstevel@tonic-gate 50516747f41Scth #define DEVI_CLR_ATTACHING(dip) { \ 50616747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 50716747f41Scth DEVI(dip)->devi_state &= ~DEVI_S_ATTACHING; \ 50816747f41Scth } 5097c478bd9Sstevel@tonic-gate 5107c478bd9Sstevel@tonic-gate #define DEVI_IS_DETACHING(dip) \ 51116747f41Scth ((DEVI(dip)->devi_state & DEVI_S_DETACHING) == DEVI_S_DETACHING) 5127c478bd9Sstevel@tonic-gate 51316747f41Scth #define DEVI_SET_DETACHING(dip) { \ 51416747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 51516747f41Scth DEVI(dip)->devi_state |= DEVI_S_DETACHING; \ 51616747f41Scth } 5177c478bd9Sstevel@tonic-gate 51816747f41Scth #define DEVI_CLR_DETACHING(dip) { \ 51916747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 52016747f41Scth DEVI(dip)->devi_state &= ~DEVI_S_DETACHING; \ 52116747f41Scth } 5227c478bd9Sstevel@tonic-gate 52316747f41Scth /* Onlining or offlining state */ 5247c478bd9Sstevel@tonic-gate #define DEVI_IS_ONLINING(dip) \ 52516747f41Scth ((DEVI(dip)->devi_state & DEVI_S_ONLINING) == DEVI_S_ONLINING) 5267c478bd9Sstevel@tonic-gate 52716747f41Scth #define DEVI_SET_ONLINING(dip) { \ 52816747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 52916747f41Scth DEVI(dip)->devi_state |= DEVI_S_ONLINING; \ 53016747f41Scth } 5317c478bd9Sstevel@tonic-gate 53216747f41Scth #define DEVI_CLR_ONLINING(dip) { \ 53316747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 53416747f41Scth DEVI(dip)->devi_state &= ~DEVI_S_ONLINING; \ 53516747f41Scth } 5367c478bd9Sstevel@tonic-gate 5377c478bd9Sstevel@tonic-gate #define DEVI_IS_OFFLINING(dip) \ 53816747f41Scth ((DEVI(dip)->devi_state & DEVI_S_OFFLINING) == DEVI_S_OFFLINING) 53916747f41Scth 54016747f41Scth #define DEVI_SET_OFFLINING(dip) { \ 54116747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 54216747f41Scth DEVI(dip)->devi_state |= DEVI_S_OFFLINING; \ 54316747f41Scth } 54416747f41Scth 54516747f41Scth #define DEVI_CLR_OFFLINING(dip) { \ 54616747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 54716747f41Scth DEVI(dip)->devi_state &= ~DEVI_S_OFFLINING; \ 54816747f41Scth } 5497c478bd9Sstevel@tonic-gate 5507c478bd9Sstevel@tonic-gate #define DEVI_IS_IN_RECONFIG(dip) \ 55116747f41Scth (DEVI(dip)->devi_state & (DEVI_S_OFFLINING | DEVI_S_ONLINING)) 5527c478bd9Sstevel@tonic-gate 55316747f41Scth /* Busy invoking a dacf task against this node */ 5547c478bd9Sstevel@tonic-gate #define DEVI_IS_INVOKING_DACF(dip) \ 55516747f41Scth ((DEVI(dip)->devi_state & DEVI_S_INVOKING_DACF) == DEVI_S_INVOKING_DACF) 5567c478bd9Sstevel@tonic-gate 55716747f41Scth #define DEVI_SET_INVOKING_DACF(dip) { \ 55816747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 55916747f41Scth DEVI(dip)->devi_state |= DEVI_S_INVOKING_DACF; \ 56016747f41Scth } 5617c478bd9Sstevel@tonic-gate 56216747f41Scth #define DEVI_CLR_INVOKING_DACF(dip) { \ 56316747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 56416747f41Scth DEVI(dip)->devi_state &= ~DEVI_S_INVOKING_DACF; \ 56516747f41Scth } 5667c478bd9Sstevel@tonic-gate 56716747f41Scth /* Events for add/remove */ 5687c478bd9Sstevel@tonic-gate #define DEVI_EVADD(dip) \ 56916747f41Scth ((DEVI(dip)->devi_state & DEVI_S_EVADD) == DEVI_S_EVADD) 57016747f41Scth 57116747f41Scth #define DEVI_SET_EVADD(dip) { \ 57216747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 57316747f41Scth DEVI(dip)->devi_state &= ~DEVI_S_EVREMOVE; \ 57416747f41Scth DEVI(dip)->devi_state |= DEVI_S_EVADD; \ 57516747f41Scth } 5767c478bd9Sstevel@tonic-gate 5777c478bd9Sstevel@tonic-gate #define DEVI_EVREMOVE(dip) \ 57816747f41Scth ((DEVI(dip)->devi_state & DEVI_S_EVREMOVE) == DEVI_S_EVREMOVE) 5797c478bd9Sstevel@tonic-gate 58016747f41Scth #define DEVI_SET_EVREMOVE(dip) { \ 58116747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 58216747f41Scth DEVI(dip)->devi_state &= ~DEVI_S_EVADD; \ 58316747f41Scth DEVI(dip)->devi_state |= DEVI_S_EVREMOVE; \ 58416747f41Scth } 58516747f41Scth 58616747f41Scth #define DEVI_SET_EVUNINIT(dip) { \ 58716747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 58816747f41Scth DEVI(dip)->devi_state &= ~(DEVI_S_EVADD | DEVI_S_EVREMOVE); \ 58916747f41Scth } 59016747f41Scth 59116747f41Scth /* Need to call the devo_reset entry point for this device at shutdown */ 5927c478bd9Sstevel@tonic-gate #define DEVI_NEED_RESET(dip) \ 59316747f41Scth ((DEVI(dip)->devi_state & DEVI_S_NEED_RESET) == DEVI_S_NEED_RESET) 5947c478bd9Sstevel@tonic-gate 59516747f41Scth #define DEVI_SET_NEED_RESET(dip) { \ 59616747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 59716747f41Scth DEVI(dip)->devi_state |= DEVI_S_NEED_RESET; \ 59816747f41Scth } 5997c478bd9Sstevel@tonic-gate 60016747f41Scth #define DEVI_CLR_NEED_RESET(dip) { \ 60116747f41Scth ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \ 60216747f41Scth DEVI(dip)->devi_state &= ~DEVI_S_NEED_RESET; \ 60316747f41Scth } 6047c478bd9Sstevel@tonic-gate 60516747f41Scth /* 60616747f41Scth * devi_flags bits 60716747f41Scth * 608b9ccdc5aScth * NOTE: all devi_state updates should be protected by devi_lock. 60916747f41Scth */ 61016747f41Scth #define DEVI_BUSY 0x00000001 /* busy configuring children */ 61116747f41Scth #define DEVI_MADE_CHILDREN 0x00000002 /* children made from specs */ 61216747f41Scth #define DEVI_ATTACHED_CHILDREN 0x00000004 /* attached all existing children */ 61316747f41Scth #define DEVI_BRANCH_HELD 0x00000008 /* branch rooted at this dip held */ 61416747f41Scth #define DEVI_NO_BIND 0x00000010 /* prevent driver binding */ 6158451e9c3SGavin Maltby #define DEVI_CACHED_DEVID 0x00000020 /* devid cached in devid cache */ 6165e3986cbScth #define DEVI_PHCI_SIGNALS_VHCI 0x00000040 /* pHCI ndi_devi_exit signals vHCI */ 617f4da9be0Scth #define DEVI_REBIND 0x00000080 /* post initchild driver rebind */ 61825e8c5aaSvikram #define DEVI_RETIRED 0x00000100 /* device is retired */ 61925e8c5aaSvikram #define DEVI_RETIRING 0x00000200 /* being evaluated for retire */ 62025e8c5aaSvikram #define DEVI_R_CONSTRAINT 0x00000400 /* constraints have been applied */ 62125e8c5aaSvikram #define DEVI_R_BLOCKED 0x00000800 /* constraints block retire */ 62225e8c5aaSvikram #define DEVI_CT_NOP 0x00001000 /* NOP contract event occurred */ 6233a634bfcSVikram Hegde #define DEVI_PCI_DEVICE 0x00002000 /* dip is PCI */ 62416747f41Scth 62516747f41Scth #define DEVI_BUSY_CHANGING(dip) (DEVI(dip)->devi_flags & DEVI_BUSY) 62616747f41Scth #define DEVI_BUSY_OWNED(dip) (DEVI_BUSY_CHANGING(dip) && \ 62716747f41Scth ((DEVI(dip))->devi_busy_thread == curthread)) 62816747f41Scth 6293a634bfcSVikram Hegde #define DEVI_IS_PCI(dip) (DEVI(dip)->devi_flags & DEVI_PCI_DEVICE) 6303a634bfcSVikram Hegde #define DEVI_SET_PCI(dip) (DEVI(dip)->devi_flags |= (DEVI_PCI_DEVICE)) 6313a634bfcSVikram Hegde 6327c478bd9Sstevel@tonic-gate char *i_ddi_devi_class(dev_info_t *); 6337bcaeddbSRobert Mustacchi int i_ddi_set_devi_class(dev_info_t *, const char *, int); 6347c478bd9Sstevel@tonic-gate 6357c478bd9Sstevel@tonic-gate /* 6367c478bd9Sstevel@tonic-gate * This structure represents one piece of bus space occupied by a given 6377c478bd9Sstevel@tonic-gate * device. It is used in an array for devices with multiple address windows. 6387c478bd9Sstevel@tonic-gate */ 6397c478bd9Sstevel@tonic-gate struct regspec { 6407c478bd9Sstevel@tonic-gate uint_t regspec_bustype; /* cookie for bus type it's on */ 6417c478bd9Sstevel@tonic-gate uint_t regspec_addr; /* address of reg relative to bus */ 6427c478bd9Sstevel@tonic-gate uint_t regspec_size; /* size of this register set */ 6437c478bd9Sstevel@tonic-gate }; 6447c478bd9Sstevel@tonic-gate 6457c478bd9Sstevel@tonic-gate /* 6461f0c5e61SRobert Mustacchi * This is a version of the above structure that works for 64-bit mappings and 6471f0c5e61SRobert Mustacchi * doesn't rely on overloading of fields as is done on SPARC. Eventually the 6481f0c5e61SRobert Mustacchi * struct regspec should be replaced with this. 6491f0c5e61SRobert Mustacchi */ 6501f0c5e61SRobert Mustacchi struct regspec64 { 6511f0c5e61SRobert Mustacchi uint64_t regspec_bustype; /* cookie for bus type it's on */ 6521f0c5e61SRobert Mustacchi uint64_t regspec_addr; /* address of reg relative to bus */ 6531f0c5e61SRobert Mustacchi uint64_t regspec_size; /* size of this register set */ 6541f0c5e61SRobert Mustacchi }; 6551f0c5e61SRobert Mustacchi 6561f0c5e61SRobert Mustacchi /* 6577c478bd9Sstevel@tonic-gate * This structure represents one piece of nexus bus space. 6587c478bd9Sstevel@tonic-gate * It is used in an array for nexi with multiple bus spaces 6597c478bd9Sstevel@tonic-gate * to define the childs offsets in the parents bus space. 6607c478bd9Sstevel@tonic-gate */ 6617c478bd9Sstevel@tonic-gate struct rangespec { 6627c478bd9Sstevel@tonic-gate uint_t rng_cbustype; /* Child's address, hi order */ 6637c478bd9Sstevel@tonic-gate uint_t rng_coffset; /* Child's address, lo order */ 6647c478bd9Sstevel@tonic-gate uint_t rng_bustype; /* Parent's address, hi order */ 6657c478bd9Sstevel@tonic-gate uint_t rng_offset; /* Parent's address, lo order */ 6667c478bd9Sstevel@tonic-gate uint_t rng_size; /* size of space for this entry */ 6677c478bd9Sstevel@tonic-gate }; 6687c478bd9Sstevel@tonic-gate 6697c478bd9Sstevel@tonic-gate #ifdef _KERNEL 6707c478bd9Sstevel@tonic-gate 6717c478bd9Sstevel@tonic-gate typedef enum { 6727c478bd9Sstevel@tonic-gate DDI_PRE = 0, 6737c478bd9Sstevel@tonic-gate DDI_POST = 1 6747c478bd9Sstevel@tonic-gate } ddi_pre_post_t; 6757c478bd9Sstevel@tonic-gate 6767c478bd9Sstevel@tonic-gate /* 6777c478bd9Sstevel@tonic-gate * This structure represents notification of a child attach event 6787c478bd9Sstevel@tonic-gate * These could both be the same if attach/detach commands were in the 6797c478bd9Sstevel@tonic-gate * same name space. 6807c478bd9Sstevel@tonic-gate * Note that the target dip is passed as an arg already. 6817c478bd9Sstevel@tonic-gate */ 6827c478bd9Sstevel@tonic-gate struct attachspec { 6837c478bd9Sstevel@tonic-gate ddi_attach_cmd_t cmd; /* type of event */ 6847c478bd9Sstevel@tonic-gate ddi_pre_post_t when; /* one of DDI_PRE or DDI_POST */ 6857c478bd9Sstevel@tonic-gate dev_info_t *pdip; /* parent of attaching node */ 6867c478bd9Sstevel@tonic-gate int result; /* result of attach op (post command only) */ 6877c478bd9Sstevel@tonic-gate }; 6887c478bd9Sstevel@tonic-gate 6897c478bd9Sstevel@tonic-gate /* 6907c478bd9Sstevel@tonic-gate * This structure represents notification of a child detach event 6917c478bd9Sstevel@tonic-gate * Note that the target dip is passed as an arg already. 6927c478bd9Sstevel@tonic-gate */ 6937c478bd9Sstevel@tonic-gate struct detachspec { 6947c478bd9Sstevel@tonic-gate ddi_detach_cmd_t cmd; /* type of event */ 6957c478bd9Sstevel@tonic-gate ddi_pre_post_t when; /* one of DDI_PRE or DDI_POST */ 6967c478bd9Sstevel@tonic-gate dev_info_t *pdip; /* parent of detaching node */ 6977c478bd9Sstevel@tonic-gate int result; /* result of detach op (post command only) */ 6987c478bd9Sstevel@tonic-gate }; 6997c478bd9Sstevel@tonic-gate 7007c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 7017c478bd9Sstevel@tonic-gate 7027c478bd9Sstevel@tonic-gate typedef enum { 7037c478bd9Sstevel@tonic-gate DDM_MINOR = 0, 7047c478bd9Sstevel@tonic-gate DDM_ALIAS, 7057c478bd9Sstevel@tonic-gate DDM_DEFAULT, 7067c478bd9Sstevel@tonic-gate DDM_INTERNAL_PATH 7077c478bd9Sstevel@tonic-gate } ddi_minor_type; 7087c478bd9Sstevel@tonic-gate 7097c478bd9Sstevel@tonic-gate /* implementation flags for driver specified device access control */ 7107c478bd9Sstevel@tonic-gate #define DM_NO_FSPERM 0x1 7117c478bd9Sstevel@tonic-gate 7127c478bd9Sstevel@tonic-gate struct devplcy; 7137c478bd9Sstevel@tonic-gate 7147c478bd9Sstevel@tonic-gate struct ddi_minor { 7157c478bd9Sstevel@tonic-gate char *name; /* name of node */ 7167c478bd9Sstevel@tonic-gate dev_t dev; /* device number */ 7177c478bd9Sstevel@tonic-gate int spec_type; /* block or char */ 7187c478bd9Sstevel@tonic-gate int flags; /* access flags */ 7197bcaeddbSRobert Mustacchi const char *node_type; /* block, byte, serial, network */ 7207c478bd9Sstevel@tonic-gate struct devplcy *node_priv; /* privilege for this minor */ 7217c478bd9Sstevel@tonic-gate mode_t priv_mode; /* default apparent privilege mode */ 7227c478bd9Sstevel@tonic-gate }; 7237c478bd9Sstevel@tonic-gate 7247c478bd9Sstevel@tonic-gate /* 7257c478bd9Sstevel@tonic-gate * devi_node_attributes contains node attributes private to the 7267c478bd9Sstevel@tonic-gate * ddi implementation. As a consumer, do not use these bit definitions 7277c478bd9Sstevel@tonic-gate * directly, use the ndi functions that check for the existence of the 7287c478bd9Sstevel@tonic-gate * specific node attributes. 7297c478bd9Sstevel@tonic-gate * 7307c478bd9Sstevel@tonic-gate * DDI_PERSISTENT indicates a 'persistent' node; one that is not 7317c478bd9Sstevel@tonic-gate * automatically freed by the framework if the driver is unloaded 7327c478bd9Sstevel@tonic-gate * or the driver fails to attach to this node. 7337c478bd9Sstevel@tonic-gate * 7347c478bd9Sstevel@tonic-gate * DDI_AUTO_ASSIGNED_NODEID indicates that the nodeid was auto-assigned 7357c478bd9Sstevel@tonic-gate * by the framework and should be auto-freed if the node is removed. 7367c478bd9Sstevel@tonic-gate * 7377c478bd9Sstevel@tonic-gate * DDI_VHCI_NODE indicates that the node type is VHCI. This flag 7387c478bd9Sstevel@tonic-gate * must be set by ndi_devi_config_vhci() routine only. 739027021c7SChris Horne * 740027021c7SChris Horne * DDI_HIDDEN_NODE indicates that the node should not show up in snapshots 741027021c7SChris Horne * or in /devices. 7424c06356bSdh142964 * 7434c06356bSdh142964 * DDI_HOTPLUG_NODE indicates that the node created by nexus hotplug. 7447c478bd9Sstevel@tonic-gate */ 7457c478bd9Sstevel@tonic-gate #define DDI_PERSISTENT 0x01 7467c478bd9Sstevel@tonic-gate #define DDI_AUTO_ASSIGNED_NODEID 0x02 7477c478bd9Sstevel@tonic-gate #define DDI_VHCI_NODE 0x04 748027021c7SChris Horne #define DDI_HIDDEN_NODE 0x08 7494c06356bSdh142964 #define DDI_HOTPLUG_NODE 0x10 7507c478bd9Sstevel@tonic-gate 75116747f41Scth #define DEVI_VHCI_NODE(dip) \ 75216747f41Scth (DEVI(dip)->devi_node_attributes & DDI_VHCI_NODE) 75316747f41Scth 7547c478bd9Sstevel@tonic-gate /* 7557c478bd9Sstevel@tonic-gate * The ddi_minor_data structure gets filled in by ddi_create_minor_node. 7567c478bd9Sstevel@tonic-gate * It then gets attached to the devinfo node as a property. 7577c478bd9Sstevel@tonic-gate */ 7587c478bd9Sstevel@tonic-gate struct ddi_minor_data { 7597c478bd9Sstevel@tonic-gate struct ddi_minor_data *next; /* next one in the chain */ 7607c478bd9Sstevel@tonic-gate dev_info_t *dip; /* pointer to devinfo node */ 7617c478bd9Sstevel@tonic-gate ddi_minor_type type; /* Following data type */ 7627c478bd9Sstevel@tonic-gate struct ddi_minor d_minor; /* Actual minor node data */ 7637c478bd9Sstevel@tonic-gate }; 7647c478bd9Sstevel@tonic-gate 7657c478bd9Sstevel@tonic-gate #define ddm_name d_minor.name 7667c478bd9Sstevel@tonic-gate #define ddm_dev d_minor.dev 7677c478bd9Sstevel@tonic-gate #define ddm_flags d_minor.flags 7687c478bd9Sstevel@tonic-gate #define ddm_spec_type d_minor.spec_type 7697c478bd9Sstevel@tonic-gate #define ddm_node_type d_minor.node_type 7707c478bd9Sstevel@tonic-gate #define ddm_node_priv d_minor.node_priv 7717c478bd9Sstevel@tonic-gate #define ddm_priv_mode d_minor.priv_mode 7727c478bd9Sstevel@tonic-gate 7737c478bd9Sstevel@tonic-gate /* 7747c478bd9Sstevel@tonic-gate * parent private data structure contains register, interrupt, property 7757c478bd9Sstevel@tonic-gate * and range information. 7767c478bd9Sstevel@tonic-gate */ 7777c478bd9Sstevel@tonic-gate struct ddi_parent_private_data { 7787c478bd9Sstevel@tonic-gate int par_nreg; /* number of regs */ 7797c478bd9Sstevel@tonic-gate struct regspec *par_reg; /* array of regs */ 7807c478bd9Sstevel@tonic-gate int par_nintr; /* number of interrupts */ 7817c478bd9Sstevel@tonic-gate struct intrspec *par_intr; /* array of possible interrupts */ 7827c478bd9Sstevel@tonic-gate int par_nrng; /* number of ranges */ 7837c478bd9Sstevel@tonic-gate struct rangespec *par_rng; /* array of ranges */ 7847c478bd9Sstevel@tonic-gate }; 7857c478bd9Sstevel@tonic-gate #define DEVI_PD(d) \ 7867c478bd9Sstevel@tonic-gate ((struct ddi_parent_private_data *)DEVI((d))->devi_parent_data) 7877c478bd9Sstevel@tonic-gate 7887c478bd9Sstevel@tonic-gate #define sparc_pd_getnreg(dev) (DEVI_PD(dev)->par_nreg) 7897c478bd9Sstevel@tonic-gate #define sparc_pd_getnintr(dev) (DEVI_PD(dev)->par_nintr) 7907c478bd9Sstevel@tonic-gate #define sparc_pd_getnrng(dev) (DEVI_PD(dev)->par_nrng) 7917c478bd9Sstevel@tonic-gate #define sparc_pd_getreg(dev, n) (&DEVI_PD(dev)->par_reg[(n)]) 7927c478bd9Sstevel@tonic-gate #define sparc_pd_getintr(dev, n) (&DEVI_PD(dev)->par_intr[(n)]) 7937c478bd9Sstevel@tonic-gate #define sparc_pd_getrng(dev, n) (&DEVI_PD(dev)->par_rng[(n)]) 7947c478bd9Sstevel@tonic-gate 7954c06356bSdh142964 #ifdef _KERNEL 7967c478bd9Sstevel@tonic-gate /* 7974c06356bSdh142964 * This data structure is private to the indexed soft state allocator. 7987c478bd9Sstevel@tonic-gate */ 7994c06356bSdh142964 typedef struct i_ddi_soft_state { 8007c478bd9Sstevel@tonic-gate void **array; /* the array of pointers */ 8017c478bd9Sstevel@tonic-gate kmutex_t lock; /* serialize access to this struct */ 8027c478bd9Sstevel@tonic-gate size_t size; /* how many bytes per state struct */ 8037c478bd9Sstevel@tonic-gate size_t n_items; /* how many structs herein */ 8047c478bd9Sstevel@tonic-gate struct i_ddi_soft_state *next; /* 'dirty' elements */ 8054c06356bSdh142964 } i_ddi_soft_state; 8064c06356bSdh142964 8074c06356bSdh142964 /* 8084c06356bSdh142964 * This data structure is private to the stringhashed soft state allocator. 8094c06356bSdh142964 */ 8104c06356bSdh142964 typedef struct i_ddi_soft_state_bystr { 8114c06356bSdh142964 size_t ss_size; /* how many bytes per state struct */ 8124c06356bSdh142964 mod_hash_t *ss_mod_hash; /* hash implementation */ 8134c06356bSdh142964 } i_ddi_soft_state_bystr; 8144c06356bSdh142964 8154c06356bSdh142964 /* 8164c06356bSdh142964 * This data structure is private to the ddi_strid_* implementation 8174c06356bSdh142964 */ 8184c06356bSdh142964 typedef struct i_ddi_strid { 8191b115575SJohn Danielson size_t strid_chunksz; 8201b115575SJohn Danielson size_t strid_spacesz; 8214c06356bSdh142964 id_space_t *strid_space; 8224c06356bSdh142964 mod_hash_t *strid_byid; 8234c06356bSdh142964 mod_hash_t *strid_bystr; 8244c06356bSdh142964 } i_ddi_strid; 8254c06356bSdh142964 #endif /* _KERNEL */ 8267c478bd9Sstevel@tonic-gate 8277c478bd9Sstevel@tonic-gate /* 8287c478bd9Sstevel@tonic-gate * Solaris DDI DMA implementation structure and function definitions. 8297c478bd9Sstevel@tonic-gate * 8307c478bd9Sstevel@tonic-gate * Note: no callers of DDI functions must depend upon data structures 8317c478bd9Sstevel@tonic-gate * declared below. They are not guaranteed to remain constant. 8327c478bd9Sstevel@tonic-gate */ 8337c478bd9Sstevel@tonic-gate 8347c478bd9Sstevel@tonic-gate /* 8357c478bd9Sstevel@tonic-gate * Implementation DMA mapping structure. 8367c478bd9Sstevel@tonic-gate * 8377c478bd9Sstevel@tonic-gate * The publicly visible ddi_dma_req structure is filled 8387c478bd9Sstevel@tonic-gate * in by a caller that wishes to map a memory object 8397c478bd9Sstevel@tonic-gate * for DMA. Internal to this implementation of the public 8407c478bd9Sstevel@tonic-gate * DDI DMA functions this request structure is put together 8417c478bd9Sstevel@tonic-gate * with bus nexus specific functions that have additional 8427c478bd9Sstevel@tonic-gate * information and constraints as to how to go about doing 8437c478bd9Sstevel@tonic-gate * the requested mapping function 8447c478bd9Sstevel@tonic-gate * 8457c478bd9Sstevel@tonic-gate * In this implementation, some of the information from the 8467c478bd9Sstevel@tonic-gate * original requester is retained throughout the lifetime 8477c478bd9Sstevel@tonic-gate * of the I/O mapping being active. 8487c478bd9Sstevel@tonic-gate */ 8497c478bd9Sstevel@tonic-gate 8507c478bd9Sstevel@tonic-gate /* 8517c478bd9Sstevel@tonic-gate * This is the implementation specific description 8527c478bd9Sstevel@tonic-gate * of how we've mapped an object for DMA. 8537c478bd9Sstevel@tonic-gate */ 8547c478bd9Sstevel@tonic-gate #if defined(__sparc) 8557c478bd9Sstevel@tonic-gate typedef struct ddi_dma_impl { 8567c478bd9Sstevel@tonic-gate /* 8577c478bd9Sstevel@tonic-gate * DMA mapping information 8587c478bd9Sstevel@tonic-gate */ 8597c478bd9Sstevel@tonic-gate ulong_t dmai_mapping; /* mapping cookie */ 8607c478bd9Sstevel@tonic-gate 8617c478bd9Sstevel@tonic-gate /* 8627c478bd9Sstevel@tonic-gate * Size of the current mapping, in bytes. 8637c478bd9Sstevel@tonic-gate * 8647c478bd9Sstevel@tonic-gate * Note that this is distinct from the size of the object being mapped 8657c478bd9Sstevel@tonic-gate * for DVMA. We might have only a portion of the object mapped at any 8667c478bd9Sstevel@tonic-gate * given point in time. 8677c478bd9Sstevel@tonic-gate */ 8687c478bd9Sstevel@tonic-gate uint_t dmai_size; 8697c478bd9Sstevel@tonic-gate 8707c478bd9Sstevel@tonic-gate /* 8717c478bd9Sstevel@tonic-gate * Offset, in bytes, into object that is currently mapped. 8727c478bd9Sstevel@tonic-gate */ 8737c478bd9Sstevel@tonic-gate off_t dmai_offset; 8747c478bd9Sstevel@tonic-gate 8757c478bd9Sstevel@tonic-gate /* 8767c478bd9Sstevel@tonic-gate * Information gathered from the original DMA mapping 8777c478bd9Sstevel@tonic-gate * request and saved for the lifetime of the mapping. 8787c478bd9Sstevel@tonic-gate */ 8797c478bd9Sstevel@tonic-gate uint_t dmai_minxfer; 8807c478bd9Sstevel@tonic-gate uint_t dmai_burstsizes; 8817c478bd9Sstevel@tonic-gate uint_t dmai_ndvmapages; 8827c478bd9Sstevel@tonic-gate uint_t dmai_pool; /* cached DVMA space */ 8837c478bd9Sstevel@tonic-gate uint_t dmai_rflags; /* requester's flags + ours */ 8847c478bd9Sstevel@tonic-gate uint_t dmai_inuse; /* active handle? */ 8857c478bd9Sstevel@tonic-gate uint_t dmai_nwin; 8867c478bd9Sstevel@tonic-gate uint_t dmai_winsize; 8879a63ec27SRobert Mustacchi uint_t dmai_ncookies; 8889a63ec27SRobert Mustacchi uint_t dmai_curcookie; 8897c478bd9Sstevel@tonic-gate caddr_t dmai_nexus_private; 8907c478bd9Sstevel@tonic-gate void *dmai_iopte; 8917c478bd9Sstevel@tonic-gate uint_t *dmai_sbi; 8927c478bd9Sstevel@tonic-gate void *dmai_minfo; /* random mapping information */ 8937c478bd9Sstevel@tonic-gate dev_info_t *dmai_rdip; /* original requester's dev_info_t */ 8947c478bd9Sstevel@tonic-gate ddi_dma_obj_t dmai_object; /* requester's object */ 8957c478bd9Sstevel@tonic-gate ddi_dma_attr_t dmai_attr; /* DMA attributes */ 8967c478bd9Sstevel@tonic-gate ddi_dma_cookie_t *dmai_cookie; /* pointer to first DMA cookie */ 8977c478bd9Sstevel@tonic-gate 8987c478bd9Sstevel@tonic-gate int (*dmai_fault_check)(struct ddi_dma_impl *handle); 8997c478bd9Sstevel@tonic-gate void (*dmai_fault_notify)(struct ddi_dma_impl *handle); 9007c478bd9Sstevel@tonic-gate int dmai_fault; 9017c478bd9Sstevel@tonic-gate ndi_err_t dmai_error; 9027c478bd9Sstevel@tonic-gate 9037c478bd9Sstevel@tonic-gate } ddi_dma_impl_t; 9047c478bd9Sstevel@tonic-gate 9057c478bd9Sstevel@tonic-gate #elif defined(__x86) 9067c478bd9Sstevel@tonic-gate 90712f080e7Smrj /* 90812f080e7Smrj * ddi_dma_impl portion that genunix (sunddi.c) depends on. x86 rootnex 90912f080e7Smrj * implementation specific state is in dmai_private. 91012f080e7Smrj */ 9117c478bd9Sstevel@tonic-gate typedef struct ddi_dma_impl { 91212f080e7Smrj ddi_dma_cookie_t *dmai_cookie; /* array of DMA cookies */ 9139a63ec27SRobert Mustacchi uint_t dmai_ncookies; 9149a63ec27SRobert Mustacchi uint_t dmai_curcookie; 91512f080e7Smrj void *dmai_private; 9167c478bd9Sstevel@tonic-gate 9177c478bd9Sstevel@tonic-gate /* 9187c478bd9Sstevel@tonic-gate * Information gathered from the original dma mapping 9197c478bd9Sstevel@tonic-gate * request and saved for the lifetime of the mapping. 9207c478bd9Sstevel@tonic-gate */ 9217c478bd9Sstevel@tonic-gate uint_t dmai_minxfer; 9227c478bd9Sstevel@tonic-gate uint_t dmai_burstsizes; 9237c478bd9Sstevel@tonic-gate uint_t dmai_rflags; /* requester's flags + ours */ 9247c478bd9Sstevel@tonic-gate int dmai_nwin; 9257c478bd9Sstevel@tonic-gate dev_info_t *dmai_rdip; /* original requester's dev_info_t */ 9267c478bd9Sstevel@tonic-gate 9277c478bd9Sstevel@tonic-gate ddi_dma_attr_t dmai_attr; /* DMA attributes */ 9287c478bd9Sstevel@tonic-gate 9297c478bd9Sstevel@tonic-gate int (*dmai_fault_check)(struct ddi_dma_impl *handle); 9307c478bd9Sstevel@tonic-gate void (*dmai_fault_notify)(struct ddi_dma_impl *handle); 9317c478bd9Sstevel@tonic-gate int dmai_fault; 9327c478bd9Sstevel@tonic-gate ndi_err_t dmai_error; 9337c478bd9Sstevel@tonic-gate } ddi_dma_impl_t; 9347c478bd9Sstevel@tonic-gate 9357c478bd9Sstevel@tonic-gate #else 9367c478bd9Sstevel@tonic-gate #error "struct ddi_dma_impl not defined for this architecture" 9377c478bd9Sstevel@tonic-gate #endif /* defined(__sparc) */ 9387c478bd9Sstevel@tonic-gate 9397c478bd9Sstevel@tonic-gate /* 9407c478bd9Sstevel@tonic-gate * For now DMA segments share state with the DMA handle 9417c478bd9Sstevel@tonic-gate */ 9427c478bd9Sstevel@tonic-gate typedef ddi_dma_impl_t ddi_dma_seg_impl_t; 9437c478bd9Sstevel@tonic-gate 9447c478bd9Sstevel@tonic-gate /* 9457c478bd9Sstevel@tonic-gate * These flags use reserved bits from the dma request flags. 9467c478bd9Sstevel@tonic-gate * 9477c478bd9Sstevel@tonic-gate * A note about the DMP_NOSYNC flags: the root nexus will 9487c478bd9Sstevel@tonic-gate * set these as it sees best. If an intermediate nexus 9497c478bd9Sstevel@tonic-gate * actually needs these operations, then during the unwind 9507c478bd9Sstevel@tonic-gate * from the call to ddi_dma_bind, the nexus driver *must* 9517c478bd9Sstevel@tonic-gate * clear the appropriate flag(s). This is because, as an 9527c478bd9Sstevel@tonic-gate * optimization, ddi_dma_sync(9F) looks at these flags before 9537c478bd9Sstevel@tonic-gate * deciding to spend the time going back up the tree. 9547c478bd9Sstevel@tonic-gate */ 9557c478bd9Sstevel@tonic-gate 9567c478bd9Sstevel@tonic-gate #define _DMCM1 DDI_DMA_RDWR|DDI_DMA_REDZONE|DDI_DMA_PARTIAL 9577c478bd9Sstevel@tonic-gate #define _DMCM2 DDI_DMA_CONSISTENT|DMP_VMEREQ 9587c478bd9Sstevel@tonic-gate #define DMP_DDIFLAGS (_DMCM1|_DMCM2) 9597c478bd9Sstevel@tonic-gate #define DMP_SHADOW 0x20 9607c478bd9Sstevel@tonic-gate #define DMP_LKIOPB 0x40 9617c478bd9Sstevel@tonic-gate #define DMP_LKSYSV 0x80 9627c478bd9Sstevel@tonic-gate #define DMP_IOCACHE 0x100 9637c478bd9Sstevel@tonic-gate #define DMP_USEHAT 0x200 9647c478bd9Sstevel@tonic-gate #define DMP_PHYSADDR 0x400 9657c478bd9Sstevel@tonic-gate #define DMP_INVALID 0x800 9667c478bd9Sstevel@tonic-gate #define DMP_NOLIMIT 0x1000 9677c478bd9Sstevel@tonic-gate #define DMP_VMEREQ 0x10000000 9687c478bd9Sstevel@tonic-gate #define DMP_BYPASSNEXUS 0x20000000 9697c478bd9Sstevel@tonic-gate #define DMP_NODEVSYNC 0x40000000 9707c478bd9Sstevel@tonic-gate #define DMP_NOCPUSYNC 0x80000000 9717c478bd9Sstevel@tonic-gate #define DMP_NOSYNC (DMP_NODEVSYNC|DMP_NOCPUSYNC) 9727c478bd9Sstevel@tonic-gate 9737c478bd9Sstevel@tonic-gate /* 9747c478bd9Sstevel@tonic-gate * In order to complete a device to device mapping that 9757c478bd9Sstevel@tonic-gate * has percolated as high as an IU nexus (gone that high 9767c478bd9Sstevel@tonic-gate * because the DMA request is a VADDR type), we define 9777c478bd9Sstevel@tonic-gate * structure to use with the DDI_CTLOPS_DMAPMAPC request 9787c478bd9Sstevel@tonic-gate * that re-traverses the request tree to finish the 9797c478bd9Sstevel@tonic-gate * DMA 'mapping' for a device. 9807c478bd9Sstevel@tonic-gate */ 9817c478bd9Sstevel@tonic-gate struct dma_phys_mapc { 9827c478bd9Sstevel@tonic-gate struct ddi_dma_req *dma_req; /* original request */ 9837c478bd9Sstevel@tonic-gate ddi_dma_impl_t *mp; /* current handle, or none */ 9847c478bd9Sstevel@tonic-gate int nptes; /* number of ptes */ 9857c478bd9Sstevel@tonic-gate void *ptes; /* ptes already read */ 9867c478bd9Sstevel@tonic-gate }; 9877c478bd9Sstevel@tonic-gate 9887c478bd9Sstevel@tonic-gate #define MAXCALLBACK 20 9897c478bd9Sstevel@tonic-gate 9907c478bd9Sstevel@tonic-gate /* 9917c478bd9Sstevel@tonic-gate * Callback definitions 9927c478bd9Sstevel@tonic-gate */ 9937c478bd9Sstevel@tonic-gate struct ddi_callback { 9947c478bd9Sstevel@tonic-gate struct ddi_callback *c_nfree; 9957c478bd9Sstevel@tonic-gate struct ddi_callback *c_nlist; 9967c478bd9Sstevel@tonic-gate int (*c_call)(); 9977c478bd9Sstevel@tonic-gate int c_count; 9987c478bd9Sstevel@tonic-gate caddr_t c_arg; 9997c478bd9Sstevel@tonic-gate size_t c_size; 10007c478bd9Sstevel@tonic-gate }; 10017c478bd9Sstevel@tonic-gate 1002b9ccdc5aScth /* 1003b9ccdc5aScth * Pure dynamic property declaration. A pure dynamic property is a property 1004b9ccdc5aScth * for which a driver's prop_op(9E) implementation will return a value on 1005b9ccdc5aScth * demand, but the property name does not exist on a property list (global, 1006b9ccdc5aScth * driver, system, or hardware) - the person asking for the value must know 1007b9ccdc5aScth * the name and type information. 1008b9ccdc5aScth * 1009b9ccdc5aScth * For a pure dynamic property to show up in a di_init() devinfo shapshot, the 1010b9ccdc5aScth * devinfo driver must know name and type. The i_ddi_prop_dyn_t mechanism 1011b9ccdc5aScth * allows a driver to define an array of the name/type information of its 1012b9ccdc5aScth * dynamic properties. When a driver declares its dynamic properties in a 1013b9ccdc5aScth * i_ddi_prop_dyn_t array, and registers that array using 1014b9ccdc5aScth * i_ddi_prop_dyn_driver_set() the devinfo driver has sufficient information 1015b9ccdc5aScth * to represent the properties in a snapshot - calling the driver's 1016b9ccdc5aScth * prop_op(9E) to obtain values. 1017b9ccdc5aScth * 1018b9ccdc5aScth * The last element of a i_ddi_prop_dyn_t is detected via a NULL dp_name value. 1019b9ccdc5aScth * 1020b9ccdc5aScth * A pure dynamic property name associated with a minor_node/dev_t should be 1021b9ccdc5aScth * defined with a dp_spec_type of S_IFCHR or S_IFBLK, as appropriate. The 1022b9ccdc5aScth * driver's prop_op(9E) entry point will be called for all 1023b9ccdc5aScth * ddi_create_minor_node(9F) nodes of the specified spec_type. For a driver 1024b9ccdc5aScth * where not all minor_node/dev_t combinations support the same named 1025b9ccdc5aScth * properties, it is the responsibility of the prop_op(9E) implementation to 1026b9ccdc5aScth * sort out what combinations are appropriate. 1027b9ccdc5aScth * 1028b9ccdc5aScth * A pure dynamic property of a devinfo node should be defined with a 1029b9ccdc5aScth * dp_spec_type of 0. 1030b9ccdc5aScth * 1031b9ccdc5aScth * NB: Public DDI property interfaces no longer support pure dynamic 1032b9ccdc5aScth * properties, but they are still still used. A prime example is the cmlb 1033b9ccdc5aScth * implementation of size(9P) properties. Using pure dynamic properties 1034b9ccdc5aScth * reduces the space required to maintain per-partition information. Since 1035b9ccdc5aScth * there are no public interfaces to create pure dynamic properties, 1036b9ccdc5aScth * the i_ddi_prop_dyn_t mechanism should remain private. 1037b9ccdc5aScth */ 1038b9ccdc5aScth typedef struct i_ddi_prop_dyn { 1039b9ccdc5aScth char *dp_name; /* name of dynamic property */ 1040b9ccdc5aScth int dp_type; /* DDI_PROP_TYPE_ of property */ 1041b9ccdc5aScth int dp_spec_type; /* 0, S_IFCHR, S_IFBLK */ 1042b9ccdc5aScth } i_ddi_prop_dyn_t; 1043b9ccdc5aScth void i_ddi_prop_dyn_driver_set(dev_info_t *, 1044b9ccdc5aScth i_ddi_prop_dyn_t *); 1045b9ccdc5aScth i_ddi_prop_dyn_t *i_ddi_prop_dyn_driver_get(dev_info_t *); 1046b9ccdc5aScth void i_ddi_prop_dyn_parent_set(dev_info_t *, 1047b9ccdc5aScth i_ddi_prop_dyn_t *); 1048b9ccdc5aScth i_ddi_prop_dyn_t *i_ddi_prop_dyn_parent_get(dev_info_t *); 1049b9ccdc5aScth void i_ddi_prop_dyn_cache_invalidate(dev_info_t *, 1050b9ccdc5aScth i_ddi_prop_dyn_t *); 10517c478bd9Sstevel@tonic-gate 10527c478bd9Sstevel@tonic-gate /* 10537c478bd9Sstevel@tonic-gate * Device id - Internal definition. 10547c478bd9Sstevel@tonic-gate */ 10557c478bd9Sstevel@tonic-gate #define DEVID_MAGIC_MSB 0x69 10567c478bd9Sstevel@tonic-gate #define DEVID_MAGIC_LSB 0x64 10577c478bd9Sstevel@tonic-gate #define DEVID_REV_MSB 0x00 10587c478bd9Sstevel@tonic-gate #define DEVID_REV_LSB 0x01 10597c478bd9Sstevel@tonic-gate #define DEVID_HINT_SIZE 4 10607c478bd9Sstevel@tonic-gate 10617c478bd9Sstevel@tonic-gate typedef struct impl_devid { 10627c478bd9Sstevel@tonic-gate uchar_t did_magic_hi; /* device id magic # (msb) */ 10637c478bd9Sstevel@tonic-gate uchar_t did_magic_lo; /* device id magic # (lsb) */ 10647c478bd9Sstevel@tonic-gate uchar_t did_rev_hi; /* device id revision # (msb) */ 10657c478bd9Sstevel@tonic-gate uchar_t did_rev_lo; /* device id revision # (lsb) */ 10667c478bd9Sstevel@tonic-gate uchar_t did_type_hi; /* device id type (msb) */ 10677c478bd9Sstevel@tonic-gate uchar_t did_type_lo; /* device id type (lsb) */ 10687c478bd9Sstevel@tonic-gate uchar_t did_len_hi; /* length of devid data (msb) */ 10697c478bd9Sstevel@tonic-gate uchar_t did_len_lo; /* length of devid data (lsb) */ 10707c478bd9Sstevel@tonic-gate char did_driver[DEVID_HINT_SIZE]; /* driver name - HINT */ 10717c478bd9Sstevel@tonic-gate char did_id[1]; /* start of device id data */ 10727c478bd9Sstevel@tonic-gate } impl_devid_t; 10737c478bd9Sstevel@tonic-gate 10747c478bd9Sstevel@tonic-gate #define DEVID_GETTYPE(devid) ((ushort_t) \ 10757c478bd9Sstevel@tonic-gate (((devid)->did_type_hi << NBBY) + \ 10767c478bd9Sstevel@tonic-gate (devid)->did_type_lo)) 10777c478bd9Sstevel@tonic-gate 10787c478bd9Sstevel@tonic-gate #define DEVID_FORMTYPE(devid, type) (devid)->did_type_hi = hibyte((type)); \ 10797c478bd9Sstevel@tonic-gate (devid)->did_type_lo = lobyte((type)); 10807c478bd9Sstevel@tonic-gate 10817c478bd9Sstevel@tonic-gate #define DEVID_GETLEN(devid) ((ushort_t) \ 10827c478bd9Sstevel@tonic-gate (((devid)->did_len_hi << NBBY) + \ 10837c478bd9Sstevel@tonic-gate (devid)->did_len_lo)) 10847c478bd9Sstevel@tonic-gate 10857c478bd9Sstevel@tonic-gate #define DEVID_FORMLEN(devid, len) (devid)->did_len_hi = hibyte((len)); \ 10867c478bd9Sstevel@tonic-gate (devid)->did_len_lo = lobyte((len)); 10877c478bd9Sstevel@tonic-gate 10887c478bd9Sstevel@tonic-gate /* 10897c478bd9Sstevel@tonic-gate * Per PSARC/1995/352, a binary devid contains fields for <magic number>, 10907c478bd9Sstevel@tonic-gate * <revision>, <driver_hint>, <type>, <id_length>, and the <id> itself. 10917c478bd9Sstevel@tonic-gate * This proposal would encode the binary devid into a string consisting 10927c478bd9Sstevel@tonic-gate * of "<magic><revision>,<driver_hint>@<type><id>" as indicated below 10937c478bd9Sstevel@tonic-gate * (<id_length> is rederived from the length of the string 10947c478bd9Sstevel@tonic-gate * representation of the <id>): 10957c478bd9Sstevel@tonic-gate * 10967c478bd9Sstevel@tonic-gate * <magic> ->"id" 10977c478bd9Sstevel@tonic-gate * 10987c478bd9Sstevel@tonic-gate * <rev> ->"%d" // "0" -> type of DEVID_NONE "id0" 10997c478bd9Sstevel@tonic-gate * // NOTE: PSARC/1995/352 <revision> is "1". 11007c478bd9Sstevel@tonic-gate * // NOTE: support limited to 10 revisions 11017c478bd9Sstevel@tonic-gate * // in current implementation 11027c478bd9Sstevel@tonic-gate * 11037c478bd9Sstevel@tonic-gate * <driver_hint> ->"%s" // "sd"/"ssd" 11047c478bd9Sstevel@tonic-gate * // NOTE: driver names limited to 4 11057c478bd9Sstevel@tonic-gate * // characters for <revision> "1" 11067c478bd9Sstevel@tonic-gate * 11077c478bd9Sstevel@tonic-gate * <type> ->'w' | // DEVID_SCSI3_WWN <hex_id> 11087c478bd9Sstevel@tonic-gate * 'W' | // DEVID_SCSI3_WWN <ascii_id> 11097c478bd9Sstevel@tonic-gate * 't' | // DEVID_SCSI3_VPD_T10 <hex_id> 11107c478bd9Sstevel@tonic-gate * 'T' | // DEVID_SCSI3_VPD_T10 <ascii_id> 11117c478bd9Sstevel@tonic-gate * 'x' | // DEVID_SCSI3_VPD_EUI <hex_id> 11127c478bd9Sstevel@tonic-gate * 'X' | // DEVID_SCSI3_VPD_EUI <ascii_id> 11137c478bd9Sstevel@tonic-gate * 'n' | // DEVID_SCSI3_VPD_NAA <hex_id> 11147c478bd9Sstevel@tonic-gate * 'N' | // DEVID_SCSI3_VPD_NAA <ascii_id> 11157c478bd9Sstevel@tonic-gate * 's' | // DEVID_SCSI_SERIAL <hex_id> 11167c478bd9Sstevel@tonic-gate * 'S' | // DEVID_SCSI_SERIAL <ascii_id> 11177c478bd9Sstevel@tonic-gate * 'f' | // DEVID_FAB <hex_id> 11187c478bd9Sstevel@tonic-gate * 'F' | // DEVID_FAB <ascii_id> 11197c478bd9Sstevel@tonic-gate * 'e' | // DEVID_ENCAP <hex_id> 11207c478bd9Sstevel@tonic-gate * 'E' | // DEVID_ENCAP <ascii_id> 11217c478bd9Sstevel@tonic-gate * 'a' | // DEVID_ATA_SERIAL <hex_id> 11227c478bd9Sstevel@tonic-gate * 'A' | // DEVID_ATA_SERIAL <ascii_id> 1123*b8f43eb6SHans Rosenfeld * 'd' | // DEVID_NVME_NSID <hex_id> 1124*b8f43eb6SHans Rosenfeld * 'D' | // DEVID_NVME_NSID <ascii_id> 1125*b8f43eb6SHans Rosenfeld * 'i' | // DEVID_NVME_EUI64 <hex_id> 1126*b8f43eb6SHans Rosenfeld * 'I' | // DEVID_NVME_EUI64 <ascii_id> 1127*b8f43eb6SHans Rosenfeld * 'g' | // DEVID_NVME_NGUID <hex_id> 1128*b8f43eb6SHans Rosenfeld * 'G' | // DEVID_NVME_NGUID <ascii_id> 11297c478bd9Sstevel@tonic-gate * 'u' | // unknown <hex_id> 11307c478bd9Sstevel@tonic-gate * 'U' // unknown <ascii_id> 11317c478bd9Sstevel@tonic-gate * // NOTE:lower case -> <hex_id> 11327c478bd9Sstevel@tonic-gate * // upper case -> <ascii_id> 11337c478bd9Sstevel@tonic-gate * // NOTE:this covers all types currently 11347c478bd9Sstevel@tonic-gate * // defined for <revision> 1. 11357c478bd9Sstevel@tonic-gate * // NOTE:a <type> can be added 11367c478bd9Sstevel@tonic-gate * // without changing the <revision>. 11377c478bd9Sstevel@tonic-gate * 11387c478bd9Sstevel@tonic-gate * <id> -> <ascii_id> | // <type> is upper case 11397c478bd9Sstevel@tonic-gate * <hex_id> // <type> is lower case 11407c478bd9Sstevel@tonic-gate * 11417c478bd9Sstevel@tonic-gate * <ascii_id> // only if all bytes of binary <id> field 11427c478bd9Sstevel@tonic-gate * // are in the set: 11437c478bd9Sstevel@tonic-gate * // [A-Z][a-z][0-9]+-.= and space and 0x00 11447c478bd9Sstevel@tonic-gate * // the encoded form is: 11457c478bd9Sstevel@tonic-gate * // [A-Z][a-z][0-9]+-.= and _ and ~ 11467c478bd9Sstevel@tonic-gate * // NOTE: ' ' <=> '_', 0x00 <=> '~' 11477c478bd9Sstevel@tonic-gate * // these sets are chosen to avoid shell 11487c478bd9Sstevel@tonic-gate * // and conflicts with DDI node names. 11497c478bd9Sstevel@tonic-gate * 11507c478bd9Sstevel@tonic-gate * <hex_id> // if not <ascii_id>; each byte of binary 11517c478bd9Sstevel@tonic-gate * // <id> maps a to 2 digit ascii hex 11527c478bd9Sstevel@tonic-gate * // representation in the string. 11537c478bd9Sstevel@tonic-gate * 11547c478bd9Sstevel@tonic-gate * This encoding provides a meaningful correlation between the /devices 11557c478bd9Sstevel@tonic-gate * path and the devid string where possible. 11567c478bd9Sstevel@tonic-gate * 11577c478bd9Sstevel@tonic-gate * Fibre: 11587c478bd9Sstevel@tonic-gate * sbus@6,0/SUNW,socal@d,10000/sf@1,0/ssd@w21000020370bb488,0:c,raw 11597c478bd9Sstevel@tonic-gate * id1,ssd@w20000020370bb488:c,raw 11607c478bd9Sstevel@tonic-gate * 11617c478bd9Sstevel@tonic-gate * Copper: 11627c478bd9Sstevel@tonic-gate * sbus@7,0/SUNW,fas@3,8800000/sd@a,0:c 11637c478bd9Sstevel@tonic-gate * id1,sd@SIBM_____1XY210__________:c 11647c478bd9Sstevel@tonic-gate */ 11657c478bd9Sstevel@tonic-gate /* determine if a byte of an id meets ASCII representation requirements */ 11667c478bd9Sstevel@tonic-gate #define DEVID_IDBYTE_ISASCII(b) ( \ 11677c478bd9Sstevel@tonic-gate (((b) >= 'a') && ((b) <= 'z')) || \ 11687c478bd9Sstevel@tonic-gate (((b) >= 'A') && ((b) <= 'Z')) || \ 11697c478bd9Sstevel@tonic-gate (((b) >= '0') && ((b) <= '9')) || \ 11707c478bd9Sstevel@tonic-gate (b == '+') || (b == '-') || (b == '.') || (b == '=') || \ 11717c478bd9Sstevel@tonic-gate (b == ' ') || (b == 0x00)) 11727c478bd9Sstevel@tonic-gate 11737c478bd9Sstevel@tonic-gate /* set type to lower case to indicate that the did_id field is ascii */ 11747c478bd9Sstevel@tonic-gate #define DEVID_TYPE_SETASCII(c) (c - 0x20) /* 'a' -> 'A' */ 11757c478bd9Sstevel@tonic-gate 11767c478bd9Sstevel@tonic-gate /* determine from type if did_id field is binary or ascii */ 11777c478bd9Sstevel@tonic-gate #define DEVID_TYPE_ISASCII(c) (((c) >= 'A') && ((c) <= 'Z')) 11787c478bd9Sstevel@tonic-gate 11797c478bd9Sstevel@tonic-gate /* convert type field from binary to ascii */ 11807c478bd9Sstevel@tonic-gate #define DEVID_TYPE_BINTOASCII(b) ( \ 11817c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_WWN) ? 'w' : \ 11827c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_VPD_T10) ? 't' : \ 11837c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_VPD_EUI) ? 'x' : \ 11847c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_VPD_NAA) ? 'n' : \ 11857c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI_SERIAL) ? 's' : \ 11867c478bd9Sstevel@tonic-gate ((b) == DEVID_FAB) ? 'f' : \ 11877c478bd9Sstevel@tonic-gate ((b) == DEVID_ENCAP) ? 'e' : \ 11887c478bd9Sstevel@tonic-gate ((b) == DEVID_ATA_SERIAL) ? 'a' : \ 1189*b8f43eb6SHans Rosenfeld ((b) == DEVID_NVME_NSID) ? 'd' : \ 1190*b8f43eb6SHans Rosenfeld ((b) == DEVID_NVME_EUI64) ? 'i' : \ 1191*b8f43eb6SHans Rosenfeld ((b) == DEVID_NVME_NGUID) ? 'g' : \ 11927c478bd9Sstevel@tonic-gate 'u') /* unknown */ 11937c478bd9Sstevel@tonic-gate 11947c478bd9Sstevel@tonic-gate /* convert type field from ascii to binary */ 11957c478bd9Sstevel@tonic-gate #define DEVID_TYPE_ASCIITOBIN(c) ( \ 11967c478bd9Sstevel@tonic-gate (((c) == 'w') || ((c) == 'W')) ? DEVID_SCSI3_WWN : \ 11977c478bd9Sstevel@tonic-gate (((c) == 't') || ((c) == 'T')) ? DEVID_SCSI3_VPD_T10 : \ 11987c478bd9Sstevel@tonic-gate (((c) == 'x') || ((c) == 'X')) ? DEVID_SCSI3_VPD_EUI : \ 11997c478bd9Sstevel@tonic-gate (((c) == 'n') || ((c) == 'N')) ? DEVID_SCSI3_VPD_NAA : \ 12007c478bd9Sstevel@tonic-gate (((c) == 's') || ((c) == 'S')) ? DEVID_SCSI_SERIAL : \ 12017c478bd9Sstevel@tonic-gate (((c) == 'f') || ((c) == 'F')) ? DEVID_FAB : \ 12027c478bd9Sstevel@tonic-gate (((c) == 'e') || ((c) == 'E')) ? DEVID_ENCAP : \ 12037c478bd9Sstevel@tonic-gate (((c) == 'a') || ((c) == 'A')) ? DEVID_ATA_SERIAL : \ 1204*b8f43eb6SHans Rosenfeld (((c) == 'd') || ((c) == 'D')) ? DEVID_NVME_NSID : \ 1205*b8f43eb6SHans Rosenfeld (((c) == 'i') || ((c) == 'I')) ? DEVID_NVME_EUI64 : \ 1206*b8f43eb6SHans Rosenfeld (((c) == 'g') || ((c) == 'G')) ? DEVID_NVME_NGUID : \ 12077c478bd9Sstevel@tonic-gate DEVID_MAXTYPE +1) /* unknown */ 12087c478bd9Sstevel@tonic-gate 12097c478bd9Sstevel@tonic-gate /* determine if the type should be forced to hex encoding (non-ascii) */ 12107c478bd9Sstevel@tonic-gate #define DEVID_TYPE_BIN_FORCEHEX(b) ( \ 12117c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_WWN) || \ 12127c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_VPD_EUI) || \ 12137c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_VPD_NAA) || \ 1214*b8f43eb6SHans Rosenfeld ((b) == DEVID_NVME_EUI64) || \ 1215*b8f43eb6SHans Rosenfeld ((b) == DEVID_NVME_NGUID) || \ 12167c478bd9Sstevel@tonic-gate ((b) == DEVID_FAB)) 12177c478bd9Sstevel@tonic-gate 12187c478bd9Sstevel@tonic-gate /* determine if the type is from a scsi3 vpd */ 12197c478bd9Sstevel@tonic-gate #define IS_DEVID_SCSI3_VPD_TYPE(b) ( \ 12207c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_VPD_T10) || \ 12217c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_VPD_EUI) || \ 12227c478bd9Sstevel@tonic-gate ((b) == DEVID_SCSI3_VPD_NAA)) 12237c478bd9Sstevel@tonic-gate 12247c478bd9Sstevel@tonic-gate /* convert rev field from binary to ascii (only supports 10 revs) */ 12257c478bd9Sstevel@tonic-gate #define DEVID_REV_BINTOASCII(b) (b + '0') 12267c478bd9Sstevel@tonic-gate 12277c478bd9Sstevel@tonic-gate /* convert rev field from ascii to binary (only supports 10 revs) */ 12287c478bd9Sstevel@tonic-gate #define DEVID_REV_ASCIITOBIN(c) (c - '0') 12297c478bd9Sstevel@tonic-gate 12307c478bd9Sstevel@tonic-gate /* name of devid property */ 12317c478bd9Sstevel@tonic-gate #define DEVID_PROP_NAME "devid" 12327c478bd9Sstevel@tonic-gate 12337c478bd9Sstevel@tonic-gate /* 12347c478bd9Sstevel@tonic-gate * prop_name used by pci_{save,restore}_config_regs() 12357c478bd9Sstevel@tonic-gate */ 12367c478bd9Sstevel@tonic-gate #define SAVED_CONFIG_REGS "pci-config-regs" 12377c478bd9Sstevel@tonic-gate #define SAVED_CONFIG_REGS_MASK "pcie-config-regs-mask" 12387c478bd9Sstevel@tonic-gate #define SAVED_CONFIG_REGS_CAPINFO "pci-cap-info" 12397c478bd9Sstevel@tonic-gate 12407c478bd9Sstevel@tonic-gate typedef struct pci_config_header_state { 12417c478bd9Sstevel@tonic-gate uint16_t chs_command; 12427c478bd9Sstevel@tonic-gate uint8_t chs_cache_line_size; 12437c478bd9Sstevel@tonic-gate uint8_t chs_latency_timer; 12447c478bd9Sstevel@tonic-gate uint8_t chs_header_type; 12457c478bd9Sstevel@tonic-gate uint8_t chs_sec_latency_timer; 12467c478bd9Sstevel@tonic-gate uint8_t chs_bridge_control; 12477c478bd9Sstevel@tonic-gate uint32_t chs_base0; 12487c478bd9Sstevel@tonic-gate uint32_t chs_base1; 12497c478bd9Sstevel@tonic-gate uint32_t chs_base2; 12507c478bd9Sstevel@tonic-gate uint32_t chs_base3; 12517c478bd9Sstevel@tonic-gate uint32_t chs_base4; 12527c478bd9Sstevel@tonic-gate uint32_t chs_base5; 12537c478bd9Sstevel@tonic-gate } pci_config_header_state_t; 12547c478bd9Sstevel@tonic-gate 12557c478bd9Sstevel@tonic-gate #ifdef _KERNEL 12567c478bd9Sstevel@tonic-gate 12577c478bd9Sstevel@tonic-gate typedef struct pci_cap_save_desc { 12587c478bd9Sstevel@tonic-gate uint16_t cap_offset; 12597c478bd9Sstevel@tonic-gate uint16_t cap_id; 12607c478bd9Sstevel@tonic-gate uint32_t cap_nregs; 12617c478bd9Sstevel@tonic-gate } pci_cap_save_desc_t; 12627c478bd9Sstevel@tonic-gate 12637c478bd9Sstevel@tonic-gate typedef struct pci_cap_entry { 12647c478bd9Sstevel@tonic-gate uint16_t cap_id; 1265cb7ea99dSJimmy Vetayases uint16_t cap_reg; 1266cb7ea99dSJimmy Vetayases uint16_t cap_mask; 12677c478bd9Sstevel@tonic-gate uint32_t cap_ndwords; 12687c478bd9Sstevel@tonic-gate uint32_t (*cap_save_func)(ddi_acc_handle_t confhdl, uint16_t cap_ptr, 12697c478bd9Sstevel@tonic-gate uint32_t *regbuf, uint32_t ndwords); 12707c478bd9Sstevel@tonic-gate } pci_cap_entry_t; 12717c478bd9Sstevel@tonic-gate 12727c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 12737c478bd9Sstevel@tonic-gate 12747c478bd9Sstevel@tonic-gate #ifdef __cplusplus 12757c478bd9Sstevel@tonic-gate } 12767c478bd9Sstevel@tonic-gate #endif 12777c478bd9Sstevel@tonic-gate 12787c478bd9Sstevel@tonic-gate #endif /* _SYS_DDI_IMPLDEFS_H */ 1279