source: trunk/hal/x86_64/core/hal_multiboot.h @ 252

Last change on this file since 252 was 234, checked in by max@…, 7 years ago

style

File size: 4.7 KB
Line 
1/*
2 * hal_multiboot.h - Multiboot-specific values and structures
3 *
4 * Copyright (c) 2017 Maxime Villard
5 *
6 * This file is part of ALMOS-MKH.
7 *
8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-MKH is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/*
23 * Multiboot header structure.
24 */
25#define MULTIBOOT_HEADER_MAGIC          0x1BADB002
26#define MULTIBOOT_HEADER_MODS_ALIGNED   0x00000001
27#define MULTIBOOT_HEADER_WANT_MEMORY    0x00000002
28#define MULTIBOOT_HEADER_HAS_VBE        0x00000004
29#define MULTIBOOT_HEADER_HAS_ADDR       0x00010000
30
31#ifndef x86_ASM
32struct multiboot_header {
33        uint32_t        mh_magic;
34        uint32_t        mh_flags;
35        uint32_t        mh_checksum;
36
37        /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */
38        paddr_t         mh_header_addr;
39        paddr_t         mh_load_addr;
40        paddr_t         mh_load_end_addr;
41        paddr_t         mh_bss_end_addr;
42        paddr_t         mh_entry_addr;
43
44        /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */
45        uint32_t        mh_mode_type;
46        uint32_t        mh_width;
47        uint32_t        mh_height;
48        uint32_t        mh_depth;
49};
50#endif
51
52/*
53 * Multiboot information structure.
54 */
55#define MULTIBOOT_INFO_MAGIC            0x2BADB002
56#define MULTIBOOT_INFO_HAS_MEMORY       0x00000001
57#define MULTIBOOT_INFO_HAS_BOOT_DEVICE  0x00000002
58#define MULTIBOOT_INFO_HAS_CMDLINE      0x00000004
59#define MULTIBOOT_INFO_HAS_MODS         0x00000008
60#define MULTIBOOT_INFO_HAS_AOUT_SYMS    0x00000010
61#define MULTIBOOT_INFO_HAS_ELF_SYMS     0x00000020
62#define MULTIBOOT_INFO_HAS_MMAP         0x00000040
63#define MULTIBOOT_INFO_HAS_DRIVES       0x00000080
64#define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100
65#define MULTIBOOT_INFO_HAS_LOADER_NAME  0x00000200
66#define MULTIBOOT_INFO_HAS_APM_TABLE    0x00000400
67#define MULTIBOOT_INFO_HAS_VBE          0x00000800
68
69#define MULTIBOOT_INFO_SIZE             92
70
71/* Offsets into the structure */
72#define MB_MI_FLAGS             0
73#define MB_MI_MMAP_LENGTH       44
74#define MB_MI_MMAP_ADDR         48
75#define MB_MI_LOADER_NAME       64
76
77#ifndef x86_ASM
78typedef uint32_t mb_paddr_t;
79
80struct multiboot_info {
81        uint32_t        mi_flags;
82
83        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */
84        uint32_t        mi_mem_lower;
85        uint32_t        mi_mem_upper;
86
87        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */
88        uint8_t         mi_boot_device_part3;
89        uint8_t         mi_boot_device_part2;
90        uint8_t         mi_boot_device_part1;
91        uint8_t         mi_boot_device_drive;
92
93        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */
94        mb_paddr_t      mi_cmdline;
95
96        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */
97        uint32_t        mi_mods_count;
98        mb_paddr_t      mi_mods_addr;
99
100        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */
101        uint32_t        mi_elfshdr_num;
102        uint32_t        mi_elfshdr_size;
103        mb_paddr_t      mi_elfshdr_addr;
104        uint32_t        mi_elfshdr_shndx;
105
106        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */
107        uint32_t        mi_mmap_length;
108        mb_paddr_t      mi_mmap_addr;
109
110        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */
111        uint32_t        mi_drives_length;
112        mb_paddr_t      mi_drives_addr;
113
114        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */
115        mb_paddr_t      unused_mi_config_table;
116
117        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */
118        mb_paddr_t      mi_loader_name;
119
120        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */
121        mb_paddr_t      unused_mi_apm_table;
122
123        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */
124        mb_paddr_t      unused_mi_vbe_control_info;
125        mb_paddr_t      unused_mi_vbe_mode_info;
126        mb_paddr_t      unused_mi_vbe_interface_seg;
127        mb_paddr_t      unused_mi_vbe_interface_off;
128        uint32_t        unused_mi_vbe_interface_len;
129};
130
131/*
132 * Drive information. This describes an entry in the drives table as
133 * pointed to by mi_drives_addr.
134 */
135struct multiboot_drive {
136        uint32_t        md_length;
137        uint8_t         md_number;
138        uint8_t         md_mode;
139        uint16_t        md_cylinders;
140        uint8_t         md_heads;
141        uint8_t         md_sectors;
142
143        /* The variable-sized 'ports' field comes here, so this structure
144         * can be longer. */
145};
146
147/*
148 * Memory mapping. This describes an entry in the memory mappings table
149 * as pointed to by mi_mmap_addr.
150 *
151 * Be aware that mm_size specifies the size of all other fields *except*
152 * for mm_size. In order to jump between two different entries, you
153 * have to count mm_size + 4 bytes.
154 */
155struct multiboot_mmap {
156        uint32_t        mm_size;
157        uint64_t        mm_base_addr;
158        uint64_t        mm_length;
159        uint32_t        mm_type;
160} __packed;
161
162/*
163 * Modules. This describes an entry in the modules table as pointed
164 * to by mi_mods_addr.
165 */
166
167struct multiboot_module {
168        uint32_t        mmo_start;
169        uint32_t        mmo_end;
170        mb_paddr_t      mmo_string;
171        uint32_t        mmo_reserved;
172};
173#endif
174
Note: See TracBrowser for help on using the repository browser.