blob: 9fa6d5b21fe84e0a78a99c5e49501fd24781e68c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#ifndef MULTIBOOT2_INFORMATION_DATA_HPP
#define MULTIBOOT2_INFORMATION_DATA_HPP
// IWYU pragma: private, include <multiboot2/information.hpp>
#include "multiboot2/constants/information_id.hpp"
#include "multiboot2/constants/memory_type.hpp"
#include <cstdint>
namespace multiboot2
{
//! A simple base mixin providing all data classes with an ID accessor.
template<auto Id>
struct tag_data
{
//! The ID of this data class.
constexpr auto static inline id = Id;
};
namespace data
{
//! Basic system memory information
//!
//! This tag contains the amount of lower memory and upper memory present in the system as detected by the boot
//! loader.
struct basic_memory : tag_data<information_id::basic_memory_information>
{
//! The amount of lower memory available to the system.
//!
//! Any memory below the 1 MiB address boundary is considered to be lower memory. The maximum possible value for
//! this field is 640 KiB.
std::uint32_t lower_KiB;
//! The amount of upper memory available to the system.
//!
//! Any memory above the 1 MiB address boundary is considered to be upper memory. The maximum possible value for
//! this field is the address of the first upper memory hole minus 1MiB.
std::uint32_t upper_KiB;
};
//! The BIOS disk the image got loaded from
//!
//! This tag is present iff. the image was loaded from a BIOS disk device.
struct bios_boot_device : tag_data<information_id::boot_device>
{
//! BIOS device number the image was loaded from, as understood by INT 13h.
//!
//! For example, the first floppy drive will receive id 0x00, while the first hard disk will receive id 0x80.
std::uint32_t device_number;
//! The partition number of the primary partition the image was loaded from.
std::uint32_t partition_number;
//! The sub-partition number of the primary partition the image was loaded from.
std::uint32_t sub_partition_number;
};
//! The command line supplied to the image during boot.
//!
//! @note This structure is intentionally left blank, since it is of variable size and the contained information
//! starts at the first byte of this structure.
struct command_line : tag_data<information_id::command_line>
{
};
//! The ELF sections of the image.
//!
//! @note The actual section header array is not part of this type's definition. The reason being that the size of
//! the array, in terms of entry count, as well as the size and format of each array element is unknown at compile
//! time. The array begins after the last member of this structure.
struct elf_symbols : tag_data<information_id::elf_sections>
{
//! The number of section header table entries.
std::uint32_t count;
//! The size of each section header table entry.
std::uint32_t entry_size;
//! The section number of the string table containing the section names.
std::uint32_t string_table_index;
};
//! The name of the boot loader that loaded the image.
//!
//! @note This structure is intentionally left blank, since it is of variable size and the contained information
//! starts at the first byte of this structure.
struct loader_name : tag_data<information_id::boot_loader_name>
{
};
//! The detailed memory map of this system.
struct memory_map : tag_data<information_id::memory_map>
{
//! A single region of memory
struct region
{
//! Check if the memory described by this region is available for use.
[[nodiscard]] constexpr auto available() const noexcept
{
return type == memory_type::available;
}
//! The physical start address of this region
std::uint64_t base;
//! The size of this region in bytes.
std::uint64_t size_in_B;
//! The type of this region.
//!
//! @see multiboot::memory_types
memory_type type;
//! This field is reserved for padding and use in future extensions.
std::uint32_t : 0;
};
//! The size of each entry present in the map.
//!
//! This field is present to allow for future extension of the entry format. Each entry's size is guaranteed to
//! always be an integer multiple of 8.
std::uint32_t entry_size;
//! The version of each entry present in the map
std::uint32_t entry_version;
};
//! A module loaded by the bootloader.
//!
//! @note the command line associated with this module is not part of this structure, since it is of variable size
//! and the contained information starts at the end of this structure.
struct module : tag_data<information_id::module>
{
//! The physical start address of this module.
std::uint32_t start_address;
//! The physical end address of this module.
std::uint32_t end_address;
};
} // namespace data
} // namespace multiboot2
#endif
|