coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
debug.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <spd.h>
4 #include <device/pci_ops.h>
5 #include <device/pci_def.h>
6 #include <device/smbus_host.h>
7 #include <console/console.h>
8 #include "i945.h"
9 
11 {
12  pci_devfn_t dev;
13  for (dev = PCI_DEV(0, 0, 0); dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
14  uint32_t id;
16  if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
17  (((id >> 16) & 0xffff) == 0xffff) ||
18  (((id >> 16) & 0xffff) == 0x0000)) {
19  continue;
20  }
21  printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x", (dev >> 20) & 0xff,
22  (dev >> 15) & 0x1f, (dev >> 12) & 7);
23  printk(BIOS_DEBUG, " [%04x:%04x]\n", id & 0xffff, id >> 16);
24  }
25 }
26 
27 void dump_pci_device(unsigned int dev)
28 {
29  int i;
30 
31  printk(BIOS_DEBUG, "PCI: %02x:%02x.%02x\n", (dev >> 20) & 0xff, (dev >> 15) & 0x1f,
32  (dev >> 12) & 7);
33 
34  for (i = 0; i <= 255; i++) {
35  unsigned char val;
36  if ((i & 0x0f) == 0)
37  printk(BIOS_DEBUG, "%02x:", i);
38  val = pci_read_config8(dev, i);
39  printk(BIOS_DEBUG, " %02x", val);
40  if ((i & 0x0f) == 0x0f)
41  printk(BIOS_DEBUG, "\n");
42  }
43 }
44 
45 void dump_pci_devices(void)
46 {
47  pci_devfn_t dev;
48  for (dev = PCI_DEV(0, 0, 0); dev <= PCI_DEV(0, 0x1f, 0x7); dev += PCI_DEV(0, 0, 1)) {
49  uint32_t id;
51  if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
52  (((id >> 16) & 0xffff) == 0xffff) ||
53  (((id >> 16) & 0xffff) == 0x0000)) {
54  continue;
55  }
56  dump_pci_device(dev);
57  }
58 }
59 
60 void dump_spd_registers(u8 spd_map[4])
61 {
62  for (unsigned int d = 0; d < 4; d++) {
63  const unsigned int device = spd_map[d];
64  if (device == 0)
65  continue;
66 
67  int status = 0;
68  int i;
69  printk(BIOS_DEBUG, "\ndimm %02x", device);
70 
71  for (i = 0; (i < 256); i++) {
72  if ((i % 16) == 0)
73  printk(BIOS_DEBUG, "\n%02x: ", i);
74  status = smbus_read_byte(device, i);
75  if (status < 0) {
76  printk(BIOS_DEBUG, "bad device: %02x\n", -status);
77  break;
78  }
79  printk(BIOS_DEBUG, "%02x ", status);
80  }
81  printk(BIOS_DEBUG, "\n");
82  }
83 }
#define printk(level,...)
Definition: stdlib.h:16
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
static int smbus_read_byte(struct device *const dev, u8 addr)
Definition: smbus.h:43
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
void dump_pci_device(unsigned int dev)
Definition: debug.c:38
void dump_spd_registers(void)
Definition: debug.c:9
void dump_pci_devices(void)
Definition: debug.c:45
void print_pci_devices(void)
Definition: debug.c:10
#define PCI_VENDOR_ID
Definition: pci_def.h:8
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
u32 pci_devfn_t
Definition: pci_type.h:8
unsigned int uint32_t
Definition: stdint.h:14
uint8_t u8
Definition: stdint.h:45
Definition: device.h:107
u8 val
Definition: sys.c:300