Skip to content

Commit

Permalink
Map and alloc user stack on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
equation314 committed Jul 30, 2024
1 parent a291d62 commit beef4f2
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ fn main() -> ! {
let entry_vaddr_align = VirtAddr::from(0x1000);
let entry_vaddr = entry_vaddr_align + entry.align_offset_4k();

let layout = core::alloc::Layout::from_size_align(USER_STACK_SIZE, 4096).unwrap();
let ustack = unsafe { alloc::alloc::alloc(layout) };
let ustack_paddr = virt_to_phys(VirtAddr::from(ustack as _));

let mut uspace = axmm::new_user_aspace().unwrap();
let ustack_top = uspace.end();
let ustack_vaddr = ustack_top - USER_STACK_SIZE;
Expand All @@ -87,11 +83,11 @@ fn main() -> ! {
)
.unwrap();
uspace
.map_linear(
.map_alloc(
ustack_vaddr,
ustack_paddr,
4096,
MappingFlags::READ | MappingFlags::WRITE | MappingFlags::USER,
false,
)
.unwrap();

Expand Down

0 comments on commit beef4f2

Please sign in to comment.