1097e1783SSimon Glass /*
2097e1783SSimon Glass * This file implements recording of each stage of the boot process. It is
3097e1783SSimon Glass * intended to implement timing of each stage, reporting this information
4097e1783SSimon Glass * to the user and passing it to the OS for logging / further analysis.
5c87dc38dSSimon Glass * Note that it requires timer_get_boot_us() to be defined by the board
6097e1783SSimon Glass *
7097e1783SSimon Glass * Copyright (c) 2011 The Chromium OS Authors.
8097e1783SSimon Glass *
91a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+
10097e1783SSimon Glass */
11097e1783SSimon Glass
12097e1783SSimon Glass #ifndef _BOOTSTAGE_H
13097e1783SSimon Glass #define _BOOTSTAGE_H
14097e1783SSimon Glass
15ee2b2434SSimon Glass /* Define this for host tools */
163a608ca0SSimon Glass #ifndef CONFIG_BOOTSTAGE_USER_COUNT
173a608ca0SSimon Glass #define CONFIG_BOOTSTAGE_USER_COUNT 20
183a608ca0SSimon Glass #endif
193a608ca0SSimon Glass
20094e06a5SSimon Glass /* Flags for each bootstage record */
21094e06a5SSimon Glass enum bootstage_flags {
22094e06a5SSimon Glass BOOTSTAGEF_ERROR = 1 << 0, /* Error record */
23094e06a5SSimon Glass BOOTSTAGEF_ALLOC = 1 << 1, /* Allocate an id */
24094e06a5SSimon Glass };
25094e06a5SSimon Glass
26a2cc9bf4SSimon Glass /* bootstate sub-IDs used for kernel and ramdisk ranges */
27a2cc9bf4SSimon Glass enum {
28a2cc9bf4SSimon Glass BOOTSTAGE_SUB_FORMAT,
29a2cc9bf4SSimon Glass BOOTSTAGE_SUB_FORMAT_OK,
30a2cc9bf4SSimon Glass BOOTSTAGE_SUB_NO_UNIT_NAME,
31a2cc9bf4SSimon Glass BOOTSTAGE_SUB_UNIT_NAME,
32a2cc9bf4SSimon Glass BOOTSTAGE_SUB_SUBNODE,
33a2cc9bf4SSimon Glass
34a2cc9bf4SSimon Glass BOOTSTAGE_SUB_CHECK,
35a2cc9bf4SSimon Glass BOOTSTAGE_SUB_HASH = 5,
36a2cc9bf4SSimon Glass BOOTSTAGE_SUB_CHECK_ARCH = 5,
37a2cc9bf4SSimon Glass BOOTSTAGE_SUB_CHECK_ALL,
38a2cc9bf4SSimon Glass BOOTSTAGE_SUB_GET_DATA,
39a2cc9bf4SSimon Glass BOOTSTAGE_SUB_CHECK_ALL_OK = 7,
40a2cc9bf4SSimon Glass BOOTSTAGE_SUB_GET_DATA_OK,
41a2cc9bf4SSimon Glass BOOTSTAGE_SUB_LOAD,
42a2cc9bf4SSimon Glass };
43a2cc9bf4SSimon Glass
44097e1783SSimon Glass /*
45097e1783SSimon Glass * A list of boot stages that we know about. Each of these indicates the
46097e1783SSimon Glass * state that we are at, and the action that we are about to perform. For
47097e1783SSimon Glass * errors, we issue an error for an item when it fails. Therefore the
48097e1783SSimon Glass * normal sequence is:
49097e1783SSimon Glass *
50097e1783SSimon Glass * progress action1
51097e1783SSimon Glass * progress action2
52097e1783SSimon Glass * progress action3
53097e1783SSimon Glass *
54097e1783SSimon Glass * and an error condition where action 3 failed would be:
55097e1783SSimon Glass *
56097e1783SSimon Glass * progress action1
57097e1783SSimon Glass * progress action2
58097e1783SSimon Glass * progress action3
59097e1783SSimon Glass * error on action3
60097e1783SSimon Glass */
61097e1783SSimon Glass enum bootstage_id {
625dc88716SSimon Glass BOOTSTAGE_ID_START = 0,
635dc88716SSimon Glass BOOTSTAGE_ID_CHECK_MAGIC, /* Checking image magic */
645dc88716SSimon Glass BOOTSTAGE_ID_CHECK_HEADER, /* Checking image header */
655dc88716SSimon Glass BOOTSTAGE_ID_CHECK_CHECKSUM, /* Checking image checksum */
665dc88716SSimon Glass BOOTSTAGE_ID_CHECK_ARCH, /* Checking architecture */
675dc88716SSimon Glass
685dc88716SSimon Glass BOOTSTAGE_ID_CHECK_IMAGETYPE = 5,/* Checking image type */
695dc88716SSimon Glass BOOTSTAGE_ID_DECOMP_IMAGE, /* Decompressing image */
705dc88716SSimon Glass BOOTSTAGE_ID_KERNEL_LOADED, /* Kernel has been loaded */
715dc88716SSimon Glass BOOTSTAGE_ID_DECOMP_UNIMPL = 7, /* Odd decompression algorithm */
725dc88716SSimon Glass BOOTSTAGE_ID_CHECK_BOOT_OS, /* Calling OS-specific boot function */
735dc88716SSimon Glass BOOTSTAGE_ID_BOOT_OS_RETURNED, /* Tried to boot OS, but it returned */
745dc88716SSimon Glass BOOTSTAGE_ID_CHECK_RAMDISK = 9, /* Checking ram disk */
755dc88716SSimon Glass
765e410883SSimon Glass BOOTSTAGE_ID_RD_MAGIC, /* Checking ram disk magic */
775e410883SSimon Glass BOOTSTAGE_ID_RD_HDR_CHECKSUM, /* Checking ram disk heder checksum */
785e410883SSimon Glass BOOTSTAGE_ID_RD_CHECKSUM, /* Checking ram disk checksum */
795e410883SSimon Glass BOOTSTAGE_ID_COPY_RAMDISK = 12, /* Copying ram disk into place */
805e410883SSimon Glass BOOTSTAGE_ID_RAMDISK, /* Checking for valid ramdisk */
815e410883SSimon Glass BOOTSTAGE_ID_NO_RAMDISK, /* No ram disk found (not an error) */
825e410883SSimon Glass
83097e1783SSimon Glass BOOTSTAGE_ID_RUN_OS = 15, /* Exiting U-Boot, entering OS */
848ade9506SSimon Glass
858ade9506SSimon Glass BOOTSTAGE_ID_NEED_RESET = 30,
868ade9506SSimon Glass BOOTSTAGE_ID_POST_FAIL, /* Post failure */
878ade9506SSimon Glass BOOTSTAGE_ID_POST_FAIL_R, /* Post failure reported after reloc */
888ade9506SSimon Glass
898ade9506SSimon Glass /*
901b15fac1SBin Meng * This set is reported only by x86, and the meaning is different. In
918ade9506SSimon Glass * this case we are reporting completion of a particular stage.
921b15fac1SBin Meng * This should probably change in the x86 code (which doesn't report
938ade9506SSimon Glass * errors in any case), but discussion this can perhaps wait until we
948ade9506SSimon Glass * have a generic board implementation.
958ade9506SSimon Glass */
968ade9506SSimon Glass BOOTSTAGE_ID_BOARD_INIT_R, /* We have relocated */
978ade9506SSimon Glass BOOTSTAGE_ID_BOARD_GLOBAL_DATA, /* Global data is set up */
988ade9506SSimon Glass
998ade9506SSimon Glass BOOTSTAGE_ID_BOARD_INIT_SEQ, /* We completed the init sequence */
1008ade9506SSimon Glass BOOTSTAGE_ID_BOARD_FLASH, /* We have configured flash banks */
1018ade9506SSimon Glass BOOTSTAGE_ID_BOARD_FLASH_37, /* In case you didn't hear... */
1028ade9506SSimon Glass BOOTSTAGE_ID_BOARD_ENV, /* Environment is relocated & ready */
1038ade9506SSimon Glass BOOTSTAGE_ID_BOARD_PCI, /* PCI is up */
1048ade9506SSimon Glass
1058ade9506SSimon Glass BOOTSTAGE_ID_BOARD_INTERRUPTS, /* Exceptions / interrupts ready */
1068ade9506SSimon Glass BOOTSTAGE_ID_BOARD_DONE, /* Board init done, off to main loop */
1078ade9506SSimon Glass /* ^^^ here ends the x86 sequence */
1088ade9506SSimon Glass
10990e153d7SSimon Glass /* Boot stages related to loading a kernel from an IDE device */
11090e153d7SSimon Glass BOOTSTAGE_ID_IDE_START = 41,
11190e153d7SSimon Glass BOOTSTAGE_ID_IDE_ADDR,
11290e153d7SSimon Glass BOOTSTAGE_ID_IDE_BOOT_DEVICE,
11390e153d7SSimon Glass BOOTSTAGE_ID_IDE_TYPE,
11490e153d7SSimon Glass
11590e153d7SSimon Glass BOOTSTAGE_ID_IDE_PART,
11690e153d7SSimon Glass BOOTSTAGE_ID_IDE_PART_INFO,
11790e153d7SSimon Glass BOOTSTAGE_ID_IDE_PART_TYPE,
11890e153d7SSimon Glass BOOTSTAGE_ID_IDE_PART_READ,
11990e153d7SSimon Glass BOOTSTAGE_ID_IDE_FORMAT,
12090e153d7SSimon Glass
12190e153d7SSimon Glass BOOTSTAGE_ID_IDE_CHECKSUM, /* 50 */
12290e153d7SSimon Glass BOOTSTAGE_ID_IDE_READ,
123cd24a6bfSSimon Glass
124cd24a6bfSSimon Glass /* Boot stages related to loading a kernel from an NAND device */
125cd24a6bfSSimon Glass BOOTSTAGE_ID_NAND_PART,
126cd24a6bfSSimon Glass BOOTSTAGE_ID_NAND_SUFFIX,
127cd24a6bfSSimon Glass BOOTSTAGE_ID_NAND_BOOT_DEVICE,
128cd24a6bfSSimon Glass BOOTSTAGE_ID_NAND_HDR_READ = 55,
129cd24a6bfSSimon Glass BOOTSTAGE_ID_NAND_AVAILABLE = 55,
130cd24a6bfSSimon Glass BOOTSTAGE_ID_NAND_TYPE = 57,
131cd24a6bfSSimon Glass BOOTSTAGE_ID_NAND_READ,
132cd24a6bfSSimon Glass
133c8e66db7SSimon Glass /* Boot stages related to loading a kernel from an network device */
134c8e66db7SSimon Glass BOOTSTAGE_ID_NET_CHECKSUM = 60,
135c8e66db7SSimon Glass BOOTSTAGE_ID_NET_ETH_START = 64,
136c8e66db7SSimon Glass BOOTSTAGE_ID_NET_ETH_INIT,
137c8e66db7SSimon Glass
138c8e66db7SSimon Glass BOOTSTAGE_ID_NET_START = 80,
139c8e66db7SSimon Glass BOOTSTAGE_ID_NET_NETLOOP_OK,
140c8e66db7SSimon Glass BOOTSTAGE_ID_NET_LOADED,
141c8e66db7SSimon Glass BOOTSTAGE_ID_NET_DONE_ERR,
142c8e66db7SSimon Glass BOOTSTAGE_ID_NET_DONE,
143c8e66db7SSimon Glass
144a2cc9bf4SSimon Glass BOOTSTAGE_ID_FIT_FDT_START = 90,
145aacc8c16SSimon Glass /*
146aacc8c16SSimon Glass * Boot stages related to loading a FIT image. Some of these are a
147aacc8c16SSimon Glass * bit wonky.
148aacc8c16SSimon Glass */
149a2cc9bf4SSimon Glass BOOTSTAGE_ID_FIT_KERNEL_START = 100,
150aacc8c16SSimon Glass
15113167dacSSimon Glass BOOTSTAGE_ID_FIT_CONFIG = 110,
152aacc8c16SSimon Glass BOOTSTAGE_ID_FIT_TYPE,
15313167dacSSimon Glass BOOTSTAGE_ID_FIT_KERNEL_INFO,
154aacc8c16SSimon Glass
155aacc8c16SSimon Glass BOOTSTAGE_ID_FIT_COMPRESSION,
156aacc8c16SSimon Glass BOOTSTAGE_ID_FIT_OS,
157aacc8c16SSimon Glass BOOTSTAGE_ID_FIT_LOADADDR,
158aacc8c16SSimon Glass BOOTSTAGE_ID_OVERWRITTEN,
159aacc8c16SSimon Glass
160a2cc9bf4SSimon Glass /* Next 10 IDs used by BOOTSTAGE_SUB_... */
161a2cc9bf4SSimon Glass BOOTSTAGE_ID_FIT_RD_START = 120, /* Ramdisk stages */
162aacc8c16SSimon Glass
16390268b87SSimon Glass /* Next 10 IDs used by BOOTSTAGE_SUB_... */
16490268b87SSimon Glass BOOTSTAGE_ID_FIT_SETUP_START = 130, /* x86 setup stages */
16590268b87SSimon Glass
166cd24a6bfSSimon Glass BOOTSTAGE_ID_IDE_FIT_READ = 140,
167cd24a6bfSSimon Glass BOOTSTAGE_ID_IDE_FIT_READ_OK,
168cd24a6bfSSimon Glass
169cd24a6bfSSimon Glass BOOTSTAGE_ID_NAND_FIT_READ = 150,
170cd24a6bfSSimon Glass BOOTSTAGE_ID_NAND_FIT_READ_OK,
1713a608ca0SSimon Glass
17284a07dbfSKarl Apsite BOOTSTAGE_ID_FIT_LOADABLE_START = 160, /* for Loadable Images */
1733a608ca0SSimon Glass /*
1743a608ca0SSimon Glass * These boot stages are new, higher level, and not directly related
1753a608ca0SSimon Glass * to the old boot progress numbers. They are useful for recording
1763a608ca0SSimon Glass * rough boot timing information.
1773a608ca0SSimon Glass */
1783a608ca0SSimon Glass BOOTSTAGE_ID_AWAKE,
179996e95d4SSimon Glass BOOTSTAGE_ID_START_SPL,
180824bb1b4SSimon Glass BOOTSTAGE_ID_END_SPL,
1813a608ca0SSimon Glass BOOTSTAGE_ID_START_UBOOT_F,
1823a608ca0SSimon Glass BOOTSTAGE_ID_START_UBOOT_R,
1833a608ca0SSimon Glass BOOTSTAGE_ID_USB_START,
1843a608ca0SSimon Glass BOOTSTAGE_ID_ETH_START,
1853a608ca0SSimon Glass BOOTSTAGE_ID_BOOTP_START,
1863a608ca0SSimon Glass BOOTSTAGE_ID_BOOTP_STOP,
1873a608ca0SSimon Glass BOOTSTAGE_ID_BOOTM_START,
1883a608ca0SSimon Glass BOOTSTAGE_ID_BOOTM_HANDOFF,
1893a608ca0SSimon Glass BOOTSTAGE_ID_MAIN_LOOP,
1903a608ca0SSimon Glass BOOTSTAGE_KERNELREAD_START,
1913a608ca0SSimon Glass BOOTSTAGE_KERNELREAD_STOP,
192996e95d4SSimon Glass BOOTSTAGE_ID_BOARD_INIT,
193996e95d4SSimon Glass BOOTSTAGE_ID_BOARD_INIT_DONE,
1943a608ca0SSimon Glass
1953a608ca0SSimon Glass BOOTSTAGE_ID_CPU_AWAKE,
1963a608ca0SSimon Glass BOOTSTAGE_ID_MAIN_CPU_AWAKE,
1973a608ca0SSimon Glass BOOTSTAGE_ID_MAIN_CPU_READY,
1983a608ca0SSimon Glass
199996e95d4SSimon Glass BOOTSTAGE_ID_ACCUM_LCD,
200abbdb262SSimon Glass BOOTSTAGE_ID_ACCUM_SCSI,
20128b5404cSSimon Glass BOOTSTAGE_ID_ACCUM_SPI,
20228b5404cSSimon Glass BOOTSTAGE_ID_ACCUM_DECOMP,
203*a132f770SSimon Glass BOOTSTAGE_ID_ACCUM_OF_LIVE,
20462afc601SMichal Simek BOOTSTAGE_ID_FPGA_INIT,
205824bb1b4SSimon Glass BOOTSTATE_ID_ACCUM_DM_SPL,
20663c5bf48SSimon Glass BOOTSTATE_ID_ACCUM_DM_F,
20763c5bf48SSimon Glass BOOTSTATE_ID_ACCUM_DM_R,
208996e95d4SSimon Glass
2093a608ca0SSimon Glass /* a few spare for the user, from here */
2103a608ca0SSimon Glass BOOTSTAGE_ID_USER,
2113a608ca0SSimon Glass BOOTSTAGE_ID_COUNT = BOOTSTAGE_ID_USER + CONFIG_BOOTSTAGE_USER_COUNT,
2123a608ca0SSimon Glass BOOTSTAGE_ID_ALLOC,
213097e1783SSimon Glass };
214097e1783SSimon Glass
215097e1783SSimon Glass /*
2163786980dSSimon Glass * Return the time since boot in microseconds, This is needed for bootstage
2173786980dSSimon Glass * and should be defined in CPU- or board-specific code. If undefined then
218c87dc38dSSimon Glass * you will get a link error.
2193786980dSSimon Glass */
2203786980dSSimon Glass ulong timer_get_boot_us(void);
2213786980dSSimon Glass
222496c5483SHeiko Schocher #if defined(USE_HOSTCC)
223496c5483SHeiko Schocher #define show_boot_progress(val) do {} while (0)
224496c5483SHeiko Schocher #else
225cbcd6970SSimon Glass /**
226097e1783SSimon Glass * Board code can implement show_boot_progress() if needed.
227097e1783SSimon Glass *
228097e1783SSimon Glass * @param val Progress state (enum bootstage_id), or -id if an error
229097e1783SSimon Glass * has occurred.
230097e1783SSimon Glass */
231097e1783SSimon Glass void show_boot_progress(int val);
2327ac2fe2dSIlya Yanok #endif
233770605e4SSimon Glass
234824bb1b4SSimon Glass #if !defined(USE_HOSTCC)
235824bb1b4SSimon Glass #if CONFIG_IS_ENABLED(BOOTSTAGE)
236824bb1b4SSimon Glass #define ENABLE_BOOTSTAGE
237824bb1b4SSimon Glass #endif
238824bb1b4SSimon Glass #endif
239824bb1b4SSimon Glass
240824bb1b4SSimon Glass #ifdef ENABLE_BOOTSTAGE
241824bb1b4SSimon Glass
242770605e4SSimon Glass /* This is the full bootstage implementation */
243770605e4SSimon Glass
244094e06a5SSimon Glass /**
245150678a5SDoug Anderson * Relocate existing bootstage records
246150678a5SDoug Anderson *
247150678a5SDoug Anderson * Call this after relocation has happened and after malloc has been initted.
248150678a5SDoug Anderson * We need to copy any pointers in bootstage records that were added pre-
249cbcd6970SSimon Glass * relocation, since memory can be overwritten later.
250150678a5SDoug Anderson * @return Always returns 0, to indicate success
251150678a5SDoug Anderson */
252150678a5SDoug Anderson int bootstage_relocate(void);
253150678a5SDoug Anderson
254150678a5SDoug Anderson /**
255094e06a5SSimon Glass * Add a new bootstage record
256094e06a5SSimon Glass *
257094e06a5SSimon Glass * @param id Bootstage ID to use (ignored if flags & BOOTSTAGEF_ALLOC)
258094e06a5SSimon Glass * @param name Name of record, or NULL for none
259094e06a5SSimon Glass * @param flags Flags (BOOTSTAGEF_...)
260094e06a5SSimon Glass * @param mark Time to record in this record, in microseconds
261094e06a5SSimon Glass */
262094e06a5SSimon Glass ulong bootstage_add_record(enum bootstage_id id, const char *name,
263094e06a5SSimon Glass int flags, ulong mark);
264094e06a5SSimon Glass
265cbcd6970SSimon Glass /**
266770605e4SSimon Glass * Mark a time stamp for the current boot stage.
267770605e4SSimon Glass */
268770605e4SSimon Glass ulong bootstage_mark(enum bootstage_id id);
269770605e4SSimon Glass
270770605e4SSimon Glass ulong bootstage_error(enum bootstage_id id);
271770605e4SSimon Glass
2723a608ca0SSimon Glass ulong bootstage_mark_name(enum bootstage_id id, const char *name);
2733a608ca0SSimon Glass
2740e996773SSimon Glass /**
275fb7db41cSSimon Glass * Mark a time stamp in the given function and line number
276fb7db41cSSimon Glass *
277fb7db41cSSimon Glass * See BOOTSTAGE_MARKER() for a convenient macro.
278fb7db41cSSimon Glass *
279fb7db41cSSimon Glass * @param file Filename to record (NULL if none)
280fb7db41cSSimon Glass * @param func Function name to record
281fb7db41cSSimon Glass * @param linenum Line number to record
282fb7db41cSSimon Glass * @return recorded time stamp
283fb7db41cSSimon Glass */
284fb7db41cSSimon Glass ulong bootstage_mark_code(const char *file, const char *func,
285fb7db41cSSimon Glass int linenum);
286fb7db41cSSimon Glass
287fb7db41cSSimon Glass /**
2880e996773SSimon Glass * Mark the start of a bootstage activity. The end will be marked later with
2890e996773SSimon Glass * bootstage_accum() and at that point we accumulate the time taken. Calling
2900e996773SSimon Glass * this function turns the given id into a accumulator rather than and
2910e996773SSimon Glass * absolute mark in time. Accumulators record the total amount of time spent
2920e996773SSimon Glass * in an activty during boot.
2930e996773SSimon Glass *
2940e996773SSimon Glass * @param id Bootstage id to record this timestamp against
2950e996773SSimon Glass * @param name Textual name to display for this id in the report (maybe NULL)
2960e996773SSimon Glass * @return start timestamp in microseconds
2970e996773SSimon Glass */
2980e996773SSimon Glass uint32_t bootstage_start(enum bootstage_id id, const char *name);
2990e996773SSimon Glass
3000e996773SSimon Glass /**
3010e996773SSimon Glass * Mark the end of a bootstage activity
3020e996773SSimon Glass *
3030e996773SSimon Glass * After previously marking the start of an activity with bootstage_start(),
3040e996773SSimon Glass * call this function to mark the end. You can call these functions in pairs
3050e996773SSimon Glass * as many times as you like.
3060e996773SSimon Glass *
3070e996773SSimon Glass * @param id Bootstage id to record this timestamp against
3080e996773SSimon Glass * @return time spent in this iteration of the activity (i.e. the time now
3090e996773SSimon Glass * less the start time recorded in the last bootstage_start() call
3100e996773SSimon Glass * with this id.
3110e996773SSimon Glass */
3120e996773SSimon Glass uint32_t bootstage_accum(enum bootstage_id id);
3130e996773SSimon Glass
3143a608ca0SSimon Glass /* Print a report about boot time */
3153a608ca0SSimon Glass void bootstage_report(void);
3163a608ca0SSimon Glass
31794fd1316SSimon Glass /**
31894fd1316SSimon Glass * Add bootstage information to the device tree
31994fd1316SSimon Glass *
32094fd1316SSimon Glass * @return 0 if ok, -ve on error
32194fd1316SSimon Glass */
32294fd1316SSimon Glass int bootstage_fdt_add_report(void);
32394fd1316SSimon Glass
324cbcd6970SSimon Glass /**
325fcf509b8SSimon Glass * Stash bootstage data into memory
326fcf509b8SSimon Glass *
327fcf509b8SSimon Glass * @param base Base address of memory buffer
328fcf509b8SSimon Glass * @param size Size of memory buffer
329fcf509b8SSimon Glass * @return 0 if stashed ok, -1 if out of space
330fcf509b8SSimon Glass */
331fcf509b8SSimon Glass int bootstage_stash(void *base, int size);
332fcf509b8SSimon Glass
333fcf509b8SSimon Glass /**
334fcf509b8SSimon Glass * Read bootstage data from memory
335fcf509b8SSimon Glass *
336fcf509b8SSimon Glass * Bootstage data is read from memory and placed in the bootstage table
337fcf509b8SSimon Glass * in the user records.
338fcf509b8SSimon Glass *
339fcf509b8SSimon Glass * @param base Base address of memory buffer
340fcf509b8SSimon Glass * @param size Size of memory buffer (-1 if unknown)
341e003310aSSimon Glass * @return 0 if unstashed ok, -ENOENT if bootstage info not found, -ENOSPC if
342e003310aSSimon Glass * there is not space for read the stacked data, or other error if
343e003310aSSimon Glass * something else went wrong
344fcf509b8SSimon Glass */
3459d2542d0SSimon Glass int bootstage_unstash(const void *base, int size);
346fcf509b8SSimon Glass
347b383d6c0SSimon Glass /**
34825e7dc6aSSimon Glass * bootstage_get_size() - Get the size of the bootstage data
34925e7dc6aSSimon Glass *
35025e7dc6aSSimon Glass * @return size of boostage data in bytes
35125e7dc6aSSimon Glass */
35225e7dc6aSSimon Glass int bootstage_get_size(void);
35325e7dc6aSSimon Glass
35425e7dc6aSSimon Glass /**
355b383d6c0SSimon Glass * bootstage_init() - Prepare bootstage for use
356b383d6c0SSimon Glass *
357b383d6c0SSimon Glass * @first: true if this is the first time bootstage is set up. This causes it
358b383d6c0SSimon Glass * to add a 'reset' record with a time of 0.
359b383d6c0SSimon Glass */
360b383d6c0SSimon Glass int bootstage_init(bool first);
361b383d6c0SSimon Glass
362770605e4SSimon Glass #else
bootstage_add_record(enum bootstage_id id,const char * name,int flags,ulong mark)363e802ee0fSSimon Glass static inline ulong bootstage_add_record(enum bootstage_id id,
364e802ee0fSSimon Glass const char *name, int flags, ulong mark)
365e802ee0fSSimon Glass {
366e802ee0fSSimon Glass return 0;
367e802ee0fSSimon Glass }
368e802ee0fSSimon Glass
369770605e4SSimon Glass /*
370770605e4SSimon Glass * This is a dummy implementation which just calls show_boot_progress(),
371770605e4SSimon Glass * and won't even do that unless CONFIG_SHOW_BOOT_PROGRESS is defined
372770605e4SSimon Glass */
373770605e4SSimon Glass
bootstage_relocate(void)374150678a5SDoug Anderson static inline int bootstage_relocate(void)
375150678a5SDoug Anderson {
376150678a5SDoug Anderson return 0;
377150678a5SDoug Anderson }
378150678a5SDoug Anderson
bootstage_mark(enum bootstage_id id)379770605e4SSimon Glass static inline ulong bootstage_mark(enum bootstage_id id)
3805ddb118dSSimon Glass {
381770605e4SSimon Glass show_boot_progress(id);
382770605e4SSimon Glass return 0;
3835ddb118dSSimon Glass }
384097e1783SSimon Glass
bootstage_error(enum bootstage_id id)385770605e4SSimon Glass static inline ulong bootstage_error(enum bootstage_id id)
386770605e4SSimon Glass {
387770605e4SSimon Glass show_boot_progress(-id);
388770605e4SSimon Glass return 0;
389770605e4SSimon Glass }
390770605e4SSimon Glass
bootstage_mark_name(enum bootstage_id id,const char * name)3913a608ca0SSimon Glass static inline ulong bootstage_mark_name(enum bootstage_id id, const char *name)
3923a608ca0SSimon Glass {
3937f442e36SHeiko Schocher show_boot_progress(id);
3943a608ca0SSimon Glass return 0;
3953a608ca0SSimon Glass }
3963a608ca0SSimon Glass
bootstage_mark_code(const char * file,const char * func,int linenum)397fb7db41cSSimon Glass static inline ulong bootstage_mark_code(const char *file, const char *func,
398fb7db41cSSimon Glass int linenum)
399fb7db41cSSimon Glass {
400fb7db41cSSimon Glass return 0;
401fb7db41cSSimon Glass }
402fb7db41cSSimon Glass
bootstage_start(enum bootstage_id id,const char * name)403e802ee0fSSimon Glass static inline uint32_t bootstage_start(enum bootstage_id id, const char *name)
404e802ee0fSSimon Glass {
405e802ee0fSSimon Glass return 0;
406e802ee0fSSimon Glass }
407e802ee0fSSimon Glass
bootstage_accum(enum bootstage_id id)408e802ee0fSSimon Glass static inline uint32_t bootstage_accum(enum bootstage_id id)
409e802ee0fSSimon Glass {
410e802ee0fSSimon Glass return 0;
411e802ee0fSSimon Glass }
412e802ee0fSSimon Glass
bootstage_stash(void * base,int size)413fcf509b8SSimon Glass static inline int bootstage_stash(void *base, int size)
414fcf509b8SSimon Glass {
415fcf509b8SSimon Glass return 0; /* Pretend to succeed */
416fcf509b8SSimon Glass }
4173a608ca0SSimon Glass
bootstage_unstash(const void * base,int size)4189d2542d0SSimon Glass static inline int bootstage_unstash(const void *base, int size)
419fcf509b8SSimon Glass {
420fcf509b8SSimon Glass return 0; /* Pretend to succeed */
421fcf509b8SSimon Glass }
422b383d6c0SSimon Glass
bootstage_get_size(void)42325e7dc6aSSimon Glass static inline int bootstage_get_size(void)
42425e7dc6aSSimon Glass {
42525e7dc6aSSimon Glass return 0;
42625e7dc6aSSimon Glass }
42725e7dc6aSSimon Glass
bootstage_init(bool first)428b383d6c0SSimon Glass static inline int bootstage_init(bool first)
429b383d6c0SSimon Glass {
430b383d6c0SSimon Glass return 0;
431b383d6c0SSimon Glass }
432824bb1b4SSimon Glass
433824bb1b4SSimon Glass #endif /* ENABLE_BOOTSTAGE */
434770605e4SSimon Glass
435fb7db41cSSimon Glass /* Helper macro for adding a bootstage to a line of code */
436fb7db41cSSimon Glass #define BOOTSTAGE_MARKER() \
437fb7db41cSSimon Glass bootstage_mark_code(__FILE__, __func__, __LINE__)
438fb7db41cSSimon Glass
439097e1783SSimon Glass #endif
440