split the one file, as the several printing functions will continue to grow
[coreboot.git] / util / inteltool / powermgt.c
1 /*
2  * inteltool - dump all registers on an Intel CPU + chipset based system.
3  *
4  * Copyright (C) 2008 by coresystems GmbH 
5  *  written by Stefan Reinauer <stepan@coresystems.de> 
6  * 
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of 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., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #include <stdio.h>
22 #include <sys/io.h>
23
24 #include "inteltool.h"
25
26 int print_pmbase(struct pci_dev *sb)
27 {
28         int i, size = 0x80;
29         uint16_t pmbase;
30
31         printf("\n============= PMBASE ============\n\n");
32
33         switch (sb->device_id) {
34         case PCI_DEVICE_ID_INTEL_ICH7:
35         case PCI_DEVICE_ID_INTEL_ICH7M:
36         case PCI_DEVICE_ID_INTEL_ICH7DH:
37         case PCI_DEVICE_ID_INTEL_ICH7MDH:
38                 pmbase = pci_read_word(sb, 0x40) & 0xfffc;
39                 break;
40         case 0x1234: // Dummy for non-existent functionality
41                 printf("This southbridge does not have PMBASE.\n");
42                 return 1;
43         default:
44                 printf("Error: Dumping PMBASE on this southbridge is not (yet) supported.\n");
45                 return 1;
46         }
47
48         printf("PMBASE = 0x%04x (IO)\n\n", pmbase);
49
50         for (i = 0; i < size; i += 4) {
51                 printf("pmbase+0x%04x: 0x%08x\n", i, inl(pmbase + i));
52         }
53
54         return 0;
55 }
56