Skip to content

Commit 46c3a88

Browse files
committed
[feat] update allocator version to support alloc_pages_at (#34)
* [feat] update allocator version to support alloc_pages_at * [feat] set phys-virt-offset as 0xffff_8000_0000_0000 for x86_64 qemu
1 parent 230e431 commit 46c3a88

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,7 @@ axsync = { path = "modules/axsync" }
6363
axtask = { path = "modules/axtask" }
6464
axdma = { path = "modules/axdma" }
6565

66+
allocator = { git = "https://github.com/arceos-org/allocator.git", tag = "v0.1.1" }
67+
6668
[profile.release]
6769
lto = true

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)