Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 1 | /* |
| 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. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 21 | |
| 22 | static void print_debug_pci_dev(unsigned dev) |
| 23 | { |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame^] | 24 | printk(BIOS_DEBUG, "PCI: %02x:%02x.%x", |
| 25 | (dev >> 16) & 0xff, (dev >> 11) & 0x1f, (dev >> 8) & 7); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 28 | static inline void print_pci_devices(void) |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 29 | { |
| 30 | device_t dev; |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 31 | for (dev = PCI_DEV(0, 0, 0); |
Stefan Reinauer | 5391fe0 | 2010-04-15 12:43:07 +0000 | [diff] [blame] | 32 | dev <= PCI_DEV(0x00, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) { |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 33 | u32 id; |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 34 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 35 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) |
| 36 | || (((id >> 16) & 0xffff) == 0xffff) |
| 37 | || (((id >> 16) & 0xffff) == 0x0000)) { |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 38 | continue; |
| 39 | } |
| 40 | print_debug_pci_dev(dev); |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame^] | 41 | printk(BIOS_DEBUG, "\n"); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | |
| 45 | static void dump_pci_device(unsigned dev) |
| 46 | { |
| 47 | int i; |
| 48 | print_debug_pci_dev(dev); |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame^] | 49 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 50 | |
| 51 | for (i = 0; i <= 255; i++) { |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 52 | unsigned char val; |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame^] | 53 | if ((i & 0x0f) == 0) |
| 54 | printk(BIOS_DEBUG, "%02x:", i); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 55 | val = pci_read_config8(dev, i); |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame^] | 56 | printk(BIOS_DEBUG, " %02x", val); |
| 57 | if ((i & 0x0f) == 0x0f) |
| 58 | printk(BIOS_DEBUG, "\n"); |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 62 | static inline void dump_pci_devices(void) |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 63 | { |
| 64 | device_t dev; |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 65 | 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. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 68 | id = pci_read_config32(dev, PCI_VENDOR_ID); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 69 | if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) |
| 70 | || (((id >> 16) & 0xffff) == 0xffff) |
| 71 | || (((id >> 16) & 0xffff) == 0x0000)) { |
Ronald G. Minnich | 2bb216a | 2006-01-27 23:46:30 +0000 | [diff] [blame] | 72 | continue; |
| 73 | } |
| 74 | dump_pci_device(dev); |
| 75 | } |
| 76 | } |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 77 | |
| 78 | |
| 79 | static inline void dump_io_resources(unsigned port) |
| 80 | { |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 81 | int i; |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame^] | 82 | printk(BIOS_DEBUG, "%04x:\n", port); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 83 | for (i = 0; i < 256; i++) { |
| 84 | u8 val; |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame^] | 85 | if ((i & 0x0f) == 0) |
| 86 | printk(BIOS_DEBUG, "%02x:", i); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 87 | val = inb(port); |
Stefan Reinauer | d686522 | 2015-01-05 13:12:38 -0800 | [diff] [blame^] | 88 | printk(BIOS_DEBUG, " %02x", val); |
| 89 | if ((i & 0x0f) == 0x0f) |
| 90 | printk(BIOS_DEBUG, "\n"); |
Stefan Reinauer | c65666f | 2010-04-03 12:41:41 +0000 | [diff] [blame] | 91 | port++; |
| 92 | } |
| 93 | } |