loader: fdt: Add fdt_is_setup function

When efi_autoload is called it will call fdt_setup_fdtp which setup the
dtb and overlays. If a user already loaded at dtb or overlays or just
printed the efi provided dtb, this will re-setup everything and also
re-applying the overlays.
Test that everything is setup before doing it again.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D20059
This commit is contained in:
Emmanuel Vadot 2019-04-25 20:08:43 +00:00
parent 0b24d24d80
commit 0eb610e8e3
3 changed files with 13 additions and 1 deletions

View File

@ -50,7 +50,8 @@ efi_autoload(void)
* imply that we're on a platform where FDT is a requirement. If we
* fix this, then the error handling here should be fixed accordingly.
*/
fdt_setup_fdtp();
if (fdt_is_setup() == 0)
fdt_setup_fdtp();
#endif
return (0);
}

View File

@ -509,6 +509,16 @@ fdt_apply_overlays()
free(overlay);
}
int
fdt_is_setup(void)
{
if (fdtp != NULL)
return (1);
return (0);
}
int
fdt_setup_fdtp()
{

View File

@ -48,6 +48,7 @@ int fdt_load_dtb_addr(struct fdt_header *);
int fdt_load_dtb_file(const char *);
void fdt_load_dtb_overlays(const char *);
int fdt_setup_fdtp(void);
int fdt_is_setup(void);
/* The platform library needs to implement these functions */
int fdt_platform_load_dtb(void);