coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
print_reset_status.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <amdblocks/acpimmio.h>
5 
6 static void print_num_status_bits(int num_bits, uint32_t status,
7  const char *const bit_names[])
8 {
9  int i;
10 
11  if (!status)
12  return;
13 
14  for (i = num_bits - 1; i >= 0; i--) {
15  if (status & (1 << i)) {
16  if (bit_names[i])
17  printk(BIOS_DEBUG, "%s ", bit_names[i]);
18  else
19  printk(BIOS_DEBUG, "BIT%d ", i);
20  }
21  }
22 }
23 
25 {
26  /* PMxC0 S5/Reset Status shows the source of previous reset. */
27  uint32_t pmxc0_status = pm_read32(PM_RST_STATUS);
28 
29  static const char *const pmxc0_status_bits[32] = {
30  [0] = "ThermalTrip",
31  [1] = "FourSecondPwrBtn",
32  [2] = "Shutdown",
33  [3] = "ThermalTripFromTemp",
34  [4] = "RemotePowerDownFromASF",
35  [5] = "ShutDownFan0",
36  [9] = "InternalThermalTrip",
37  [16] = "UserRst",
38  [17] = "SoftPciRst",
39  [18] = "DoInit",
40  [19] = "DoReset",
41  [20] = "DoFullReset",
42  [21] = "SleepReset",
43  [22] = "KbReset",
44  [23] = "LtReset/ShutdownMsg",
45  [24] = "FailBootRst",
46  [25] = "WatchdogIssueReset",
47  [26] = "RemoteResetFromASF",
48  [27] = "SyncFlood",
49  [28] = "HangReset",
50  [29] = "EcWatchdogRst",
51  [30] = "SdpParityErr",
52  [31] = "SwSyncFloodFlag",
53  };
54 
55  printk(BIOS_DEBUG, "PMxC0 STATUS: 0x%x ", pmxc0_status);
56  print_num_status_bits(ARRAY_SIZE(pmxc0_status_bits), pmxc0_status, pmxc0_status_bits);
57  printk(BIOS_DEBUG, "\n");
58 }
#define PM_RST_STATUS
Definition: acpimmio.h:34
static uint32_t pm_read32(uint8_t reg)
Definition: acpimmio.h:176
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
void fch_print_pmxc0_status(void)
static void print_num_status_bits(int num_bits, uint32_t status, const char *const bit_names[])
unsigned int uint32_t
Definition: stdint.h:14