Skip to content

Commit 391f743

Browse files
committed
Remove LegacyMemoryRegion::set_start method
It is not really needed and might be dangerous to use, as it adjusts only the start address, not the length.
1 parent 92b069a commit 391f743

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

src/binary/bios/memory_descriptor.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ impl LegacyMemoryRegion for E820MemoryRegion {
1616
other => MemoryRegionKind::UnknownBios(other),
1717
}
1818
}
19-
20-
fn set_start(&mut self, new_start: PhysAddr) {
21-
self.start_addr = new_start.as_u64();
22-
}
2319
}
2420

2521
#[doc(hidden)]

src/binary/legacy_memory_region.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ pub trait LegacyMemoryRegion: Copy + core::fmt::Debug {
1313
fn len(&self) -> u64;
1414
/// Returns the type of the region, e.g. whether it is usable or reserved.
1515
fn kind(&self) -> MemoryRegionKind;
16-
17-
fn set_start(&mut self, new_start: PhysAddr);
1816
}
1917

2018
pub struct LegacyFrameAllocator<I, D> {
@@ -97,8 +95,9 @@ where
9795
) -> &mut [MemoryRegion] {
9896
let mut next_index = 0;
9997

100-
for mut descriptor in self.original {
101-
let end = descriptor.start() + descriptor.len();
98+
for descriptor in self.original {
99+
let mut start = descriptor.start();
100+
let end = start + descriptor.len();
102101
let next_free = self.next_frame.start_address();
103102
let kind = match descriptor.kind() {
104103
MemoryRegionKind::Usable => {
@@ -107,7 +106,7 @@ where
107106
} else if descriptor.start() >= next_free {
108107
MemoryRegionKind::Usable
109108
} else {
110-
// part of the region is used -> add is separately
109+
// part of the region is used -> add it separately
111110
let used_region = MemoryRegion {
112111
start: descriptor.start().as_u64(),
113112
end: next_free.as_u64(),
@@ -117,7 +116,7 @@ where
117116
.expect("Failed to add memory region");
118117

119118
// add unused part normally
120-
descriptor.set_start(next_free);
119+
start = next_free;
121120
MemoryRegionKind::Usable
122121
}
123122
}
@@ -139,7 +138,7 @@ where
139138
};
140139

141140
let region = MemoryRegion {
142-
start: descriptor.start().as_u64(),
141+
start: start.as_u64(),
143142
end: end.as_u64(),
144143
kind,
145144
};

src/binary/uefi/memory_descriptor.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,4 @@ impl<'a> LegacyMemoryRegion for MemoryDescriptor {
1919
other => MemoryRegionKind::UnknownUefi(other.0),
2020
}
2121
}
22-
23-
fn set_start(&mut self, new_start: PhysAddr) {
24-
self.phys_start = new_start.as_u64();
25-
}
2622
}

0 commit comments

Comments
 (0)