]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/MAI/bios_emulator/scitech/src/pm/tests/showpci.c
1 /****************************************************************************
3 * SciTech OS Portability Manager Library
5 * ========================================================================
7 * The contents of this file are subject to the SciTech MGL Public
8 * License Version 1.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of
10 * the License at http://www.scitechsoft.com/mgl-license.txt
12 * Software distributed under the License is distributed on an
13 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * rights and limitations under the License.
17 * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
19 * The Initial Developer of the Original Code is SciTech Software, Inc.
20 * All Rights Reserved.
22 * ========================================================================
27 * Description: Test program to test the PCI library functions.
29 ****************************************************************************/
38 /*------------------------- Global Variables ------------------------------*/
40 static int NumPCI
= -1;
41 static PCIDeviceInfo
*PCI
;
42 static int *BridgeIndex
;
43 static int *DeviceIndex
;
44 static int NumBridges
;
45 static PCIDeviceInfo
*AGPBridge
= NULL
;
46 static int NumDevices
;
48 /*-------------------------- Implementation -------------------------------*/
50 /****************************************************************************
52 Enumerates the PCI bus and dumps the PCI configuration information to the
54 ****************************************************************************/
55 static void EnumeratePCI(void)
60 printf("Displaying enumeration of PCI bus (%d devices, %d display devices)\n",
62 for (index
= 0; index
< NumDevices
; index
++)
63 printf(" Display device %d is PCI device %d\n",index
,DeviceIndex
[index
]);
65 printf("Bus Slot Fnc DeviceID SubSystem Rev Class IRQ Int Cmd\n");
66 for (i
= 0; i
< NumPCI
; i
++) {
67 printf("%2d %2d %2d %04X:%04X %04X:%04X %02X %02X:%02X %02X %02X %04X ",
70 PCI
[i
].slot
.p
.Function
,
73 PCI
[i
].u
.type0
.SubSystemVendorID
,
74 PCI
[i
].u
.type0
.SubSystemID
,
78 PCI
[i
].u
.type0
.InterruptLine
,
79 PCI
[i
].u
.type0
.InterruptPin
,
81 for (index
= 0; index
< NumDevices
; index
++) {
82 if (DeviceIndex
[index
] == i
)
85 if (index
< NumDevices
)
86 printf("<- %d\n", index
);
91 printf("DeviceID Stat Ifc Cch Lat Hdr BIST\n");
92 for (i
= 0; i
< NumPCI
; i
++) {
93 printf("%04X:%04X %04X %02X %02X %02X %02X %02X ",
102 for (index
= 0; index
< NumDevices
; index
++) {
103 if (DeviceIndex
[index
] == i
)
106 if (index
< NumDevices
)
107 printf("<- %d\n", index
);
112 printf("DeviceID Base10h Base14h Base18h Base1Ch Base20h Base24h ROMBase\n");
113 for (i
= 0; i
< NumPCI
; i
++) {
114 printf("%04X:%04X %08lX %08lX %08lX %08lX %08lX %08lX %08lX ",
117 PCI
[i
].u
.type0
.BaseAddress10
,
118 PCI
[i
].u
.type0
.BaseAddress14
,
119 PCI
[i
].u
.type0
.BaseAddress18
,
120 PCI
[i
].u
.type0
.BaseAddress1C
,
121 PCI
[i
].u
.type0
.BaseAddress20
,
122 PCI
[i
].u
.type0
.BaseAddress24
,
123 PCI
[i
].u
.type0
.ROMBaseAddress
);
124 for (index
= 0; index
< NumDevices
; index
++) {
125 if (DeviceIndex
[index
] == i
)
128 if (index
< NumDevices
)
129 printf("<- %d\n", index
);
134 printf("DeviceID BAR10Len BAR14Len BAR18Len BAR1CLen BAR20Len BAR24Len ROMLen\n");
135 for (i
= 0; i
< NumPCI
; i
++) {
136 printf("%04X:%04X %08lX %08lX %08lX %08lX %08lX %08lX %08lX ",
139 PCI
[i
].u
.type0
.BaseAddress10Len
,
140 PCI
[i
].u
.type0
.BaseAddress14Len
,
141 PCI
[i
].u
.type0
.BaseAddress18Len
,
142 PCI
[i
].u
.type0
.BaseAddress1CLen
,
143 PCI
[i
].u
.type0
.BaseAddress20Len
,
144 PCI
[i
].u
.type0
.BaseAddress24Len
,
145 PCI
[i
].u
.type0
.ROMBaseAddressLen
);
146 for (index
= 0; index
< NumDevices
; index
++) {
147 if (DeviceIndex
[index
] == i
)
150 if (index
< NumDevices
)
151 printf("<- %d\n", index
);
156 printf("Displaying enumeration of %d bridge devices\n",NumBridges
);
158 printf("DeviceID P# S# B# IOB IOL MemBase MemLimit PreBase PreLimit Ctrl\n");
159 for (i
= 0; i
< NumBridges
; i
++) {
160 info
= (PCIDeviceInfo
*)&PCI
[BridgeIndex
[i
]];
161 printf("%04X:%04X %02X %02X %02X %04X %04X %08X %08X %08X %08X %04X\n",
164 info
->u
.type1
.PrimaryBusNumber
,
165 info
->u
.type1
.SecondayBusNumber
,
166 info
->u
.type1
.SubordinateBusNumber
,
167 ((u16
)info
->u
.type1
.IOBase
<< 8) & 0xF000,
168 info
->u
.type1
.IOLimit
?
169 ((u16
)info
->u
.type1
.IOLimit
<< 8) | 0xFFF : 0,
170 ((u32
)info
->u
.type1
.MemoryBase
<< 16) & 0xFFF00000,
171 info
->u
.type1
.MemoryLimit
?
172 ((u32
)info
->u
.type1
.MemoryLimit
<< 16) | 0xFFFFF : 0,
173 ((u32
)info
->u
.type1
.PrefetchableMemoryBase
<< 16) & 0xFFF00000,
174 info
->u
.type1
.PrefetchableMemoryLimit
?
175 ((u32
)info
->u
.type1
.PrefetchableMemoryLimit
<< 16) | 0xFFFFF : 0,
176 info
->u
.type1
.BridgeControl
);
181 /****************************************************************************
183 Number of display devices found.
186 This function enumerates the number of available display devices on the
187 PCI bus, and returns the number found.
188 ****************************************************************************/
189 static int PCI_enumerateDevices(void)
194 /* If this is the first time we have been called, enumerate all */
195 /* devices on the PCI bus. */
197 if ((NumPCI
= PCI_getNumDevices()) == 0)
199 PCI
= malloc(NumPCI
* sizeof(PCI
[0]));
200 BridgeIndex
= malloc(NumPCI
* sizeof(BridgeIndex
[0]));
201 DeviceIndex
= malloc(NumPCI
* sizeof(DeviceIndex
[0]));
202 if (!PCI
|| !BridgeIndex
|| !DeviceIndex
)
204 for (i
= 0; i
< NumPCI
; i
++)
205 PCI
[i
].dwSize
= sizeof(PCI
[i
]);
206 if (PCI_enumerate(PCI
) == 0)
209 /* Build a list of all PCI bridge devices */
210 for (i
= 0,NumBridges
= 0,BridgeIndex
[0] = -1; i
< NumPCI
; i
++) {
211 if (PCI
[i
].BaseClass
== PCI_BRIDGE_CLASS
)
212 BridgeIndex
[NumBridges
++] = i
;
215 /* Now build a list of all display class devices */
216 for (i
= 0,NumDevices
= 1,DeviceIndex
[0] = -1; i
< NumPCI
; i
++) {
217 if (PCI_IS_DISPLAY_CLASS(&PCI
[i
])) {
218 if ((PCI
[i
].Command
& 0x3) == 0x3)
221 DeviceIndex
[NumDevices
++] = i
;
222 if (PCI
[i
].slot
.p
.Bus
!= 0) {
223 /* This device is on a different bus than the primary */
224 /* PCI bus, so it is probably an AGP device. Find the */
225 /* AGP bus device that controls that bus so we can */
227 for (j
= 0; j
< NumBridges
; j
++) {
228 info
= (PCIDeviceInfo
*)&PCI
[BridgeIndex
[j
]];
229 if (info
->u
.type1
.SecondayBusNumber
== PCI
[i
].slot
.p
.Bus
) {
238 /* Enumerate all PCI and bridge devices to standard output */
246 /* Enumerate all PCI devices */
248 if (PCI_enumerateDevices() < 1) {
249 printf("No PCI display devices found!\n");