* Copyright (c) 2011, Google Inc. All rights reserved.
*/
-
/*
* This module records the progress of boot and arbitrary commands, and
* permits accurate timestamping of each.
*/
-#include <common.h>
+#define LOG_CATEGORY LOGC_BOOT
+
#include <bootstage.h>
#include <hang.h>
#include <log.h>
u32 next_id; /* Next ID to use for bootstage */
};
-int bootstage_relocate(void)
+int bootstage_relocate(void *to)
{
- struct bootstage_data *data = gd->bootstage;
+ struct bootstage_data *data;
int i;
char *ptr;
+ debug("Copying bootstage from %p to %p\n", gd->bootstage, to);
+ memcpy(to, gd->bootstage, sizeof(struct bootstage_data));
+ data = gd->bootstage = to;
+
/* Figure out where to relocate the strings to */
ptr = (char *)(data + 1);
/* Only record the first event for each */
rec = find_id(data, id);
- if (!rec && data->rec_count < RECORD_COUNT) {
- rec = &data->record[data->rec_count++];
- rec->time_us = mark;
- rec->name = name;
- rec->flags = flags;
- rec->id = id;
+ if (!rec) {
+ if (data->rec_count < RECORD_COUNT) {
+ rec = &data->record[data->rec_count++];
+ rec->time_us = mark;
+ rec->name = name;
+ rec->flags = flags;
+ rec->id = id;
+ } else {
+ log_warning("Bootstage space exhausted\n");
+ }
}
/* Tell the board about this progress */
return mark;
}
-
-ulong bootstage_mark(enum bootstage_id id)
+ulong bootstage_error_name(enum bootstage_id id, const char *name)
{
- return bootstage_add_record(id, NULL, 0, timer_get_boot_us());
-}
-
-ulong bootstage_error(enum bootstage_id id)
-{
- return bootstage_add_record(id, NULL, BOOTSTAGEF_ERROR,
+ return bootstage_add_record(id, name, BOOTSTAGEF_ERROR,
timer_get_boot_us());
}
* @param buf Buffer to put name if needed
* @param len Length of buffer
* @param rec Boot stage record to get the name from
- * @return pointer to name, either from the record or pointing to buf.
+ * Return: pointer to name, either from the record or pointing to buf.
*/
static const char *get_record_name(char *buf, int len,
const struct bootstage_record *rec)
* Add all bootstage timings to a device tree.
*
* @param blob Device tree blob
- * @return 0 on success, != 0 on failure.
+ * Return: 0 on success, != 0 on failure.
*/
static int add_bootstages_devicetree(struct fdt_header *blob)
{
for (rec = data->record + data->next_id, i = 0; i < hdr->count;
i++, rec++) {
rec->name = ptr;
- if (spl_phase() == PHASE_SPL)
+ if (xpl_phase() == PHASE_SPL)
rec->name = strdup(ptr);
/* Assume no data corruption here */
return 0;
}
+#if IS_ENABLED(CONFIG_BOOTSTAGE_STASH)
+int _bootstage_stash_default(void)
+{
+ return bootstage_stash(map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR, 0),
+ CONFIG_BOOTSTAGE_STASH_SIZE);
+}
+
+int _bootstage_unstash_default(void)
+{
+ const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
+ CONFIG_BOOTSTAGE_STASH_SIZE);
+
+ return bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
+}
+#endif
+
int bootstage_get_size(void)
{
struct bootstage_data *data = gd->bootstage;