blob: 6ae598532cf2d87c6799b76103d4e852f6ddc249 [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.
Stefan Reinauerc65666f2010-04-03 12:41:41 +000015 */
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000016
Lee Leahy75b85992017-03-08 16:34:12 -080017static void print_debug_pci_dev(unsigned int dev)
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000018{
Stefan Reinauerd6865222015-01-05 13:12:38 -080019 printk(BIOS_DEBUG, "PCI: %02x:%02x.%x",
20 (dev >> 16) & 0xff, (dev >> 11) & 0x1f, (dev >> 8) & 7);
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000021}
22
Stefan Reinauerc65666f2010-04-03 12:41:41 +000023static inline void print_pci_devices(void)
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000024{
25 device_t dev;
Stefan Reinauerc65666f2010-04-03 12:41:41 +000026 for (dev = PCI_DEV(0, 0, 0);
Stefan Reinauer5391fe02010-04-15 12:43:07 +000027 dev <= PCI_DEV(0x00, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
Stefan Reinauerc65666f2010-04-03 12:41:41 +000028 u32 id;
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000029 id = pci_read_config32(dev, PCI_VENDOR_ID);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000030 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
31 || (((id >> 16) & 0xffff) == 0xffff)
32 || (((id >> 16) & 0xffff) == 0x0000)) {
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000033 continue;
34 }
35 print_debug_pci_dev(dev);
Stefan Reinauerd6865222015-01-05 13:12:38 -080036 printk(BIOS_DEBUG, "\n");
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000037 }
38}
39
Lee Leahy75b85992017-03-08 16:34:12 -080040static void dump_pci_device(unsigned int dev)
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000041{
42 int i;
43 print_debug_pci_dev(dev);
Stefan Reinauerd6865222015-01-05 13:12:38 -080044 printk(BIOS_DEBUG, "\n");
Stefan Reinauerc65666f2010-04-03 12:41:41 +000045
46 for (i = 0; i <= 255; i++) {
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000047 unsigned char val;
Stefan Reinauerd6865222015-01-05 13:12:38 -080048 if ((i & 0x0f) == 0)
49 printk(BIOS_DEBUG, "%02x:", i);
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000050 val = pci_read_config8(dev, i);
Stefan Reinauerd6865222015-01-05 13:12:38 -080051 printk(BIOS_DEBUG, " %02x", val);
52 if ((i & 0x0f) == 0x0f)
53 printk(BIOS_DEBUG, "\n");
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000054 }
55}
56
Stefan Reinauerc65666f2010-04-03 12:41:41 +000057static inline void dump_pci_devices(void)
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000058{
59 device_t dev;
Stefan Reinauerc65666f2010-04-03 12:41:41 +000060 for (dev = PCI_DEV(0, 0, 0);
61 dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
62 u32 id;
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000063 id = pci_read_config32(dev, PCI_VENDOR_ID);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000064 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
65 || (((id >> 16) & 0xffff) == 0xffff)
66 || (((id >> 16) & 0xffff) == 0x0000)) {
Ronald G. Minnich2bb216a2006-01-27 23:46:30 +000067 continue;
68 }
69 dump_pci_device(dev);
70 }
71}
Stefan Reinauerc65666f2010-04-03 12:41:41 +000072
73
Lee Leahy75b85992017-03-08 16:34:12 -080074static inline void dump_io_resources(unsigned int port)
Stefan Reinauerc65666f2010-04-03 12:41:41 +000075{
Stefan Reinauerc65666f2010-04-03 12:41:41 +000076 int i;
Stefan Reinauerd6865222015-01-05 13:12:38 -080077 printk(BIOS_DEBUG, "%04x:\n", port);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000078 for (i = 0; i < 256; i++) {
79 u8 val;
Stefan Reinauerd6865222015-01-05 13:12:38 -080080 if ((i & 0x0f) == 0)
81 printk(BIOS_DEBUG, "%02x:", i);
Stefan Reinauerc65666f2010-04-03 12:41:41 +000082 val = inb(port);
Stefan Reinauerd6865222015-01-05 13:12:38 -080083 printk(BIOS_DEBUG, " %02x", val);
84 if ((i & 0x0f) == 0x0f)
85 printk(BIOS_DEBUG, "\n");
Stefan Reinauerc65666f2010-04-03 12:41:41 +000086 port++;
87 }
88}