xref: /freebsd/stand/efi/loader/autoload.c (revision 3e15b01d6914c927e37d1699645783acf286655c)
1ca987d46SWarner Losh /*-
2ca987d46SWarner Losh  * Copyright (c) 2010 Rui Paulo <rpaulo@FreeBSD.org>
3ca987d46SWarner Losh  * All rights reserved.
4ca987d46SWarner Losh  *
5ca987d46SWarner Losh  * Redistribution and use in source and binary forms, with or without
6ca987d46SWarner Losh  * modification, are permitted provided that the following conditions
7ca987d46SWarner Losh  * are met:
8ca987d46SWarner Losh  *
9ca987d46SWarner Losh  * 1. Redistributions of source code must retain the above copyright
10ca987d46SWarner Losh  *    notice, this list of conditions and the following disclaimer.
11ca987d46SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
12ca987d46SWarner Losh  *    notice, this list of conditions and the following disclaimer in the
13ca987d46SWarner Losh  *    documentation and/or other materials provided with the distribution.
14ca987d46SWarner Losh  *
15ca987d46SWarner Losh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16ca987d46SWarner Losh  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17ca987d46SWarner Losh  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18ca987d46SWarner Losh  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19ca987d46SWarner Losh  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20ca987d46SWarner Losh  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21ca987d46SWarner Losh  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22ca987d46SWarner Losh  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23ca987d46SWarner Losh  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24ca987d46SWarner Losh  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25ca987d46SWarner Losh  */
26ca987d46SWarner Losh 
2735437b1fSKyle Evans #if defined(LOADER_FDT_SUPPORT)
2835437b1fSKyle Evans #include <sys/param.h>
2935437b1fSKyle Evans #include <fdt_platform.h>
3035437b1fSKyle Evans #endif
3135437b1fSKyle Evans 
32ca987d46SWarner Losh #include "loader_efi.h"
33ca987d46SWarner Losh 
34ca987d46SWarner Losh int
efi_autoload(void)35ca987d46SWarner Losh efi_autoload(void)
36ca987d46SWarner Losh {
37ca987d46SWarner Losh 
3835437b1fSKyle Evans #if defined(LOADER_FDT_SUPPORT)
3935437b1fSKyle Evans 	/*
4035437b1fSKyle Evans 	 * Setup the FDT early so that we're not loading files during bi_load.
4135437b1fSKyle Evans 	 * Any such loading is inherently broken since bi_load uses the space
4235437b1fSKyle Evans 	 * just after all currently loaded files for the data that will be
4335437b1fSKyle Evans 	 * passed to the kernel and newly loaded files will be positioned in
4435437b1fSKyle Evans 	 * that same space.
4535437b1fSKyle Evans 	 *
4635437b1fSKyle Evans 	 * We're glossing over errors here because LOADER_FDT_SUPPORT does not
4735437b1fSKyle Evans 	 * imply that we're on a platform where FDT is a requirement.  If we
4835437b1fSKyle Evans 	 * fix this, then the error handling here should be fixed accordingly.
4935437b1fSKyle Evans 	 */
50*0eb610e8SEmmanuel Vadot 	if (fdt_is_setup() == 0)
5135437b1fSKyle Evans 		fdt_setup_fdtp();
5235437b1fSKyle Evans #endif
53ca987d46SWarner Losh 	return (0);
54ca987d46SWarner Losh }
55