blob: 35d1f90bcbff12f06be9aa6072e5ed1a951f50ec [file] [log] [blame]
Stefan Reinauerc65666f2010-04-03 12:41:41 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * (C) 2007-2009 coresystems GmbH
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19 * MA 02110-1301 USA
20 */
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000021
22static void print_debug_pci_dev(unsigned dev)
23{
24 print_debug("PCI: ");
25 print_debug_hex8((dev >> 16) & 0xff);
26 print_debug_char(':');
27 print_debug_hex8((dev >> 11) & 0x1f);
28 print_debug_char('.');
29 print_debug_hex8((dev >> 8) & 7);
30}
31
Stefan Reinauerc65666f2010-04-03 12:41:41 +000032static inline void print_pci_devices(void)
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000033{
34 device_t dev;
Stefan Reinauerc65666f2010-04-03 12:41:41 +000035 for (dev = PCI_DEV(0, 0, 0);
36 dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
37 u32 id;
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000038 id = pci_read_config32(dev, PCI_VENDOR_ID);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000039 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
40 || (((id >> 16) & 0xffff) == 0xffff)
41 || (((id >> 16) & 0xffff) == 0x0000)) {
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000042 continue;
43 }
44 print_debug_pci_dev(dev);
Stefan Reinauer64ed2b72010-03-31 14:47:43 +000045 print_debug("\n");
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000046 }
47}
48
49static void dump_pci_device(unsigned dev)
50{
51 int i;
52 print_debug_pci_dev(dev);
Stefan Reinauer64ed2b72010-03-31 14:47:43 +000053 print_debug("\n");
Stefan Reinauerc65666f2010-04-03 12:41:41 +000054
55 for (i = 0; i <= 255; i++) {
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000056 unsigned char val;
57 if ((i & 0x0f) == 0) {
58 print_debug_hex8(i);
59 print_debug_char(':');
60 }
61 val = pci_read_config8(dev, i);
62 print_debug_char(' ');
63 print_debug_hex8(val);
64 if ((i & 0x0f) == 0x0f) {
Stefan Reinauer64ed2b72010-03-31 14:47:43 +000065 print_debug("\n");
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000066 }
67 }
68}
69
Stefan Reinauerc65666f2010-04-03 12:41:41 +000070static inline void dump_pci_devices(void)
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000071{
72 device_t dev;
Stefan Reinauerc65666f2010-04-03 12:41:41 +000073 for (dev = PCI_DEV(0, 0, 0);
74 dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
75 u32 id;
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000076 id = pci_read_config32(dev, PCI_VENDOR_ID);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000077 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
78 || (((id >> 16) & 0xffff) == 0xffff)
79 || (((id >> 16) & 0xffff) == 0x0000)) {
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000080 continue;
81 }
82 dump_pci_device(dev);
83 }
84}
Stefan Reinauerc65666f2010-04-03 12:41:41 +000085
86
87static inline void dump_io_resources(unsigned port)
88{
89
90 int i;
91 udelay(2000);
92 print_debug_hex16(port);
93 print_debug(":\n");
94 for (i = 0; i < 256; i++) {
95 u8 val;
96 if ((i & 0x0f) == 0) {
97 print_debug_hex8(i);
98 print_debug_char(':');
99 }
100 val = inb(port);
101 print_debug_char(' ');
102 print_debug_hex8(val);
103 if ((i & 0x0f) == 0x0f) {
104 print_debug("\n");
105 }
106 port++;
107 }
108}