1 /*-
2  * Copyright (c) 2018-2022 Intel Corporation.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  */
26 
27 #ifndef	_CORE_SW_LOAD_
28 #define _CORE_SW_LOAD_
29 
30 #define STR_LEN 1024
31 #define BOOT_ARG_LEN 2048
32 
33 /* E820 memory types */
34 #define E820_TYPE_RAM           1U   /* EFI 1, 2, 3, 4, 5, 6, 7 */
35 /* EFI 0, 11, 12, 13 (everything not used elsewhere) */
36 #define E820_TYPE_RESERVED      2U
37 #define E820_TYPE_ACPI_RECLAIM  3U   /* EFI 9 */
38 #define E820_TYPE_ACPI_NVS      4U   /* EFI 10 */
39 #define E820_TYPE_UNUSABLE      5U   /* EFI 8 */
40 
41 #define NUM_E820_ENTRIES	7
42 #define LOWRAM_E820_ENTRY	1
43 #define HIGHRAM_E820_ENTRY	6
44 
45 #define HIGHRAM_START_ADDR	 0x100000000UL /* 4GB */
46 
47 /* Defines a single entry in an E820 memory map. */
48 struct e820_entry {
49 	/** The base address of the memory range. */
50 	uint64_t baseaddr;
51 	/** The length of the memory range. */
52 	uint64_t length;
53 	/** The type of memory region. */
54 	uint32_t type;
55 } __attribute__((packed));
56 
57 extern const struct e820_entry e820_default_entries[NUM_E820_ENTRIES];
58 extern int with_bootargs;
59 
60 size_t ovmf_image_size(void);
61 
62 int acrn_parse_kernel(char *arg);
63 int acrn_parse_ramdisk(char *arg);
64 int acrn_parse_bootargs(char *arg);
65 int acrn_parse_gvtargs(char *arg);         /* obsolete interface */
66 int acrn_parse_vsbl(char *arg);            /* obsolete interface */
67 int acrn_parse_ovmf(char *arg);
68 int acrn_parse_elf(char *arg);
69 int acrn_parse_guest_part_info(char *arg); /* obsolete interface */
70 char *get_bootargs(void);
71 void vsbl_set_bdf(int bnum, int snum, int fnum);
72 
73 int check_image(char *path, size_t size_limit, size_t *size);
74 uint32_t acrn_create_e820_table(struct vmctx *ctx, struct e820_entry *e820);
75 int add_e820_entry(struct e820_entry *e820, int len, uint64_t start,
76 	uint64_t size, uint32_t type);
77 
78 int acrn_sw_load_bzimage(struct vmctx *ctx);
79 int acrn_sw_load_elf(struct vmctx *ctx);
80 int acrn_sw_load_vsbl(struct vmctx *ctx);
81 int acrn_sw_load_ovmf(struct vmctx *ctx);
82 int acrn_writeback_ovmf_nvstorage(struct vmctx *ctx);
83 int acrn_sw_load(struct vmctx *ctx);
84 #endif
85 
86