inteltool: add --ahci for printing AHCI registers

According to datasheets for Intel ICH/PCH, it works for chipsets from
ICH7 to 9-series PCH, with PCI device address D31:F2.

Change-Id: If1ddd7208108bda949b5a94894a7bf9e8bfe1e5f
Signed-off-by: Iru Cai <mytbk920423@gmail.com>
Reviewed-on: https://review.coreboot.org/15106
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Iru Cai 2016-06-08 22:39:22 +08:00 committed by Patrick Georgi
parent 1ba3432301
commit 904538bcc1
4 changed files with 102 additions and 5 deletions

View File

@ -23,7 +23,7 @@ PREFIX ?= /usr/local
CFLAGS ?= -O2 -g -Wall -W
LDFLAGS += -lpci -lz
OBJS = inteltool.o cpu.o gpio.o rootcmplx.o powermgt.o memory.o pcie.o amb.o ivy_memory.o spi.o gfx.o
OBJS = inteltool.o cpu.o gpio.o rootcmplx.o powermgt.o memory.o pcie.o amb.o ivy_memory.o spi.o gfx.o ahci.o
OS_ARCH = $(shell uname)
ifeq ($(OS_ARCH), Darwin)

77
util/inteltool/ahci.c Normal file
View File

@ -0,0 +1,77 @@
/*
* ahci.c: dump AHCI registers
*
* Copyright (C) 2016 Iru Cai
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2 of the
* License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "inteltool.h"
#define NUM_SATA_PORTS 6
#define MMIO_SIZE 0x400
static const char *ghc_regs[] = {
"CAP", "GHC", "IS", "PI",
"VS", "CCC_CTL", "CCC_PORTS", "EM_LOC",
"EM_CTL", "CAP2", "BOHC"
};
static const char *port_ctl_regs[] = {
"PxCLB", "PxCLBU", "PxFB", "PxFBU",
"PxIS", "PxIE", "PxCMD", "Reserved",
"PxTFD", "PxSIG", "PxSSTS", "PxSCTL",
"PxSERR", "PxSACT", "PxCI", "PxSNTF",
"PxFBS", "PxDEVSLP", "Reserved"
};
#define NUM_GHC (sizeof(ghc_regs)/sizeof(ghc_regs[0]))
#define NUM_PORTCTL (sizeof(port_ctl_regs)/sizeof(port_ctl_regs[0]))
int print_ahci(struct pci_dev *ahci)
{
uint64_t mmio_phys;
uint8_t *mmio;
uint32_t i, j;
if (!ahci) {
puts("No SATA device found");
return 0;
}
printf("\n============= AHCI Registers ==============\n\n");
mmio_phys = ahci->base_addr[5] & ~0x7ULL;
printf("ABAR = 0x%08llx (MEM)\n\n", (unsigned long long)mmio_phys);
mmio = map_physical(mmio_phys, MMIO_SIZE);
if (mmio == NULL) {
perror("Error mapping MMIO");
exit(1);
}
puts("Generic Host Control Registers:");
for (i = 0; i < 0x100; i += 4) {
printf("0x%02x: 0x%08x (%s)\n", i, *(uint32_t *)(mmio + i),
(i / 4 < NUM_GHC) ? ghc_regs[i / 4]:"Reserved");
}
for (i = 0; i < NUM_SATA_PORTS; i++) {
printf("\nPort %d Control Registers:\n", i);
uint8_t *mmio_port = mmio + 0x100 + i * 0x80;
for (j = 0; j < 0x80; j += 4) {
printf("0x%03x: 0x%08x (%s)\n", 0x100+i*0x80+j, *(uint32_t *)(mmio_port + j),
(j / 4 < NUM_PORTCTL) ? port_ctl_regs[j / 4]:"Reserved");
}
}
unmap_physical((void *)mmio, MMIO_SIZE);
return 0;
}

View File

@ -215,12 +215,13 @@ void print_version(void)
void print_usage(const char *name)
{
printf("usage: %s [-vh?gGrpmedPMaAsfS]\n", name);
printf("usage: %s [-vh?gGrpmedPMaAsfSR]\n", name);
printf("\n"
" -v | --version: print the version\n"
" -h | --help: print this help\n\n"
" -s | --spi: dump southbridge spi and bios_cntrl registers\n"
" -f | --gfx: dump graphics registers (UNSAFE: may hang system!)\n"
" -R | --ahci: dump AHCI registers\n"
" -g | --gpio: dump southbridge GPIO registers\n"
" -G | --gpio-diffs: show GPIO differences from defaults\n"
" -r | --rcba: dump southbridge RCBA registers\n"
@ -240,7 +241,7 @@ void print_usage(const char *name)
int main(int argc, char *argv[])
{
struct pci_access *pacc;
struct pci_dev *sb = NULL, *nb, *gfx = NULL, *dev;
struct pci_dev *sb = NULL, *nb, *gfx = NULL, *ahci = NULL, *dev;
const char *dump_spd_file = NULL;
int i, opt, option_index = 0;
unsigned int id;
@ -250,7 +251,7 @@ int main(int argc, char *argv[])
int dump_gpios = 0, dump_mchbar = 0, dump_rcba = 0;
int dump_pmbase = 0, dump_epbar = 0, dump_dmibar = 0;
int dump_pciexbar = 0, dump_coremsrs = 0, dump_ambs = 0;
int dump_spi = 0, dump_gfx = 0;
int dump_spi = 0, dump_gfx = 0, dump_ahci = 0;
int show_gpio_diffs = 0;
static struct option long_options[] = {
@ -270,10 +271,11 @@ int main(int argc, char *argv[])
{"spd", 0, 0, 'S'},
{"all", 0, 0, 'a'},
{"gfx", 0, 0, 'f'},
{"ahci", 0, 0, 'R'},
{0, 0, 0, 0}
};
while ((opt = getopt_long(argc, argv, "vh?gGrpmedPMaAsfS:",
while ((opt = getopt_long(argc, argv, "vh?gGrpmedPMaAsfRS:",
long_options, &option_index)) != EOF) {
switch (opt) {
case 'v':
@ -290,6 +292,9 @@ int main(int argc, char *argv[])
case 'f':
dump_gfx = 1;
break;
case 'R':
dump_ahci = 1;
break;
case 'G':
show_gpio_diffs = 1;
break;
@ -326,6 +331,7 @@ int main(int argc, char *argv[])
dump_coremsrs = 1;
dump_ambs = 1;
dump_spi = 1;
dump_ahci = 1;
break;
case 'A':
dump_ambs = 1;
@ -422,6 +428,15 @@ int main(int argc, char *argv[])
gfx = 0;
}
ahci = pci_get_dev(pacc, 0, 0, 0x1f, 2);
if (ahci) {
pci_fill_info(ahci, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
if (ahci->vendor_id != PCI_VENDOR_ID_INTEL)
ahci = 0;
}
id = cpuid(1);
/* Intel has suggested applications to display the family of a CPU as
@ -515,6 +530,10 @@ int main(int argc, char *argv[])
print_gfx(gfx);
}
if (dump_ahci) {
print_ahci(ahci);
}
/* Clean up */
pci_free_dev(nb);
// pci_free_dev(sb); // TODO: glibc detected "double free or corruption"

View File

@ -235,4 +235,5 @@ int print_pciexbar(struct pci_dev *nb);
int print_ambs(struct pci_dev *nb, struct pci_access *pacc);
int print_spi(struct pci_dev *sb);
int print_gfx(struct pci_dev *gfx);
int print_ahci(struct pci_dev *ahci);
void ivybridge_dump_timings(const char *dump_spd_file);