readcis.h revision 59053
1/* 2 * Copyright (c) 1995 Andrew McRae. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. The name of the author may not be used to endorse or promote products 13 * derived from this software without specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 * $FreeBSD: head/usr.sbin/pccard/pccardd/readcis.h 59053 2000-04-05 18:39:21Z iwasaki $ 27 */ 28 29#define CIS_MAXSTR 254 30struct tuple { 31 struct tuple *next; 32 unsigned char code; 33 int length; 34 unsigned char *data; 35}; 36 37struct tuple_list { 38 struct tuple_list *next; 39 struct tuple *tuples; 40 off_t offs; 41 int flags; 42}; 43 44struct tuple_info { 45 char *name; 46 unsigned char code; 47 unsigned char length; /* 255 means variable length */ 48}; 49 50/* 51 * Memory device descriptor. 52 */ 53struct dev_mem { 54 unsigned char valid; 55 unsigned char type; 56 unsigned char speed; 57 unsigned char wps; 58 unsigned char addr; 59 unsigned char units; 60}; 61 62/* 63 * One I/O structure describing a possible I/O map 64 * of the card. 65 */ 66struct cis_ioblk { 67 struct cis_ioblk *next; 68 unsigned int addr; 69 unsigned int size; 70}; 71 72/* 73 * A structure storing a memory map for the card. 74 */ 75struct cis_memblk { 76 struct cis_memblk *next; 77 unsigned int address; 78 unsigned int length; 79 unsigned int host_address; 80}; 81 82/* 83 * One configuration entry for the card. 84 */ 85struct cis_config { 86 struct cis_config *next; 87 unsigned int pwr:1; /* Which values are defined. */ 88 unsigned int timing:1; 89 unsigned int iospace:1; 90 unsigned int irq:1; 91 unsigned int memspace:1; 92 unsigned int misc_valid:1; 93 unsigned char id; 94 unsigned char io_blks; 95 unsigned char io_addr; 96 unsigned char io_bus; 97 struct cis_ioblk *io; 98 unsigned char irqlevel; 99 unsigned char irq_flags; 100 unsigned irq_mask; 101 unsigned char memwins; 102 struct cis_memblk *mem; 103 unsigned char misc; 104}; 105 106/* 107 * Structure holding all data retrieved from the 108 * CIS block on the card. 109 * The default configuration contains interface defaults 110 * not listed in each separate configuration. 111 */ 112struct cis { 113 struct tuple_list *tlist; 114 char manuf[CIS_MAXSTR]; 115 char vers[CIS_MAXSTR]; 116 char add_info1[CIS_MAXSTR]; 117 char add_info2[CIS_MAXSTR]; 118 unsigned char maj_v, min_v; 119 unsigned char last_config; 120 unsigned char ccrs; 121 unsigned long reg_addr; 122 unsigned char func_id1, func_id2; 123 struct dev_mem attr_mem; 124 struct dev_mem common_mem; 125 struct cis_config *def_config; 126 struct cis_config *conf; 127}; 128 129void *xmalloc(int); 130void dumpcis(struct cis *); 131void freecis(struct cis *); 132struct cis *readcis(int); 133 134char *tuple_name(unsigned char); 135