Skip to content

Commit 8184db6

Browse files
committed
[wip] support alloc_pages_at
1 parent 9a84555 commit 8184db6

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

Cargo.lock

Lines changed: 10 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/axalloc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ cfg-if = "1.0"
2121
kspin = "0.1"
2222
memory_addr = "0.3"
2323
axerrno = "0.1"
24-
allocator = { git = "https://github.com/arceos-org/allocator.git", tag ="v0.1.0", features = ["bitmap"] }
24+
allocator = { path = "../../../arceos-crates/allocator", features = ["bitmap", "page-alloc-64g"] }

modules/axalloc/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,24 @@ impl GlobalAllocator {
146146
self.palloc.lock().alloc_pages(num_pages, align_pow2)
147147
}
148148

149+
/// Allocates contiguous pages starting from the given address.
150+
///
151+
/// It allocates `num_pages` pages from the page allocator starting from the
152+
/// given address.
153+
///
154+
/// `align_pow2` must be a power of 2, and the returned region bound will be
155+
/// aligned to it.
156+
pub fn alloc_pages_at(
157+
&self,
158+
start: usize,
159+
num_pages: usize,
160+
align_pow2: usize,
161+
) -> AllocResult<usize> {
162+
self.palloc
163+
.lock()
164+
.alloc_pages_at(start, num_pages, align_pow2)
165+
}
166+
149167
/// Gives back the allocated pages starts from `pos` to the page allocator.
150168
///
151169
/// The pages should be allocated by [`alloc_pages`], and `align_pow2`

0 commit comments

Comments
 (0)