Compare commits

...

2 Commits

Author SHA1 Message Date
Runji Wang d1741dd7a9 recover zircon shell on libos! 2021-04-05 18:47:30 +08:00
Runji Wang ac520afbe3 vmo: recover simple version VMO-paged 2021-04-05 17:06:16 +08:00
7 changed files with 110 additions and 961 deletions

View File

@ -50,7 +50,7 @@ cargo run --release -p linux-loader -- /bin/busybox [args]
Run native Zircon program (shell):
```sh
cargo run --release -p zircon-loader -- prebuilt/zircon/x64
ASYNC_STD_THREAD_COUNT=1 cargo run --release -p zircon-loader -- prebuilt/zircon/x64
```
Run Linux shell on bare-metal (zCore):

View File

@ -184,12 +184,20 @@ impl PhysFrame {
#[linkage = "weak"]
#[export_name = "hal_frame_alloc_contiguous"]
pub fn alloc_contiguous_base(_size: usize, _align_log2: usize) -> Option<PhysAddr> {
fn alloc_contiguous_base(_size: usize, _align_log2: usize) -> Option<PhysAddr> {
unimplemented!()
}
pub fn alloc_contiguous(size: usize, align_log2: usize) -> Vec<Self> {
pub fn alloc_zeroed() -> Option<Self> {
Self::alloc().map(|f| {
pmem_zero(f.addr(), PAGE_SIZE);
f
})
}
pub fn alloc_contiguous_zeroed(size: usize, align_log2: usize) -> Vec<Self> {
PhysFrame::alloc_contiguous_base(size, align_log2).map_or(Vec::new(), |base| {
pmem_zero(base, size * PAGE_SIZE);
(0..size)
.map(|i| PhysFrame {
paddr: base + i * PAGE_SIZE,

View File

@ -32,6 +32,13 @@ pub mod defs {
WriteCombining = 3,
}
}
impl Default for CachePolicy {
fn default() -> Self {
CachePolicy::Cached
}
}
pub const CACHE_POLICY_MASK: u32 = 3;
pub type PhysAddr = usize;

View File

@ -14,7 +14,7 @@ struct Opt {
#[structopt(parse(from_os_str))]
prebuilt_path: PathBuf,
#[structopt(default_value = "")]
#[structopt(default_value = "console.shell=true")]
cmdline: String,
}

View File

@ -880,32 +880,6 @@ impl VmMapping {
}
}
/// Remove WRITE flag from the mappings for Copy-on-Write.
pub(super) fn range_change(&self, offset: usize, len: usize, op: RangeChangeOp) {
let inner = self.inner.try_lock();
// If we are already locked, we are handling page fault/map range
// In this case we can just ignore the operation since we will update the mapping later
if let Some(inner) = inner {
let start = offset.max(inner.vmo_offset);
let end = (inner.vmo_offset + inner.size / PAGE_SIZE).min(offset + len);
if !(start..end).is_empty() {
let mut pg_table = self.page_table.lock();
for i in (start - inner.vmo_offset)..(end - inner.vmo_offset) {
match op {
RangeChangeOp::RemoveWrite => {
let mut new_flag = inner.flags[i];
new_flag.remove(MMUFlags::WRITE);
pg_table
.protect(inner.addr + i * PAGE_SIZE, new_flag)
.unwrap()
}
RangeChangeOp::Unmap => pg_table.unmap(inner.addr + i * PAGE_SIZE).unwrap(),
}
}
}
}
}
/// Handle page fault happened on this VmMapping.
pub(crate) fn handle_page_fault(&self, vaddr: VirtAddr, access_flags: MMUFlags) -> ZxResult {
let vaddr = round_down_pages(vaddr);

File diff suppressed because it is too large Load Diff

View File

@ -154,7 +154,8 @@ impl Syscall<'_> {
permissions,
mapping_flags,
overwrite,
map_range,
// force immediate mapping for libos
map_range || cfg!(not(target_os = "none")),
)?;
info!("vmar.map: at {:#x?}", vaddr);
mapped_addr.write(vaddr)?;