1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1995-1999 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 28*7c478bd9Sstevel@tonic-gate #include <sys/systm.h> 29*7c478bd9Sstevel@tonic-gate #include <sys/user.h> 30*7c478bd9Sstevel@tonic-gate #include <sys/buf.h> 31*7c478bd9Sstevel@tonic-gate #include <sys/file.h> 32*7c478bd9Sstevel@tonic-gate #include <sys/uio.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/conf.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/autoconf.h> 36*7c478bd9Sstevel@tonic-gate #include <sys/vtoc.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/dkio.h> 38*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/kstat.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/kobj.h> 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate #include <sys/pctypes.h> 47*7c478bd9Sstevel@tonic-gate #include <pcmcia/sys/cs_types.h> 48*7c478bd9Sstevel@tonic-gate #include <pcmcia/sys/cis.h> 49*7c478bd9Sstevel@tonic-gate #include <pcmcia/sys/cis_handlers.h> 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate /* 52*7c478bd9Sstevel@tonic-gate * 53*7c478bd9Sstevel@tonic-gate * The following speed tables are used by cistpl_devspeed() to generate 54*7c478bd9Sstevel@tonic-gate * device speeds from tuple data. 55*7c478bd9Sstevel@tonic-gate * 56*7c478bd9Sstevel@tonic-gate * Define the device speed table. For a description of this table's contents, 57*7c478bd9Sstevel@tonic-gate * see PCMCIA Release 2.01 Card Metaformat pg. 5-14 table 5-12. 58*7c478bd9Sstevel@tonic-gate * 59*7c478bd9Sstevel@tonic-gate * All times in this table are in nS. 60*7c478bd9Sstevel@tonic-gate */ 61*7c478bd9Sstevel@tonic-gate uint32_t cistpl_devspeed_table[CISTPL_DEVSPEED_MAX_TBL] = { 62*7c478bd9Sstevel@tonic-gate 0, /* 0x00 - DSPEED_NULL */ 63*7c478bd9Sstevel@tonic-gate 250, /* 0x01 - DSPEED_250NS */ 64*7c478bd9Sstevel@tonic-gate 200, /* 0x02 - DSPEED_200NS */ 65*7c478bd9Sstevel@tonic-gate 150, /* 0x03 - DSPEED_150NS */ 66*7c478bd9Sstevel@tonic-gate 100, /* 0x04 - DSPEED_100NS */ 67*7c478bd9Sstevel@tonic-gate 0, /* 0x05 - reserved */ 68*7c478bd9Sstevel@tonic-gate 0, /* 0x06 - reserved */ 69*7c478bd9Sstevel@tonic-gate 0 /* 0x07 - use extended speed byte */ 70*7c478bd9Sstevel@tonic-gate }; 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate /* 73*7c478bd9Sstevel@tonic-gate * Define the power-of-10 table. 74*7c478bd9Sstevel@tonic-gate */ 75*7c478bd9Sstevel@tonic-gate uint32_t cistpl_exspeed_tenfac[] = { 76*7c478bd9Sstevel@tonic-gate 1, /* 10^0 */ 77*7c478bd9Sstevel@tonic-gate 10, /* 10^1 */ 78*7c478bd9Sstevel@tonic-gate 100, /* 10^2 */ 79*7c478bd9Sstevel@tonic-gate 1000, /* 10^3 */ 80*7c478bd9Sstevel@tonic-gate 10000, /* 10^4 */ 81*7c478bd9Sstevel@tonic-gate 100000, /* 10^5 */ 82*7c478bd9Sstevel@tonic-gate 1000000, /* 10^6 */ 83*7c478bd9Sstevel@tonic-gate 10000000 /* 10^7 */ 84*7c478bd9Sstevel@tonic-gate }; 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* 87*7c478bd9Sstevel@tonic-gate * The extended device speed code mantissa table. 88*7c478bd9Sstevel@tonic-gate * 89*7c478bd9Sstevel@tonic-gate * This table is described in PCMCIA Release 2.01 Card Metaformat 90*7c478bd9Sstevel@tonic-gate * pg. 5-15 table 5-13. 91*7c478bd9Sstevel@tonic-gate * 92*7c478bd9Sstevel@tonic-gate * The description of this table uses non-integer values. We multiply 93*7c478bd9Sstevel@tonic-gate * everything by 10 before it goes into the table, and the code 94*7c478bd9Sstevel@tonic-gate * will divide by 10 after it calculates the device speed. 95*7c478bd9Sstevel@tonic-gate */ 96*7c478bd9Sstevel@tonic-gate uint32_t cistpl_devspeed_man[CISTPL_DEVSPEED_MAX_MAN] = { 97*7c478bd9Sstevel@tonic-gate 0, /* no units */ 98*7c478bd9Sstevel@tonic-gate 10, /* no units */ 99*7c478bd9Sstevel@tonic-gate 12, /* no units */ 100*7c478bd9Sstevel@tonic-gate 13, /* no units */ 101*7c478bd9Sstevel@tonic-gate 15, /* no units */ 102*7c478bd9Sstevel@tonic-gate 20, /* no units */ 103*7c478bd9Sstevel@tonic-gate 25, /* no units */ 104*7c478bd9Sstevel@tonic-gate 30, /* no units */ 105*7c478bd9Sstevel@tonic-gate 35, /* no units */ 106*7c478bd9Sstevel@tonic-gate 40, /* no units */ 107*7c478bd9Sstevel@tonic-gate 45, /* no units */ 108*7c478bd9Sstevel@tonic-gate 50, /* no units */ 109*7c478bd9Sstevel@tonic-gate 55, /* no units */ 110*7c478bd9Sstevel@tonic-gate 60, /* no units */ 111*7c478bd9Sstevel@tonic-gate 70, /* no units */ 112*7c478bd9Sstevel@tonic-gate 80, /* no units */ 113*7c478bd9Sstevel@tonic-gate }; 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate /* 116*7c478bd9Sstevel@tonic-gate * The extended device speed code exponent table. 117*7c478bd9Sstevel@tonic-gate * 118*7c478bd9Sstevel@tonic-gate * This table is described in PCMCIA Release 2.01 Card Metaformat 119*7c478bd9Sstevel@tonic-gate * pg. 5-15 table 5-13. 120*7c478bd9Sstevel@tonic-gate * 121*7c478bd9Sstevel@tonic-gate * The description of this table uses various timing units. This 122*7c478bd9Sstevel@tonic-gate * table contains all times in nS. 123*7c478bd9Sstevel@tonic-gate */ 124*7c478bd9Sstevel@tonic-gate uint32_t cistpl_devspeed_exp[CISTPL_DEVSPEED_MAX_EXP] = { 125*7c478bd9Sstevel@tonic-gate 1, /* 1 nS */ 126*7c478bd9Sstevel@tonic-gate 10, /* 10 nS */ 127*7c478bd9Sstevel@tonic-gate 100, /* 100 nS */ 128*7c478bd9Sstevel@tonic-gate 1000, /* 1000 nS */ 129*7c478bd9Sstevel@tonic-gate 10000, /* 10000 nS */ 130*7c478bd9Sstevel@tonic-gate 100000, /* 100000 nS */ 131*7c478bd9Sstevel@tonic-gate 1000000, /* 1000000 nS */ 132*7c478bd9Sstevel@tonic-gate 10000000 /* 10000000 nS */ 133*7c478bd9Sstevel@tonic-gate }; 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate /* 136*7c478bd9Sstevel@tonic-gate * The power description mantissa table. 137*7c478bd9Sstevel@tonic-gate * 138*7c478bd9Sstevel@tonic-gate * This table is described in PCMCIA Release 2.01 Card Metaformat 139*7c478bd9Sstevel@tonic-gate * pg. 5-28 table 5-32. 140*7c478bd9Sstevel@tonic-gate * 141*7c478bd9Sstevel@tonic-gate * The description of this table uses non-integer values. We multiply 142*7c478bd9Sstevel@tonic-gate * everything by 10 before it goes into the table, and the code 143*7c478bd9Sstevel@tonic-gate * will divide by 10 after it calculates the device power. 144*7c478bd9Sstevel@tonic-gate */ 145*7c478bd9Sstevel@tonic-gate uint32_t cistpl_pd_man[] = { 146*7c478bd9Sstevel@tonic-gate 10, /* no units */ 147*7c478bd9Sstevel@tonic-gate 12, /* no units */ 148*7c478bd9Sstevel@tonic-gate 13, /* no units */ 149*7c478bd9Sstevel@tonic-gate 15, /* no units */ 150*7c478bd9Sstevel@tonic-gate 20, /* no units */ 151*7c478bd9Sstevel@tonic-gate 25, /* no units */ 152*7c478bd9Sstevel@tonic-gate 30, /* no units */ 153*7c478bd9Sstevel@tonic-gate 35, /* no units */ 154*7c478bd9Sstevel@tonic-gate 40, /* no units */ 155*7c478bd9Sstevel@tonic-gate 45, /* no units */ 156*7c478bd9Sstevel@tonic-gate 50, /* no units */ 157*7c478bd9Sstevel@tonic-gate 55, /* no units */ 158*7c478bd9Sstevel@tonic-gate 60, /* no units */ 159*7c478bd9Sstevel@tonic-gate 70, /* no units */ 160*7c478bd9Sstevel@tonic-gate 80, /* no units */ 161*7c478bd9Sstevel@tonic-gate 90, /* no units */ 162*7c478bd9Sstevel@tonic-gate }; 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate /* 165*7c478bd9Sstevel@tonic-gate * The power description exponent table. 166*7c478bd9Sstevel@tonic-gate * 167*7c478bd9Sstevel@tonic-gate * This table is described in PCMCIA Release 2.01 Card Metaformat 168*7c478bd9Sstevel@tonic-gate * pg. 5-28 table 5-32. 169*7c478bd9Sstevel@tonic-gate * 170*7c478bd9Sstevel@tonic-gate * The description of this table uses various voltage and current units. 171*7c478bd9Sstevel@tonic-gate * This table contains all currents in nanoAMPS and all voltages 172*7c478bd9Sstevel@tonic-gate * in microVOLTS. 173*7c478bd9Sstevel@tonic-gate * 174*7c478bd9Sstevel@tonic-gate * Note if you're doing a current table lookup, you need to multiply 175*7c478bd9Sstevel@tonic-gate * the lookup value by ten. 176*7c478bd9Sstevel@tonic-gate */ 177*7c478bd9Sstevel@tonic-gate uint32_t cistpl_pd_exp[] = { 178*7c478bd9Sstevel@tonic-gate 10, /* 10 microVOLTS, 100 nanoAMPS */ 179*7c478bd9Sstevel@tonic-gate 100, /* 100 microVOLTS, 1000 nanoAMPS */ 180*7c478bd9Sstevel@tonic-gate 1000, /* 1000 microVOLTS, 10000 nanoAMPS */ 181*7c478bd9Sstevel@tonic-gate 10000, /* 10000 microVOLTS, 100000 nanoAMPS */ 182*7c478bd9Sstevel@tonic-gate 100000, /* 100000 microVOLTS, 1000000 nanoAMPS */ 183*7c478bd9Sstevel@tonic-gate 1000000, /* 1000000 microVOLTS, 10000000 nanoAMPS */ 184*7c478bd9Sstevel@tonic-gate 10000000, /* 10000000 microVOLTS, 100000000 nanoAMPS */ 185*7c478bd9Sstevel@tonic-gate 100000000 /* 100000000 microVOLTS, 1000000000 nanoAMPS */ 186*7c478bd9Sstevel@tonic-gate }; 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate /* 189*7c478bd9Sstevel@tonic-gate * Fill out the structure pointers. 190*7c478bd9Sstevel@tonic-gate */ 191*7c478bd9Sstevel@tonic-gate cistpl_devspeed_struct_t cistpl_devspeed_struct = { 192*7c478bd9Sstevel@tonic-gate cistpl_devspeed_table, 193*7c478bd9Sstevel@tonic-gate cistpl_exspeed_tenfac, 194*7c478bd9Sstevel@tonic-gate cistpl_devspeed_man, 195*7c478bd9Sstevel@tonic-gate cistpl_devspeed_exp, 196*7c478bd9Sstevel@tonic-gate }; 197*7c478bd9Sstevel@tonic-gate 198*7c478bd9Sstevel@tonic-gate cistpl_pd_struct_t cistpl_pd_struct = { 199*7c478bd9Sstevel@tonic-gate cistpl_pd_man, 200*7c478bd9Sstevel@tonic-gate cistpl_pd_exp, 201*7c478bd9Sstevel@tonic-gate }; 202*7c478bd9Sstevel@tonic-gate 203*7c478bd9Sstevel@tonic-gate /* 204*7c478bd9Sstevel@tonic-gate * Some handy lookup tables that should probably eventually be 205*7c478bd9Sstevel@tonic-gate * done away with. 206*7c478bd9Sstevel@tonic-gate * 207*7c478bd9Sstevel@tonic-gate * These are used mostly by the CISTPL_CFTABLE_ENTRY tuple handler. 208*7c478bd9Sstevel@tonic-gate */ 209*7c478bd9Sstevel@tonic-gate uint32_t cistpl_cftable_io_size_table[] = { 210*7c478bd9Sstevel@tonic-gate 0, 211*7c478bd9Sstevel@tonic-gate 1, 212*7c478bd9Sstevel@tonic-gate 2, 213*7c478bd9Sstevel@tonic-gate 4, 214*7c478bd9Sstevel@tonic-gate }; 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate uint32_t cistpl_cftable_shift_table[] = { 217*7c478bd9Sstevel@tonic-gate 0, 218*7c478bd9Sstevel@tonic-gate 8, 219*7c478bd9Sstevel@tonic-gate 16, 220*7c478bd9Sstevel@tonic-gate 24, 221*7c478bd9Sstevel@tonic-gate }; 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate /* 224*7c478bd9Sstevel@tonic-gate * List of tuples in the global CIS to ignore if they show 225*7c478bd9Sstevel@tonic-gate * up in both the global and function-specific CIS lists. 226*7c478bd9Sstevel@tonic-gate * This list MUST end with CISTPL_NULL. 227*7c478bd9Sstevel@tonic-gate */ 228*7c478bd9Sstevel@tonic-gate cistpl_ignore_list_t cistpl_ignore_list[] = { 229*7c478bd9Sstevel@tonic-gate CISTPL_FUNCID, 230*7c478bd9Sstevel@tonic-gate CISTPL_FUNCE, 231*7c478bd9Sstevel@tonic-gate CISTPL_CONFIG, 232*7c478bd9Sstevel@tonic-gate CISTPL_CFTABLE_ENTRY, 233*7c478bd9Sstevel@tonic-gate CISTPL_NULL /* list must end with CISTPL_NULL */ 234*7c478bd9Sstevel@tonic-gate }; 235