Skip to content

Commit c62b386

Browse files
authored
[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 9a84555 commit c62b386

File tree

7 files changed

+36
-12
lines changed

7 files changed

+36
-12
lines changed

Cargo.lock

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

Cargo.toml

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

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

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 = { workspace = true, 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`

modules/axdma/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ log = "=0.4.21"
1515
kspin = "0.1"
1616
memory_addr = "0.3"
1717
axerrno = "0.1"
18-
allocator = { git = "https://github.com/arceos-org/allocator.git", tag = "v0.1.0" }
18+
allocator = { workspace = true }
1919
axalloc = { workspace = true }
2020
axmm = { workspace = true }
2121
axconfig = { workspace = true }

modules/axhal/src/platform/x86_pc/multiboot.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ ap_entry64:
123123
.Ltmp_pml4:
124124
# 0x0000_0000 ~ 0xffff_ffff
125125
.quad .Ltmp_pdpt_low - {offset} + 0x3 # PRESENT | WRITABLE | paddr(tmp_pdpt)
126-
.zero 8 * 510
127-
# 0xffff_ff80_0000_0000 ~ 0xffff_ff80_ffff_ffff
126+
.zero 8 * 255
127+
# 0xffff_8000_0000_0000 ~ 0xffff_8000_ffff_ffff
128128
.quad .Ltmp_pdpt_high - {offset} + 0x3 # PRESENT | WRITABLE | paddr(tmp_pdpt)
129+
.zero 8 * 255
129130

130131
# FIXME: may not work on macOS using hvf as the CPU does not support 1GB page (pdpe1gb)
131132
.Ltmp_pdpt_low:

platforms/x86_64-qemu-q35.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,26 @@ phys-memory-size = "0x800_0000" # 128M
1212
# Base physical address of the kernel image.
1313
kernel-base-paddr = "0x20_0000"
1414
# Base virtual address of the kernel image.
15-
kernel-base-vaddr = "0xffff_ff80_0020_0000"
15+
kernel-base-vaddr = "0xffff_8000_0020_0000"
1616
# Linear mapping offset, for quick conversions between physical and virtual
1717
# addresses.
18-
phys-virt-offset = "0xffff_ff80_0000_0000"
18+
phys-virt-offset = "0xffff_8000_0000_0000"
1919
# Offset of bus address and phys address. some boards, the bus address is
2020
# different from the physical address.
2121
phys-bus-offset = "0"
2222
# Kernel address space base.
23-
kernel-aspace-base = "0xffff_ff80_0000_0000"
23+
kernel-aspace-base = "0xffff_8000_0000_0000"
2424
# Kernel address space size.
25-
kernel-aspace-size = "0x0000_007f_ffff_f000"
25+
kernel-aspace-size = "0x0000_7fff_ffff_f000"
2626
# MMIO regions with format (`base_paddr`, `size`).
2727
mmio-regions = [
2828
["0xb000_0000", "0x1000_0000"], # PCI config space
2929
["0xfe00_0000", "0xc0_0000"], # PCI devices
3030
["0xfec0_0000", "0x1000"], # IO APIC
3131
["0xfed0_0000", "0x1000"], # HPET
3232
["0xfee0_0000", "0x1000"], # Local APIC
33+
["0xc000000000", "0x4000"], # PCI devices
34+
["0x380000000000", "0x4000"] # PCI devices
3335
]
3436
# VirtIO MMIO regions with format (`base_paddr`, `size`).
3537
virtio-mmio-regions = []

0 commit comments

Comments
 (0)