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
//! Module for [`ApmTag`].
use crate::{TagHeader, TagType};
use core::mem;
use multiboot2_common::{MaybeDynSized, Tag};
/// The Advanced Power Management (APM) tag.
#[derive(Debug)]
#[repr(C, align(8))]
pub struct ApmTag {
header: TagHeader,
version: u16,
cseg: u16,
offset: u32,
cset_16: u16,
dseg: u16,
flags: u16,
cseg_len: u16,
cseg_16_len: u16,
dseg_len: u16,
}
impl ApmTag {
/// Creates a new tag.
#[allow(clippy::too_many_arguments)]
#[must_use]
pub fn new(
version: u16,
cseg: u16,
offset: u32,
cset_16: u16,
dset: u16,
flags: u16,
cseg_len: u16,
cseg_16_len: u16,
dseg_len: u16,
) -> Self {
Self {
header: TagHeader::new(Self::ID, mem::size_of::<Self>() as u32),
version,
cseg,
offset,
cset_16,
dseg: dset,
flags,
cseg_len,
cseg_16_len,
dseg_len,
}
}
/// The version number of the APM BIOS.
#[must_use]
pub const fn version(&self) -> u16 {
self.version
}
/// Contains the 16-bit code segment (CS) address for the APM entry point.
#[must_use]
pub const fn cseg(&self) -> u16 {
self.cseg
}
/// Represents the offset address within the code segment (`cseg`) for the
/// APM entry point.
#[must_use]
pub const fn offset(&self) -> u32 {
self.offset
}
/// Contains the 16-bit code segment (CS) address used for 16-bit protected
/// mode APM functions.
#[must_use]
pub const fn cset_16(&self) -> u16 {
self.cset_16
}
/// Holds the 16-bit data segment (DS) address used by the APM BIOS for
/// data operations.
#[must_use]
pub const fn dseg(&self) -> u16 {
self.dseg
}
/// Indicates the status and characteristics of the APM connection, such as
/// if APM is present and its capabilities.
#[must_use]
pub const fn flags(&self) -> u16 {
self.flags
}
/// Indicates the length, in bytes, of the data segment (`dseg`) used by
/// the APM BIOS
#[must_use]
pub const fn cseg_len(&self) -> u16 {
self.cseg_len
}
/// Provides the length, in bytes, of the 16-bit code segment (`cseg_16`)
/// used for APM functions.
#[must_use]
pub const fn cseg_16_len(&self) -> u16 {
self.cseg_16_len
}
/// Indicates the length, in bytes, of the data segment (`dseg`) used by
/// the APM BIOS.
#[must_use]
pub const fn dseg_len(&self) -> u16 {
self.dseg_len
}
}
impl MaybeDynSized for ApmTag {
type Header = TagHeader;
const BASE_SIZE: usize = mem::size_of::<Self>();
fn dst_len(_: &TagHeader) {}
}
impl Tag for ApmTag {
type IDType = TagType;
const ID: TagType = TagType::Apm;
}