1 /*
2  * Copyright (c) 2019 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_INCLUDE_ARCH_X86_MULTIBOOT_H_
8 #define ZEPHYR_INCLUDE_ARCH_X86_MULTIBOOT_H_
9 
10 #ifndef _ASMLANGUAGE
11 
12 #include "multiboot_info.h"
13 
14 extern struct multiboot_info multiboot_info;
15 
16 #ifdef CONFIG_MULTIBOOT_INFO
17 
18 void z_multiboot_init(struct multiboot_info *info_pa);
19 
20 #else
21 
z_multiboot_init(struct multiboot_info * info_pa)22 inline void z_multiboot_init(struct multiboot_info *info_pa)
23 {
24 	ARG_UNUSED(info_pa);
25 }
26 
27 #endif /* CONFIG_MULTIBOOT_INFO */
28 
29 /*
30  * the mmap_addr field points to a series of entries of the following form.
31  */
32 
33 struct multiboot_mmap {
34 	uint32_t size;
35 	uint64_t base;
36 	uint64_t length;
37 	uint32_t type;
38 } __packed;
39 
40 #endif /* _ASMLANGUAGE */
41 
42 /* Boot type value (see prep_c.c) */
43 #define MULTIBOOT_BOOT_TYPE 1
44 
45 /*
46  * Possible values for multiboot_mmap.type field.
47  * Other values should be assumed to be unusable ranges.
48  */
49 
50 #define MULTIBOOT_MMAP_RAM		1	/* available RAM */
51 #define MULTIBOOT_MMAP_ACPI		3	/* reserved for ACPI */
52 #define MULTIBOOT_MMAP_NVS		4	/* ACPI non-volatile */
53 #define MULTIBOOT_MMAP_DEFECTIVE	5	/* defective RAM module */
54 
55 /*
56  * Magic numbers: the kernel multiboot header (see crt0.S) begins with
57  * MULTIBOOT_HEADER_MAGIC to signal to the booter that it supports
58  * multiboot. On kernel entry, EAX is set to MULTIBOOT_EAX_MAGIC to
59  * signal that the boot loader is multiboot compliant.
60  */
61 
62 #define MULTIBOOT_HEADER_MAGIC		0x1BADB002
63 #define MULTIBOOT_EAX_MAGIC		0x2BADB002
64 
65 /*
66  * Typically, we put no flags in the multiboot header, as it exists solely
67  * to reassure the loader that we're a valid binary. The exception to this
68  * is when we want the loader to configure the framebuffer for us.
69  */
70 
71 #define MULTIBOOT_HEADER_FLAG_MEM	BIT(1)	/* want mem_/mmap_* info */
72 #define MULTIBOOT_HEADER_FLAG_FB	BIT(2)	/* want fb_* info */
73 
74 #ifdef CONFIG_INTEL_MULTIBOOTFB_DISPLAY
75 #define MULTIBOOT_HEADER_FLAGS \
76 	(MULTIBOOT_HEADER_FLAG_FB | MULTIBOOT_HEADER_FLAG_MEM)
77 #else
78 #define MULTIBOOT_HEADER_FLAGS MULTIBOOT_HEADER_FLAG_MEM
79 #endif
80 
81 /* The flags in the boot info structure tell us which fields are valid. */
82 
83 #define MULTIBOOT_INFO_FLAGS_MEM		BIT(0)	/* mem_* valid */
84 #define MULTIBOOT_INFO_FLAGS_CMDLINE		BIT(2)	/* cmdline* valid */
85 #define MULTIBOOT_INFO_FLAGS_MMAP		BIT(6)	/* mmap_* valid */
86 #define MULTIBOOT_INFO_FLAGS_FB			BIT(12)	/* fb_* valid */
87 
88 /* The only fb_type we support is RGB. No text modes and no color palettes. */
89 
90 #define MULTIBOOT_INFO_FB_TYPE_RGB	1
91 
92 #endif /* ZEPHYR_INCLUDE_ARCH_X86_MULTIBOOT_H_ */
93