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