use movsl for copying resume memory back
[coreboot.git] / src / lib / debug.c
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  */
21
22 static 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
32 static inline void print_pci_devices(void)
33 {
34         device_t dev;
35         for (dev = PCI_DEV(0, 0, 0);
36              dev <= PCI_DEV(0x00, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
37                 u32 id;
38                 id = pci_read_config32(dev, PCI_VENDOR_ID);
39                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
40                     || (((id >> 16) & 0xffff) == 0xffff)
41                     || (((id >> 16) & 0xffff) == 0x0000)) {
42                         continue;
43                 }
44                 print_debug_pci_dev(dev);
45                 print_debug("\n");
46         }
47 }
48
49 static void dump_pci_device(unsigned dev)
50 {
51         int i;
52         print_debug_pci_dev(dev);
53         print_debug("\n");
54
55         for (i = 0; i <= 255; i++) {
56                 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) {
65                         print_debug("\n");
66                 }
67         }
68 }
69
70 static inline void dump_pci_devices(void)
71 {
72         device_t dev;
73         for (dev = PCI_DEV(0, 0, 0);
74              dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
75                 u32 id;
76                 id = pci_read_config32(dev, PCI_VENDOR_ID);
77                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff)
78                     || (((id >> 16) & 0xffff) == 0xffff)
79                     || (((id >> 16) & 0xffff) == 0x0000)) {
80                         continue;
81                 }
82                 dump_pci_device(dev);
83         }
84 }
85
86
87 static inline void dump_io_resources(unsigned port)
88 {
89
90         int i;
91         print_debug_hex16(port);
92         print_debug(":\n");
93         for (i = 0; i < 256; i++) {
94                 u8 val;
95                 if ((i & 0x0f) == 0) {
96                         print_debug_hex8(i);
97                         print_debug_char(':');
98                 }
99                 val = inb(port);
100                 print_debug_char(' ');
101                 print_debug_hex8(val);
102                 if ((i & 0x0f) == 0x0f) {
103                         print_debug("\n");
104                 }
105                 port++;
106         }
107 }