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

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

Add a --no-smp option.

File size: 4.8 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_CMDLINE           16
74#define MB_MI_MMAP_LENGTH       44
75#define MB_MI_MMAP_ADDR         48
76#define MB_MI_LOADER_NAME       64
77
78#ifndef x86_ASM
79typedef uint32_t mb_paddr_t;
80
81struct multiboot_info {
82        uint32_t        mi_flags;
83
84        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */
85        uint32_t        mi_mem_lower;
86        uint32_t        mi_mem_upper;
87
88        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */
89        uint8_t         mi_boot_device_part3;
90        uint8_t         mi_boot_device_part2;
91        uint8_t         mi_boot_device_part1;
92        uint8_t         mi_boot_device_drive;
93
94        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */
95        mb_paddr_t      mi_cmdline;
96
97        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */
98        uint32_t        mi_mods_count;
99        mb_paddr_t      mi_mods_addr;
100
101        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */
102        uint32_t        mi_elfshdr_num;
103        uint32_t        mi_elfshdr_size;
104        mb_paddr_t      mi_elfshdr_addr;
105        uint32_t        mi_elfshdr_shndx;
106
107        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */
108        uint32_t        mi_mmap_length;
109        mb_paddr_t      mi_mmap_addr;
110
111        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */
112        uint32_t        mi_drives_length;
113        mb_paddr_t      mi_drives_addr;
114
115        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */
116        mb_paddr_t      unused_mi_config_table;
117
118        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */
119        mb_paddr_t      mi_loader_name;
120
121        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */
122        mb_paddr_t      unused_mi_apm_table;
123
124        /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */
125        mb_paddr_t      unused_mi_vbe_control_info;
126        mb_paddr_t      unused_mi_vbe_mode_info;
127        mb_paddr_t      unused_mi_vbe_interface_seg;
128        mb_paddr_t      unused_mi_vbe_interface_off;
129        uint32_t        unused_mi_vbe_interface_len;
130};
131
132/*
133 * Drive information. This describes an entry in the drives table as
134 * pointed to by mi_drives_addr.
135 */
136struct multiboot_drive {
137        uint32_t        md_length;
138        uint8_t         md_number;
139        uint8_t         md_mode;
140        uint16_t        md_cylinders;
141        uint8_t         md_heads;
142        uint8_t         md_sectors;
143
144        /* The variable-sized 'ports' field comes here, so this structure
145         * can be longer. */
146};
147
148/*
149 * Memory mapping. This describes an entry in the memory mappings table
150 * as pointed to by mi_mmap_addr.
151 *
152 * Be aware that mm_size specifies the size of all other fields *except*
153 * for mm_size. In order to jump between two different entries, you
154 * have to count mm_size + 4 bytes.
155 */
156struct multiboot_mmap {
157        uint32_t        mm_size;
158        uint64_t        mm_base_addr;
159        uint64_t        mm_length;
160        uint32_t        mm_type;
161} __packed;
162
163/*
164 * Modules. This describes an entry in the modules table as pointed
165 * to by mi_mods_addr.
166 */
167
168struct multiboot_module {
169        uint32_t        mmo_start;
170        uint32_t        mmo_end;
171        mb_paddr_t      mmo_string;
172        uint32_t        mmo_reserved;
173};
174#endif
175
Note: See TracBrowser for help on using the repository browser.