summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2013-06-10 10:41:04 -0700
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-11-26 19:10:38 +0100
commitcb73a8410cb80c8ff86e3d860ac3c8ae458b19ac (patch)
tree1172582fd4fb0835597dfdccceb581113cd30b68
parent8adf7a2c50dcb3a7f09b66c1f3918ab195d8c5ec (diff)
downloadcoreboot-cb73a8410cb80c8ff86e3d860ac3c8ae458b19ac.tar.xz
Clean up POST codes for Boot State machine
Now that there is a clearly defined boot state machine we can add some useful post codes to indicate the current point in the state machine by having it log a post code before the execution of each state. This removes the currently defined POST codes that were used by hardwaremain in favor of a new contiguous range that are defined for each boot state. The reason for this is that the existing codes are mostly used to indicate when something is done, which is confusing for actual debug because POST code debugging relies on knowing what is about to happen (to know what may be at fault) rather than what has just finished. One additonal change is added during device init step as this step often does the bulk of the work, and frequently logs POST codes itself. Therefore in order to keep better track of what device is being initialized POST_BS_DEV_INIT is logged before each device is initialized. interrupted boot with reset button and gathered the eventlog. Mosys has been extended to decode the well-known POST codes: 26 | 2013-06-10 10:32:48 | System boot | 120 27 | 2013-06-10 10:32:48 | Last post code in previous boot | 0x75 | Device Initialize 28 | 2013-06-10 10:32:48 | Extra info from previous boot | PCI | 00:16.0 29 | 2013-06-10 10:32:48 | Reset Button 30 | 2013-06-10 10:32:48 | System Reset Change-Id: Ida1e1129d274d28cbe8e49e4a01483e335a03d96 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/58106 Reviewed-on: http://review.coreboot.org/4231 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
-rw-r--r--src/device/device.c1
-rw-r--r--src/include/console/post_codes.h80
-rw-r--r--src/lib/hardwaremain.c13
3 files changed, 77 insertions, 17 deletions
diff --git a/src/device/device.c b/src/device/device.c
index dee797ed35..8bde663076 100644
--- a/src/device/device.c
+++ b/src/device/device.c
@@ -1162,6 +1162,7 @@ static void init_link(struct bus *link)
struct bus *c_link;
for (dev = link->children; dev; dev = dev->sibling) {
+ post_code(POST_BS_DEV_INIT);
post_log_path(dev);
init_dev(dev);
}
diff --git a/src/include/console/post_codes.h b/src/include/console/post_codes.h
index 4dc3d37aa8..df1d5e8837 100644
--- a/src/include/console/post_codes.h
+++ b/src/include/console/post_codes.h
@@ -120,32 +120,88 @@
#define POST_ENABLING_CACHE 0x60
/**
- * \brief Devices have been enumerated
+ * \brief Before Device Probe
*
- * Bus scan, and device enumeration has completed.
+ * Boot State Machine: bs_pre_device()
*/
-#define POST_DEVICE_ENUMERATION_COMPLETE 0x66
+#define POST_BS_PRE_DEVICE 0x70
/**
- * \brief Devices have been configured
+ * \brief Initializing Chips
*
- * Device configuration has completed.
+ * Boot State Machine: bs_dev_init_chips()
*/
-#define POST_DEVICE_CONFIGURATION_COMPLETE 0x88
+#define POST_BS_DEV_INIT_CHIPS 0x71
/**
- * \brief Devices have been enabled
+ * \brief Starting Device Enumeration
*
- * Devices have been enabled.
+ * Boot State Machine: bs_dev_enumerate()
*/
-#define POST_DEVICES_ENABLED 0x89
+#define POST_BS_DEV_ENUMERATE 0x72
/**
- * \brief Devices have been initialized
+ * \brief Device Resource Allocatio
*
- * Devices have been initialized.
+ * Boot State Machine: bs_dev_resources()
*/
-#define POST_DEVICES_INITIALIZED 0x8a
+#define POST_BS_DEV_RESOURCES 0x73
+
+/**
+ * \brief Device Enable
+ *
+ * Boot State Machine: bs_dev_enable()
+ */
+#define POST_BS_DEV_ENABLE 0x74
+
+/**
+ * \brief Device Initialization
+ *
+ * Boot State Machine: bs_dev_init()
+ */
+#define POST_BS_DEV_INIT 0x75
+
+/**
+ * \brief After Device Probe
+ *
+ * Boot State Machine: bs_post_device()
+ */
+#define POST_BS_POST_DEVICE 0x76
+
+/**
+ * \brief OS Resume Check
+ *
+ * Boot State Machine: bs_os_resume_check()
+ */
+#define POST_BS_OS_RESUME_CHECK 0x77
+
+/**
+ * \brief OS Resume
+ *
+ * Boot State Machine: bs_os_resume()
+ */
+#define POST_BS_OS_RESUME 0x78
+
+/**
+ * \brief Write Tables
+ *
+ * Boot State Machine: bs_write_tables()
+ */
+#define POST_BS_WRITE_TABLES 0x79
+
+/**
+ * \brief Load Payload
+ *
+ * Boot State Machine: bs_payload_load()
+ */
+#define POST_BS_PAYLOAD_LOAD 0x7a
+
+/**
+ * \brief Boot Payload
+ *
+ * Boot State Machine: bs_payload_boot()
+ */
+#define POST_BS_PAYLOAD_BOOT 0x7b
/**
* \brief Entry into elf boot
diff --git a/src/lib/hardwaremain.c b/src/lib/hardwaremain.c
index 501591f114..fed153be48 100644
--- a/src/lib/hardwaremain.c
+++ b/src/lib/hardwaremain.c
@@ -24,6 +24,7 @@
#include <bootstate.h>
#include <console/console.h>
+#include <console/post_codes.h>
#include <version.h>
#include <device/device.h>
#include <device/pci.h>
@@ -83,6 +84,7 @@ struct boot_phase {
struct boot_state {
const char *name;
boot_state_t id;
+ u8 post_code;
struct boot_phase phases[2];
boot_state_t (*run_state)(void *arg);
void *arg;
@@ -96,6 +98,7 @@ struct boot_state {
{ \
.name = #state_, \
.id = state_, \
+ .post_code = POST_ ## state_, \
.phases = { { NULL, 0 }, { NULL, 0 } }, \
.run_state = run_func_, \
.arg = NULL, \
@@ -138,7 +141,6 @@ static boot_state_t bs_dev_enumerate(void *arg)
{
/* Find the devices we don't have hard coded knowledge about. */
dev_enumerate();
- post_code(POST_DEVICE_ENUMERATION_COMPLETE);
return BS_DEV_RESOURCES;
}
@@ -146,9 +148,9 @@ static boot_state_t bs_dev_enumerate(void *arg)
static boot_state_t bs_dev_resources(void *arg)
{
timestamp_add_now(TS_DEVICE_CONFIGURE);
+
/* Now compute and assign the bus resources. */
dev_configure();
- post_code(POST_DEVICE_CONFIGURATION_COMPLETE);
return BS_DEV_ENABLE;
}
@@ -156,9 +158,9 @@ static boot_state_t bs_dev_resources(void *arg)
static boot_state_t bs_dev_enable(void *arg)
{
timestamp_add_now(TS_DEVICE_ENABLE);
+
/* Now actually enable devices on the bus */
dev_enable();
- post_code(POST_DEVICES_ENABLED);
return BS_DEV_INIT;
}
@@ -166,9 +168,9 @@ static boot_state_t bs_dev_enable(void *arg)
static boot_state_t bs_dev_init(void *arg)
{
timestamp_add_now(TS_DEVICE_INITIALIZE);
+
/* And of course initialize devices on the bus */
dev_initialize();
- post_code(POST_DEVICES_INITIALIZED);
return BS_POST_DEVICE;
}
@@ -194,7 +196,6 @@ static boot_state_t bs_os_resume_check(void *arg)
boot_states[BS_OS_RESUME].arg = wake_vector;
return BS_OS_RESUME;
}
- post_code(0x8a);
#endif
timestamp_add_now(TS_CBMEM_POST);
@@ -376,6 +377,8 @@ static void bs_walk_state_machine(void)
bs_sample_time(state);
+ post_code(state->post_code);
+
next_id = state->run_state(state->arg);
printk(BS_DEBUG_LVL, "BS: Exiting %s state.\n", state->name);