1/*
2 * Copyright 2014, General Dynamics C4 Systems
3 *
4 * This software may be distributed and modified according to the terms of
5 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
6 * See "LICENSE_GPLv2.txt" for details.
7 *
8 * @TAG(GD_GPL)
9 */
10
11#ifndef __ARCH_KERNEL_MULTIBOOT_H
12#define __ARCH_KERNEL_MULTIBOOT_H
13
14/* Adapted from the MultiBoot Specification:  */
15/* www.gnu.org/software/grub/manual/multiboot */
16
17#define MULTIBOOT_MAGIC 0x2BADB002
18
19#include <types.h>
20#include <arch/api/bootinfo_types.h>
21
22typedef struct multiboot_module {
23    uint32_t  start;
24    uint32_t  end;
25    uint32_t  name;
26    uint32_t reserved;
27} PACKED multiboot_module_t;
28
29typedef struct multiboot_mmap {
30    uint32_t size;
31    uint64_t base_addr;
32    uint64_t length;
33    uint32_t type;
34} PACKED multiboot_mmap_t;
35
36typedef struct multiboot_info {
37    /* struct split into multiple parts due to details of how C parser works */
38    struct multiboot_part1 {
39        uint32_t flags;
40        uint32_t mem_lower;
41        uint32_t mem_upper;
42        uint32_t boot_device;
43        uint32_t cmdline;
44        uint32_t mod_count;
45        uint32_t mod_list;
46    } part1;
47    /* The symbol table information in the multiboot header is comprised of a union
48     * as we neither a. support unions in the kernel or b. need the symbol information
49     * we will just skip the 4 words of this */
50    struct multiboot_part2 {
51        uint32_t syms[4];
52        uint32_t mmap_length;
53        uint32_t mmap_addr;
54        uint32_t drives_length;
55        uint32_t drives_addr;
56        uint32_t config_table;
57        uint32_t boot_loader_name;
58        uint32_t apm_table;
59        uint32_t vbe_control_info;
60        uint32_t vbe_mode_info;
61        uint16_t vbe_mode;
62        uint16_t vbe_interface_seg;
63        uint16_t vbe_interface_off;
64        uint16_t vbe_interface_len;
65    } part2;
66} PACKED multiboot_info_t;
67
68#define MULTIBOOT_INFO_MEM_FLAG     BIT(0)
69#define MULTIBOOT_INFO_CMDLINE_FLAG BIT(2)
70#define MULTIBOOT_INFO_MODS_FLAG    BIT(3)
71#define MULTIBOOT_INFO_MMAP_FLAG    BIT(6)
72#define MULTIBOOT_INFO_GRAPHICS_FLAG BIT(11)
73#define MULTIBOOT_MMAP_USEABLE_TYPE     1
74#define MULTIBOOT_MMAP_RESERVED_TYPE    2
75#define MULTIBOOT_MMAP_ACPI_TYPE        3
76#define MULTIBOOT_MMAP_ACPI_NVS_TYPE    4
77#define MULTIBOOT_MMAP_BAD_TYPE         5
78
79#endif
80