soc/mediatek/mt8173: Remove unneeded header inclusion
[coreboot.git] / src / lib / debug.c
blob6ae598532cf2d87c6799b76103d4e852f6ddc249
1 /*
2 * This file is part of the coreboot project.
4 * (C) 2007-2009 coresystems GmbH
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.
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.
17 static void print_debug_pci_dev(unsigned int dev)
19 printk(BIOS_DEBUG, "PCI: %02x:%02x.%x",
20 (dev >> 16) & 0xff, (dev >> 11) & 0x1f, (dev >> 8) & 7);
23 static inline void print_pci_devices(void)
25 device_t dev;
26 for (dev = PCI_DEV(0, 0, 0);
27 dev <= PCI_DEV(0x00, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
28 u32 id;
29 id = pci_read_config32(dev, PCI_VENDOR_ID);
30 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
31 || (((id >> 16) & 0xffff) == 0xffff)
32 || (((id >> 16) & 0xffff) == 0x0000)) {
33 continue;
35 print_debug_pci_dev(dev);
36 printk(BIOS_DEBUG, "\n");
40 static void dump_pci_device(unsigned int dev)
42 int i;
43 print_debug_pci_dev(dev);
44 printk(BIOS_DEBUG, "\n");
46 for (i = 0; i <= 255; i++) {
47 unsigned char val;
48 if ((i & 0x0f) == 0)
49 printk(BIOS_DEBUG, "%02x:", i);
50 val = pci_read_config8(dev, i);
51 printk(BIOS_DEBUG, " %02x", val);
52 if ((i & 0x0f) == 0x0f)
53 printk(BIOS_DEBUG, "\n");
57 static inline void dump_pci_devices(void)
59 device_t dev;
60 for (dev = PCI_DEV(0, 0, 0);
61 dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
62 u32 id;
63 id = pci_read_config32(dev, PCI_VENDOR_ID);
64 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
65 || (((id >> 16) & 0xffff) == 0xffff)
66 || (((id >> 16) & 0xffff) == 0x0000)) {
67 continue;
69 dump_pci_device(dev);
74 static inline void dump_io_resources(unsigned int port)
76 int i;
77 printk(BIOS_DEBUG, "%04x:\n", port);
78 for (i = 0; i < 256; i++) {
79 u8 val;
80 if ((i & 0x0f) == 0)
81 printk(BIOS_DEBUG, "%02x:", i);
82 val = inb(port);
83 printk(BIOS_DEBUG, " %02x", val);
84 if ((i & 0x0f) == 0x0f)
85 printk(BIOS_DEBUG, "\n");
86 port++;