[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/amd64/isa/isa.c

Version: -  FREEBSD  -  FREEBSD7  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  OPENSOLARIS  -  minix-3-1-1  -  TRUSTEDBSD-SEBSD  -  FREEBSD-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  excerpts  -  bigexcerpts 

  1 /*-
  2  * Copyright (c) 1998 Doug Rabson
  3  * All rights reserved.
  4  *
  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.
 13  *
 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.
 25  */
 26 
 27 #include <sys/cdefs.h>
 28 __FBSDID("$FreeBSD: src/sys/amd64/isa/isa.c,v 1.149 2007/02/23 12:18:26 piso Exp $");
 29 
 30 /*-
 31  * Modifications for Intel architecture by Garrett A. Wollman.
 32  * Copyright 1998 Massachusetts Institute of Technology
 33  *
 34  * Permission to use, copy, modify, and distribute this software and
 35  * its documentation for any purpose and without fee is hereby
 36  * granted, provided that both the above copyright notice and this
 37  * permission notice appear in all copies, that both the above
 38  * copyright notice and this permission notice appear in all
 39  * supporting documentation, and that the name of M.I.T. not be used
 40  * in advertising or publicity pertaining to distribution of the
 41  * software without specific, written prior permission.  M.I.T. makes
 42  * no representations about the suitability of this software for any
 43  * purpose.  It is provided "as is" without express or implied
 44  * warranty.
 45  * 
 46  * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
 47  * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
 48  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 49  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
 50  * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 51  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 52  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 53  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 54  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 55  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 56  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 57  * SUCH DAMAGE.
 58  */
 59 
 60 #include <sys/param.h>
 61 #include <sys/bus.h>
 62 #include <sys/kernel.h>
 63 #include <sys/malloc.h>
 64 #include <sys/module.h>
 65 #include <machine/bus.h>
 66 #include <sys/rman.h>
 67 
 68 #include <machine/resource.h>
 69 
 70 #include <isa/isavar.h>
 71 #include <isa/isa_common.h>
 72 
 73 void
 74 isa_init(device_t dev)
 75 {
 76 }
 77 
 78 /*
 79  * This implementation simply passes the request up to the parent
 80  * bus, which in our case is the special i386 nexus, substituting any
 81  * configured values if the caller defaulted.  We can get away with
 82  * this because there is no special mapping for ISA resources on an Intel
 83  * platform.  When porting this code to another architecture, it may be
 84  * necessary to interpose a mapping layer here.
 85  */
 86 struct resource *
 87 isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
 88                    u_long start, u_long end, u_long count, u_int flags)
 89 {
 90         /*
 91          * Consider adding a resource definition.
 92          */
 93         int passthrough = (device_get_parent(child) != bus);
 94         int isdefault = (start == 0UL && end == ~0UL);
 95         struct isa_device* idev = DEVTOISA(child);
 96         struct resource_list *rl = &idev->id_resources;
 97         struct resource_list_entry *rle;
 98         
 99         if (!passthrough && !isdefault) {
100                 rle = resource_list_find(rl, type, *rid);
101                 if (!rle) {
102                         if (*rid < 0)
103                                 return 0;
104                         switch (type) {
105                         case SYS_RES_IRQ:
106                                 if (*rid >= ISA_NIRQ)
107                                         return 0;
108                                 break;
109                         case SYS_RES_DRQ:
110                                 if (*rid >= ISA_NDRQ)
111                                         return 0;
112                                 break;
113                         case SYS_RES_MEMORY:
114                                 if (*rid >= ISA_NMEM)
115                                         return 0;
116                                 break;
117                         case SYS_RES_IOPORT:
118                                 if (*rid >= ISA_NPORT)
119                                         return 0;
120                                 break;
121                         default:
122                                 return 0;
123                         }
124                         resource_list_add(rl, type, *rid, start, end, count);
125                 }
126         }
127 
128         return resource_list_alloc(rl, bus, child, type, rid,
129                                    start, end, count, flags);
130 }
131 
132 int
133 isa_release_resource(device_t bus, device_t child, int type, int rid,
134                      struct resource *r)
135 {
136         struct isa_device* idev = DEVTOISA(child);
137         struct resource_list *rl = &idev->id_resources;
138 
139         return resource_list_release(rl, bus, child, type, rid, r);
140 }
141 
142 /*
143  * We can't use the bus_generic_* versions of these methods because those
144  * methods always pass the bus param as the requesting device, and we need
145  * to pass the child (the i386 nexus knows about this and is prepared to
146  * deal).
147  */
148 int
149 isa_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
150                driver_filter_t *filter, void (*ihand)(void *), void *arg, 
151                void **cookiep)
152 {
153         return (BUS_SETUP_INTR(device_get_parent(bus), child, r, flags,
154                                filter, ihand, arg, cookiep));
155 }
156 
157 int
158 isa_teardown_intr(device_t bus, device_t child, struct resource *r,
159                   void *cookie)
160 {
161         return (BUS_TEARDOWN_INTR(device_get_parent(bus), child, r, cookie));
162 }
163 
164 /*
165  * On this platform, isa can also attach to the legacy bus.
166  */
167 DRIVER_MODULE(isa, legacy, isa_driver, isa_devclass, 0, 0);
168 

Cache object: acfbdb56e8c8d643c8a055ab60d7bef7


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.