split the one file, as the several printing functions will continue to grow
[coreboot.git] / util / inteltool / rootcmplx.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 <errno.h>
22 #include <fcntl.h>
23 #include <unistd.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include <stdlib.h>
27 #include <stdint.h>
28 #include <getopt.h>
29 #include <sys/mman.h>
30 #include <sys/io.h>
31 #include <pci/pci.h>
32
33 #include "inteltool.h"
34
35 int print_rcba(struct pci_dev *sb)
36 {
37         int i, size = 0x4000;
38         volatile uint8_t *rcba;
39         uint32_t rcba_phys;
40
41         printf("\n============= RCBA ==============\n\n");
42
43         switch (sb->device_id) {
44         case PCI_DEVICE_ID_INTEL_ICH7:
45         case PCI_DEVICE_ID_INTEL_ICH7M:
46         case PCI_DEVICE_ID_INTEL_ICH7DH:
47         case PCI_DEVICE_ID_INTEL_ICH7MDH:
48                 rcba_phys = pci_read_long(sb, 0xf0) & 0xfffffffe;
49                 break;
50         case PCI_DEVICE_ID_INTEL_ICH:
51         case PCI_DEVICE_ID_INTEL_ICH0:
52         case PCI_DEVICE_ID_INTEL_ICH4:
53         case PCI_DEVICE_ID_INTEL_ICH4M:
54                 printf("This southbridge does not have RCBA.\n");
55                 return 1;
56         default:
57                 printf("Error: Dumping RCBA on this southbridge is not (yet) supported.\n");
58                 return 1;
59         }
60
61         rcba = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
62                     fd_mem, (off_t) rcba_phys);
63         
64         if (rcba == MAP_FAILED) {
65                 perror("Error mapping RCBA");
66                 exit(1);
67         }
68
69         printf("RCBA = 0x%08x (MEM)\n\n", rcba_phys);
70
71         for (i = 0; i < size; i += 4) {
72                 if (*(uint32_t *)(rcba + i))
73                         printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(rcba + i));
74         }
75
76         munmap((void *)rcba, size);
77         return 0;
78 }
79