blob: 8d629c201982291af83e60e60178ab3984d01d2e [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{
Stefan Reinauerd6865222015-01-05 13:12:38 -080024 printk(BIOS_DEBUG, "PCI: %02x:%02x.%x",
25 (dev >> 16) & 0xff, (dev >> 11) & 0x1f, (dev >> 8) & 7);
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000026}
27
Stefan Reinauerc65666f2010-04-03 12:41:41 +000028static inline void print_pci_devices(void)
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000029{
30 device_t dev;
Stefan Reinauerc65666f2010-04-03 12:41:41 +000031 for (dev = PCI_DEV(0, 0, 0);
Stefan Reinauer5391fe02010-04-15 12:43:07 +000032 dev <= PCI_DEV(0x00, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
Stefan Reinauerc65666f2010-04-03 12:41:41 +000033 u32 id;
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000034 id = pci_read_config32(dev, PCI_VENDOR_ID);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000035 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
36 || (((id >> 16) & 0xffff) == 0xffff)
37 || (((id >> 16) & 0xffff) == 0x0000)) {
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000038 continue;
39 }
40 print_debug_pci_dev(dev);
Stefan Reinauerd6865222015-01-05 13:12:38 -080041 printk(BIOS_DEBUG, "\n");
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000042 }
43}
44
45static void dump_pci_device(unsigned dev)
46{
47 int i;
48 print_debug_pci_dev(dev);
Stefan Reinauerd6865222015-01-05 13:12:38 -080049 printk(BIOS_DEBUG, "\n");
Stefan Reinauerc65666f2010-04-03 12:41:41 +000050
51 for (i = 0; i <= 255; i++) {
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000052 unsigned char val;
Stefan Reinauerd6865222015-01-05 13:12:38 -080053 if ((i & 0x0f) == 0)
54 printk(BIOS_DEBUG, "%02x:", i);
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000055 val = pci_read_config8(dev, i);
Stefan Reinauerd6865222015-01-05 13:12:38 -080056 printk(BIOS_DEBUG, " %02x", val);
57 if ((i & 0x0f) == 0x0f)
58 printk(BIOS_DEBUG, "\n");
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000059 }
60}
61
Stefan Reinauerc65666f2010-04-03 12:41:41 +000062static inline void dump_pci_devices(void)
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000063{
64 device_t dev;
Stefan Reinauerc65666f2010-04-03 12:41:41 +000065 for (dev = PCI_DEV(0, 0, 0);
66 dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
67 u32 id;
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000068 id = pci_read_config32(dev, PCI_VENDOR_ID);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000069 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
70 || (((id >> 16) & 0xffff) == 0xffff)
71 || (((id >> 16) & 0xffff) == 0x0000)) {
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000072 continue;
73 }
74 dump_pci_device(dev);
75 }
76}
Stefan Reinauerc65666f2010-04-03 12:41:41 +000077
78
79static inline void dump_io_resources(unsigned port)
80{
Stefan Reinauerc65666f2010-04-03 12:41:41 +000081 int i;
Stefan Reinauerd6865222015-01-05 13:12:38 -080082 printk(BIOS_DEBUG, "%04x:\n", port);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000083 for (i = 0; i < 256; i++) {
84 u8 val;
Stefan Reinauerd6865222015-01-05 13:12:38 -080085 if ((i & 0x0f) == 0)
86 printk(BIOS_DEBUG, "%02x:", i);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000087 val = inb(port);
Stefan Reinauerd6865222015-01-05 13:12:38 -080088 printk(BIOS_DEBUG, " %02x", val);
89 if ((i & 0x0f) == 0x0f)
90 printk(BIOS_DEBUG, "\n");
Stefan Reinauerc65666f2010-04-03 12:41:41 +000091 port++;
92 }
93}