1 | /*
|
---|
2 | * Copyright (c) 2011 Martin Decky
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup genarch
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /** @file
|
---|
33 | */
|
---|
34 |
|
---|
35 | #ifndef KERN_MULTIBOOT2_H_
|
---|
36 | #define KERN_MULTIBOOT2_H_
|
---|
37 |
|
---|
38 | #define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
|
---|
39 | #define MULTIBOOT2_HEADER_ARCH_I386 0
|
---|
40 |
|
---|
41 | #define MULTIBOOT2_LOADER_MAGIC 0x36d76289
|
---|
42 |
|
---|
43 | #define MULTIBOOT2_FLAGS_REQUIRED 0
|
---|
44 | #define MULTIBOOT2_FLAGS_CONSOLE 0x03
|
---|
45 |
|
---|
46 | #define MULTIBOOT2_TAG_TERMINATOR 0
|
---|
47 | #define MULTIBOOT2_TAG_INFO_REQ 1
|
---|
48 | #define MULTIBOOT2_TAG_ADDRESS 2
|
---|
49 | #define MULTIBOOT2_TAG_ENTRY_ADDRESS 3
|
---|
50 | #define MULTIBOOT2_TAG_FLAGS 4
|
---|
51 | #define MULTIBOOT2_TAG_FRAMEBUFFER 5
|
---|
52 | #define MULTIBOOT2_TAG_MODULE_ALIGN 6
|
---|
53 |
|
---|
54 | #define MULTIBOOT2_TAG_MODULE 3
|
---|
55 | #define MULTIBOOT2_TAG_MEMMAP 6
|
---|
56 | #define MULTIBOOT2_TAG_FBINFO 8
|
---|
57 |
|
---|
58 | #define MULTIBOOT2_VISUAL_INDEXED 0
|
---|
59 | #define MULTIBOOT2_VISUAL_RGB 1
|
---|
60 | #define MULTIBOOT2_VISUAL_EGA 2
|
---|
61 |
|
---|
62 | #ifndef __ASM__
|
---|
63 |
|
---|
64 | #include <typedefs.h>
|
---|
65 | #include <arch/boot/memmap.h>
|
---|
66 |
|
---|
67 | /** Multiboot2 32-bit address. */
|
---|
68 | typedef uint32_t mb2addr_t;
|
---|
69 |
|
---|
70 | /** Multiboot2 information structure */
|
---|
71 | typedef struct {
|
---|
72 | uint32_t size;
|
---|
73 | uint32_t reserved;
|
---|
74 | } __attribute__((packed)) multiboot2_info_t;
|
---|
75 |
|
---|
76 | /** Multiboot2 modules structure */
|
---|
77 | typedef struct {
|
---|
78 | mb2addr_t start;
|
---|
79 | mb2addr_t end;
|
---|
80 | char string[];
|
---|
81 | } __attribute__((packed)) multiboot2_module_t;
|
---|
82 |
|
---|
83 | /** Multiboot2 memmap structure */
|
---|
84 | typedef struct {
|
---|
85 | uint32_t entry_size;
|
---|
86 | uint32_t entry_version;
|
---|
87 | } __attribute__ ((packed)) multiboot2_memmap_t;
|
---|
88 |
|
---|
89 | /** Multiboot2 memmap entry structure */
|
---|
90 | typedef struct {
|
---|
91 | uint64_t base_address;
|
---|
92 | uint64_t size;
|
---|
93 | uint32_t type;
|
---|
94 | uint32_t reserved;
|
---|
95 | } __attribute__((packed)) multiboot2_memmap_entry_t;
|
---|
96 |
|
---|
97 | /** Multiboot2 palette structure */
|
---|
98 | typedef struct {
|
---|
99 | uint8_t red;
|
---|
100 | uint8_t green;
|
---|
101 | uint8_t blue;
|
---|
102 | } __attribute__((packed)) multiboot2_colorinfo_palette_t;
|
---|
103 |
|
---|
104 | /** Multiboot2 indexed color information structure */
|
---|
105 | typedef struct {
|
---|
106 | uint32_t colors;
|
---|
107 | multiboot2_colorinfo_palette_t palette[];
|
---|
108 | } __attribute__((packed)) multiboot2_colorinfo_indexed_t;
|
---|
109 |
|
---|
110 | /** Multiboot2 RGB color information structure */
|
---|
111 | typedef struct {
|
---|
112 | uint8_t red_pos;
|
---|
113 | uint8_t red_size;
|
---|
114 | uint8_t green_pos;
|
---|
115 | uint8_t green_size;
|
---|
116 | uint8_t blue_pos;
|
---|
117 | uint8_t blue_size;
|
---|
118 | } __attribute__((packed)) multiboot2_colorinfo_rgb_t;
|
---|
119 |
|
---|
120 | /** Multiboot2 framebuffer information structure */
|
---|
121 | typedef struct {
|
---|
122 | uint64_t addr;
|
---|
123 | uint32_t scanline;
|
---|
124 | uint32_t width;
|
---|
125 | uint32_t height;
|
---|
126 | uint8_t bpp;
|
---|
127 | uint8_t visual;
|
---|
128 | uint8_t reserved;
|
---|
129 | union {
|
---|
130 | multiboot2_colorinfo_indexed_t indexed;
|
---|
131 | multiboot2_colorinfo_rgb_t rgb;
|
---|
132 | };
|
---|
133 | } __attribute__((packed)) multiboot2_fbinfo_t;
|
---|
134 |
|
---|
135 | /** Generic multiboot2 tag */
|
---|
136 | typedef struct {
|
---|
137 | uint32_t type;
|
---|
138 | uint32_t size;
|
---|
139 | union {
|
---|
140 | multiboot2_module_t module;
|
---|
141 | multiboot2_memmap_t memmap;
|
---|
142 | multiboot2_fbinfo_t fbinfo;
|
---|
143 | };
|
---|
144 | } __attribute__((packed)) multiboot2_tag_t;
|
---|
145 |
|
---|
146 | extern void multiboot2_info_parse(uint32_t, const multiboot2_info_t *);
|
---|
147 |
|
---|
148 | #endif /* __ASM__ */
|
---|
149 |
|
---|
150 | #endif
|
---|
151 |
|
---|
152 | /** @}
|
---|
153 | */
|
---|