Misc KNF. No binary changes on HADES and MILAN-PCIIDE kernels.diff -r1.14 -r1.15 src/sys/arch/atari/pci/pci_hades.c
(tsutsui)
--- src/sys/arch/atari/pci/pci_hades.c 2015/10/02 05:22:50 1.14
+++ src/sys/arch/atari/pci/pci_hades.c 2019/05/04 08:20:05 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pci_hades.c,v 1.14 2015/10/02 05:22:50 msaitoh Exp $ */ | 1 | /* $NetBSD: pci_hades.c,v 1.15 2019/05/04 08:20:05 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Leo Weppelman. All rights reserved. | 4 | * Copyright (c) 1996 Leo Weppelman. All rights reserved. | |
5 | * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. | 5 | * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. | |
6 | * Copyright (c) 1994 Charles M. Hannum. All rights reserved. | 6 | * Copyright (c) 1994 Charles M. Hannum. All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -22,216 +22,224 @@ | @@ -22,216 +22,224 @@ | |||
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: pci_hades.c,v 1.14 2015/10/02 05:22:50 msaitoh Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: pci_hades.c,v 1.15 2019/05/04 08:20:05 tsutsui Exp $"); | |
36 | 36 | |||
37 | #include <sys/types.h> | 37 | #include <sys/types.h> | |
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | #include <sys/device.h> | 40 | #include <sys/device.h> | |
41 | 41 | |||
42 | #include <uvm/uvm_extern.h> | 42 | #include <uvm/uvm_extern.h> | |
43 | 43 | |||
44 | #include <sys/bus.h> | 44 | #include <sys/bus.h> | |
45 | 45 | |||
46 | #include <dev/pci/pcivar.h> | 46 | #include <dev/pci/pcivar.h> | |
47 | #include <dev/pci/pcireg.h> | 47 | #include <dev/pci/pcireg.h> | |
48 | 48 | |||
49 | #include <machine/cpu.h> | 49 | #include <machine/cpu.h> | |
50 | #include <machine/iomap.h> | 50 | #include <machine/iomap.h> | |
51 | #include <machine/mfp.h> | 51 | #include <machine/mfp.h> | |
52 | #include <sys/bswap.h> | 52 | #include <sys/bswap.h> | |
53 | 53 | |||
54 | #include <atari/atari/device.h> | 54 | #include <atari/atari/device.h> | |
55 | #include <atari/pci/pci_vga.h> | 55 | #include <atari/pci/pci_vga.h> | |
56 | #include <atari/dev/grf_etreg.h> | 56 | #include <atari/dev/grf_etreg.h> | |
57 | 57 | |||
58 | int | 58 | int | |
59 | pci_bus_maxdevs(pci_chipset_tag_t pc, int busno) | 59 | pci_bus_maxdevs(pci_chipset_tag_t pc, int busno) | |
60 | { | 60 | { | |
61 | return (4); | 61 | ||
62 | return 4; | |||
62 | } | 63 | } | |
63 | 64 | |||
64 | static int pci_config_offset(pcitag_t); | 65 | static int pci_config_offset(pcitag_t); | |
65 | 66 | |||
66 | /* | 67 | /* | |
67 | * Atari_init.c maps the config areas PAGE_SIZE bytes apart.... | 68 | * Atari_init.c maps the config areas PAGE_SIZE bytes apart.... | |
68 | */ | 69 | */ | |
69 | static int pci_config_offset(pcitag_t tag) | 70 | static int | |
71 | pci_config_offset(pcitag_t tag) | |||
70 | { | 72 | { | |
71 | int device; | 73 | int device; | |
72 | 74 | |||
73 | device = (tag >> 11) & 0x1f; | 75 | device = (tag >> 11) & 0x1f; | |
74 | return(device * PAGE_SIZE); | 76 | ||
77 | return device * PAGE_SIZE; | |||
75 | } | 78 | } | |
76 | 79 | |||
77 | pcireg_t | 80 | pcireg_t | |
78 | pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) | 81 | pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) | |
79 | { | 82 | { | |
80 | u_long data; | 83 | uint32_t data; | |
81 | 84 | |||
82 | if ((unsigned int)reg >= PCI_CONF_SIZE) | 85 | if ((uint32_t)reg >= PCI_CONF_SIZE) | |
83 | return ((pcireg_t) -1); | 86 | return 0xffffffff; | |
84 | 87 | |||
85 | data = *(u_long *)(pci_conf_addr + pci_config_offset(tag) + reg); | 88 | data = *(uint32_t *)(pci_conf_addr + pci_config_offset(tag) + reg); | |
86 | return (bswap32(data)); | 89 | return bswap32(data); | |
87 | } | 90 | } | |
88 | 91 | |||
89 | void | 92 | void | |
90 | pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data) | 93 | pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data) | |
91 | { | 94 | { | |
92 | 95 | |||
93 | if ((unsigned int)reg >= PCI_CONF_SIZE) | 96 | if ((uint32_t)reg >= PCI_CONF_SIZE) | |
94 | return; | 97 | return; | |
95 | 98 | |||
96 | *((u_long *)(pci_conf_addr + pci_config_offset(tag) + reg)) | 99 | *((uint32_t *)(pci_conf_addr + pci_config_offset(tag) + reg)) | |
97 | = bswap32(data); | 100 | = bswap32(data); | |
98 | } | 101 | } | |
99 | 102 | |||
100 | /* | 103 | /* | |
101 | * The interrupt stuff is rather ugly. On the Hades, all interrupt lines | 104 | * The interrupt stuff is rather ugly. On the Hades, all interrupt lines | |
102 | * for a slot are wired together and connected to IO 0,1,2 or 5 (slots: | 105 | * for a slot are wired together and connected to IO 0,1,2 or 5 (slots: | |
103 | * (0-3) on the TT-MFP. The Pci-config code initializes the irq. number | 106 | * (0-3) on the TT-MFP. The Pci-config code initializes the irq. number | |
104 | * to the slot position. | 107 | * to the slot position. | |
105 | */ | 108 | */ | |
106 | static pci_intr_info_t iinfo[4] = { { -1 }, { -1 }, { -1 }, { -1 } }; | 109 | static pci_intr_info_t iinfo[4] = { { -1 }, { -1 }, { -1 }, { -1 } }; | |
107 | 110 | |||
108 | static int iifun(int, int); | 111 | static int iifun(int, int); | |
109 | 112 | |||
110 | static int | 113 | static int | |
111 | iifun(int slot, int sr) | 114 | iifun(int slot, int sr) | |
112 | { | 115 | { | |
113 | pci_intr_info_t *iinfo_p; | 116 | pci_intr_info_t *iinfo_p; | |
114 | int s; | 117 | int s; | |
115 | 118 | |||
116 | iinfo_p = &iinfo[slot]; | 119 | iinfo_p = &iinfo[slot]; | |
117 | 120 | |||
118 | /* | 121 | /* | |
119 | * Disable the interrupts | 122 | * Disable the interrupts | |
120 | */ | 123 | */ | |
121 | MFP2->mf_imrb &= ~iinfo_p->imask; | 124 | MFP2->mf_imrb &= ~iinfo_p->imask; | |
122 | 125 | |||
123 | if ((sr & PSL_IPL) >= (iinfo_p->ipl & PSL_IPL)) { | 126 | if ((sr & PSL_IPL) >= (iinfo_p->ipl & PSL_IPL)) { | |
124 | /* | 127 | /* | |
125 | * We're running at a too high priority now. | 128 | * We're running at a too high priority now. | |
126 | */ | 129 | */ | |
127 | add_sicallback((si_farg)iifun, (void*)slot, 0); | 130 | add_sicallback((si_farg)iifun, (void*)slot, 0); | |
128 | } | 131 | } else { | |
129 | else { | |||
130 | s = splx(iinfo_p->ipl); | 132 | s = splx(iinfo_p->ipl); | |
131 | (void) (iinfo_p->ifunc)(iinfo_p->iarg); | 133 | (void)(iinfo_p->ifunc)(iinfo_p->iarg); | |
132 | splx(s); | 134 | splx(s); | |
133 | 135 | |||
134 | /* | 136 | /* | |
135 | * Re-enable interrupts after handling | 137 | * Re-enable interrupts after handling | |
136 | */ | 138 | */ | |
137 | MFP2->mf_imrb |= iinfo_p->imask; | 139 | MFP2->mf_imrb |= iinfo_p->imask; | |
138 | } | 140 | } | |
139 | return 1; | 141 | return 1; | |
140 | } | 142 | } | |
141 | 143 | |||
142 | int | 144 | int | |
143 | pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ih, | 145 | pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ih, | |
144 | int attr, uint64_t data) | 146 | int attr, uint64_t data) | |
145 | { | 147 | { | |
146 | 148 | |||
147 | switch (attr) { | 149 | switch (attr) { | |
148 | case PCI_INTR_MPSAFE: | 150 | case PCI_INTR_MPSAFE: | |
149 | return 0; | 151 | return 0; | |
150 | default: | 152 | default: | |
151 | return ENODEV; | 153 | return ENODEV; | |
152 | } | 154 | } | |
153 | } | 155 | } | |
154 | 156 | |||
155 | void * | 157 | void * | |
156 | pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, int (*ih_fun)(void *), void *ih_arg) | 158 | pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, | |
159 | int (*ih_fun)(void *), void *ih_arg) | |||
157 | { | 160 | { | |
158 | pci_intr_info_t *iinfo_p; | 161 | pci_intr_info_t *iinfo_p; | |
159 | struct intrhand *ihand; | 162 | struct intrhand *ihand; | |
160 | int slot; | 163 | int slot; | |
161 | 164 | |||
162 | slot = ih; | 165 | slot = ih; | |
163 | iinfo_p = &iinfo[slot]; | 166 | iinfo_p = &iinfo[slot]; | |
164 | 167 | |||
165 | if (iinfo_p->ipl > 0) | 168 | if (iinfo_p->ipl > 0) | |
166 | panic("pci_intr_establish: interrupt was already established"); | 169 | panic("pci_intr_establish: interrupt was already established"); | |
167 | 170 | |||
168 | ihand = intr_establish((slot == 3) ? 23 : 16 + slot, USER_VEC, 0, | 171 | ihand = intr_establish((slot == 3) ? 23 : 16 + slot, USER_VEC, 0, | |
169 | (hw_ifun_t)iifun, (void *)slot); | 172 | (hw_ifun_t)iifun, (void *)slot); | |
170 | if (ihand != NULL) { | 173 | if (ihand != NULL) { | |
171 | iinfo_p->ipl = level; | 174 | iinfo_p->ipl = level; | |
172 | iinfo_p->imask = (slot == 3) ? 0x80 : (0x01 << slot); | 175 | iinfo_p->imask = (slot == 3) ? 0x80 : (0x01 << slot); | |
173 | iinfo_p->ifunc = ih_fun; | 176 | iinfo_p->ifunc = ih_fun; | |
174 | iinfo_p->iarg = ih_arg; | 177 | iinfo_p->iarg = ih_arg; | |
175 | iinfo_p->ihand = ihand; | 178 | iinfo_p->ihand = ihand; | |
176 | 179 | |||
177 | /* | 180 | /* | |
178 | * Enable (unmask) the interrupt | 181 | * Enable (unmask) the interrupt | |
179 | */ | 182 | */ | |
180 | MFP2->mf_imrb |= iinfo_p->imask; | 183 | MFP2->mf_imrb |= iinfo_p->imask; | |
181 | MFP2->mf_ierb |= iinfo_p->imask; | 184 | MFP2->mf_ierb |= iinfo_p->imask; | |
182 | return(iinfo_p); | 185 | return iinfo_p; | |
183 | } | 186 | } | |
184 | return NULL; | 187 | return NULL; | |
185 | } | 188 | } | |
186 | 189 | |||
187 | void | 190 | void | |
188 | pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie) | 191 | pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie) | |
189 | { | 192 | { | |
190 | pci_intr_info_t *iinfo_p = (pci_intr_info_t *)cookie; | 193 | pci_intr_info_t *iinfo_p = (pci_intr_info_t *)cookie; | |
191 | 194 | |||
192 | if (iinfo->ipl < 0) | 195 | if (iinfo->ipl < 0) | |
193 | panic("pci_intr_disestablish: interrupt was not established"); | 196 | panic("pci_intr_disestablish: interrupt was not established"); | |
194 | 197 | |||
195 | MFP2->mf_imrb &= ~iinfo->imask; | 198 | MFP2->mf_imrb &= ~iinfo->imask; | |
196 | MFP2->mf_ierb &= ~iinfo->imask; | 199 | MFP2->mf_ierb &= ~iinfo->imask; | |
197 | (void) intr_disestablish(iinfo_p->ihand); | 200 | (void)intr_disestablish(iinfo_p->ihand); | |
198 | iinfo_p->ipl = -1; | 201 | iinfo_p->ipl = -1; | |
199 | } | 202 | } | |
200 | 203 | |||
201 | /* | 204 | /* | |
202 | * XXX: Why are we repeating this everywhere! (Leo) | 205 | * XXX: Why are we repeating this everywhere! (Leo) | |
203 | */ | 206 | */ | |
204 | #define PCI_LINMEMBASE 0x0e000000 | 207 | #define PCI_LINMEMBASE 0x0e000000 | |
205 | 208 | |||
206 | static u_char crt_tab[] = { | 209 | static uint8_t crt_tab[] = { | |
207 | 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, | 210 | 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, | |
208 | 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, | 211 | 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, | |
209 | 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, | 212 | 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, | |
210 | 0xff }; | 213 | 0xff }; | |
211 | 214 | |||
212 | static u_char seq_tab[] = { | 215 | static uint8_t seq_tab[] = { | |
213 | 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00 }; | 216 | 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00 | |
214 | 217 | }; | ||
215 | static u_char attr_tab[] = { | 218 | ||
216 | 0x0c, 0x00, 0x0f, 0x08, 0x00, 0x00, 0x00, 0x00 }; | 219 | static uint8_t attr_tab[] = { | |
217 | 220 | 0x0c, 0x00, 0x0f, 0x08, 0x00, 0x00, 0x00, 0x00 | ||
218 | static u_char gdc_tab[] = { | 221 | }; | |
219 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff }; | 222 | ||
223 | static uint8_t gdc_tab[] = { | |||
224 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff | |||
225 | }; | |||
220 | 226 | |||
221 | void | 227 | void | |
222 | ati_vga_init(pci_chipset_tag_t pc, pcitag_t tag, int id, volatile u_char *ba, u_char *fb) | 228 | ati_vga_init(pci_chipset_tag_t pc, pcitag_t tag, int id, volatile uint8_t *ba, | |
229 | uint8_t *fb) | |||
223 | { | 230 | { | |
224 | int i, csr; | 231 | uint32_t csr; | |
232 | int i; | |||
225 | 233 | |||
226 | /* Turn on the card */ | 234 | /* Turn on the card */ | |
227 | pci_conf_write(pc, tag, PCI_MAPREG_START, PCI_LINMEMBASE); | 235 | pci_conf_write(pc, tag, PCI_MAPREG_START, PCI_LINMEMBASE); | |
228 | csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); | 236 | csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); | |
229 | csr |= (PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE); | 237 | csr |= (PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE); | |
230 | csr |= PCI_COMMAND_MASTER_ENABLE; | 238 | csr |= PCI_COMMAND_MASTER_ENABLE; | |
231 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr); | 239 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr); | |
232 | 240 | |||
233 | /* | 241 | /* | |
234 | * Make sure we're allowed to write all crt-registers and reload them. | 242 | * Make sure we're allowed to write all crt-registers and reload them. | |
235 | */ | 243 | */ | |
236 | WCrt(ba, CRT_ID_END_VER_RETR, (RCrt(ba, CRT_ID_END_VER_RETR) & 0x7f)); | 244 | WCrt(ba, CRT_ID_END_VER_RETR, (RCrt(ba, CRT_ID_END_VER_RETR) & 0x7f)); | |
237 | 245 |
--- src/sys/arch/atari/pci/pci_vga.c 2009/10/20 19:10:11 1.14
+++ src/sys/arch/atari/pci/pci_vga.c 2019/05/04 08:20:05 1.15
@@ -1,95 +1,96 @@ | @@ -1,95 +1,96 @@ | |||
1 | /* $NetBSD: pci_vga.c,v 1.14 2009/10/20 19:10:11 snj Exp $ */ | 1 | /* $NetBSD: pci_vga.c,v 1.15 2019/05/04 08:20:05 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1999 Leo Weppelman. All rights reserved. | 4 | * Copyright (c) 1999 Leo Weppelman. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | */ | 25 | */ | |
26 | 26 | |||
27 | #include <sys/cdefs.h> | 27 | #include <sys/cdefs.h> | |
28 | __KERNEL_RCSID(0, "$NetBSD: pci_vga.c,v 1.14 2009/10/20 19:10:11 snj Exp $"); | 28 | __KERNEL_RCSID(0, "$NetBSD: pci_vga.c,v 1.15 2019/05/04 08:20:05 tsutsui Exp $"); | |
29 | 29 | |||
30 | #include <sys/param.h> | 30 | #include <sys/param.h> | |
31 | #include <sys/queue.h> | 31 | #include <sys/queue.h> | |
32 | #include <sys/systm.h> | 32 | #include <sys/systm.h> | |
33 | #include <dev/pci/pcireg.h> | 33 | #include <dev/pci/pcireg.h> | |
34 | #include <dev/pci/pcivar.h> | 34 | #include <dev/pci/pcivar.h> | |
35 | #include <dev/pci/pcidevs.h> | 35 | #include <dev/pci/pcidevs.h> | |
36 | #include <atari/pci/pci_vga.h> | 36 | #include <atari/pci/pci_vga.h> | |
37 | #include <atari/dev/grf_etreg.h> | 37 | #include <atari/dev/grf_etreg.h> | |
38 | #include <atari/include/iomap.h> | 38 | #include <atari/include/iomap.h> | |
39 | 39 | |||
40 | #include <atari/dev/font.h> | 40 | #include <atari/dev/font.h> | |
41 | 41 | |||
42 | #include "vga_pci.h" | 42 | #include "vga_pci.h" | |
43 | #if NVGA_PCI > 0 | 43 | #if NVGA_PCI > 0 | |
44 | #include <dev/cons.h> | 44 | #include <dev/cons.h> | |
45 | #include <dev/ic/mc6845reg.h> | 45 | #include <dev/ic/mc6845reg.h> | |
46 | #include <dev/ic/pcdisplayvar.h> | 46 | #include <dev/ic/pcdisplayvar.h> | |
47 | #include <dev/ic/vgareg.h> | 47 | #include <dev/ic/vgareg.h> | |
48 | #include <dev/ic/vgavar.h> | 48 | #include <dev/ic/vgavar.h> | |
49 | #endif | 49 | #endif | |
50 | 50 | |||
51 | static void loadfont(volatile u_char *, u_char *fb); | 51 | static void loadfont(volatile uint8_t *, uint8_t *fb); | |
52 | 52 | |||
53 | /* XXX: Shouldn't these be in font.h???? */ | 53 | /* XXX: Shouldn't these be in font.h???? */ | |
54 | extern font_info font_info_8x8; | 54 | extern font_info font_info_8x8; | |
55 | extern font_info font_info_8x16; | 55 | extern font_info font_info_8x16; | |
56 | 56 | |||
57 | /* Console colors */ | 57 | /* Console colors */ | |
58 | static u_char conscolors[3][3] = { /* background, foreground, hilite */ | 58 | static uint8_t conscolors[3][3] = { /* background, foreground, hilite */ | |
59 | {0x0, 0x0, 0x0}, {0x30, 0x30, 0x30}, { 0x3f, 0x3f, 0x3f} | 59 | {0x0, 0x0, 0x0}, {0x30, 0x30, 0x30}, { 0x3f, 0x3f, 0x3f} | |
60 | }; | 60 | }; | |
61 | 61 | |||
62 | static bus_space_tag_t vga_iot, vga_memt; | 62 | static bus_space_tag_t vga_iot, vga_memt; | |
63 | static int tags_valid = 0; | 63 | static int tags_valid = 0; | |
64 | 64 | |||
65 | #define VGA_REG_SIZE (8*1024) | 65 | #define VGA_REG_SIZE (8*1024) | |
66 | #define VGA_FB_SIZE (32*1024) | 66 | #define VGA_FB_SIZE (32*1024) | |
67 | 67 | |||
68 | /* | 68 | /* | |
69 | * Go look for a VGA card on the PCI-bus. This search is a | 69 | * Go look for a VGA card on the PCI-bus. This search is a | |
70 | * stripped down version of the PCI-probe. It only looks on | 70 | * stripped down version of the PCI-probe. It only looks on | |
71 | * bus0 for VGA cards. The first card found is used. | 71 | * bus0 for VGA cards. The first card found is used. | |
72 | */ | 72 | */ | |
73 | int | 73 | int | |
74 | check_for_vga(bus_space_tag_t iot, bus_space_tag_t memt) | 74 | check_for_vga(bus_space_tag_t iot, bus_space_tag_t memt) | |
75 | { | 75 | { | |
76 | pci_chipset_tag_t pc = NULL; /* XXX */ | 76 | pci_chipset_tag_t pc = NULL; /* XXX */ | |
77 | bus_space_handle_t ioh_regs, memh_fb; | 77 | bus_space_handle_t ioh_regs, memh_fb; | |
78 | pcitag_t tag; | 78 | pcitag_t tag; | |
79 | int device, found, id, maxndevs, i, j; | 79 | int device, found, id, maxndevs, i, j; | |
80 | int class, got_ioh, got_memh, rv; | 80 | int got_ioh, got_memh, rv; | |
81 | volatile u_char *regs; | 81 | int class; | |
82 | u_char *fb; | 82 | volatile uint8_t *regs; | |
83 | uint8_t *fb; | |||
83 | const char *nbd = "NetBSD/Atari"; | 84 | const char *nbd = "NetBSD/Atari"; | |
84 | 85 | |||
85 | found = 0; | 86 | found = 0; | |
86 | tag = 0; | 87 | tag = 0; | |
87 | id = 0; | 88 | id = 0; | |
88 | rv = 0; | 89 | rv = 0; | |
89 | got_ioh = 0; | 90 | got_ioh = 0; | |
90 | got_memh = 0; | 91 | got_memh = 0; | |
91 | maxndevs = pci_bus_maxdevs(pc, 0); | 92 | maxndevs = pci_bus_maxdevs(pc, 0); | |
92 | 93 | |||
93 | /* | 94 | /* | |
94 | * Map 8Kb of registers and 32Kb frame buffer. | 95 | * Map 8Kb of registers and 32Kb frame buffer. | |
95 | * XXX: The way the registers are mapped here is plain wrong. | 96 | * XXX: The way the registers are mapped here is plain wrong. | |
@@ -188,89 +189,91 @@ check_for_vga(bus_space_tag_t iot, bus_s | @@ -188,89 +189,91 @@ check_for_vga(bus_space_tag_t iot, bus_s | |||
188 | * is of diagnostic/debug use only. | 189 | * is of diagnostic/debug use only. | |
189 | */ | 190 | */ | |
190 | for (i = 50 * 80; i >= 0; i -= 2) { | 191 | for (i = 50 * 80; i >= 0; i -= 2) { | |
191 | fb[i] = 0x20; fb[i+1] = 0x07; | 192 | fb[i] = 0x20; fb[i+1] = 0x07; | |
192 | } | 193 | } | |
193 | for (i = 56; *nbd; i += 2) | 194 | for (i = 56; *nbd; i += 2) | |
194 | fb[i] = *nbd++; | 195 | fb[i] = *nbd++; | |
195 | 196 | |||
196 | rv = 1; | 197 | rv = 1; | |
197 | vga_iot = iot; | 198 | vga_iot = iot; | |
198 | vga_memt = memt; | 199 | vga_memt = memt; | |
199 | rv = tags_valid = 1; | 200 | rv = tags_valid = 1; | |
200 | 201 | |||
201 | bad: | 202 | bad: | |
202 | if (got_memh) | 203 | if (got_memh) | |
203 | bus_space_unmap(memt, memh_fb, VGA_FB_SIZE); | 204 | bus_space_unmap(memt, memh_fb, VGA_FB_SIZE); | |
204 | if (got_ioh) | 205 | if (got_ioh) | |
205 | bus_space_unmap(iot, ioh_regs, VGA_REG_SIZE); | 206 | bus_space_unmap(iot, ioh_regs, VGA_REG_SIZE); | |
206 | return (rv); | 207 | return rv; | |
207 | } | 208 | } | |
208 | 209 | |||
209 | #if NVGA_PCI > 0 | 210 | #if NVGA_PCI > 0 | |
210 | void vgacnprobe(struct consdev *); | 211 | void vgacnprobe(struct consdev *); | |
211 | void vgacninit(struct consdev *); | 212 | void vgacninit(struct consdev *); | |
212 | 213 | |||
213 | void | 214 | void | |
214 | vgacnprobe(struct consdev *cp) | 215 | vgacnprobe(struct consdev *cp) | |
215 | { | 216 | { | |
217 | ||||
216 | if (tags_valid) | 218 | if (tags_valid) | |
217 | cp->cn_pri = CN_NORMAL; | 219 | cp->cn_pri = CN_NORMAL; | |
218 | } | 220 | } | |
219 | 221 | |||
220 | void | 222 | void | |
221 | vgacninit(struct consdev *cp) | 223 | vgacninit(struct consdev *cp) | |
222 | { | 224 | { | |
225 | ||||
223 | if (tags_valid) { | 226 | if (tags_valid) { | |
224 | /* XXX: Are those arguments correct? Leo */ | 227 | /* XXX: Are those arguments correct? Leo */ | |
225 | vga_cnattach(vga_iot, vga_memt, 8, 0); | 228 | vga_cnattach(vga_iot, vga_memt, 8, 0); | |
226 | } | 229 | } | |
227 | } | 230 | } | |
228 | #endif /* NVGA_PCI */ | 231 | #endif /* NVGA_PCI */ | |
229 | 232 | |||
230 | /* | 233 | /* | |
231 | * Generic VGA. Load the configured kernel font into the videomemory and | 234 | * Generic VGA. Load the configured kernel font into the videomemory and | |
232 | * place the card into textmode. | 235 | * place the card into textmode. | |
233 | */ | 236 | */ | |
234 | static void | 237 | static void | |
235 | loadfont(volatile u_char *ba, u_char *fb) | 238 | loadfont(volatile uint8_t *ba, uint8_t *fb) | |
236 | /* ba: Register area KVA */ | 239 | /* ba: Register area KVA */ | |
237 | /* fb: Frame buffer KVA */ | 240 | /* fb: Frame buffer KVA */ | |
238 | { | 241 | { | |
239 | font_info *fd; | 242 | font_info *fd; | |
240 | u_char *c, *f, tmp; | 243 | uint8_t *c, *f, tmp; | |
241 | u_short z, y; | 244 | uint16_t z, y; | |
242 | 245 | |||
243 | #if defined(KFONT_8X8) | 246 | #if defined(KFONT_8X8) | |
244 | fd = &font_info_8x8; | 247 | fd = &font_info_8x8; | |
245 | #else | 248 | #else | |
246 | fd = &font_info_8x16; | 249 | fd = &font_info_8x16; | |
247 | #endif | 250 | #endif | |
248 | 251 | |||
249 | WAttr(ba, 0x20 | ACT_ID_ATTR_MODE_CNTL, 0x0a); | 252 | WAttr(ba, 0x20 | ACT_ID_ATTR_MODE_CNTL, 0x0a); | |
250 | WSeq(ba, SEQ_ID_MAP_MASK, 0x04); | 253 | WSeq(ba, SEQ_ID_MAP_MASK, 0x04); | |
251 | WSeq(ba, SEQ_ID_MEMORY_MODE, 0x06); | 254 | WSeq(ba, SEQ_ID_MEMORY_MODE, 0x06); | |
252 | WGfx(ba, GCT_ID_READ_MAP_SELECT, 0x02); | 255 | WGfx(ba, GCT_ID_READ_MAP_SELECT, 0x02); | |
253 | WGfx(ba, GCT_ID_GRAPHICS_MODE, 0x00); | 256 | WGfx(ba, GCT_ID_GRAPHICS_MODE, 0x00); | |
254 | WGfx(ba, GCT_ID_MISC, 0x0c); | 257 | WGfx(ba, GCT_ID_MISC, 0x0c); | |
255 | 258 | |||
256 | /* | 259 | /* | |
257 | * load text font into beginning of display memory. Each | 260 | * load text font into beginning of display memory. Each | |
258 | * character cell is 32 bytes long (enough for 4 planes) | 261 | * character cell is 32 bytes long (enough for 4 planes) | |
259 | */ | 262 | */ | |
260 | for (z = 0, c = fb; z < 256 * 32; z++) | 263 | for (z = 0, c = fb; z < 256 * 32; z++) | |
261 | *c++ = 0; | 264 | *c++ = 0; | |
262 | 265 | |||
263 | c = (unsigned char *) (fb) + (32 * fd->font_lo); | 266 | c = (uint8_t *)(fb) + (32 * fd->font_lo); | |
264 | f = fd->font_p; | 267 | f = fd->font_p; | |
265 | z = fd->font_lo; | 268 | z = fd->font_lo; | |
266 | for (; z <= fd->font_hi; z++, c += (32 - fd->height)) | 269 | for (; z <= fd->font_hi; z++, c += (32 - fd->height)) | |
267 | for (y = 0; y < fd->height; y++) { | 270 | for (y = 0; y < fd->height; y++) { | |
268 | *c++ = *f++; | 271 | *c++ = *f++; | |
269 | } | 272 | } | |
270 | 273 | |||
271 | /* | 274 | /* | |
272 | * Odd/Even addressing | 275 | * Odd/Even addressing | |
273 | */ | 276 | */ | |
274 | WSeq(ba, SEQ_ID_MAP_MASK, 0x03); | 277 | WSeq(ba, SEQ_ID_MAP_MASK, 0x03); | |
275 | WSeq(ba, SEQ_ID_MEMORY_MODE, 0x03); | 278 | WSeq(ba, SEQ_ID_MEMORY_MODE, 0x03); | |
276 | WGfx(ba, GCT_ID_READ_MAP_SELECT, 0x00); | 279 | WGfx(ba, GCT_ID_READ_MAP_SELECT, 0x00); |
--- src/sys/arch/atari/pci/pci_machdep.c 2018/02/09 15:24:35 1.56
+++ src/sys/arch/atari/pci/pci_machdep.c 2019/05/04 08:20:05 1.57
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pci_machdep.c,v 1.56 2018/02/09 15:24:35 tsutsui Exp $ */ | 1 | /* $NetBSD: pci_machdep.c,v 1.57 2019/05/04 08:20:05 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Leo Weppelman. All rights reserved. | 4 | * Copyright (c) 1996 Leo Weppelman. All rights reserved. | |
5 | * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. | 5 | * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. | |
6 | * Copyright (c) 1994 Charles M. Hannum. All rights reserved. | 6 | * Copyright (c) 1994 Charles M. Hannum. All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.56 2018/02/09 15:24:35 tsutsui Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.57 2019/05/04 08:20:05 tsutsui Exp $"); | |
36 | 36 | |||
37 | #include "opt_mbtype.h" | 37 | #include "opt_mbtype.h" | |
38 | 38 | |||
39 | #include <sys/types.h> | 39 | #include <sys/types.h> | |
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/time.h> | 41 | #include <sys/time.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/errno.h> | 43 | #include <sys/errno.h> | |
44 | #include <sys/device.h> | 44 | #include <sys/device.h> | |
45 | #include <sys/malloc.h> | 45 | #include <sys/malloc.h> | |
46 | 46 | |||
47 | #define _ATARI_BUS_DMA_PRIVATE | 47 | #define _ATARI_BUS_DMA_PRIVATE | |
48 | #include <sys/bus.h> | 48 | #include <sys/bus.h> | |
@@ -79,32 +79,32 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep. | @@ -79,32 +79,32 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep. | |||
79 | */ | 79 | */ | |
80 | #define PCI_MACHDEP_IO_ALIGN_MASK 0xffffff00 | 80 | #define PCI_MACHDEP_IO_ALIGN_MASK 0xffffff00 | |
81 | #define PCI_MACHDEP_MEM_ALIGN_MASK 0xfffff000 | 81 | #define PCI_MACHDEP_MEM_ALIGN_MASK 0xfffff000 | |
82 | 82 | |||
83 | /* | 83 | /* | |
84 | * Convert a PCI 'device' number to a slot number. | 84 | * Convert a PCI 'device' number to a slot number. | |
85 | */ | 85 | */ | |
86 | #define DEV2SLOT(dev) (3 - dev) | 86 | #define DEV2SLOT(dev) (3 - dev) | |
87 | 87 | |||
88 | /* | 88 | /* | |
89 | * Struct to hold the memory and I/O datas of the pci devices | 89 | * Struct to hold the memory and I/O datas of the pci devices | |
90 | */ | 90 | */ | |
91 | struct pci_memreg { | 91 | struct pci_memreg { | |
92 | LIST_ENTRY(pci_memreg) link; | 92 | LIST_ENTRY(pci_memreg) link; | |
93 | int dev; | 93 | int dev; | |
94 | pcitag_t tag; | 94 | pcitag_t tag; | |
95 | pcireg_t reg, address, mask; | 95 | pcireg_t reg, address, mask; | |
96 | u_int32_t size; | 96 | uint32_t size; | |
97 | u_int32_t csr; | 97 | uint32_t csr; | |
98 | }; | 98 | }; | |
99 | 99 | |||
100 | typedef LIST_HEAD(pci_memreg_head, pci_memreg) PCI_MEMREG; | 100 | typedef LIST_HEAD(pci_memreg_head, pci_memreg) PCI_MEMREG; | |
101 | 101 | |||
102 | /* | 102 | /* | |
103 | * Entry points for PCI DMA. Use only the 'standard' functions. | 103 | * Entry points for PCI DMA. Use only the 'standard' functions. | |
104 | */ | 104 | */ | |
105 | int _bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t, | 105 | int _bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t, | |
106 | bus_size_t, int, bus_dmamap_t *); | 106 | bus_size_t, int, bus_dmamap_t *); | |
107 | struct atari_bus_dma_tag pci_bus_dma_tag = { | 107 | struct atari_bus_dma_tag pci_bus_dma_tag = { | |
108 | 0, | 108 | 0, | |
109 | #if defined(_ATARIHW_) | 109 | #if defined(_ATARIHW_) | |
110 | 0x80000000, /* On the Hades, CPU memory starts here PCI-wise */ | 110 | 0x80000000, /* On the Hades, CPU memory starts here PCI-wise */ | |
@@ -118,64 +118,64 @@ struct atari_bus_dma_tag pci_bus_dma_tag | @@ -118,64 +118,64 @@ struct atari_bus_dma_tag pci_bus_dma_tag | |||
118 | _bus_dmamap_load_uio, | 118 | _bus_dmamap_load_uio, | |
119 | _bus_dmamap_load_raw, | 119 | _bus_dmamap_load_raw, | |
120 | _bus_dmamap_unload, | 120 | _bus_dmamap_unload, | |
121 | _bus_dmamap_sync, | 121 | _bus_dmamap_sync, | |
122 | }; | 122 | }; | |
123 | 123 | |||
124 | int ataripcibusprint(void *, const char *); | 124 | int ataripcibusprint(void *, const char *); | |
125 | int pcibusmatch(device_t, cfdata_t, void *); | 125 | int pcibusmatch(device_t, cfdata_t, void *); | |
126 | void pcibusattach(device_t, device_t, void *); | 126 | void pcibusattach(device_t, device_t, void *); | |
127 | 127 | |||
128 | static void enable_pci_devices(void); | 128 | static void enable_pci_devices(void); | |
129 | static void insert_into_list(PCI_MEMREG *head, struct pci_memreg *elem); | 129 | static void insert_into_list(PCI_MEMREG *head, struct pci_memreg *elem); | |
130 | static int overlap_pci_areas(struct pci_memreg *p, | 130 | static int overlap_pci_areas(struct pci_memreg *p, | |
131 | struct pci_memreg *self, u_int addr, u_int size, u_int what); | 131 | struct pci_memreg *self, u_int addr, u_int size, u_int what); | |
132 | 132 | |||
133 | CFATTACH_DECL_NEW(pcib, 0, | 133 | CFATTACH_DECL_NEW(pcib, 0, | |
134 | pcibusmatch, pcibusattach, NULL, NULL); | 134 | pcibusmatch, pcibusattach, NULL, NULL); | |
135 | 135 | |||
136 | /* | 136 | /* | |
137 | * We need some static storage to probe pci-busses for VGA cards during | 137 | * We need some static storage to probe pci-busses for VGA cards during | |
138 | * early console init. | 138 | * early console init. | |
139 | */ | 139 | */ | |
140 | static struct atari_bus_space bs_storage[2]; /* 1 iot, 1 memt */ | 140 | static struct atari_bus_space bs_storage[2]; /* 1 iot, 1 memt */ | |
141 | 141 | |||
142 | int | 142 | int | |
143 | pcibusmatch(device_t parent, cfdata_t cf, void *aux) | 143 | pcibusmatch(device_t parent, cfdata_t cf, void *aux) | |
144 | { | 144 | { | |
145 | static int nmatched = 0; | 145 | static int nmatched = 0; | |
146 | 146 | |||
147 | if (strcmp((char *)aux, "pcib")) | 147 | if (strcmp((char *)aux, "pcib")) | |
148 | return 0; /* Wrong number... */ | 148 | return 0; /* Wrong number... */ | |
149 | 149 | |||
150 | if (atari_realconfig == 0) | 150 | if (atari_realconfig == 0) | |
151 | return 1; | 151 | return 1; | |
152 | 152 | |||
153 | if (machineid & (ATARI_HADES|ATARI_MILAN)) { | 153 | if ((machineid & (ATARI_HADES|ATARI_MILAN)) != 0) { | |
154 | /* | 154 | /* | |
155 | * Both Hades and Milan have only one pci bus | 155 | * Both Hades and Milan have only one pci bus | |
156 | */ | 156 | */ | |
157 | if (nmatched) | 157 | if (nmatched) | |
158 | return 0; | 158 | return 0; | |
159 | nmatched++; | 159 | nmatched++; | |
160 | return 1; | 160 | return 1; | |
161 | } | 161 | } | |
162 | return 0; | 162 | return 0; | |
163 | } | 163 | } | |
164 | 164 | |||
165 | void | 165 | void | |
166 | pcibusattach(device_t parent, device_t self, void *aux) | 166 | pcibusattach(device_t parent, device_t self, void *aux) | |
167 | { | 167 | { | |
168 | struct pcibus_attach_args pba; | 168 | struct pcibus_attach_args pba; | |
169 | 169 | |||
170 | pba.pba_pc = NULL; | 170 | pba.pba_pc = NULL; | |
171 | pba.pba_bus = 0; | 171 | pba.pba_bus = 0; | |
172 | pba.pba_bridgetag = NULL; | 172 | pba.pba_bridgetag = NULL; | |
173 | pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY; | 173 | pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY; | |
174 | pba.pba_dmat = &pci_bus_dma_tag; | 174 | pba.pba_dmat = &pci_bus_dma_tag; | |
175 | pba.pba_iot = leb_alloc_bus_space_tag(&bs_storage[0]); | 175 | pba.pba_iot = leb_alloc_bus_space_tag(&bs_storage[0]); | |
176 | pba.pba_memt = leb_alloc_bus_space_tag(&bs_storage[1]); | 176 | pba.pba_memt = leb_alloc_bus_space_tag(&bs_storage[1]); | |
177 | if ((pba.pba_iot == NULL) || (pba.pba_memt == NULL)) { | 177 | if ((pba.pba_iot == NULL) || (pba.pba_memt == NULL)) { | |
178 | printf("leb_alloc_bus_space_tag failed!\n"); | 178 | printf("leb_alloc_bus_space_tag failed!\n"); | |
179 | return; | 179 | return; | |
180 | } | 180 | } | |
181 | pba.pba_iot->base = PCI_IO_PHYS; | 181 | pba.pba_iot->base = PCI_IO_PHYS; | |
@@ -217,27 +217,28 @@ pci_attach_hook(device_t parent, device_ | @@ -217,27 +217,28 @@ pci_attach_hook(device_t parent, device_ | |||
217 | } | 217 | } | |
218 | 218 | |||
219 | /* | 219 | /* | |
220 | * Initialize the PCI-bus. The Atari-BIOS does not do this, so.... | 220 | * Initialize the PCI-bus. The Atari-BIOS does not do this, so.... | |
221 | * We only disable all devices here. Memory and I/O enabling is done | 221 | * We only disable all devices here. Memory and I/O enabling is done | |
222 | * later at pcibusattach. | 222 | * later at pcibusattach. | |
223 | */ | 223 | */ | |
224 | void | 224 | void | |
225 | init_pci_bus(void) | 225 | init_pci_bus(void) | |
226 | { | 226 | { | |
227 | pci_chipset_tag_t pc = NULL; /* XXX */ | 227 | pci_chipset_tag_t pc = NULL; /* XXX */ | |
228 | pcitag_t tag; | 228 | pcitag_t tag; | |
229 | pcireg_t csr; | 229 | pcireg_t csr; | |
230 | int device, id, maxndevs; | 230 | int device, maxndevs; | |
231 | int id; | |||
231 | 232 | |||
232 | tag = 0; | 233 | tag = 0; | |
233 | id = 0; | 234 | id = 0; | |
234 | 235 | |||
235 | maxndevs = pci_bus_maxdevs(pc, 0); | 236 | maxndevs = pci_bus_maxdevs(pc, 0); | |
236 | 237 | |||
237 | for (device = 0; device < maxndevs; device++) { | 238 | for (device = 0; device < maxndevs; device++) { | |
238 | 239 | |||
239 | tag = pci_make_tag(pc, 0, device, 0); | 240 | tag = pci_make_tag(pc, 0, device, 0); | |
240 | id = pci_conf_read(pc, tag, PCI_ID_REG); | 241 | id = pci_conf_read(pc, tag, PCI_ID_REG); | |
241 | if (id == 0 || id == 0xffffffff) | 242 | if (id == 0 || id == 0xffffffff) | |
242 | continue; | 243 | continue; | |
243 | 244 | |||
@@ -245,384 +246,416 @@ init_pci_bus(void) | @@ -245,384 +246,416 @@ init_pci_bus(void) | |||
245 | csr &= ~(PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE); | 246 | csr &= ~(PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE); | |
246 | csr &= ~PCI_COMMAND_MASTER_ENABLE; | 247 | csr &= ~PCI_COMMAND_MASTER_ENABLE; | |
247 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr); | 248 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr); | |
248 | } | 249 | } | |
249 | } | 250 | } | |
250 | 251 | |||
251 | /* | 252 | /* | |
252 | * insert a new element in an existing list that the ID's (size in struct | 253 | * insert a new element in an existing list that the ID's (size in struct | |
253 | * pci_memreg) are sorted. | 254 | * pci_memreg) are sorted. | |
254 | */ | 255 | */ | |
255 | static void | 256 | static void | |
256 | insert_into_list(PCI_MEMREG *head, struct pci_memreg *elem) | 257 | insert_into_list(PCI_MEMREG *head, struct pci_memreg *elem) | |
257 | { | 258 | { | |
258 | struct pci_memreg *p, *q; | 259 | struct pci_memreg *p, *q; | |
259 | 260 | |||
260 | p = LIST_FIRST(head); | 261 | p = LIST_FIRST(head); | |
261 | q = NULL; | 262 | q = NULL; | |
262 | 263 | |||
263 | for (; p != NULL && p->size < elem->size; q = p, p = LIST_NEXT(p, link)); | 264 | for (; p != NULL && p->size < elem->size; | |
264 | 265 | q = p, p = LIST_NEXT(p, link)) | ||
265 | if (q == NULL) { | 266 | ; | |
266 | LIST_INSERT_HEAD(head, elem, link); | 267 | ||
267 | } else { | 268 | if (q == NULL) { | |
268 | LIST_INSERT_AFTER(q, elem, link); | 269 | LIST_INSERT_HEAD(head, elem, link); | |
269 | } | 270 | } else { | |
271 | LIST_INSERT_AFTER(q, elem, link); | |||
272 | } | |||
270 | } | 273 | } | |
271 | 274 | |||
272 | /* | 275 | /* | |
273 | * Test if a new selected area overlaps with an already (probably preselected) | 276 | * Test if a new selected area overlaps with an already (probably preselected) | |
274 | * pci area. | 277 | * pci area. | |
275 | */ | 278 | */ | |
276 | static int | 279 | static int | |
277 | overlap_pci_areas(struct pci_memreg *p, struct pci_memreg *self, u_int addr, u_int size, u_int what) | 280 | overlap_pci_areas(struct pci_memreg *p, struct pci_memreg *self, u_int addr, | |
281 | u_int size, u_int what) | |||
278 | { | 282 | { | |
279 | struct pci_memreg *q; | 283 | struct pci_memreg *q; | |
280 | 284 | |||
281 | if (p == NULL) | 285 | if (p == NULL) | |
282 | return 0; | 286 | return 0; | |
283 | 287 | |||
284 | q = p; | 288 | q = p; | |
285 | while (q != NULL) { | 289 | while (q != NULL) { | |
286 | if ((q != self) && (q->csr & what)) { | 290 | if ((q != self) && (q->csr & what)) { | |
287 | if ((addr >= q->address) && (addr < (q->address + q->size))) { | 291 | if ((addr >= q->address) && | |
292 | (addr < (q->address + q->size))) { | |||
288 | #ifdef DEBUG_PCI_MACHDEP | 293 | #ifdef DEBUG_PCI_MACHDEP | |
289 | printf("\noverlap area dev %d reg 0x%02x with dev %d reg 0x%02x", | 294 | printf("\noverlap area dev %d reg 0x%02x " | |
290 | self->dev, self->reg, q->dev, q->reg); | 295 | "with dev %d reg 0x%02x", | |
296 | self->dev, self->reg, q->dev, q->reg); | |||
291 | #endif | 297 | #endif | |
292 | return 1; | 298 | return 1; | |
293 | } | 299 | } | |
294 | if ((q->address >= addr) && (q->address < (addr + size))) { | 300 | if ((q->address >= addr) && | |
301 | (q->address < (addr + size))) { | |||
295 | #ifdef DEBUG_PCI_MACHDEP | 302 | #ifdef DEBUG_PCI_MACHDEP | |
296 | printf("\noverlap area dev %d reg 0x%02x with dev %d reg 0x%02x", | 303 | printf("\noverlap area dev %d reg 0x%02x " | |
297 | self->dev, self->reg, q->dev, q->reg); | 304 | "with dev %d reg 0x%02x", | |
305 | self->dev, self->reg, q->dev, q->reg); | |||
298 | #endif | 306 | #endif | |
299 | return 1; | 307 | return 1; | |
308 | } | |||
309 | } | |||
310 | q = LIST_NEXT(q, link); | |||
300 | } | 311 | } | |
301 | } | 312 | return 0; | |
302 | q = LIST_NEXT(q, link); | |||
303 | } | |||
304 | return 0; | |||
305 | } | 313 | } | |
306 | 314 | |||
307 | /* | 315 | /* | |
308 | * Enable memory and I/O on pci devices. Care about already enabled devices | 316 | * Enable memory and I/O on pci devices. Care about already enabled devices | |
309 | * (probabaly by the console driver). | 317 | * (probabaly by the console driver). | |
310 | * | 318 | * | |
311 | * The idea behind the following code is: | 319 | * The idea behind the following code is: | |
312 | * We build a by sizes sorted list of the requirements of the different | 320 | * We build a by sizes sorted list of the requirements of the different | |
313 | * pci devices. After that we choose the start addresses of that areas | 321 | * pci devices. After that we choose the start addresses of that areas | |
314 | * in such a way that they are placed as closed as possible together. | 322 | * in such a way that they are placed as closed as possible together. | |
315 | */ | 323 | */ | |
316 | static void | 324 | static void | |
317 | enable_pci_devices(void) | 325 | enable_pci_devices(void) | |
318 | { | 326 | { | |
319 | PCI_MEMREG memlist; | 327 | PCI_MEMREG memlist; | |
320 | PCI_MEMREG iolist; | 328 | PCI_MEMREG iolist; | |
321 | struct pci_memreg *p, *q; | 329 | struct pci_memreg *p, *q; | |
322 | int dev, reg, id, class; | 330 | int dev, reg; | |
323 | pcitag_t tag; | 331 | int id, class; | |
324 | pcireg_t csr, address, mask; | 332 | pcitag_t tag; | |
325 | pci_chipset_tag_t pc; | 333 | pcireg_t csr, address, mask; | |
326 | int sizecnt, membase_1m; | 334 | pci_chipset_tag_t pc; | |
327 | 335 | int sizecnt, membase_1m; | ||
328 | pc = 0; | 336 | ||
329 | csr = 0; | 337 | pc = 0; | |
330 | tag = 0; | 338 | csr = 0; | |
331 | 339 | tag = 0; | ||
332 | LIST_INIT(&memlist); | |||
333 | LIST_INIT(&iolist); | |||
334 | ||||
335 | /* | |||
336 | * first step: go through all devices and gather memory and I/O | |||
337 | * sizes | |||
338 | */ | |||
339 | for (dev = 0; dev < pci_bus_maxdevs(pc,0); dev++) { | |||
340 | ||||
341 | tag = pci_make_tag(pc, 0, dev, 0); | |||
342 | id = pci_conf_read(pc, tag, PCI_ID_REG); | |||
343 | if (id == 0 || id == 0xffffffff) | |||
344 | continue; | |||
345 | 340 | |||
346 | csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); | 341 | LIST_INIT(&memlist); | |
342 | LIST_INIT(&iolist); | |||
347 | 343 | |||
348 | /* | 344 | /* | |
349 | * special case: if a display card is found and memory is enabled | 345 | * first step: go through all devices and gather memory and I/O | |
350 | * preserve 128k at 0xa0000 as vga memory. | 346 | * sizes | |
351 | * XXX: if a display card is found without being enabled, leave | |||
352 | * it alone! You will usually only create conflicts by enabeling | |||
353 | * it. | |||
354 | */ | 347 | */ | |
355 | class = pci_conf_read(pc, tag, PCI_CLASS_REG); | 348 | for (dev = 0; dev < pci_bus_maxdevs(pc,0); dev++) { | |
356 | switch (PCI_CLASS(class)) { | 349 | ||
357 | case PCI_CLASS_PREHISTORIC: | 350 | tag = pci_make_tag(pc, 0, dev, 0); | |
358 | case PCI_CLASS_DISPLAY: | 351 | id = pci_conf_read(pc, tag, PCI_ID_REG); | |
359 | if (csr & (PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE)) { | 352 | if (id == 0 || id == 0xffffffff) | |
360 | p = (struct pci_memreg *)malloc(sizeof(struct pci_memreg), | 353 | continue; | |
361 | M_TEMP, M_WAITOK); | |||
362 | memset(p, '\0', sizeof(struct pci_memreg)); | |||
363 | p->dev = dev; | |||
364 | p->csr = csr; | |||
365 | p->tag = tag; | |||
366 | p->reg = 0; /* there is no register about this */ | |||
367 | p->size = 0x20000; /* 128kByte */ | |||
368 | p->mask = 0xfffe0000; | |||
369 | p->address = 0xa0000; | |||
370 | ||||
371 | insert_into_list(&memlist, p); | |||
372 | } | |||
373 | else continue; | |||
374 | } | |||
375 | ||||
376 | for (reg = PCI_MAPREG_START; reg < PCI_MAPREG_END; reg += 4) { | |||
377 | ||||
378 | address = pci_conf_read(pc, tag, reg); | |||
379 | pci_conf_write(pc, tag, reg, 0xffffffff); | |||
380 | mask = pci_conf_read(pc, tag, reg); | |||
381 | pci_conf_write(pc, tag, reg, address); | |||
382 | if (mask == 0) | |||
383 | continue; /* Register unused */ | |||
384 | ||||
385 | p = (struct pci_memreg *)malloc(sizeof(struct pci_memreg), | |||
386 | M_TEMP, M_WAITOK); | |||
387 | memset(p, '\0', sizeof(struct pci_memreg)); | |||
388 | p->dev = dev; | |||
389 | p->csr = csr; | |||
390 | p->tag = tag; | |||
391 | p->reg = reg; | |||
392 | p->mask = mask; | |||
393 | p->address = 0; | |||
394 | 354 | |||
395 | if (mask & PCI_MAPREG_TYPE_IO) { | 355 | csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); | |
396 | p->size = PCI_MAPREG_IO_SIZE(mask); | |||
397 | 356 | |||
398 | /* | 357 | /* | |
399 | * Align IO if necessary | 358 | * special case: if a display card is found and memory is | |
359 | * enabled preserve 128k at 0xa0000 as vga memory. | |||
360 | * XXX: if a display card is found without being enabled, | |||
361 | * leave it alone! You will usually only create conflicts | |||
362 | * by enabeling it. | |||
400 | */ | 363 | */ | |
401 | if (p->size < PCI_MAPREG_IO_SIZE(PCI_MACHDEP_IO_ALIGN_MASK)) { | 364 | class = pci_conf_read(pc, tag, PCI_CLASS_REG); | |
402 | p->mask = PCI_MACHDEP_IO_ALIGN_MASK; | 365 | switch (PCI_CLASS(class)) { | |
403 | p->size = PCI_MAPREG_IO_SIZE(p->mask); | 366 | case PCI_CLASS_PREHISTORIC: | |
367 | case PCI_CLASS_DISPLAY: | |||
368 | if (csr & (PCI_COMMAND_MEM_ENABLE | | |||
369 | PCI_COMMAND_MASTER_ENABLE)) { | |||
370 | p = malloc(sizeof(struct pci_memreg), | |||
371 | M_TEMP, M_WAITOK); | |||
372 | memset(p, 0, sizeof(struct pci_memreg)); | |||
373 | p->dev = dev; | |||
374 | p->csr = csr; | |||
375 | p->tag = tag; | |||
376 | p->reg = 0; /* there is no register | |||
377 | about this */ | |||
378 | p->size = 0x20000; /* 128kByte */ | |||
379 | p->mask = 0xfffe0000; | |||
380 | p->address = 0xa0000; | |||
381 | ||||
382 | insert_into_list(&memlist, p); | |||
383 | } else | |||
384 | continue; | |||
404 | } | 385 | } | |
405 | 386 | |||
406 | /* | 387 | for (reg = PCI_MAPREG_START; reg < PCI_MAPREG_END; reg += 4) { | |
407 | * if I/O is already enabled (probably by the console driver) | 388 | address = pci_conf_read(pc, tag, reg); | |
408 | * save the address in order to take care about it later. | 389 | pci_conf_write(pc, tag, reg, 0xffffffff); | |
409 | */ | 390 | mask = pci_conf_read(pc, tag, reg); | |
410 | if (csr & PCI_COMMAND_IO_ENABLE) | 391 | pci_conf_write(pc, tag, reg, address); | |
411 | p->address = address; | 392 | if (mask == 0) | |
412 | 393 | continue; /* Register unused */ | ||
413 | insert_into_list(&iolist, p); | 394 | ||
414 | } else { | 395 | p = malloc(sizeof(struct pci_memreg), | |
415 | p->size = PCI_MAPREG_MEM_SIZE(mask); | 396 | M_TEMP, M_WAITOK); | |
416 | 397 | memset(p, 0, sizeof(struct pci_memreg)); | ||
417 | /* | 398 | p->dev = dev; | |
418 | * Align memory if necessary | 399 | p->csr = csr; | |
419 | */ | 400 | p->tag = tag; | |
420 | if (p->size < PCI_MAPREG_IO_SIZE(PCI_MACHDEP_MEM_ALIGN_MASK)) { | 401 | p->reg = reg; | |
421 | p->mask = PCI_MACHDEP_MEM_ALIGN_MASK; | 402 | p->mask = mask; | |
422 | p->size = PCI_MAPREG_MEM_SIZE(p->mask); | 403 | p->address = 0; | |
404 | ||||
405 | if ((mask & PCI_MAPREG_TYPE_IO) != 0) { | |||
406 | p->size = PCI_MAPREG_IO_SIZE(mask); | |||
407 | ||||
408 | /* | |||
409 | * Align IO if necessary | |||
410 | */ | |||
411 | if (p->size < PCI_MAPREG_IO_SIZE( | |||
412 | PCI_MACHDEP_IO_ALIGN_MASK)) { | |||
413 | p->mask = PCI_MACHDEP_IO_ALIGN_MASK; | |||
414 | p->size = PCI_MAPREG_IO_SIZE(p->mask); | |||
415 | } | |||
416 | ||||
417 | /* | |||
418 | * if I/O is already enabled | |||
419 | * (probably by the console driver) | |||
420 | * save the address in order to take care | |||
421 | * about it later. | |||
422 | */ | |||
423 | if ((csr & PCI_COMMAND_IO_ENABLE) != 0) | |||
424 | p->address = address; | |||
425 | ||||
426 | insert_into_list(&iolist, p); | |||
427 | } else { | |||
428 | p->size = PCI_MAPREG_MEM_SIZE(mask); | |||
429 | ||||
430 | /* | |||
431 | * Align memory if necessary | |||
432 | */ | |||
433 | if (p->size < PCI_MAPREG_IO_SIZE( | |||
434 | PCI_MACHDEP_MEM_ALIGN_MASK)) { | |||
435 | p->mask = PCI_MACHDEP_MEM_ALIGN_MASK; | |||
436 | p->size = PCI_MAPREG_MEM_SIZE(p->mask); | |||
437 | } | |||
438 | ||||
439 | /* | |||
440 | * if memory is already enabled | |||
441 | * (probably by the console driver) | |||
442 | * save the address in order to take care | |||
443 | * about it later. | |||
444 | */ | |||
445 | if ((csr & PCI_COMMAND_MEM_ENABLE) != 0) | |||
446 | p->address = address; | |||
447 | ||||
448 | insert_into_list(&memlist, p); | |||
449 | ||||
450 | if (PCI_MAPREG_MEM_TYPE(mask) == | |||
451 | PCI_MAPREG_MEM_TYPE_64BIT) | |||
452 | reg++; | |||
453 | } | |||
423 | } | 454 | } | |
424 | 455 | |||
456 | #if defined(_ATARIHW_) | |||
425 | /* | 457 | /* | |
426 | * if memory is already enabled (probably by the console driver) | 458 | * Both interrupt pin & line are set to the device (== slot) | |
427 | * save the address in order to take care about it later. | 459 | * number. This makes sense on the atari Hades because the | |
460 | * individual slots are hard-wired to a specific MFP-pin. | |||
428 | */ | 461 | */ | |
429 | if (csr & PCI_COMMAND_MEM_ENABLE) | 462 | csr = (DEV2SLOT(dev) << PCI_INTERRUPT_PIN_SHIFT); | |
430 | p->address = address; | 463 | csr |= (DEV2SLOT(dev) << PCI_INTERRUPT_LINE_SHIFT); | |
431 | 464 | pci_conf_write(pc, tag, PCI_INTERRUPT_REG, csr); | ||
432 | insert_into_list(&memlist, p); | |||
433 | ||||
434 | if (PCI_MAPREG_MEM_TYPE(mask) == PCI_MAPREG_MEM_TYPE_64BIT) | |||
435 | reg++; | |||
436 | } | |||
437 | } | |||
438 | ||||
439 | ||||
440 | #if defined(_ATARIHW_) | |||
441 | /* | |||
442 | * Both interrupt pin & line are set to the device (== slot) | |||
443 | * number. This makes sense on the atari Hades because the | |||
444 | * individual slots are hard-wired to a specific MFP-pin. | |||
445 | */ | |||
446 | csr = (DEV2SLOT(dev) << PCI_INTERRUPT_PIN_SHIFT); | |||
447 | csr |= (DEV2SLOT(dev) << PCI_INTERRUPT_LINE_SHIFT); | |||
448 | pci_conf_write(pc, tag, PCI_INTERRUPT_REG, csr); | |||
449 | #else | 465 | #else | |
450 | /* | |||
451 | * On the Milan, we accept the BIOS's choice. | |||
452 | */ | |||
453 | /* ..except the secondary IDE interrupt that the BIOS doesn't setup. */ | |||
454 | #define PIIX_PCIB_MBIRQ0 0x70 | |||
455 | if ((PCI_VENDOR(id) == PCI_VENDOR_INTEL) && | |||
456 | (PCI_PRODUCT(id) == PCI_PRODUCT_INTEL_82371FB_ISA)) { | |||
457 | /* | 466 | /* | |
458 | * Set Interrupt Routing for MBIRQ0 to IRQ15. | 467 | * On the Milan, we accept the BIOS's choice. | |
459 | * Note Milan's ROM bootloader v1.2 and v1.4 incorrectly | |||
460 | * set MBIRQ0 to IRQ14 (not 15) and unused MBIRQ1 to IRQ 15, | |||
461 | * so explicitly disable MBIRQ1. | |||
462 | */ | 468 | */ | |
463 | csr = pci_conf_read(pc, tag, PIIX_PCIB_MBIRQ0); | 469 | /* | |
464 | csr &= ~0x000ffff; | 470 | * ..except the secondary IDE interrupt that | |
465 | csr |= 0x000800f; /* MBIRQ1: disable, MBIRQ0: IRQ15 */ | 471 | * the BIOS doesn't setup. | |
466 | pci_conf_write(pc, tag, PIIX_PCIB_MBIRQ0, csr); | 472 | */ | |
473 | #define PIIX_PCIB_MBIRQ0 0x70 | |||
474 | if ((PCI_VENDOR(id) == PCI_VENDOR_INTEL) && | |||
475 | (PCI_PRODUCT(id) == PCI_PRODUCT_INTEL_82371FB_ISA)) { | |||
476 | /* | |||
477 | * Set Interrupt Routing for MBIRQ0 to IRQ15. | |||
478 | * Note Milan's ROM bootloader v1.2 and v1.4 | |||
479 | * incorrectly set MBIRQ0 to IRQ14 (not 15) | |||
480 | * and unused MBIRQ1 to IRQ 15, | |||
481 | * so explicitly disable MBIRQ1. | |||
482 | */ | |||
483 | csr = pci_conf_read(pc, tag, PIIX_PCIB_MBIRQ0); | |||
484 | csr &= ~0x0000ffff; | |||
485 | /* MBIRQ1: disable, MBIRQ0: IRQ15 */ | |||
486 | csr |= 0x0000800f; | |||
487 | pci_conf_write(pc, tag, PIIX_PCIB_MBIRQ0, csr); | |||
467 | #ifdef DEBUG_PCI_MACHDEP | 488 | #ifdef DEBUG_PCI_MACHDEP | |
468 | printf("\npcib0: enable and route MBIRQ0 to irq 15\n"); | 489 | printf("\npcib0: enable and route MBIRQ0 to irq 15\n"); | |
469 | #endif | 490 | #endif | |
470 | } | 491 | } | |
471 | #endif | 492 | #endif | |
472 | } | 493 | } | |
473 | 494 | |||
474 | /* | 495 | /* | |
475 | * second step: calculate the memory and I/O addresses beginning from | 496 | * second step: calculate the memory and I/O addresses beginning from | |
476 | * PCI_MEM_START and PCI_IO_START. Care about already mapped areas. | 497 | * PCI_MEM_START and PCI_IO_START. Care about already mapped areas. | |
477 | * | 498 | * | |
478 | * begin with memory list | 499 | * begin with memory list | |
479 | */ | 500 | */ | |
480 | ||||
481 | address = PCI_MEM_START; | |||
482 | sizecnt = 0; | |||
483 | membase_1m = 0; | |||
484 | p = LIST_FIRST(&memlist); | |||
485 | while (p != NULL) { | |||
486 | if (!(p->csr & PCI_COMMAND_MEM_ENABLE)) { | |||
487 | if (PCI_MAPREG_MEM_TYPE(p->mask) == PCI_MAPREG_MEM_TYPE_32BIT_1M) { | |||
488 | if (p->size > membase_1m) | |||
489 | membase_1m = p->size; | |||
490 | do { | |||
491 | p->address = membase_1m; | |||
492 | membase_1m += p->size; | |||
493 | } while (overlap_pci_areas(LIST_FIRST(&memlist), p, p->address, | |||
494 | p->size, PCI_COMMAND_MEM_ENABLE)); | |||
495 | if (membase_1m > 0x00100000) { | |||
496 | /* | |||
497 | * Should we panic here? | |||
498 | */ | |||
499 | printf("\npcibus0: dev %d reg %d: memory not configured", | |||
500 | p->dev, p->reg); | |||
501 | p->reg = 0; | |||
502 | } | |||
503 | } else { | |||
504 | 501 | |||
505 | if (sizecnt && (p->size > sizecnt)) | 502 | address = PCI_MEM_START; | |
506 | sizecnt = ((p->size + sizecnt) & p->mask) & | 503 | sizecnt = 0; | |
507 | PCI_MAPREG_MEM_ADDR_MASK; | 504 | membase_1m = 0; | |
508 | if (sizecnt > address) { | 505 | p = LIST_FIRST(&memlist); | |
509 | address = sizecnt; | 506 | while (p != NULL) { | |
510 | sizecnt = 0; | 507 | if ((p->csr & PCI_COMMAND_MEM_ENABLE) == 0) { | |
508 | if (PCI_MAPREG_MEM_TYPE(p->mask) == | |||
509 | PCI_MAPREG_MEM_TYPE_32BIT_1M) { | |||
510 | if (p->size > membase_1m) | |||
511 | membase_1m = p->size; | |||
512 | do { | |||
513 | p->address = membase_1m; | |||
514 | membase_1m += p->size; | |||
515 | } while (overlap_pci_areas(LIST_FIRST(&memlist), | |||
516 | p, p->address, p->size, | |||
517 | PCI_COMMAND_MEM_ENABLE)); | |||
518 | if (membase_1m > 0x00100000) { | |||
519 | /* | |||
520 | * Should we panic here? | |||
521 | */ | |||
522 | printf("\npcibus0: dev %d reg %d:" | |||
523 | " memory not configured", | |||
524 | p->dev, p->reg); | |||
525 | p->reg = 0; | |||
526 | } | |||
527 | } else { | |||
528 | if (sizecnt && (p->size > sizecnt)) | |||
529 | sizecnt = | |||
530 | ((p->size + sizecnt) & p->mask) & | |||
531 | PCI_MAPREG_MEM_ADDR_MASK; | |||
532 | if (sizecnt > address) { | |||
533 | address = sizecnt; | |||
534 | sizecnt = 0; | |||
535 | } | |||
536 | ||||
537 | do { | |||
538 | p->address = address + sizecnt; | |||
539 | sizecnt += p->size; | |||
540 | } while (overlap_pci_areas(LIST_FIRST(&memlist), | |||
541 | p, p->address, p->size, | |||
542 | PCI_COMMAND_MEM_ENABLE)); | |||
543 | ||||
544 | if ((address + sizecnt) > PCI_MEM_END) { | |||
545 | /* | |||
546 | * Should we panic here? | |||
547 | */ | |||
548 | printf("\npcibus0: dev %d reg %d:" | |||
549 | " memory not configured", | |||
550 | p->dev, p->reg); | |||
551 | p->reg = 0; | |||
552 | } | |||
553 | } | |||
554 | if (p->reg > 0) { | |||
555 | pci_conf_write(pc, p->tag, p->reg, p->address); | |||
556 | csr = pci_conf_read(pc, p->tag, | |||
557 | PCI_COMMAND_STATUS_REG); | |||
558 | csr |= PCI_COMMAND_MEM_ENABLE | | |||
559 | PCI_COMMAND_MASTER_ENABLE; | |||
560 | pci_conf_write(pc, p->tag, | |||
561 | PCI_COMMAND_STATUS_REG, csr); | |||
562 | p->csr = csr; | |||
563 | } | |||
511 | } | 564 | } | |
565 | p = LIST_NEXT(p, link); | |||
566 | } | |||
512 | 567 | |||
513 | do { | 568 | /* | |
514 | p->address = address + sizecnt; | 569 | * now the I/O list | |
515 | sizecnt += p->size; | 570 | */ | |
516 | } while (overlap_pci_areas(LIST_FIRST(&memlist), p, p->address, | |||
517 | p->size, PCI_COMMAND_MEM_ENABLE)); | |||
518 | ||||
519 | if ((address + sizecnt) > PCI_MEM_END) { | |||
520 | /* | |||
521 | * Should we panic here? | |||
522 | */ | |||
523 | printf("\npcibus0: dev %d reg %d: memory not configured", | |||
524 | p->dev, p->reg); | |||
525 | p->reg = 0; | |||
526 | } | |||
527 | } | |||
528 | if (p->reg > 0) { | |||
529 | pci_conf_write(pc, p->tag, p->reg, p->address); | |||
530 | csr = pci_conf_read(pc, p->tag, PCI_COMMAND_STATUS_REG); | |||
531 | csr |= PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE; | |||
532 | pci_conf_write(pc, p->tag, PCI_COMMAND_STATUS_REG, csr); | |||
533 | p->csr = csr; | |||
534 | } | |||
535 | } | |||
536 | p = LIST_NEXT(p, link); | |||
537 | } | |||
538 | ||||
539 | /* | |||
540 | * now the I/O list | |||
541 | */ | |||
542 | ||||
543 | address = PCI_IO_START; | |||
544 | sizecnt = 0; | |||
545 | p = LIST_FIRST(&iolist); | |||
546 | while (p != NULL) { | |||
547 | if (!(p->csr & PCI_COMMAND_IO_ENABLE)) { | |||
548 | ||||
549 | if (sizecnt && (p->size > sizecnt)) | |||
550 | sizecnt = ((p->size + sizecnt) & p->mask) & | |||
551 | PCI_MAPREG_IO_ADDR_MASK; | |||
552 | if (sizecnt > address) { | |||
553 | address = sizecnt; | |||
554 | sizecnt = 0; | |||
555 | } | |||
556 | ||||
557 | do { | |||
558 | p->address = address + sizecnt; | |||
559 | sizecnt += p->size; | |||
560 | } while (overlap_pci_areas(LIST_FIRST(&iolist), p, p->address, | |||
561 | p->size, PCI_COMMAND_IO_ENABLE)); | |||
562 | 571 | |||
563 | if ((address + sizecnt) > PCI_IO_END) { | 572 | address = PCI_IO_START; | |
564 | /* | 573 | sizecnt = 0; | |
565 | * Should we panic here? | 574 | p = LIST_FIRST(&iolist); | |
566 | */ | 575 | while (p != NULL) { | |
567 | printf("\npcibus0: dev %d reg %d: io not configured", | 576 | if (!(p->csr & PCI_COMMAND_IO_ENABLE)) { | |
568 | p->dev, p->reg); | 577 | ||
569 | } else { | 578 | if (sizecnt && (p->size > sizecnt)) | |
570 | pci_conf_write(pc, p->tag, p->reg, p->address); | 579 | sizecnt = ((p->size + sizecnt) & p->mask) & | |
571 | csr = pci_conf_read(pc, p->tag, PCI_COMMAND_STATUS_REG); | 580 | PCI_MAPREG_IO_ADDR_MASK; | |
572 | csr |= PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MASTER_ENABLE; | 581 | if (sizecnt > address) { | |
573 | pci_conf_write(pc, p->tag, PCI_COMMAND_STATUS_REG, csr); | 582 | address = sizecnt; | |
574 | p->csr = csr; | 583 | sizecnt = 0; | |
575 | } | 584 | } | |
585 | ||||
586 | do { | |||
587 | p->address = address + sizecnt; | |||
588 | sizecnt += p->size; | |||
589 | } while (overlap_pci_areas(LIST_FIRST(&iolist), p, | |||
590 | p->address, p->size, PCI_COMMAND_IO_ENABLE)); | |||
591 | ||||
592 | if ((address + sizecnt) > PCI_IO_END) { | |||
593 | /* | |||
594 | * Should we panic here? | |||
595 | */ | |||
596 | printf("\npcibus0: dev %d reg %d:" | |||
597 | " io not configured", | |||
598 | p->dev, p->reg); | |||
599 | } else { | |||
600 | pci_conf_write(pc, p->tag, p->reg, p->address); | |||
601 | csr = pci_conf_read(pc, p->tag, | |||
602 | PCI_COMMAND_STATUS_REG); | |||
603 | csr |= PCI_COMMAND_IO_ENABLE | | |||
604 | PCI_COMMAND_MASTER_ENABLE; | |||
605 | pci_conf_write(pc, p->tag, | |||
606 | PCI_COMMAND_STATUS_REG, csr); | |||
607 | p->csr = csr; | |||
608 | } | |||
609 | } | |||
610 | p = LIST_NEXT(p, link); | |||
576 | } | 611 | } | |
577 | p = LIST_NEXT(p, link); | |||
578 | } | |||
579 | 612 | |||
580 | #ifdef DEBUG_PCI_MACHDEP | 613 | #ifdef DEBUG_PCI_MACHDEP | |
581 | printf("\nI/O List:\n"); | 614 | printf("\nI/O List:\n"); | |
582 | p = LIST_FIRST(&iolist); | 615 | p = LIST_FIRST(&iolist); | |
583 | 616 | |||
584 | while (p != NULL) { | 617 | while (p != NULL) { | |
585 | printf("\ndev: %d, reg: 0x%02x, size: 0x%08x, addr: 0x%08x", p->dev, | 618 | printf("\ndev: %d, reg: 0x%02x, size: 0x%08x, addr: 0x%08x", | |
586 | p->reg, p->size, p->address); | 619 | p->dev, p->reg, p->size, p->address); | |
587 | p = LIST_NEXT(p, link); | 620 | p = LIST_NEXT(p, link); | |
588 | } | 621 | } | |
589 | printf("\nMemlist:"); | 622 | printf("\nMemlist:"); | |
590 | p = LIST_FIRST(&memlist); | 623 | p = LIST_FIRST(&memlist); | |
591 | 624 | |||
592 | while (p != NULL) { | 625 | while (p != NULL) { | |
593 | printf("\ndev: %d, reg: 0x%02x, size: 0x%08x, addr: 0x%08x", p->dev, | 626 | printf("\ndev: %d, reg: 0x%02x, size: 0x%08x, addr: 0x%08x", | |
594 | p->reg, p->size, p->address); | 627 | p->dev, p->reg, p->size, p->address); | |
595 | p = LIST_NEXT(p, link); | 628 | p = LIST_NEXT(p, link); | |
596 | } | 629 | } | |
597 | #endif | 630 | #endif | |
598 | 631 | |||
599 | /* | 632 | /* | |
600 | * Free the lists | 633 | * Free the lists | |
601 | */ | 634 | */ | |
602 | p = LIST_FIRST(&iolist); | |||
603 | while (p != NULL) { | |||
604 | q = p; | |||
605 | LIST_REMOVE(q, link); | |||
606 | free(p, M_WAITOK); | |||
607 | p = LIST_FIRST(&iolist); | 635 | p = LIST_FIRST(&iolist); | |
608 | } | 636 | while (p != NULL) { | |
609 | p = LIST_FIRST(&memlist); | 637 | q = p; | |
610 | while (p != NULL) { | 638 | LIST_REMOVE(q, link); | |
611 | q = p; | 639 | free(p, M_WAITOK); | |
612 | LIST_REMOVE(q, link); | 640 | p = LIST_FIRST(&iolist); | |
613 | free(p, M_WAITOK); | 641 | } | |
614 | p = LIST_FIRST(&memlist); | 642 | p = LIST_FIRST(&memlist); | |
615 | } | 643 | while (p != NULL) { | |
644 | q = p; | |||
645 | LIST_REMOVE(q, link); | |||
646 | free(p, M_WAITOK); | |||
647 | p = LIST_FIRST(&memlist); | |||
648 | } | |||
616 | } | 649 | } | |
617 | 650 | |||
618 | pcitag_t | 651 | pcitag_t | |
619 | pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function) | 652 | pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function) | |
620 | { | 653 | { | |
621 | 654 | |||
622 | return (bus << 16) | (device << 11) | (function << 8); | 655 | return (bus << 16) | (device << 11) | (function << 8); | |
623 | } | 656 | } | |
624 | 657 | |||
625 | void | 658 | void | |
626 | pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp, int *dp, int *fp) | 659 | pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp, int *dp, int *fp) | |
627 | { | 660 | { | |
628 | 661 | |||
@@ -682,28 +715,30 @@ pci_intr_map(const struct pci_attach_arg | @@ -682,28 +715,30 @@ pci_intr_map(const struct pci_attach_arg | |||
682 | /* Assume line == 0 means unassigned */ | 715 | /* Assume line == 0 means unassigned */ | |
683 | if (line == 0) | 716 | if (line == 0) | |
684 | goto bad; | 717 | goto bad; | |
685 | #endif | 718 | #endif | |
686 | *ihp = line; | 719 | *ihp = line; | |
687 | return 0; | 720 | return 0; | |
688 | 721 | |||
689 | bad: | 722 | bad: | |
690 | *ihp = -1; | 723 | *ihp = -1; | |
691 | return 1; | 724 | return 1; | |
692 | } | 725 | } | |
693 | 726 | |||
694 | const char * | 727 | const char * | |
695 | pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf, size_t len) | 728 | pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf, | |
729 | size_t len) | |||
696 | { | 730 | { | |
731 | ||||
697 | if (ih == -1) | 732 | if (ih == -1) | |
698 | panic("pci_intr_string: bogus handle 0x%x", ih); | 733 | panic("pci_intr_string: bogus handle 0x%x", ih); | |
699 | 734 | |||
700 | snprintf(buf, len, "irq %d", ih); | 735 | snprintf(buf, len, "irq %d", ih); | |
701 | return buf; | 736 | return buf; | |
702 | 737 | |||
703 | } | 738 | } | |
704 | 739 | |||
705 | const struct evcnt * | 740 | const struct evcnt * | |
706 | pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih) | 741 | pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih) | |
707 | { | 742 | { | |
708 | 743 | |||
709 | /* XXX for now, no evcnt parent reported */ | 744 | /* XXX for now, no evcnt parent reported */ |
--- src/sys/arch/atari/pci/pci_milan.c 2018/01/28 14:22:23 1.15
+++ src/sys/arch/atari/pci/pci_milan.c 2019/05/04 08:20:05 1.16
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pci_milan.c,v 1.15 2018/01/28 14:22:23 tsutsui Exp $ */ | 1 | /* $NetBSD: pci_milan.c,v 1.16 2019/05/04 08:20:05 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Leo Weppelman. | 8 | * by Leo Weppelman. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,111 +20,115 @@ | @@ -20,111 +20,115 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: pci_milan.c,v 1.15 2018/01/28 14:22:23 tsutsui Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: pci_milan.c,v 1.16 2019/05/04 08:20:05 tsutsui Exp $"); | |
34 | 34 | |||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | 39 | |||
40 | #include <dev/pci/pcivar.h> | 40 | #include <dev/pci/pcivar.h> | |
41 | #include <dev/pci/pcireg.h> | 41 | #include <dev/pci/pcireg.h> | |
42 | 42 | |||
43 | #include <dev/isa/isavar.h> /* isa_intr_{dis}establish */ | 43 | #include <dev/isa/isavar.h> /* isa_intr_{dis}establish */ | |
44 | #include <dev/isa/isareg.h> /* isa_intr_{dis}establish */ | 44 | #include <dev/isa/isareg.h> /* isa_intr_{dis}establish */ | |
45 | 45 | |||
46 | #include <sys/bswap.h> | 46 | #include <sys/bswap.h> | |
47 | #include <machine/isa_machdep.h> /* isa_intr_{dis}establish */ | 47 | #include <machine/isa_machdep.h> /* isa_intr_{dis}establish */ | |
48 | 48 | |||
49 | #include <atari/pci/pci_vga.h> | 49 | #include <atari/pci/pci_vga.h> | |
50 | #include <atari/dev/grf_etreg.h> | 50 | #include <atari/dev/grf_etreg.h> | |
51 | 51 | |||
52 | int | 52 | int | |
53 | pci_bus_maxdevs(pci_chipset_tag_t pc, int busno) | 53 | pci_bus_maxdevs(pci_chipset_tag_t pc, int busno) | |
54 | { | 54 | { | |
55 | return (6); | 55 | ||
56 | return 6; | |||
56 | } | 57 | } | |
57 | 58 | |||
58 | /* | 59 | /* | |
59 | * These are defined in locore.s: | 60 | * These are defined in locore.s: | |
60 | */ | 61 | */ | |
61 | pcireg_t milan_pci_confread(pcitag_t); | 62 | pcireg_t milan_pci_confread(pcitag_t); | |
62 | void milan_pci_confwrite(u_long, pcireg_t); | 63 | void milan_pci_confwrite(uint32_t, pcireg_t); | |
63 | extern u_long plx_status; | 64 | extern uint32_t plx_status; | |
64 | 65 | |||
65 | pcireg_t | 66 | pcireg_t | |
66 | pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) | 67 | pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) | |
67 | { | 68 | { | |
68 | u_long data; | 69 | uint32_t data; | |
69 | 70 | |||
70 | if ((unsigned int)reg >= PCI_CONF_SIZE) | 71 | if ((uint32_t)reg >= PCI_CONF_SIZE) | |
71 | return 0xffffffff; | 72 | return 0xffffffff; | |
72 | 73 | |||
73 | data = bswap32(milan_pci_confread(tag | reg)); | 74 | data = bswap32(milan_pci_confread(tag | reg)); | |
74 | if ((plx_status) & 0xf9000000) { | 75 | if ((plx_status & 0xf9000000) != 0) { | |
75 | /* | 76 | /* | |
76 | * Access error, assume nothing there... | 77 | * Access error, assume nothing there... | |
77 | */ | 78 | */ | |
78 | data = 0xffffffff; | 79 | data = 0xffffffff; | |
79 | } | 80 | } | |
80 | return(data); | 81 | return data; | |
81 | } | 82 | } | |
82 | 83 | |||
83 | 84 | |||
84 | void | 85 | void | |
85 | pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data) | 86 | pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data) | |
86 | { | 87 | { | |
87 | 88 | |||
88 | if ((unsigned int)reg >= PCI_CONF_SIZE) | 89 | if ((uint32_t)reg >= PCI_CONF_SIZE) | |
89 | return; | 90 | return; | |
90 | 91 | |||
91 | milan_pci_confwrite(tag | reg, bswap32(data)); | 92 | milan_pci_confwrite(tag | reg, bswap32(data)); | |
92 | } | 93 | } | |
93 | 94 | |||
94 | int | 95 | int | |
95 | pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ih, | 96 | pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ih, int attr, | |
96 | int attr, uint64_t data) | 97 | uint64_t data) | |
97 | { | 98 | { | |
98 | 99 | |||
99 | switch (attr) { | 100 | switch (attr) { | |
100 | case PCI_INTR_MPSAFE: | 101 | case PCI_INTR_MPSAFE: | |
101 | return 0; | 102 | return 0; | |
102 | default: | 103 | default: | |
103 | return ENODEV; | 104 | return ENODEV; | |
104 | } | 105 | } | |
105 | } | 106 | } | |
106 | 107 | |||
107 | void * | 108 | void * | |
108 | pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, int (*ih_fun)(void *), void *ih_arg) | 109 | pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, | |
110 | int (*ih_fun)(void *), void *ih_arg) | |||
109 | { | 111 | { | |
112 | ||||
110 | if (ih == 0 || ih >= 16 || ih == 2) | 113 | if (ih == 0 || ih >= 16 || ih == 2) | |
111 | panic("pci_intr_establish: bogus handle 0x%x", ih); | 114 | panic("pci_intr_establish: bogus handle 0x%x", ih); | |
112 | return isa_intr_establish(NULL, ih, IST_LEVEL, level, ih_fun, ih_arg); | 115 | return isa_intr_establish(NULL, ih, IST_LEVEL, level, ih_fun, ih_arg); | |
113 | } | 116 | } | |
114 | 117 | |||
115 | void | 118 | void | |
116 | pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie) | 119 | pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie) | |
117 | { | 120 | { | |
121 | ||||
118 | isa_intr_disestablish(NULL, cookie); | 122 | isa_intr_disestablish(NULL, cookie); | |
119 | } | 123 | } | |
120 | 124 | |||
121 | /* | 125 | /* | |
122 | * VGA related stuff... | 126 | * VGA related stuff... | |
123 | * | 127 | * | |
124 | * It looks like the Milan BIOS is initializing the VGA card in a reasonably | 128 | * It looks like the Milan BIOS is initializing the VGA card in a reasonably | |
125 | * standard text mode. However, the screen mode is 640*480 instead of 640*400. | 129 | * standard text mode. However, the screen mode is 640*480 instead of 640*400. | |
126 | * Since wscons does not handle the right by default, the card is reprogrammed | 130 | * Since wscons does not handle the right by default, the card is reprogrammed | |
127 | * to 640*400 using only 'standard' VGA registers (I hope!). So this ought to | 131 | * to 640*400 using only 'standard' VGA registers (I hope!). So this ought to | |
128 | * work on cards other than the S3Trio card I have tested it on. | 132 | * work on cards other than the S3Trio card I have tested it on. | |
129 | */ | 133 | */ | |
130 | static const uint8_t crt_tab[] = { | 134 | static const uint8_t crt_tab[] = { | |
@@ -152,29 +156,31 @@ static const uint8_t crt_tab[] = { | @@ -152,29 +156,31 @@ static const uint8_t crt_tab[] = { | |||
152 | 0x00, /* 14: underline location */ | 156 | 0x00, /* 14: underline location */ | |
153 | 0x96, /* 15: start vertical blanking */ | 157 | 0x96, /* 15: start vertical blanking */ | |
154 | 0xb9, /* 16: end vertical blanking */ | 158 | 0xb9, /* 16: end vertical blanking */ | |
155 | 0xa3, /* 17: CRT mode control */ | 159 | 0xa3, /* 17: CRT mode control */ | |
156 | 0xff /* 18: line compare */ | 160 | 0xff /* 18: line compare */ | |
157 | }; | 161 | }; | |
158 | 162 | |||
159 | /* | 163 | /* | |
160 | * XXX: Why are we repeating this everywhere! (Leo) | 164 | * XXX: Why are we repeating this everywhere! (Leo) | |
161 | */ | 165 | */ | |
162 | #define PCI_LINMEMBASE 0x0e000000 | 166 | #define PCI_LINMEMBASE 0x0e000000 | |
163 | 167 | |||
164 | void | 168 | void | |
165 | milan_vga_init(pci_chipset_tag_t pc, pcitag_t tag, int id, volatile u_char *ba, u_char *fb) | 169 | milan_vga_init(pci_chipset_tag_t pc, pcitag_t tag, int id, | |
170 | volatile uint8_t *ba, uint8_t *fb) | |||
166 | { | 171 | { | |
167 | int i, csr; | 172 | uint32_t csr; | |
173 | int i; | |||
168 | 174 | |||
169 | /* Turn on the card */ | 175 | /* Turn on the card */ | |
170 | pci_conf_write(pc, tag, PCI_MAPREG_START, PCI_LINMEMBASE); | 176 | pci_conf_write(pc, tag, PCI_MAPREG_START, PCI_LINMEMBASE); | |
171 | csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); | 177 | csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); | |
172 | csr |= (PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE); | 178 | csr |= (PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE); | |
173 | csr |= PCI_COMMAND_MASTER_ENABLE; | 179 | csr |= PCI_COMMAND_MASTER_ENABLE; | |
174 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr); | 180 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr); | |
175 | 181 | |||
176 | /* | 182 | /* | |
177 | * Make sure we're allowed to write all crt-registers and reload them. | 183 | * Make sure we're allowed to write all crt-registers and reload them. | |
178 | */ | 184 | */ | |
179 | WCrt(ba, CRT_ID_END_VER_RETR, (RCrt(ba, CRT_ID_END_VER_RETR) & 0x7f)); | 185 | WCrt(ba, CRT_ID_END_VER_RETR, (RCrt(ba, CRT_ID_END_VER_RETR) & 0x7f)); | |
180 | 186 |
--- src/sys/arch/atari/pci/pci_tseng.c 2009/10/20 19:10:11 1.11
+++ src/sys/arch/atari/pci/pci_tseng.c 2019/05/04 08:20:05 1.12
@@ -1,98 +1,105 @@ | @@ -1,98 +1,105 @@ | |||
1 | /* $NetBSD: pci_tseng.c,v 1.11 2009/10/20 19:10:11 snj Exp $ */ | 1 | /* $NetBSD: pci_tseng.c,v 1.12 2019/05/04 08:20:05 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1999 Leo Weppelman. All rights reserved. | 4 | * Copyright (c) 1999 Leo Weppelman. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | */ | 25 | */ | |
26 | 26 | |||
27 | #include <sys/cdefs.h> | 27 | #include <sys/cdefs.h> | |
28 | __KERNEL_RCSID(0, "$NetBSD: pci_tseng.c,v 1.11 2009/10/20 19:10:11 snj Exp $"); | 28 | __KERNEL_RCSID(0, "$NetBSD: pci_tseng.c,v 1.12 2019/05/04 08:20:05 tsutsui Exp $"); | |
29 | 29 | |||
30 | #include <sys/param.h> | 30 | #include <sys/param.h> | |
31 | #include <sys/queue.h> | 31 | #include <sys/queue.h> | |
32 | #include <sys/systm.h> | 32 | #include <sys/systm.h> | |
33 | #include <dev/pci/pcireg.h> | 33 | #include <dev/pci/pcireg.h> | |
34 | #include <dev/pci/pcivar.h> | 34 | #include <dev/pci/pcivar.h> | |
35 | #include <dev/pci/pcidevs.h> | 35 | #include <dev/pci/pcidevs.h> | |
36 | #include <atari/pci/pci_vga.h> | 36 | #include <atari/pci/pci_vga.h> | |
37 | #include <atari/dev/grf_etreg.h> | 37 | #include <atari/dev/grf_etreg.h> | |
38 | 38 | |||
39 | #define PCI_LINMEMBASE 0x0e000000 | 39 | #define PCI_LINMEMBASE 0x0e000000 | |
40 | #define PCI_IOBASE 0x800 | 40 | #define PCI_IOBASE 0x800 | |
41 | 41 | |||
42 | static void et6000_init(volatile u_char *, u_char *, int); | 42 | static void et6000_init(volatile uint8_t *, uint8_t *, int); | |
43 | 43 | |||
44 | /* | 44 | /* | |
45 | * Use tables for the card init... | 45 | * Use tables for the card init... | |
46 | */ | 46 | */ | |
47 | static u_char seq_tab[] = { | 47 | static uint8_t seq_tab[] = { | |
48 | 0x03, 0x01, 0x03, 0x00, 0x02, 0x00, 0x00, 0xb4 }; | 48 | 0x03, 0x01, 0x03, 0x00, 0x02, 0x00, 0x00, 0xb4 | |
49 | }; | |||
50 | ||||
51 | static uint8_t gfx_tab[] = { | |||
52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff | |||
53 | }; | |||
54 | ||||
55 | static uint8_t attr_tab[] = { | |||
56 | 0x0a, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00 | |||
57 | }; | |||
49 | 58 | |||
50 | static u_char gfx_tab[] = { | 59 | static uint8_t crt_tab[] = { | |
51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x0f, 0xff }; | |||
52 | ||||
53 | static u_char attr_tab[] = { | |||
54 | 0x0a, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00 }; | |||
55 | ||||
56 | static u_char crt_tab[] = { | |||
57 | 0x60, 0x53, 0x4f, 0x94, 0x56, 0x05, 0xc1, 0x1f, | 60 | 0x60, 0x53, 0x4f, 0x94, 0x56, 0x05, 0xc1, 0x1f, | |
58 | 0x00, 0x4f, 0x00, 0x0f, 0x00, 0x00, 0x07, 0x80, | 61 | 0x00, 0x4f, 0x00, 0x0f, 0x00, 0x00, 0x07, 0x80, | |
59 | 0x98, 0x3d, 0x8f, 0x28, 0x0f, 0x8f, 0xc2, 0xa3, | 62 | 0x98, 0x3d, 0x8f, 0x28, 0x0f, 0x8f, 0xc2, 0xa3, | |
60 | 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 63 | 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
61 | 0x00, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, | 64 | 0x00, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, | |
62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
63 | #ifdef ET4000_HAS_2MB_MEM | 66 | #ifdef ET4000_HAS_2MB_MEM | |
64 | 0x00, 0x80, 0xa0, 0x00, 0x00, 0x10, 0x03, 0x89, /* 2 MB video memory */ | 67 | 0x00, 0x80, 0xa0, 0x00, 0x00, 0x10, 0x03, 0x89, /* 2 MB video memory */ | |
65 | #else | 68 | #else | |
66 | 0x00, 0x80, 0x28, 0x00, 0x00, 0x10, 0x43, 0x09, /* 1 MB video memory */ | 69 | 0x00, 0x80, 0x28, 0x00, 0x00, 0x10, 0x43, 0x09, /* 1 MB video memory */ | |
67 | #endif | 70 | #endif | |
68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
72 | }; | |||
69 | 73 | |||
70 | static u_char ras_cas_tab[] = { | 74 | static uint8_t ras_cas_tab[] = { | |
71 | 0x11, 0x14, 0x15 }; | 75 | 0x11, 0x14, 0x15 | |
76 | }; | |||
72 | 77 | |||
73 | void | 78 | void | |
74 | tseng_init(pci_chipset_tag_t pc, pcitag_t tag, int id, volatile u_char *ba, u_char *fb) | 79 | tseng_init(pci_chipset_tag_t pc, pcitag_t tag, int id, volatile uint8_t *ba, | |
80 | uint8_t *fb) | |||
75 | { | 81 | { | |
76 | int i, j, csr; | 82 | int i, j; | |
77 | int is_et6000 = 0; | 83 | int is_et6000 = 0; | |
84 | uint32_t csr; | |||
78 | 85 | |||
79 | is_et6000 = (id == PCI_PRODUCT_TSENG_ET6000) ? 1 : 0; | 86 | is_et6000 = (id == PCI_PRODUCT_TSENG_ET6000) ? 1 : 0; | |
80 | 87 | |||
81 | /* Turn on the card */ | 88 | /* Turn on the card */ | |
82 | pci_conf_write(pc, tag, PCI_MAPREG_START, PCI_LINMEMBASE); | 89 | pci_conf_write(pc, tag, PCI_MAPREG_START, PCI_LINMEMBASE); | |
83 | if (is_et6000) | 90 | if (is_et6000) | |
84 | pci_conf_write(pc, tag, PCI_MAPREG_START+4, | 91 | pci_conf_write(pc, tag, PCI_MAPREG_START + 4, | |
85 | PCI_IOBASE | PCI_MAPREG_TYPE_IO); | 92 | PCI_IOBASE | PCI_MAPREG_TYPE_IO); | |
86 | csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); | 93 | csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); | |
87 | csr |= (PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE); | 94 | csr |= (PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE); | |
88 | csr |= PCI_COMMAND_MASTER_ENABLE; | 95 | csr |= PCI_COMMAND_MASTER_ENABLE; | |
89 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr); | 96 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, csr); | |
90 | 97 | |||
91 | if (is_et6000) { | 98 | if (is_et6000) { | |
92 | /* | 99 | /* | |
93 | * The et6[01]000 cards have MDRAM chips. The | 100 | * The et6[01]000 cards have MDRAM chips. The | |
94 | * timing to those chips is not properly initialized | 101 | * timing to those chips is not properly initialized | |
95 | * by the card on init. The way to determine the | 102 | * by the card on init. The way to determine the | |
96 | * values is not documented either :-( So that's why | 103 | * values is not documented either :-( So that's why | |
97 | * all this mess below (and in et6000_init().... | 104 | * all this mess below (and in et6000_init().... | |
98 | */ | 105 | */ | |
@@ -148,58 +155,56 @@ tseng_init(pci_chipset_tag_t pc, pcitag_ | @@ -148,58 +155,56 @@ tseng_init(pci_chipset_tag_t pc, pcitag_ | |||
148 | WAttr(ba, i, i); | 155 | WAttr(ba, i, i); | |
149 | for (; i < 0x18; i++) | 156 | for (; i < 0x18; i++) | |
150 | WAttr(ba, i, attr_tab[i - 0x10]); | 157 | WAttr(ba, i, attr_tab[i - 0x10]); | |
151 | WAttr(ba, 0x20, 0); | 158 | WAttr(ba, 0x20, 0); | |
152 | } | 159 | } | |
153 | 160 | |||
154 | /* | 161 | /* | |
155 | * Initialize the et6000 specific (PCI) registers. Try to do it like the | 162 | * Initialize the et6000 specific (PCI) registers. Try to do it like the | |
156 | * video-bios would have done it, so things like Xservers get what they | 163 | * video-bios would have done it, so things like Xservers get what they | |
157 | * expect. Most info was kindly provided by Koen Gadeyne. | 164 | * expect. Most info was kindly provided by Koen Gadeyne. | |
158 | */ | 165 | */ | |
159 | 166 | |||
160 | static void | 167 | static void | |
161 | et6000_init(volatile u_char *ba, u_char *fb, int iter) | 168 | et6000_init(volatile uint8_t *ba, uint8_t *fb, int iter) | |
162 | { | 169 | { | |
163 | ||||
164 | int i; | 170 | int i; | |
165 | u_char dac_tab[] = { 0x7d,0x67, 0x5d,0x64, 0x56,0x63, | 171 | uint8_t dac_tab[] = { 0x7d,0x67, 0x5d,0x64, 0x56,0x63, | |
166 | 0x28,0x22, 0x79,0x49, 0x6f,0x47, | 172 | 0x28,0x22, 0x79,0x49, 0x6f,0x47, | |
167 | 0x28,0x41, 0x6b,0x44, 0x00,0x00, | 173 | 0x28,0x41, 0x6b,0x44, 0x00,0x00, | |
168 | 0x00,0x00, 0x5d,0x25, 0x00,0x00, | 174 | 0x00,0x00, 0x5d,0x25, 0x00,0x00, | |
169 | 0x00,0x00, 0x00,0x96 }; | 175 | 0x00,0x00, 0x00,0x96 }; | |
170 | 176 | |||
171 | ba += 0x800; | 177 | ba += 0x800; | |
172 | 178 | |||
173 | ||||
174 | ba[0x40] = 0x06; /* Use standard vga addressing */ | 179 | ba[0x40] = 0x06; /* Use standard vga addressing */ | |
175 | ba[0x41] = 0x2a; /* Performance control */ | 180 | ba[0x41] = 0x2a; /* Performance control */ | |
176 | ba[0x43] = 0x02; /* XCLK/SCLK config */ | 181 | ba[0x43] = 0x02; /* XCLK/SCLK config */ | |
177 | ba[0x44] = ras_cas_tab[iter]; /* RAS/CAS config */ | 182 | ba[0x44] = ras_cas_tab[iter]; /* RAS/CAS config */ | |
178 | ba[0x46] = 0x00; /* CRT display feature */ | 183 | ba[0x46] = 0x00; /* CRT display feature */ | |
179 | ba[0x47] = 0x10; | 184 | ba[0x47] = 0x10; | |
180 | ba[0x58] = 0x00; /* Video Control 1 */ | 185 | ba[0x58] = 0x00; /* Video Control 1 */ | |
181 | ba[0x59] = 0x04; /* Video Control 2 */ | 186 | ba[0x59] = 0x04; /* Video Control 2 */ | |
182 | 187 | |||
183 | /* | 188 | /* | |
184 | * Setup a 'standard' CLKDAC | 189 | * Setup a 'standard' CLKDAC | |
185 | */ | 190 | */ | |
186 | ba[0x42] = 0x00; /* MCLK == CLK0 */ | 191 | ba[0x42] = 0x00; /* MCLK == CLK0 */ | |
187 | ba[0x67] = 0x00; /* Start filling from dac-reg 0 and up... */ | 192 | ba[0x67] = 0x00; /* Start filling from dac-reg 0 and up... */ | |
188 | for (i = 0; i < 0x16; i++) | 193 | for (i = 0; i < 0x16; i++) | |
189 | ba[0x69] = dac_tab[i]; | 194 | ba[0x69] = dac_tab[i]; | |
190 | 195 | |||
191 | if (ba[8] == 0x70) { /* et6100, right? */ | 196 | if (ba[8] == 0x70) { /* et6100, right? */ | |
192 | volatile u_char *ma = (volatile u_char *)fb; | 197 | volatile uint8_t *ma = (volatile uint8_t *)fb; | |
193 | u_char bv; | 198 | uint8_t bv; | |
194 | 199 | |||
195 | /* | 200 | /* | |
196 | * XXX Black magic to get the bloody MDRAM's to function... | 201 | * XXX Black magic to get the bloody MDRAM's to function... | |
197 | * XXX _Only_ tested on my card! [leo] | 202 | * XXX _Only_ tested on my card! [leo] | |
198 | */ | 203 | */ | |
199 | bv = ba[45]; | 204 | bv = ba[45]; | |
200 | ba[0x45] = bv | 0x40; /* Reset MDRAM's */ | 205 | ba[0x45] = bv | 0x40; /* Reset MDRAM's */ | |
201 | ba[0x45] = bv | 0x70; /* Program latency value */ | 206 | ba[0x45] = bv | 0x70; /* Program latency value */ | |
202 | ma[0x0] = 0; /* Yeah, right :-( */ | 207 | ma[0x0] = 0; /* Yeah, right :-( */ | |
203 | ba[0x45] = bv; /* Back to normal */ | 208 | ba[0x45] = bv; /* Back to normal */ | |
204 | } | 209 | } | |
205 | } | 210 | } |
--- src/sys/arch/atari/pci/pci_vga.h 2009/10/20 19:10:11 1.5
+++ src/sys/arch/atari/pci/pci_vga.h 2019/05/04 08:20:05 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pci_vga.h,v 1.5 2009/10/20 19:10:11 snj Exp $ */ | 1 | /* $NetBSD: pci_vga.h,v 1.6 2019/05/04 08:20:05 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1999 Leo Weppelman. All rights reserved. | 4 | * Copyright (c) 1999 Leo Weppelman. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -18,18 +18,19 @@ | @@ -18,18 +18,19 @@ | |||
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | */ | 25 | */ | |
26 | int check_for_vga(bus_space_tag_t, bus_space_tag_t); | 26 | int check_for_vga(bus_space_tag_t, bus_space_tag_t); | |
27 | 27 | |||
28 | /* | 28 | /* | |
29 | * Card specific functions | 29 | * Card specific functions | |
30 | */ | 30 | */ | |
31 | void ati_vga_init (pci_chipset_tag_t, pcitag_t, int, volatile u_char *, | 31 | void ati_vga_init(pci_chipset_tag_t, pcitag_t, int, volatile uint8_t *, | |
32 | u_char *); | 32 | uint8_t *); | |
33 | void tseng_init (pci_chipset_tag_t, pcitag_t, int, volatile u_char *, u_char *); | 33 | void tseng_init(pci_chipset_tag_t, pcitag_t, int, volatile uint8_t *, | |
34 | void milan_vga_init(pci_chipset_tag_t, pcitag_t, int, volatile u_char *, | 34 | uint8_t *); | |
35 | u_char *); | 35 | void milan_vga_init(pci_chipset_tag_t, pcitag_t, int, volatile uint8_t *, | |
36 | uint8_t *); |
--- src/sys/arch/atari/pci/pciide_machdep.c 2012/10/27 17:17:43 1.7
+++ src/sys/arch/atari/pci/pciide_machdep.c 2019/05/04 08:20:05 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pciide_machdep.c,v 1.7 2012/10/27 17:17:43 chs Exp $ */ | 1 | /* $NetBSD: pciide_machdep.c,v 1.8 2019/05/04 08:20:05 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998 Christopher G. Demetriou. All rights reserved. | 4 | * Copyright (c) 1998 Christopher G. Demetriou. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. All advertising materials mentioning features or use of this software | 14 | * 3. All advertising materials mentioning features or use of this software | |
@@ -31,41 +31,41 @@ | @@ -31,41 +31,41 @@ | |||
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * PCI IDE controller driver (i386 machine-dependent portion). | 34 | * PCI IDE controller driver (i386 machine-dependent portion). | |
35 | * | 35 | * | |
36 | * Author: Christopher G. Demetriou, March 2, 1998 (derived from NetBSD | 36 | * Author: Christopher G. Demetriou, March 2, 1998 (derived from NetBSD | |
37 | * sys/dev/pci/ppb.c, revision 1.16). | 37 | * sys/dev/pci/ppb.c, revision 1.16). | |
38 | * | 38 | * | |
39 | * See "PCI IDE Controller Specification, Revision 1.0 3/4/94" from the | 39 | * See "PCI IDE Controller Specification, Revision 1.0 3/4/94" from the | |
40 | * PCI SIG. | 40 | * PCI SIG. | |
41 | */ | 41 | */ | |
42 | 42 | |||
43 | #include <sys/cdefs.h> | 43 | #include <sys/cdefs.h> | |
44 | __KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.7 2012/10/27 17:17:43 chs Exp $"); | 44 | __KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.8 2019/05/04 08:20:05 tsutsui Exp $"); | |
45 | 45 | |||
46 | #include <sys/param.h> | 46 | #include <sys/param.h> | |
47 | #include <sys/systm.h> | 47 | #include <sys/systm.h> | |
48 | #include <sys/device.h> | 48 | #include <sys/device.h> | |
49 | 49 | |||
50 | #include <dev/pci/pcireg.h> | 50 | #include <dev/pci/pcireg.h> | |
51 | #include <dev/pci/pcivar.h> | 51 | #include <dev/pci/pcivar.h> | |
52 | #include <dev/pci/pciidereg.h> | 52 | #include <dev/pci/pciidereg.h> | |
53 | #include <dev/pci/pciidevar.h> | 53 | #include <dev/pci/pciidevar.h> | |
54 | 54 | |||
55 | #include <dev/isa/isavar.h> | 55 | #include <dev/isa/isavar.h> | |
56 | 56 | |||
57 | void * | 57 | void * | |
58 | pciide_machdep_compat_intr_establish(device_t dev, | 58 | pciide_machdep_compat_intr_establish(device_t dev, | |
59 | const struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg) | 59 | const struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg) | |
60 | { | 60 | { | |
61 | int irq; | 61 | int irq; | |
62 | void *cookie; | 62 | void *cookie; | |
63 | 63 | |||
64 | irq = PCIIDE_COMPAT_IRQ(chan); | 64 | irq = PCIIDE_COMPAT_IRQ(chan); | |
65 | cookie = isa_intr_establish(NULL, irq, IST_EDGE, IPL_BIO, func, arg); | 65 | cookie = isa_intr_establish(NULL, irq, IST_EDGE, IPL_BIO, func, arg); | |
66 | if (cookie == NULL) | 66 | if (cookie == NULL) | |
67 | return (NULL); | 67 | return (NULL); | |
68 | printf("%s: %s channel interrupting at irq %d\n", device_xname(dev), | 68 | printf("%s: %s channel interrupting at irq %d\n", device_xname(dev), | |
69 | PCIIDE_CHANNEL_NAME(chan), irq); | 69 | PCIIDE_CHANNEL_NAME(chan), irq); | |
70 | return (cookie); | 70 | return cookie; | |
71 | } | 71 | } |