xref: /openbmc/u-boot/include/bootm.h (revision 2502bfc4)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2000-2009
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  */
6 
7 #ifndef _BOOTM_H
8 #define _BOOTM_H
9 
10 #include <command.h>
11 #include <image.h>
12 
13 #define BOOTM_ERR_RESET		(-1)
14 #define BOOTM_ERR_OVERLAP		(-2)
15 #define BOOTM_ERR_UNIMPLEMENTED	(-3)
16 
17 /*
18  *  Continue booting an OS image; caller already has:
19  *  - copied image header to global variable `header'
20  *  - checked header magic number, checksums (both header & image),
21  *  - verified image architecture (PPC) and type (KERNEL or MULTI),
22  *  - loaded (first part of) image to header load address,
23  *  - disabled interrupts.
24  *
25  * @flag: Flags indicating what to do (BOOTM_STATE_...)
26  * @argc: Number of arguments. Note that the arguments are shifted down
27  *	 so that 0 is the first argument not processed by U-Boot, and
28  *	 argc is adjusted accordingly. This avoids confusion as to how
29  *	 many arguments are available for the OS.
30  * @images: Pointers to os/initrd/fdt
31  * @return 1 on error. On success the OS boots so this function does
32  * not return.
33  */
34 typedef int boot_os_fn(int flag, int argc, char * const argv[],
35 			bootm_headers_t *images);
36 
37 extern boot_os_fn do_bootm_linux;
38 extern boot_os_fn do_bootm_vxworks;
39 
40 int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
41 void lynxkdi_boot(image_header_t *hdr);
42 
43 boot_os_fn *bootm_os_get_boot_func(int os);
44 
45 int bootm_host_load_images(const void *fit, int cfg_noffset);
46 
47 int boot_selected_os(int argc, char * const argv[], int state,
48 		     bootm_headers_t *images, boot_os_fn *boot_fn);
49 
50 ulong bootm_disable_interrupts(void);
51 
52 /* This is a special function used by booti/bootz */
53 int bootm_find_images(int flag, int argc, char * const argv[]);
54 
55 /*
56  * Measure the boot images. Measurement is the process of hashing some binary
57  * data and storing it into secure memory, i.e. TPM PCRs. In addition, each
58  * measurement is logged into the platform event log such that the operating
59  * system can access it and perform attestation of the boot.
60  *
61  * @images:	The structure containing the various images to boot (linux,
62  *		initrd, dts, etc.)
63  */
64 int bootm_measure(struct bootm_headers *images);
65 
66 int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
67 		    int states, bootm_headers_t *images, int boot_progress);
68 
69 void arch_preboot_os(void);
70 
71 /**
72  * bootm_decomp_image() - decompress the operating system
73  *
74  * @comp:	Compression algorithm that is used (IH_COMP_...)
75  * @load:	Destination load address in U-Boot memory
76  * @image_start Image start address (where we are decompressing from)
77  * @type:	OS type (IH_OS_...)
78  * @load_bug:	Place to decompress to
79  * @image_buf:	Address to decompress from
80  * @image_len:	Number of bytes in @image_buf to decompress
81  * @unc_len:	Available space for decompression
82  * @return 0 if OK, -ve on error (BOOTM_ERR_...)
83  */
84 int bootm_decomp_image(int comp, ulong load, ulong image_start, int type,
85 		       void *load_buf, void *image_buf, ulong image_len,
86 		       uint unc_len, ulong *load_end);
87 
88 /*
89  * boards should define this to disable devices when EFI exits from boot
90  * services.
91  *
92  * TODO(sjg@chromium.org>): Update this to use driver model's device_remove().
93  */
94 void board_quiesce_devices(void);
95 
96 /**
97  * switch_to_non_secure_mode() - switch to non-secure mode
98  */
99 void switch_to_non_secure_mode(void);
100 
101 #endif
102