Deleted Added
full compact
pci_cfgreg.c (10710) pci_cfgreg.c (10735)
1/**************************************************************************
2**
1/**************************************************************************
2**
3** $Id: pcibus.c,v 1.10 1995/06/30 16:11:42 se Exp $
3** $Id: pcibus.c,v 1.11 1995/09/13 17:03:47 se Exp $
4**
5** pci bus subroutines for i386 architecture.
6**
7** FreeBSD
8**
9**-------------------------------------------------------------------------
10**
11** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved.

--- 66 unchanged lines hidden (view full) ---

78** pcibus_regirq():
79** Register an interupt handler for a pci device.
80** Requires a tag (from pcitag), the register number
81** (should be a long word alligned one), and a value.
82**
83**-----------------------------------------------------------------
84*/
85
4**
5** pci bus subroutines for i386 architecture.
6**
7** FreeBSD
8**
9**-------------------------------------------------------------------------
10**
11** Copyright (c) 1994 Wolfgang Stanglmeier. All rights reserved.

--- 66 unchanged lines hidden (view full) ---

78** pcibus_regirq():
79** Register an interupt handler for a pci device.
80** Requires a tag (from pcitag), the register number
81** (should be a long word alligned one), and a value.
82**
83**-----------------------------------------------------------------
84*/
85
86static int
87pcibus_check (void);
88
86static void
87pcibus_setup (void);
88
89static pcici_t
90pcibus_tag (u_char bus, u_char device, u_char func);
91
92static pcici_t
93pcibus_ftag (pcici_t tag, u_char func);

--- 51 unchanged lines hidden (view full) ---

145#define CONF1_ADDR_PORT 0x0cf8
146#define CONF1_DATA_PORT 0x0cfc
147
148
149#define CONF2_ENABLE_PORT 0x0cf8
150#define CONF2_FORWARD_PORT 0x0cfa
151
152
89static void
90pcibus_setup (void);
91
92static pcici_t
93pcibus_tag (u_char bus, u_char device, u_char func);
94
95static pcici_t
96pcibus_ftag (pcici_t tag, u_char func);

--- 51 unchanged lines hidden (view full) ---

148#define CONF1_ADDR_PORT 0x0cf8
149#define CONF1_DATA_PORT 0x0cfc
150
151
152#define CONF2_ENABLE_PORT 0x0cf8
153#define CONF2_FORWARD_PORT 0x0cfa
154
155
156static int
157pcibus_check (void)
158{
159 u_char device;
160
161 for (device = 0; device < pci_maxdevice; device++) {
162 if (pcibus_read (pcibus_tag (0,device,0), 0) != 0xfffffffful)
163 return 1;
164 }
165 return 0;
166}
167
153static void
154pcibus_setup (void)
155{
156 u_long result, oldval;
157
158 /*---------------------------------------
159 ** Configuration mode 1 ?
160 **---------------------------------------
161 */
162
163 oldval = inl (CONF1_ADDR_PORT);
164 outl (CONF1_ADDR_PORT, CONF1_ENABLE_CHK1);
165 outb (CONF1_ADDR_PORT +3, 0);
166 result = inl (CONF1_ADDR_PORT);
167 outl (CONF1_ADDR_PORT, oldval);
168
169 if (result & CONF1_ENABLE) {
170 pci_mechanism = 1;
171 pci_maxdevice = 32;
168static void
169pcibus_setup (void)
170{
171 u_long result, oldval;
172
173 /*---------------------------------------
174 ** Configuration mode 1 ?
175 **---------------------------------------
176 */
177
178 oldval = inl (CONF1_ADDR_PORT);
179 outl (CONF1_ADDR_PORT, CONF1_ENABLE_CHK1);
180 outb (CONF1_ADDR_PORT +3, 0);
181 result = inl (CONF1_ADDR_PORT);
182 outl (CONF1_ADDR_PORT, oldval);
183
184 if (result & CONF1_ENABLE) {
185 pci_mechanism = 1;
186 pci_maxdevice = 32;
172 if (pcibus_read (pcibus_tag (0,0,0), 0) != 0xfffffffful)
187 if (pcibus_check())
173 return;
174 };
175
176 /*---------------------------------------
177 ** Configuration mode 2 ?
178 **---------------------------------------
179 */
180
181 outb (CONF2_ENABLE_PORT, 0);
182 outb (CONF2_FORWARD_PORT, 0);
183 if (!inb (CONF2_ENABLE_PORT) && !inb (CONF2_FORWARD_PORT)) {
184 pci_mechanism = 2;
185 pci_maxdevice = 16;
188 return;
189 };
190
191 /*---------------------------------------
192 ** Configuration mode 2 ?
193 **---------------------------------------
194 */
195
196 outb (CONF2_ENABLE_PORT, 0);
197 outb (CONF2_FORWARD_PORT, 0);
198 if (!inb (CONF2_ENABLE_PORT) && !inb (CONF2_FORWARD_PORT)) {
199 pci_mechanism = 2;
200 pci_maxdevice = 16;
186 if (pcibus_read (pcibus_tag (0,0,0), 0) != 0xfffffffful)
201 if (pcibus_check())
187 return;
188 };
189
190
191 /*-----------------------------------------------------
192 ** Well, is it Configuration mode 1, after all ?
193 **-----------------------------------------------------
194 */
195
196 oldval = inl (CONF1_ADDR_PORT);
197 outl (CONF1_ADDR_PORT, CONF1_ENABLE_CHK2);
198 result = inl (CONF1_ADDR_PORT);
199 outl (CONF1_ADDR_PORT, oldval);
200
201 if (result == CONF1_ENABLE_RES2) {
202 pci_mechanism = 1;
203 pci_maxdevice = 32;
202 return;
203 };
204
205
206 /*-----------------------------------------------------
207 ** Well, is it Configuration mode 1, after all ?
208 **-----------------------------------------------------
209 */
210
211 oldval = inl (CONF1_ADDR_PORT);
212 outl (CONF1_ADDR_PORT, CONF1_ENABLE_CHK2);
213 result = inl (CONF1_ADDR_PORT);
214 outl (CONF1_ADDR_PORT, oldval);
215
216 if (result == CONF1_ENABLE_RES2) {
217 pci_mechanism = 1;
218 pci_maxdevice = 32;
204 if (pcibus_read (pcibus_tag (0,0,0), 0) != 0xfffffffful)
219 if (pcibus_check())
205 return;
206 }
207 if (result != 0xfffffffful)
208 printf ("pcibus_setup: "
209 "wrote 0x%08x, read back 0x%08x, expected 0x%08x\n",
210 CONF1_ENABLE_CHK2, result, CONF1_ENABLE_RES2);
211
212 /*---------------------------------------

--- 231 unchanged lines hidden ---
220 return;
221 }
222 if (result != 0xfffffffful)
223 printf ("pcibus_setup: "
224 "wrote 0x%08x, read back 0x%08x, expected 0x%08x\n",
225 CONF1_ENABLE_CHK2, result, CONF1_ENABLE_RES2);
226
227 /*---------------------------------------

--- 231 unchanged lines hidden ---