Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ members = [
]

[workspace.package]
version = "0.4.0"
edition = "2021"
authors = ["Yuekai Jia <[email protected]>", "aarkegz <[email protected]>"]
license = "GPL-3.0-or-later OR Apache-2.0 OR MulanPSL-2.0"
Expand Down
2 changes: 1 addition & 1 deletion memory_addr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "memory_addr"
version = "0.4.0"
description = "Wrappers and helper functions for physical and virtual addresses"
documentation = "https://docs.rs/memory_addr"
keywords = ["arceos", "address", "virtual-memory"]

version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand Down
1 change: 1 addition & 0 deletions memory_addr/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ mod test {
}

#[test]
#[allow(clippy::reversed_empty_ranges)]
fn test_range() {
let start = va!(0x1000);
let end = va!(0x2000);
Expand Down
2 changes: 1 addition & 1 deletion memory_set/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "memory_set"
version = "0.4.0"
description = "Data structures and operations for managing memory mappings"
documentation = "https://docs.rs/memory_set"
keywords = ["arceos", "virtual-memory", "memory-area", "mmap"]

version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
Expand Down
6 changes: 6 additions & 0 deletions memory_set/src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ impl<B: MappingBackend> MemorySet<B> {
}
}

impl<B: MappingBackend> Default for MemorySet<B> {
fn default() -> Self {
Self::new()
}
}

impl<B: MappingBackend> fmt::Debug for MemorySet<B>
where
B::Addr: fmt::Debug,
Expand Down
84 changes: 40 additions & 44 deletions memory_set/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ fn test_map_unmap() {
}
dump_memory_set(&set);
assert_eq!(set.len(), 16);
for addr in 0..MAX_ADDR {
assert!(pt[addr] == 1 || pt[addr] == 2);
for &e in &pt[0..MAX_ADDR] {
assert!(e == 1 || e == 2);
}

// Found [0x4000, 0x5000), flags = 1.
Expand Down Expand Up @@ -137,8 +137,8 @@ fn test_map_unmap() {
assert_eq!(area.start(), 0x4000.into());
assert_eq!(area.end(), 0x8000.into());
assert_eq!(area.flags(), 3);
for addr in 0x4000..0x8000 {
assert_eq!(pt[addr], 3);
for &e in &pt[0x4000..0x8000] {
assert_eq!(e, 3);
}

// Unmap areas in the middle.
Expand All @@ -147,8 +147,8 @@ fn test_map_unmap() {
// Unmap the remaining areas, including the unmapped ranges.
assert_ok!(set.unmap(0.into(), MAX_ADDR * 2, &mut pt));
assert_eq!(set.len(), 0);
for addr in 0..MAX_ADDR {
assert_eq!(pt[addr], 0);
for &e in &pt[0..MAX_ADDR] {
assert_eq!(e, 0);
}
}

Expand Down Expand Up @@ -183,8 +183,8 @@ fn test_unmap_split() {
assert_eq!(area.end().align_offset_4k(), 0xc00);
assert_eq!(area.size(), 0x800);
}
for addr in area.start().as_usize()..area.end().as_usize() {
assert_eq!(pt[addr], 1);
for &e in &pt[area.start().as_usize()..area.end().as_usize()] {
assert_eq!(e, 1);
}
}

Expand All @@ -207,15 +207,15 @@ fn test_unmap_split() {
} else {
unreachable!();
}
for addr in area.start().as_usize()..area.end().as_usize() {
assert_eq!(pt[addr], 1);
for &e in &pt[area.start().as_usize()..area.end().as_usize()] {
assert_eq!(e, 1);
}
}
let mut iter = set.iter();
while let Some(area) = iter.next() {
if let Some(next) = iter.next() {
for addr in area.end().as_usize()..next.start().as_usize() {
assert_eq!(pt[addr], 0);
for &e in &pt[area.end().as_usize()..next.start().as_usize()] {
assert_eq!(e, 0);
}
}
}
Expand All @@ -224,8 +224,8 @@ fn test_unmap_split() {
// Unmap all areas.
assert_ok!(set.unmap(0.into(), MAX_ADDR, &mut pt));
assert_eq!(set.len(), 0);
for addr in 0..MAX_ADDR {
assert_eq!(pt[addr], 0);
for &e in &pt[0..MAX_ADDR] {
assert_eq!(e, 0);
}
}

Expand Down Expand Up @@ -266,17 +266,15 @@ fn test_protect() {
if area.start().as_usize() == 0 {
assert_eq!(area.size(), 0xc00);
assert_eq!(area.flags(), 0x7);
} else {
if off == 0 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x1);
} else if off == 0x400 {
assert_eq!(area.size(), 0x800);
assert_eq!(area.flags(), 0x7);
} else if off == 0xc00 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x1);
}
} else if off == 0 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x1);
} else if off == 0x400 {
assert_eq!(area.size(), 0x800);
assert_eq!(area.flags(), 0x7);
} else if off == 0xc00 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x1);
}
}

Expand All @@ -293,23 +291,21 @@ fn test_protect() {
if area.start().as_usize() == 0 {
assert_eq!(area.size(), 0x800);
assert_eq!(area.flags(), 0x7);
} else {
if off == 0 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x1);
} else if off == 0x400 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x7);
} else if off == 0x800 {
assert_eq!(area.size(), 0x100);
assert_eq!(area.flags(), 0x3);
} else if off == 0x900 {
assert_eq!(area.size(), 0x300);
assert_eq!(area.flags(), 0x7);
} else if off == 0xc00 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x1);
}
} else if off == 0 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x1);
} else if off == 0x400 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x7);
} else if off == 0x800 {
assert_eq!(area.size(), 0x100);
assert_eq!(area.flags(), 0x3);
} else if off == 0x900 {
assert_eq!(area.size(), 0x300);
assert_eq!(area.flags(), 0x7);
} else if off == 0xc00 {
assert_eq!(area.size(), 0x400);
assert_eq!(area.flags(), 0x1);
}
}

Expand All @@ -322,8 +318,8 @@ fn test_protect() {
// Unmap all areas.
assert_ok!(set.unmap(0.into(), MAX_ADDR, &mut pt));
assert_eq!(set.len(), 0);
for addr in 0..MAX_ADDR {
assert_eq!(pt[addr], 0);
for &e in &pt[0..MAX_ADDR] {
assert_eq!(e, 0);
}
}

Expand Down