MFC r1.2. Fix CVE-2008-3831. Affects the Intel G33 series and newer only.
[dragonfly.git] / sys / bus / pccard / card_if.m
blob81c995114f4022a9e3ae83d5781bb7c096c227e8
1 #-
2 # Copyright (c) 1999 M. Warner Losh.
3 # All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 # SUCH DAMAGE.
26 # $FreeBSD: src/sys/dev/pccard/card_if.m,v 1.29 2005/07/01 03:40:28 imp Exp $
27 # $DragonFly: src/sys/bus/pccard/card_if.m,v 1.2 2007/07/05 12:08:53 sephe Exp $
30 #include <sys/bus.h>
31 #include <bus/pccard/pccardvar.h>
33 INTERFACE card;
35 # WARNING: THIS FILE IS USED BY BOTH OLDCARD AND NEWCARD.  MAKE SURE
36 # YOU TEST BOTH KERNELS IF CHANGING THIS FILE.
39 # Companion interface for pccard.  We need to set attributes for memory
40 # and i/o port mappings (as well as other types of attributes) that have
41 # a well defined meaning inside the pccard/cardbus system.  The bus
42 # methods are inadequate for this because this must be done at the time the
43 # resources are set for the device, which predates their activation.  Also,
44 # the driver activating the resources doesn't necessarily know or need to know
45 # these attributes.
47 METHOD int set_res_flags {
48         device_t dev;
49         device_t child;
50         int      restype;
51         int      rid;
52         u_long   value;
55 METHOD int get_res_flags {
56         device_t dev;
57         device_t child;
58         int      restype;
59         int      rid;
60         u_long   *value;
64 # Sets the memory offset of the pccard bridge's window into attribute
65 # or common memory space.
67 METHOD int set_memory_offset {
68         device_t  dev;
69         device_t  child;
70         int       rid;
71         uint32_t cardaddr;
72         uint32_t *deltap;
75 METHOD int get_memory_offset {
76         device_t  dev;
77         device_t  child;
78         int       rid;
79         uint32_t *offset;
83 # pccard bridges call this method to initate the attachment of a card
85 METHOD int attach_card {
86         device_t  dev;
90 # pccard bridges call this to detach a card.
92 METHOD int detach_card {
93         device_t  dev;
97 # Compatibility methods for OLDCARD drivers.  We use these routines to make
98 # it possible to call the OLDCARD driver's probe routine in the context that
99 # it expects.  For OLDCARD these are implemented as pass throughs to the
100 # device_{probe,attach} routines.  For NEWCARD they are implemented such
101 # such that probe becomes strictly a matching routine and attach does both
102 # the old probe and old attach.
104 # compat devices should use the following:
106 #       /* Device interface */
107 #       DEVMETHOD(device_probe),        pccard_compat_probe),
108 #       DEVMETHOD(device_attach),       pccard_compat_attach),
109 #       /* Card interface */
110 #       DEVMETHOD(card_compat_match,    foo_match),     /* newly written */
111 #       DEVMETHOD(card_compat_probe,    foo_probe),     /* old probe */
112 #       DEVMETHOD(card_compat_attach,   foo_attach),    /* old attach */
114 # This will allow a single driver binary image to be used for both
115 # OLDCARD and NEWCARD.
117 # Drivers wishing to not retain OLDCARD compatibility needn't do this.
119 # The compat_do_* versions are so that we can make the pccard_compat_probe
120 # and _attach static lines and have the bus system pick the right version
121 # to use so we don't enshrine pccard_* symbols in the driver's module.
123 METHOD int compat_probe {
124         device_t dev;
127 METHOD int compat_attach {
128         device_t dev;
131 CODE {
132         static int null_do_probe(device_t bus, device_t dev)
133         {
134                 return (CARD_COMPAT_DO_PROBE(device_get_parent(bus), dev));
135         }
137         static int null_do_attach(device_t bus, device_t dev)
138         {
139                 return (CARD_COMPAT_DO_ATTACH(device_get_parent(bus), dev));
140         }
143 METHOD int compat_do_probe {
144         device_t bus;
145         device_t dev;
146 } DEFAULT null_do_probe;
148 METHOD int compat_do_attach {
149         device_t bus;
150         device_t dev;
151 } DEFAULT null_do_attach;
154 # Find "dev" in the passed table of devices.  Return it or NULL.
156 METHOD struct pccard_product * do_product_lookup {
157         device_t bus;
158         device_t dev;
159         const struct pccard_product *tab;
160         size_t ent_size;
161         pccard_product_match_fn matchfn;
165 # Helper method for the above.  When a compatibility driver is converted,
166 # one must write a match routine.  This routine is unused on OLDCARD but
167 # is used as a discriminator for NEWCARD.
169 METHOD int compat_match {
170         device_t dev;
174 # Scanning function for accessing the CIS of a card in its driver.
176 METHOD int cis_scan {
177         device_t bus;
178         pccard_scan_t fnp;
179         void *argp;