xref: /openbmc/u-boot/include/bootstage.h (revision e8f80a5a)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2097e1783SSimon Glass /*
3097e1783SSimon Glass  * This file implements recording of each stage of the boot process. It is
4097e1783SSimon Glass  * intended to implement timing of each stage, reporting this information
5097e1783SSimon Glass  * to the user and passing it to the OS for logging / further analysis.
6c87dc38dSSimon Glass  * Note that it requires timer_get_boot_us() to be defined by the board
7097e1783SSimon Glass  *
8097e1783SSimon Glass  * Copyright (c) 2011 The Chromium OS Authors.
9097e1783SSimon Glass  */
10097e1783SSimon Glass 
11097e1783SSimon Glass #ifndef _BOOTSTAGE_H
12097e1783SSimon Glass #define _BOOTSTAGE_H
13097e1783SSimon Glass 
14094e06a5SSimon Glass /* Flags for each bootstage record */
15094e06a5SSimon Glass enum bootstage_flags {
16094e06a5SSimon Glass 	BOOTSTAGEF_ERROR	= 1 << 0,	/* Error record */
17094e06a5SSimon Glass 	BOOTSTAGEF_ALLOC	= 1 << 1,	/* Allocate an id */
18094e06a5SSimon Glass };
19094e06a5SSimon Glass 
20a2cc9bf4SSimon Glass /* bootstate sub-IDs used for kernel and ramdisk ranges */
21a2cc9bf4SSimon Glass enum {
22a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_FORMAT,
23a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_FORMAT_OK,
24a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_NO_UNIT_NAME,
25a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_UNIT_NAME,
26a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_SUBNODE,
27a2cc9bf4SSimon Glass 
28a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_CHECK,
29a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_HASH = 5,
30a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_CHECK_ARCH = 5,
31a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_CHECK_ALL,
32a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_GET_DATA,
33a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_CHECK_ALL_OK = 7,
34a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_GET_DATA_OK,
35a2cc9bf4SSimon Glass 	BOOTSTAGE_SUB_LOAD,
36a2cc9bf4SSimon Glass };
37a2cc9bf4SSimon Glass 
38097e1783SSimon Glass /*
39097e1783SSimon Glass  * A list of boot stages that we know about. Each of these indicates the
40097e1783SSimon Glass  * state that we are at, and the action that we are about to perform. For
41097e1783SSimon Glass  * errors, we issue an error for an item when it fails. Therefore the
42097e1783SSimon Glass  * normal sequence is:
43097e1783SSimon Glass  *
44097e1783SSimon Glass  * progress action1
45097e1783SSimon Glass  * progress action2
46097e1783SSimon Glass  * progress action3
47097e1783SSimon Glass  *
48097e1783SSimon Glass  * and an error condition where action 3 failed would be:
49097e1783SSimon Glass  *
50097e1783SSimon Glass  * progress action1
51097e1783SSimon Glass  * progress action2
52097e1783SSimon Glass  * progress action3
53097e1783SSimon Glass  * error on action3
54097e1783SSimon Glass  */
55097e1783SSimon Glass enum bootstage_id {
565dc88716SSimon Glass 	BOOTSTAGE_ID_START = 0,
575dc88716SSimon Glass 	BOOTSTAGE_ID_CHECK_MAGIC,	/* Checking image magic */
585dc88716SSimon Glass 	BOOTSTAGE_ID_CHECK_HEADER,	/* Checking image header */
595dc88716SSimon Glass 	BOOTSTAGE_ID_CHECK_CHECKSUM,	/* Checking image checksum */
605dc88716SSimon Glass 	BOOTSTAGE_ID_CHECK_ARCH,	/* Checking architecture */
615dc88716SSimon Glass 
625dc88716SSimon Glass 	BOOTSTAGE_ID_CHECK_IMAGETYPE = 5,/* Checking image type */
635dc88716SSimon Glass 	BOOTSTAGE_ID_DECOMP_IMAGE,	/* Decompressing image */
645dc88716SSimon Glass 	BOOTSTAGE_ID_KERNEL_LOADED,	/* Kernel has been loaded */
655dc88716SSimon Glass 	BOOTSTAGE_ID_DECOMP_UNIMPL = 7,	/* Odd decompression algorithm */
665dc88716SSimon Glass 	BOOTSTAGE_ID_CHECK_BOOT_OS,	/* Calling OS-specific boot function */
675dc88716SSimon Glass 	BOOTSTAGE_ID_BOOT_OS_RETURNED,	/* Tried to boot OS, but it returned */
685dc88716SSimon Glass 	BOOTSTAGE_ID_CHECK_RAMDISK = 9,	/* Checking ram disk */
695dc88716SSimon Glass 
705e410883SSimon Glass 	BOOTSTAGE_ID_RD_MAGIC,		/* Checking ram disk magic */
715e410883SSimon Glass 	BOOTSTAGE_ID_RD_HDR_CHECKSUM,	/* Checking ram disk heder checksum */
725e410883SSimon Glass 	BOOTSTAGE_ID_RD_CHECKSUM,	/* Checking ram disk checksum */
735e410883SSimon Glass 	BOOTSTAGE_ID_COPY_RAMDISK = 12,	/* Copying ram disk into place */
745e410883SSimon Glass 	BOOTSTAGE_ID_RAMDISK,		/* Checking for valid ramdisk */
755e410883SSimon Glass 	BOOTSTAGE_ID_NO_RAMDISK,	/* No ram disk found (not an error) */
765e410883SSimon Glass 
77097e1783SSimon Glass 	BOOTSTAGE_ID_RUN_OS	= 15,	/* Exiting U-Boot, entering OS */
788ade9506SSimon Glass 
798ade9506SSimon Glass 	BOOTSTAGE_ID_NEED_RESET = 30,
808ade9506SSimon Glass 	BOOTSTAGE_ID_POST_FAIL,		/* Post failure */
818ade9506SSimon Glass 	BOOTSTAGE_ID_POST_FAIL_R,	/* Post failure reported after reloc */
828ade9506SSimon Glass 
838ade9506SSimon Glass 	/*
841b15fac1SBin Meng 	 * This set is reported only by x86, and the meaning is different. In
858ade9506SSimon Glass 	 * this case we are reporting completion of a particular stage.
861b15fac1SBin Meng 	 * This should probably change in the x86 code (which doesn't report
878ade9506SSimon Glass 	 * errors in any case), but discussion this can perhaps wait until we
888ade9506SSimon Glass 	 * have a generic board implementation.
898ade9506SSimon Glass 	 */
908ade9506SSimon Glass 	BOOTSTAGE_ID_BOARD_INIT_R,	/* We have relocated */
918ade9506SSimon Glass 	BOOTSTAGE_ID_BOARD_GLOBAL_DATA,	/* Global data is set up */
928ade9506SSimon Glass 
938ade9506SSimon Glass 	BOOTSTAGE_ID_BOARD_INIT_SEQ,	/* We completed the init sequence */
948ade9506SSimon Glass 	BOOTSTAGE_ID_BOARD_FLASH,	/* We have configured flash banks */
958ade9506SSimon Glass 	BOOTSTAGE_ID_BOARD_FLASH_37,	/* In case you didn't hear... */
968ade9506SSimon Glass 	BOOTSTAGE_ID_BOARD_ENV,		/* Environment is relocated & ready */
978ade9506SSimon Glass 	BOOTSTAGE_ID_BOARD_PCI,		/* PCI is up */
988ade9506SSimon Glass 
998ade9506SSimon Glass 	BOOTSTAGE_ID_BOARD_INTERRUPTS,	/* Exceptions / interrupts ready */
1008ade9506SSimon Glass 	BOOTSTAGE_ID_BOARD_DONE,	/* Board init done, off to main loop */
1018ade9506SSimon Glass 	/* ^^^ here ends the x86 sequence */
1028ade9506SSimon Glass 
10390e153d7SSimon Glass 	/* Boot stages related to loading a kernel from an IDE device */
10490e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_START = 41,
10590e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_ADDR,
10690e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_BOOT_DEVICE,
10790e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_TYPE,
10890e153d7SSimon Glass 
10990e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_PART,
11090e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_PART_INFO,
11190e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_PART_TYPE,
11290e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_PART_READ,
11390e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_FORMAT,
11490e153d7SSimon Glass 
11590e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_CHECKSUM,	/* 50 */
11690e153d7SSimon Glass 	BOOTSTAGE_ID_IDE_READ,
117cd24a6bfSSimon Glass 
118cd24a6bfSSimon Glass 	/* Boot stages related to loading a kernel from an NAND device */
119cd24a6bfSSimon Glass 	BOOTSTAGE_ID_NAND_PART,
120cd24a6bfSSimon Glass 	BOOTSTAGE_ID_NAND_SUFFIX,
121cd24a6bfSSimon Glass 	BOOTSTAGE_ID_NAND_BOOT_DEVICE,
122cd24a6bfSSimon Glass 	BOOTSTAGE_ID_NAND_HDR_READ = 55,
123cd24a6bfSSimon Glass 	BOOTSTAGE_ID_NAND_AVAILABLE = 55,
124cd24a6bfSSimon Glass 	BOOTSTAGE_ID_NAND_TYPE = 57,
125cd24a6bfSSimon Glass 	BOOTSTAGE_ID_NAND_READ,
126cd24a6bfSSimon Glass 
127c8e66db7SSimon Glass 	/* Boot stages related to loading a kernel from an network device */
128c8e66db7SSimon Glass 	BOOTSTAGE_ID_NET_CHECKSUM = 60,
129c8e66db7SSimon Glass 	BOOTSTAGE_ID_NET_ETH_START = 64,
130c8e66db7SSimon Glass 	BOOTSTAGE_ID_NET_ETH_INIT,
131c8e66db7SSimon Glass 
132c8e66db7SSimon Glass 	BOOTSTAGE_ID_NET_START = 80,
133c8e66db7SSimon Glass 	BOOTSTAGE_ID_NET_NETLOOP_OK,
134c8e66db7SSimon Glass 	BOOTSTAGE_ID_NET_LOADED,
135c8e66db7SSimon Glass 	BOOTSTAGE_ID_NET_DONE_ERR,
136c8e66db7SSimon Glass 	BOOTSTAGE_ID_NET_DONE,
137c8e66db7SSimon Glass 
138a2cc9bf4SSimon Glass 	BOOTSTAGE_ID_FIT_FDT_START = 90,
139aacc8c16SSimon Glass 	/*
140aacc8c16SSimon Glass 	 * Boot stages related to loading a FIT image. Some of these are a
141aacc8c16SSimon Glass 	 * bit wonky.
142aacc8c16SSimon Glass 	 */
143a2cc9bf4SSimon Glass 	BOOTSTAGE_ID_FIT_KERNEL_START = 100,
144aacc8c16SSimon Glass 
14513167dacSSimon Glass 	BOOTSTAGE_ID_FIT_CONFIG = 110,
146aacc8c16SSimon Glass 	BOOTSTAGE_ID_FIT_TYPE,
14713167dacSSimon Glass 	BOOTSTAGE_ID_FIT_KERNEL_INFO,
148aacc8c16SSimon Glass 
149aacc8c16SSimon Glass 	BOOTSTAGE_ID_FIT_COMPRESSION,
150aacc8c16SSimon Glass 	BOOTSTAGE_ID_FIT_OS,
151aacc8c16SSimon Glass 	BOOTSTAGE_ID_FIT_LOADADDR,
152aacc8c16SSimon Glass 	BOOTSTAGE_ID_OVERWRITTEN,
153aacc8c16SSimon Glass 
154a2cc9bf4SSimon Glass 	/* Next 10 IDs used by BOOTSTAGE_SUB_... */
155a2cc9bf4SSimon Glass 	BOOTSTAGE_ID_FIT_RD_START = 120,	/* Ramdisk stages */
156aacc8c16SSimon Glass 
15790268b87SSimon Glass 	/* Next 10 IDs used by BOOTSTAGE_SUB_... */
15890268b87SSimon Glass 	BOOTSTAGE_ID_FIT_SETUP_START = 130,	/* x86 setup stages */
15990268b87SSimon Glass 
160cd24a6bfSSimon Glass 	BOOTSTAGE_ID_IDE_FIT_READ = 140,
161cd24a6bfSSimon Glass 	BOOTSTAGE_ID_IDE_FIT_READ_OK,
162cd24a6bfSSimon Glass 
163cd24a6bfSSimon Glass 	BOOTSTAGE_ID_NAND_FIT_READ = 150,
164cd24a6bfSSimon Glass 	BOOTSTAGE_ID_NAND_FIT_READ_OK,
1653a608ca0SSimon Glass 
16684a07dbfSKarl Apsite 	BOOTSTAGE_ID_FIT_LOADABLE_START = 160,	/* for Loadable Images */
1673a608ca0SSimon Glass 	/*
1683a608ca0SSimon Glass 	 * These boot stages are new, higher level, and not directly related
1693a608ca0SSimon Glass 	 * to the old boot progress numbers. They are useful for recording
1703a608ca0SSimon Glass 	 * rough boot timing information.
1713a608ca0SSimon Glass 	 */
1723a608ca0SSimon Glass 	BOOTSTAGE_ID_AWAKE,
173996e95d4SSimon Glass 	BOOTSTAGE_ID_START_SPL,
174824bb1b4SSimon Glass 	BOOTSTAGE_ID_END_SPL,
1753a608ca0SSimon Glass 	BOOTSTAGE_ID_START_UBOOT_F,
1763a608ca0SSimon Glass 	BOOTSTAGE_ID_START_UBOOT_R,
1773a608ca0SSimon Glass 	BOOTSTAGE_ID_USB_START,
1783a608ca0SSimon Glass 	BOOTSTAGE_ID_ETH_START,
1793a608ca0SSimon Glass 	BOOTSTAGE_ID_BOOTP_START,
1803a608ca0SSimon Glass 	BOOTSTAGE_ID_BOOTP_STOP,
1813a608ca0SSimon Glass 	BOOTSTAGE_ID_BOOTM_START,
1823a608ca0SSimon Glass 	BOOTSTAGE_ID_BOOTM_HANDOFF,
1833a608ca0SSimon Glass 	BOOTSTAGE_ID_MAIN_LOOP,
1843a608ca0SSimon Glass 	BOOTSTAGE_KERNELREAD_START,
1853a608ca0SSimon Glass 	BOOTSTAGE_KERNELREAD_STOP,
186996e95d4SSimon Glass 	BOOTSTAGE_ID_BOARD_INIT,
187996e95d4SSimon Glass 	BOOTSTAGE_ID_BOARD_INIT_DONE,
1883a608ca0SSimon Glass 
1893a608ca0SSimon Glass 	BOOTSTAGE_ID_CPU_AWAKE,
1903a608ca0SSimon Glass 	BOOTSTAGE_ID_MAIN_CPU_AWAKE,
1913a608ca0SSimon Glass 	BOOTSTAGE_ID_MAIN_CPU_READY,
1923a608ca0SSimon Glass 
193996e95d4SSimon Glass 	BOOTSTAGE_ID_ACCUM_LCD,
194abbdb262SSimon Glass 	BOOTSTAGE_ID_ACCUM_SCSI,
19528b5404cSSimon Glass 	BOOTSTAGE_ID_ACCUM_SPI,
19628b5404cSSimon Glass 	BOOTSTAGE_ID_ACCUM_DECOMP,
197a132f770SSimon Glass 	BOOTSTAGE_ID_ACCUM_OF_LIVE,
19862afc601SMichal Simek 	BOOTSTAGE_ID_FPGA_INIT,
199824bb1b4SSimon Glass 	BOOTSTATE_ID_ACCUM_DM_SPL,
20063c5bf48SSimon Glass 	BOOTSTATE_ID_ACCUM_DM_F,
20163c5bf48SSimon Glass 	BOOTSTATE_ID_ACCUM_DM_R,
202996e95d4SSimon Glass 
2033a608ca0SSimon Glass 	/* a few spare for the user, from here */
2043a608ca0SSimon Glass 	BOOTSTAGE_ID_USER,
2053a608ca0SSimon Glass 	BOOTSTAGE_ID_ALLOC,
206097e1783SSimon Glass };
207097e1783SSimon Glass 
208097e1783SSimon Glass /*
2093786980dSSimon Glass  * Return the time since boot in microseconds, This is needed for bootstage
2103786980dSSimon Glass  * and should be defined in CPU- or board-specific code. If undefined then
211c87dc38dSSimon Glass  * you will get a link error.
2123786980dSSimon Glass  */
2133786980dSSimon Glass ulong timer_get_boot_us(void);
2143786980dSSimon Glass 
215496c5483SHeiko Schocher #if defined(USE_HOSTCC)
216496c5483SHeiko Schocher #define show_boot_progress(val) do {} while (0)
217496c5483SHeiko Schocher #else
218cbcd6970SSimon Glass /**
219097e1783SSimon Glass  * Board code can implement show_boot_progress() if needed.
220097e1783SSimon Glass  *
221097e1783SSimon Glass  * @param val	Progress state (enum bootstage_id), or -id if an error
222097e1783SSimon Glass  *		has occurred.
223097e1783SSimon Glass  */
224097e1783SSimon Glass void show_boot_progress(int val);
2257ac2fe2dSIlya Yanok #endif
226770605e4SSimon Glass 
227824bb1b4SSimon Glass #if !defined(USE_HOSTCC)
228824bb1b4SSimon Glass #if CONFIG_IS_ENABLED(BOOTSTAGE)
229824bb1b4SSimon Glass #define ENABLE_BOOTSTAGE
230824bb1b4SSimon Glass #endif
231824bb1b4SSimon Glass #endif
232824bb1b4SSimon Glass 
233824bb1b4SSimon Glass #ifdef ENABLE_BOOTSTAGE
234824bb1b4SSimon Glass 
235770605e4SSimon Glass /* This is the full bootstage implementation */
236770605e4SSimon Glass 
237094e06a5SSimon Glass /**
238150678a5SDoug Anderson  * Relocate existing bootstage records
239150678a5SDoug Anderson  *
240150678a5SDoug Anderson  * Call this after relocation has happened and after malloc has been initted.
241150678a5SDoug Anderson  * We need to copy any pointers in bootstage records that were added pre-
242cbcd6970SSimon Glass  * relocation, since memory can be overwritten later.
243150678a5SDoug Anderson  * @return Always returns 0, to indicate success
244150678a5SDoug Anderson  */
245150678a5SDoug Anderson int bootstage_relocate(void);
246150678a5SDoug Anderson 
247150678a5SDoug Anderson /**
248094e06a5SSimon Glass  * Add a new bootstage record
249094e06a5SSimon Glass  *
250094e06a5SSimon Glass  * @param id	Bootstage ID to use (ignored if flags & BOOTSTAGEF_ALLOC)
251094e06a5SSimon Glass  * @param name	Name of record, or NULL for none
252094e06a5SSimon Glass  * @param flags	Flags (BOOTSTAGEF_...)
253094e06a5SSimon Glass  * @param mark	Time to record in this record, in microseconds
254094e06a5SSimon Glass  */
255094e06a5SSimon Glass ulong bootstage_add_record(enum bootstage_id id, const char *name,
256094e06a5SSimon Glass 			   int flags, ulong mark);
257094e06a5SSimon Glass 
258cbcd6970SSimon Glass /**
259770605e4SSimon Glass  * Mark a time stamp for the current boot stage.
260770605e4SSimon Glass  */
261770605e4SSimon Glass ulong bootstage_mark(enum bootstage_id id);
262770605e4SSimon Glass 
263770605e4SSimon Glass ulong bootstage_error(enum bootstage_id id);
264770605e4SSimon Glass 
2653a608ca0SSimon Glass ulong bootstage_mark_name(enum bootstage_id id, const char *name);
2663a608ca0SSimon Glass 
2670e996773SSimon Glass /**
268fb7db41cSSimon Glass  * Mark a time stamp in the given function and line number
269fb7db41cSSimon Glass  *
270fb7db41cSSimon Glass  * See BOOTSTAGE_MARKER() for a convenient macro.
271fb7db41cSSimon Glass  *
272fb7db41cSSimon Glass  * @param file		Filename to record (NULL if none)
273fb7db41cSSimon Glass  * @param func		Function name to record
274fb7db41cSSimon Glass  * @param linenum	Line number to record
275fb7db41cSSimon Glass  * @return recorded time stamp
276fb7db41cSSimon Glass  */
277fb7db41cSSimon Glass ulong bootstage_mark_code(const char *file, const char *func,
278fb7db41cSSimon Glass 			  int linenum);
279fb7db41cSSimon Glass 
280fb7db41cSSimon Glass /**
2810e996773SSimon Glass  * Mark the start of a bootstage activity. The end will be marked later with
2820e996773SSimon Glass  * bootstage_accum() and at that point we accumulate the time taken. Calling
2830e996773SSimon Glass  * this function turns the given id into a accumulator rather than and
2840e996773SSimon Glass  * absolute mark in time. Accumulators record the total amount of time spent
2850e996773SSimon Glass  * in an activty during boot.
2860e996773SSimon Glass  *
2870e996773SSimon Glass  * @param id	Bootstage id to record this timestamp against
2880e996773SSimon Glass  * @param name	Textual name to display for this id in the report (maybe NULL)
2890e996773SSimon Glass  * @return start timestamp in microseconds
2900e996773SSimon Glass  */
2910e996773SSimon Glass uint32_t bootstage_start(enum bootstage_id id, const char *name);
2920e996773SSimon Glass 
2930e996773SSimon Glass /**
2940e996773SSimon Glass  * Mark the end of a bootstage activity
2950e996773SSimon Glass  *
2960e996773SSimon Glass  * After previously marking the start of an activity with bootstage_start(),
2970e996773SSimon Glass  * call this function to mark the end. You can call these functions in pairs
2980e996773SSimon Glass  * as many times as you like.
2990e996773SSimon Glass  *
3000e996773SSimon Glass  * @param id	Bootstage id to record this timestamp against
3010e996773SSimon Glass  * @return time spent in this iteration of the activity (i.e. the time now
3020e996773SSimon Glass  *		less the start time recorded in the last bootstage_start() call
3030e996773SSimon Glass  *		with this id.
3040e996773SSimon Glass  */
3050e996773SSimon Glass uint32_t bootstage_accum(enum bootstage_id id);
3060e996773SSimon Glass 
3073a608ca0SSimon Glass /* Print a report about boot time */
3083a608ca0SSimon Glass void bootstage_report(void);
3093a608ca0SSimon Glass 
31094fd1316SSimon Glass /**
31194fd1316SSimon Glass  * Add bootstage information to the device tree
31294fd1316SSimon Glass  *
31394fd1316SSimon Glass  * @return 0 if ok, -ve on error
31494fd1316SSimon Glass  */
31594fd1316SSimon Glass int bootstage_fdt_add_report(void);
31694fd1316SSimon Glass 
317cbcd6970SSimon Glass /**
318fcf509b8SSimon Glass  * Stash bootstage data into memory
319fcf509b8SSimon Glass  *
320fcf509b8SSimon Glass  * @param base	Base address of memory buffer
321fcf509b8SSimon Glass  * @param size	Size of memory buffer
322fcf509b8SSimon Glass  * @return 0 if stashed ok, -1 if out of space
323fcf509b8SSimon Glass  */
324fcf509b8SSimon Glass int bootstage_stash(void *base, int size);
325fcf509b8SSimon Glass 
326fcf509b8SSimon Glass /**
327fcf509b8SSimon Glass  * Read bootstage data from memory
328fcf509b8SSimon Glass  *
329fcf509b8SSimon Glass  * Bootstage data is read from memory and placed in the bootstage table
330fcf509b8SSimon Glass  * in the user records.
331fcf509b8SSimon Glass  *
332fcf509b8SSimon Glass  * @param base	Base address of memory buffer
333fcf509b8SSimon Glass  * @param size	Size of memory buffer (-1 if unknown)
334e003310aSSimon Glass  * @return 0 if unstashed ok, -ENOENT if bootstage info not found, -ENOSPC if
335e003310aSSimon Glass  *	there is not space for read the stacked data, or other error if
336e003310aSSimon Glass  *	something else went wrong
337fcf509b8SSimon Glass  */
3389d2542d0SSimon Glass int bootstage_unstash(const void *base, int size);
339fcf509b8SSimon Glass 
340b383d6c0SSimon Glass /**
34125e7dc6aSSimon Glass  * bootstage_get_size() - Get the size of the bootstage data
34225e7dc6aSSimon Glass  *
34325e7dc6aSSimon Glass  * @return size of boostage data in bytes
34425e7dc6aSSimon Glass  */
34525e7dc6aSSimon Glass int bootstage_get_size(void);
34625e7dc6aSSimon Glass 
34725e7dc6aSSimon Glass /**
348b383d6c0SSimon Glass  * bootstage_init() - Prepare bootstage for use
349b383d6c0SSimon Glass  *
350b383d6c0SSimon Glass  * @first: true if this is the first time bootstage is set up. This causes it
351b383d6c0SSimon Glass  *	to add a 'reset' record with a time of 0.
352b383d6c0SSimon Glass  */
353b383d6c0SSimon Glass int bootstage_init(bool first);
354b383d6c0SSimon Glass 
355770605e4SSimon Glass #else
bootstage_add_record(enum bootstage_id id,const char * name,int flags,ulong mark)356e802ee0fSSimon Glass static inline ulong bootstage_add_record(enum bootstage_id id,
357e802ee0fSSimon Glass 		const char *name, int flags, ulong mark)
358e802ee0fSSimon Glass {
359e802ee0fSSimon Glass 	return 0;
360e802ee0fSSimon Glass }
361e802ee0fSSimon Glass 
362770605e4SSimon Glass /*
363770605e4SSimon Glass  * This is a dummy implementation which just calls show_boot_progress(),
364770605e4SSimon Glass  * and won't even do that unless CONFIG_SHOW_BOOT_PROGRESS is defined
365770605e4SSimon Glass  */
366770605e4SSimon Glass 
bootstage_relocate(void)367150678a5SDoug Anderson static inline int bootstage_relocate(void)
368150678a5SDoug Anderson {
369150678a5SDoug Anderson 	return 0;
370150678a5SDoug Anderson }
371150678a5SDoug Anderson 
bootstage_mark(enum bootstage_id id)372770605e4SSimon Glass static inline ulong bootstage_mark(enum bootstage_id id)
3735ddb118dSSimon Glass {
374770605e4SSimon Glass 	show_boot_progress(id);
375770605e4SSimon Glass 	return 0;
3765ddb118dSSimon Glass }
377097e1783SSimon Glass 
bootstage_error(enum bootstage_id id)378770605e4SSimon Glass static inline ulong bootstage_error(enum bootstage_id id)
379770605e4SSimon Glass {
380770605e4SSimon Glass 	show_boot_progress(-id);
381770605e4SSimon Glass 	return 0;
382770605e4SSimon Glass }
383770605e4SSimon Glass 
bootstage_mark_name(enum bootstage_id id,const char * name)3843a608ca0SSimon Glass static inline ulong bootstage_mark_name(enum bootstage_id id, const char *name)
3853a608ca0SSimon Glass {
3867f442e36SHeiko Schocher 	show_boot_progress(id);
3873a608ca0SSimon Glass 	return 0;
3883a608ca0SSimon Glass }
3893a608ca0SSimon Glass 
bootstage_mark_code(const char * file,const char * func,int linenum)390fb7db41cSSimon Glass static inline ulong bootstage_mark_code(const char *file, const char *func,
391fb7db41cSSimon Glass 					int linenum)
392fb7db41cSSimon Glass {
393fb7db41cSSimon Glass 	return 0;
394fb7db41cSSimon Glass }
395fb7db41cSSimon Glass 
bootstage_start(enum bootstage_id id,const char * name)396e802ee0fSSimon Glass static inline uint32_t bootstage_start(enum bootstage_id id, const char *name)
397e802ee0fSSimon Glass {
398e802ee0fSSimon Glass 	return 0;
399e802ee0fSSimon Glass }
400e802ee0fSSimon Glass 
bootstage_accum(enum bootstage_id id)401e802ee0fSSimon Glass static inline uint32_t bootstage_accum(enum bootstage_id id)
402e802ee0fSSimon Glass {
403e802ee0fSSimon Glass 	return 0;
404e802ee0fSSimon Glass }
405e802ee0fSSimon Glass 
bootstage_stash(void * base,int size)406fcf509b8SSimon Glass static inline int bootstage_stash(void *base, int size)
407fcf509b8SSimon Glass {
408fcf509b8SSimon Glass 	return 0;	/* Pretend to succeed */
409fcf509b8SSimon Glass }
4103a608ca0SSimon Glass 
bootstage_unstash(const void * base,int size)4119d2542d0SSimon Glass static inline int bootstage_unstash(const void *base, int size)
412fcf509b8SSimon Glass {
413fcf509b8SSimon Glass 	return 0;	/* Pretend to succeed */
414fcf509b8SSimon Glass }
415b383d6c0SSimon Glass 
bootstage_get_size(void)41625e7dc6aSSimon Glass static inline int bootstage_get_size(void)
41725e7dc6aSSimon Glass {
41825e7dc6aSSimon Glass 	return 0;
41925e7dc6aSSimon Glass }
42025e7dc6aSSimon Glass 
bootstage_init(bool first)421b383d6c0SSimon Glass static inline int bootstage_init(bool first)
422b383d6c0SSimon Glass {
423b383d6c0SSimon Glass 	return 0;
424b383d6c0SSimon Glass }
425824bb1b4SSimon Glass 
426824bb1b4SSimon Glass #endif /* ENABLE_BOOTSTAGE */
427770605e4SSimon Glass 
428fb7db41cSSimon Glass /* Helper macro for adding a bootstage to a line of code */
429fb7db41cSSimon Glass #define BOOTSTAGE_MARKER()	\
430fb7db41cSSimon Glass 		bootstage_mark_code(__FILE__, __func__, __LINE__)
431fb7db41cSSimon Glass 
432097e1783SSimon Glass #endif
433