rbus_machdep.c revision 1.1 1 /* $NetBSD: rbus_machdep.c,v 1.1 2005/09/04 07:24:57 kiyohara Exp $ */
2
3 /*
4 * Copyright (c) 2003
5 * KIYOHARA Takashi. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #include <sys/cdefs.h>
29
30 #include <sys/param.h>
31 #include <sys/device.h>
32 #include <sys/systm.h>
33
34 #include <sys/extent.h>
35
36 #include <uvm/uvm_extern.h>
37
38 #include <machine/bus.h>
39
40 #include <dev/pci/pcivar.h>
41 #include <dev/pci/pcidevs.h>
42 #include <dev/cardbus/rbus.h>
43
44 #include "opt_pci.h"
45
46 #ifndef PCI_NETBSD_CONFIGURE
47 #error requird macro PCI_NETBSD_CONFIGURE
48 #endif
49
50 #ifdef RBUS_DEBUG
51 # define DPRINTF printf
52 #else
53 # define DPRINTF while (0) printf
54 #endif
55
56 int
57 md_space_map(t, bpa, size, flags, bshp)
58 bus_space_tag_t t;
59 bus_addr_t bpa;
60 bus_size_t size;
61 int flags;
62 bus_space_handle_t *bshp;
63 {
64 DPRINTF("md_space_map: 0x%x, 0x%x, 0x%x\n", t->pbs_base, bpa, size);
65
66 return bus_space_map(t, bpa, size, flags, bshp);
67 }
68
69 void
70 md_space_unmap(t, bsh, size, adrp)
71 bus_space_tag_t t;
72 bus_space_handle_t bsh;
73 bus_size_t size;
74 bus_addr_t *adrp;
75 {
76 paddr_t pa;
77
78 DPRINTF("md_space_unmap: 0x%x 0x%x\n", t->pbs_base, bsh);
79
80 if (adrp != NULL) {
81 pmap_extract(pmap_kernel(), bsh, &pa);
82 *adrp = pa - t->pbs_offset;
83 }
84 bus_space_unmap(t, bsh, size);
85 }
86
87 rbus_tag_t
88 rbus_pccbb_parent_mem(pa)
89 struct pci_attach_args *pa;
90 {
91 bus_addr_t start;
92 bus_size_t size;
93 pci_chipset_tag_t pc = pa->pa_pc;
94 struct extent *ex = pc->memext;
95
96 start = ex->ex_start;
97 size = ex->ex_end - start;
98
99 return rbus_new_root_share(pa->pa_memt, ex, start, size, 0);
100 }
101
102 rbus_tag_t
103 rbus_pccbb_parent_io(pa)
104 struct pci_attach_args *pa;
105 {
106 bus_addr_t start;
107 bus_size_t size;
108 pci_chipset_tag_t pc = pa->pa_pc;
109 struct extent *ex = pc->ioext;
110
111 start = ex->ex_start;
112 size = ex->ex_end - start;
113
114 return rbus_new_root_share(pa->pa_iot, ex, start, size, 0);
115 }
116