Skip to content

Commit

Permalink
[feat] update allocator version to support alloc_pages_at (#34)
Browse files Browse the repository at this point in the history
* [feat] update allocator version to support alloc_pages_at
* [feat] set phys-virt-offset as 0xffff_8000_0000_0000 for x86_64 qemu
  • Loading branch information
hky1999 authored Dec 17, 2024
1 parent 9a84555 commit c62b386
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 12 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ axsync = { path = "modules/axsync" }
axtask = { path = "modules/axtask" }
axdma = { path = "modules/axdma" }

allocator = { git = "https://github.com/arceos-org/allocator.git", tag = "v0.1.1" }

[profile.release]
lto = true
2 changes: 1 addition & 1 deletion modules/axalloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ cfg-if = "1.0"
kspin = "0.1"
memory_addr = "0.3"
axerrno = "0.1"
allocator = { git = "https://github.com/arceos-org/allocator.git", tag ="v0.1.0", features = ["bitmap"] }
allocator = { workspace = true, features = ["bitmap", "page-alloc-64g"] }
18 changes: 18 additions & 0 deletions modules/axalloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ impl GlobalAllocator {
self.palloc.lock().alloc_pages(num_pages, align_pow2)
}

/// Allocates contiguous pages starting from the given address.
///
/// It allocates `num_pages` pages from the page allocator starting from the
/// given address.
///
/// `align_pow2` must be a power of 2, and the returned region bound will be
/// aligned to it.
pub fn alloc_pages_at(
&self,
start: usize,
num_pages: usize,
align_pow2: usize,
) -> AllocResult<usize> {
self.palloc
.lock()
.alloc_pages_at(start, num_pages, align_pow2)
}

/// Gives back the allocated pages starts from `pos` to the page allocator.
///
/// The pages should be allocated by [`alloc_pages`], and `align_pow2`
Expand Down
2 changes: 1 addition & 1 deletion modules/axdma/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ log = "=0.4.21"
kspin = "0.1"
memory_addr = "0.3"
axerrno = "0.1"
allocator = { git = "https://github.com/arceos-org/allocator.git", tag = "v0.1.0" }
allocator = { workspace = true }
axalloc = { workspace = true }
axmm = { workspace = true }
axconfig = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions modules/axhal/src/platform/x86_pc/multiboot.S
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ ap_entry64:
.Ltmp_pml4:
# 0x0000_0000 ~ 0xffff_ffff
.quad .Ltmp_pdpt_low - {offset} + 0x3 # PRESENT | WRITABLE | paddr(tmp_pdpt)
.zero 8 * 510
# 0xffff_ff80_0000_0000 ~ 0xffff_ff80_ffff_ffff
.zero 8 * 255
# 0xffff_8000_0000_0000 ~ 0xffff_8000_ffff_ffff
.quad .Ltmp_pdpt_high - {offset} + 0x3 # PRESENT | WRITABLE | paddr(tmp_pdpt)
.zero 8 * 255

# FIXME: may not work on macOS using hvf as the CPU does not support 1GB page (pdpe1gb)
.Ltmp_pdpt_low:
Expand Down
10 changes: 6 additions & 4 deletions platforms/x86_64-qemu-q35.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,26 @@ phys-memory-size = "0x800_0000" # 128M
# Base physical address of the kernel image.
kernel-base-paddr = "0x20_0000"
# Base virtual address of the kernel image.
kernel-base-vaddr = "0xffff_ff80_0020_0000"
kernel-base-vaddr = "0xffff_8000_0020_0000"
# Linear mapping offset, for quick conversions between physical and virtual
# addresses.
phys-virt-offset = "0xffff_ff80_0000_0000"
phys-virt-offset = "0xffff_8000_0000_0000"
# Offset of bus address and phys address. some boards, the bus address is
# different from the physical address.
phys-bus-offset = "0"
# Kernel address space base.
kernel-aspace-base = "0xffff_ff80_0000_0000"
kernel-aspace-base = "0xffff_8000_0000_0000"
# Kernel address space size.
kernel-aspace-size = "0x0000_007f_ffff_f000"
kernel-aspace-size = "0x0000_7fff_ffff_f000"
# MMIO regions with format (`base_paddr`, `size`).
mmio-regions = [
["0xb000_0000", "0x1000_0000"], # PCI config space
["0xfe00_0000", "0xc0_0000"], # PCI devices
["0xfec0_0000", "0x1000"], # IO APIC
["0xfed0_0000", "0x1000"], # HPET
["0xfee0_0000", "0x1000"], # Local APIC
["0xc000000000", "0x4000"], # PCI devices
["0x380000000000", "0x4000"] # PCI devices
]
# VirtIO MMIO regions with format (`base_paddr`, `size`).
virtio-mmio-regions = []
Expand Down

0 comments on commit c62b386

Please sign in to comment.