Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / usr.sbin / pccard / pccardd / readcis.h
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: src/usr.sbin/pccard/pccardd/readcis.h,v 1.11.2.2 2000/06/05 14:59:03 iwasaki Exp $
27  * $DragonFly: src/usr.sbin/pccard/pccardd/Attic/readcis.h,v 1.2 2003/06/17 04:29:59 dillon Exp $
28  */
29
30 struct tuple {
31         struct tuple *next;
32         unsigned char code;
33         int     length;
34         unsigned char *data;
35 };
36
37 struct tuple_list {
38         struct tuple_list *next;
39         struct tuple *tuples;
40         off_t   offs;
41         int     flags;
42 };
43
44 struct 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  */
53 struct 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  */
66 struct 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  */
75 struct 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  */
85 struct 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  */
112 struct cis {
113         struct tuple_list *tlist;
114         char    *manuf;
115         char    *vers;
116         char    *add_info1;
117         char    *add_info2;
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         unsigned char *lan_nid;
128 };
129
130 #define tpl32(tp)       ((*((tp) + 3) << 24) | \
131                          (*((tp) + 2) << 16) | \
132                          (*((tp) + 1) << 8)  | *(tp))
133 #define tpl24(tp)       ((*((tp) + 2) << 16) | \
134                          (*((tp) + 1) << 8)  | *(tp))
135 #define tpl16(tp)       ((*((tp) + 1) << 8)  | *(tp))
136
137 void   *xmalloc(int);
138 void    dump(unsigned char *, int);
139 void    dumpcis(struct cis *);
140 void    freecis(struct cis *);
141 struct cis *readcis(int);
142
143 char   *tuple_name(unsigned char);
144 u_int   parse_num(int, u_char *, u_char **, int);