1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
8 * See "LICENSE_GPLv2.txt" for details.
9 *
10 * @TAG(DATA61_GPL)
11 */
12
13/* Configuration for MultiBoot, see MultiBoot Specification:
14   www.gnu.org/software/grub/manual/multiboot
15   We use a flags field of 3, indicating that we want modules loaded on page
16   boundaries and access to the memory map information. We do not set bit 16,
17   indicating that the structure of the image should be taken from its ELF
18   headers. */
19
20#include <config.h>
21#include <machine/assembler.h>
22
23#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
24
25#ifdef CONFIG_MULTIBOOT_GRAPHICS_MODE_NONE
26    #define MULTIBOOT_HEADER_FLAGS 3
27    #define MULTIBOOT_GRAPHICS_TEXT 0
28#else /* CONFIG_MULTIBOOT_GRAPHICS_MODE_NONE */
29    #define MULTIBOOT_HEADER_FLAGS 7
30    #ifdef CONFIG_MULTIBOOT_GRAPHICS_MODE_TEXT
31        #define MULTIBOOT_GRAPHICS_TEXT 1
32    #else /* CONFIG_MULTIBOOT_GRAPHICS_MODE_TEXT */
33        #define MULTIBOOT_GRAPHICS_TEXT 0
34    #endif /* CONFIG_MULTIBOOT_GRAPHICS_MODE_TEXT */
35#endif /* CONFIG_MULTIBOOT_GRAPHICS_MODE_NONE */
36
37/* These configs will be set if a graphics mode is set. if they aren't
38 * then we can put whatever in the multiboot header and it will be ignored.
39 * This seems to be the easiest way to make things compile */
40#ifndef CONFIG_MULTIBOOT_GRAPHICS_MODE_HEIGHT
41#define CONFIG_MULTIBOOT_GRAPHICS_MODE_HEIGHT 0
42#endif
43#ifndef CONFIG_MULTIBOOT_GRAPHICS_MODE_WIDTH
44#define CONFIG_MULTIBOOT_GRAPHICS_MODE_WIDTH 0
45#endif
46#ifndef CONFIG_MULTIBOOT_GRAPHICS_MODE_DEPTH
47#define CONFIG_MULTIBOOT_GRAPHICS_MODE_DEPTH 0
48#endif
49
50.section .mbh
51#ifdef CONFIG_MULTIBOOT1_HEADER
52    /* MultiBoot header */
53    .align  4
54    .long   MULTIBOOT_HEADER_MAGIC; /*magic*/
55    .long   MULTIBOOT_HEADER_FLAGS; /*flags*/
56    .long   - MULTIBOOT_HEADER_FLAGS - MULTIBOOT_HEADER_MAGIC; /*checksum*/
57    .long   0 /*header_addr*/
58    .long   0 /*load_addr*/
59    .long   0 /*load_end_addr*/
60    .long   0 /*bss_end_addr*/
61    .long   0 /*entry_addr*/
62    .long   MULTIBOOT_GRAPHICS_TEXT /*mode_type*/
63    .long   CONFIG_MULTIBOOT_GRAPHICS_MODE_WIDTH /*width*/
64    .long   CONFIG_MULTIBOOT_GRAPHICS_MODE_HEIGHT /*height*/
65    .long   CONFIG_MULTIBOOT_GRAPHICS_MODE_DEPTH /*depth*/
66#endif
67#ifdef CONFIG_MULTIBOOT2_HEADER
68    .align  8
69    __mbi2_start:
70    /* magic multi-boot 2 header */
71    .long   0xe85250d6
72    .long   0x0
73    .long   (__mbi2_end - __mbi2_start)
74    .long  -(0xe85250d6 + (__mbi2_end - __mbi2_start))
75    /* end tag - type, flags, size */
76    .word   0x0
77    .word   0x0
78    .long   0x8
79    __mbi2_end:
80#endif
81