printk_foo -> printk(BIOS_FOO, ...)
[coreboot.git] / src / northbridge / intel / i945 / debug.c
1 /*
2  * This file is part of the coreboot project.
3  * 
4  * Copyright (C) 2007-2008 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 #define SMBUS_MEM_DEVICE_START 0x50
23 #define SMBUS_MEM_DEVICE_END 0x53
24 #define SMBUS_MEM_DEVICE_INC 1
25
26 static void print_pci_devices(void)
27 {
28         device_t dev;
29         for(dev = PCI_DEV(0, 0, 0); 
30                 dev <= PCI_DEV(0, 0x1f, 0x7); 
31                 dev += PCI_DEV(0,0,1)) {
32                 uint32_t id;
33                 id = pci_read_config32(dev, PCI_VENDOR_ID);
34                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
35                         (((id >> 16) & 0xffff) == 0xffff) ||
36                         (((id >> 16) & 0xffff) == 0x0000)) {
37                         continue;
38                 }
39                 printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev >> 20) & 0xff,
40                         (dev >> 15) & 0x1f, (dev >> 12) & 7);
41                 printk(BIOS_DEBUG, " [%04x:%04x]\n", id &0xffff, id >> 16);
42         }
43 }
44
45 static void dump_pci_device(unsigned dev)
46 {
47         int i;
48
49         printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x\n", (dev >> 20) & 0xff, (dev >> 15) & 0x1f, (dev >> 12) & 7);
50
51         for(i = 0; i <= 255; i++) {
52                 unsigned char val;
53                 if ((i & 0x0f) == 0) {
54                         printk(BIOS_DEBUG, "%02x:", i);
55                 }
56                 val = pci_read_config8(dev, i);
57                 printk(BIOS_DEBUG, " %02x", val);
58                 if ((i & 0x0f) == 0x0f) {
59                         printk(BIOS_DEBUG, "\n");
60                 }
61         }
62 }
63
64 static void dump_pci_devices(void)
65 {
66         device_t dev;
67         for(dev = PCI_DEV(0, 0, 0); 
68                 dev <= PCI_DEV(0, 0x1f, 0x7); 
69                 dev += PCI_DEV(0,0,1)) {
70                 uint32_t id;
71                 id = pci_read_config32(dev, PCI_VENDOR_ID);
72                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
73                         (((id >> 16) & 0xffff) == 0xffff) ||
74                         (((id >> 16) & 0xffff) == 0x0000)) {
75                         continue;
76                 }
77                 dump_pci_device(dev);
78         }
79 }
80
81 void dump_spd_registers(void)
82 {
83         unsigned device;
84         device = SMBUS_MEM_DEVICE_START;
85         while(device <= SMBUS_MEM_DEVICE_END) {
86                 int status = 0;
87                 int i;
88                 printk(BIOS_DEBUG, "\ndimm %02x", device);
89                 
90                 for(i = 0; (i < 256) ; i++) {
91                         if ((i % 16) == 0) {
92                                 printk(BIOS_DEBUG, "\n%02x: ", i);
93                         }
94                         status = smbus_read_byte(device, i);
95                         if (status < 0) {
96                                  printk(BIOS_DEBUG, "bad device: %02x\n", -status);
97                                  break; 
98                         }
99                         printk(BIOS_DEBUG, "%02x ", status);
100                 }
101                 device += SMBUS_MEM_DEVICE_INC;
102                 printk(BIOS_DEBUG, "\n");
103         }
104 }
105
106 static void dump_mem(unsigned start, unsigned end)
107 {
108         unsigned i;
109         print_debug("dump_mem:");
110         for(i=start;i<end;i++) {
111                 if((i & 0xf)==0) {
112                         printk(BIOS_DEBUG, "\n%08x:", i);
113                 }
114                 printk(BIOS_DEBUG, " %02x", (unsigned char)*((unsigned char *)i));
115         }
116         print_debug("\n");
117  }