2 * Copyright (c) 1998 Doug Rabson
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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
26 * $FreeBSD: src/sys/i386/isa/isa.c,v 1.132.2.5 2002/03/03 05:42:50 nyan Exp $
27 * $DragonFly: src/sys/bus/isa/i386/isa.c,v 1.8 2006/10/25 20:55:51 dillon Exp $
31 * Modifications for Intel architecture by Garrett A. Wollman.
32 * Copyright 1998 Massachusetts Institute of Technology
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
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
60 #include <sys/param.h>
62 #include <sys/malloc.h>
64 #include <sys/machintr.h>
66 #include "../isavar.h"
67 #include "../isa_common.h"
69 #include "opt_compat_oldisa.h"
75 isa_wrap_old_drivers();
80 * This implementation simply passes the request up to the parent
81 * bus, which in our case is the special i386 nexus, substituting any
82 * configured values if the caller defaulted. We can get away with
83 * this because there is no special mapping for ISA resources on an Intel
84 * platform. When porting this code to another architecture, it may be
85 * necessary to interpose a mapping layer here.
88 isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
89 u_long start, u_long end, u_long count, u_int flags, int cpuid)
92 * Consider adding a resource definition. We allow rid 0-1 for
93 * irq and drq, 0-3 for memory and 0-7 for ports which is
94 * sufficient for isapnp.
96 int passthrough = (device_get_parent(child) != bus);
97 int isdefault = (start == 0UL && end == ~0UL);
98 struct isa_device* idev = DEVTOISA(child);
99 struct resource_list *rl = &idev->id_resources;
100 struct resource_list_entry *rle;
102 if (!passthrough && !isdefault) {
103 rle = resource_list_find(rl, type, *rid);
109 if (*rid >= ISA_NIRQ)
111 cpuid = machintr_legacy_intr_cpuid(start);
114 if (*rid >= ISA_NDRQ)
118 if (*rid >= ISA_NMEM)
122 if (*rid >= ISA_NPORT)
128 resource_list_add(rl, type, *rid, start, end,
133 return resource_list_alloc(rl, bus, child, type, rid,
134 start, end, count, flags, cpuid);
138 isa_release_resource(device_t bus, device_t child, int type, int rid,
141 struct isa_device* idev = DEVTOISA(child);
142 struct resource_list *rl = &idev->id_resources;
144 return resource_list_release(rl, bus, child, type, rid, r);
148 * We can't use the bus_generic_* versions of these methods because those
149 * methods always pass the bus param as the requesting device, and we need
150 * to pass the child (the i386 nexus knows about this and is prepared to
154 isa_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
155 void (*ihand)(void *), void *arg,
156 void **cookiep, lwkt_serialize_t serializer)
158 return (BUS_SETUP_INTR(device_get_parent(bus), child, r, flags,
159 ihand, arg, cookiep, serializer, NULL));
163 isa_teardown_intr(device_t bus, device_t child, struct resource *r,
166 return (BUS_TEARDOWN_INTR(device_get_parent(bus), child, r, cookie));