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