diff options
| author | Tom Rini <[email protected]> | 2019-10-08 18:45:26 -0400 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2019-10-08 18:45:26 -0400 |
| commit | efea5a34bb5be542630ce7161bd3b9cc26a0bcf3 (patch) | |
| tree | fb747d83d81f9c3400a561782114e4c6ecd61a07 /include/spl.h | |
| parent | 9d536fe8ae7672bdee091f9100389b6f3e53cfc6 (diff) | |
| parent | cc2d27dcdc3e1c76d09d54015e3992380bd7e0fa (diff) | |
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-x86
- Rename existing FSP code to fsp1
- Add fsp2 directory in preparation to support FSP 2.0
- Various x86 platform codes update
- Various bug fixes and updates in dm core, sandbox and spl
Diffstat (limited to 'include/spl.h')
| -rw-r--r-- | include/spl.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/include/spl.h b/include/spl.h index e4640f3830b..c7cc2b0767c 100644 --- a/include/spl.h +++ b/include/spl.h @@ -49,6 +49,72 @@ static inline bool u_boot_first_phase(void) return false; } +enum u_boot_phase { + PHASE_TPL, /* Running in TPL */ + PHASE_SPL, /* Running in SPL */ + PHASE_BOARD_F, /* Running in U-Boot before relocation */ + PHASE_BOARD_R, /* Running in U-Boot after relocation */ +}; + +/** + * spl_phase() - Find out the phase of U-Boot + * + * This can be used to avoid #ifdef logic and use if() instead. + * + * For example, to include code only in TPL, you might do: + * + * #ifdef CONFIG_TPL_BUILD + * ... + * #endif + * + * but with this you can use: + * + * if (spl_phase() == PHASE_TPL) { + * ... + * } + * + * To include code only in SPL, you might do: + * + * #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) + * ... + * #endif + * + * but with this you can use: + * + * if (spl_phase() == PHASE_SPL) { + * ... + * } + * + * To include code only in U-Boot proper, you might do: + * + * #ifndef CONFIG_SPL_BUILD + * ... + * #endif + * + * but with this you can use: + * + * if (spl_phase() == PHASE_BOARD_F) { + * ... + * } + * + * @return U-Boot phase + */ +static inline enum u_boot_phase spl_phase(void) +{ +#ifdef CONFIG_TPL_BUILD + return PHASE_TPL; +#elif CONFIG_SPL_BUILD + return PHASE_SPL; +#else + DECLARE_GLOBAL_DATA_PTR; + + if (!(gd->flags & GD_FLG_RELOC)) + return PHASE_BOARD_F; + else + return PHASE_BOARD_R; +#endif +} + /* A string name for SPL or TPL */ #ifdef CONFIG_SPL_BUILD # ifdef CONFIG_TPL_BUILD |
