Remove UserSpace abstraction from OSTD

This commit is contained in:
Chen Chengjun
2025-03-17 13:55:53 +08:00
committed by Tate, Hongliang Tian
parent 244a34a2fc
commit 248b24fb4e
10 changed files with 139 additions and 201 deletions

View File

@ -1,10 +1,6 @@
// SPDX-License-Identifier: MPL-2.0
use ostd::{
cpu::UserContext,
task::Task,
user::{UserContextApi, UserSpace},
};
use ostd::{cpu::UserContext, task::Task, user::UserContextApi};
use super::{builder::PosixThreadBuilder, name::ThreadName, PosixThread};
use crate::{
@ -55,13 +51,11 @@ pub fn create_posix_task_from_executable(
load_program_to_vm(process_vm, elf_file, argv, envp, &fs_resolver, 1)?
};
let vm_space = process_vm.root_vmar().vm_space().clone();
let mut cpu_ctx = UserContext::default();
cpu_ctx.set_instruction_pointer(elf_load_info.entry_point() as _);
cpu_ctx.set_stack_pointer(elf_load_info.user_stack_top() as _);
let user_space = Arc::new(UserSpace::new(vm_space, cpu_ctx));
let mut user_ctx = UserContext::default();
user_ctx.set_instruction_pointer(elf_load_info.entry_point() as _);
user_ctx.set_stack_pointer(elf_load_info.user_stack_top() as _);
let thread_name = Some(ThreadName::new_from_executable_path(executable_path)?);
let thread_builder = PosixThreadBuilder::new(tid, user_space, credentials)
let thread_builder = PosixThreadBuilder::new(tid, Arc::new(user_ctx), credentials)
.thread_name(thread_name)
.process(process)
.fs(Arc::new(fs));