Skip to content

Commit

Permalink
Fix project structure, create workspace for two crates
Browse files Browse the repository at this point in the history
  • Loading branch information
aarkegz committed Aug 19, 2024
1 parent c6d8219 commit 40c82cf
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 101 deletions.
22 changes: 13 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
[package]
name = "memory_addr"
version = "0.2.1"
[workspace]
resolver = "2"

members = [
"memory_addr",
"memory_set",
]

[workspace.package]
version = "0.3.0-dev" # dev here to avoid publishing it mistakenly, as `memory_set` is not updated yet
edition = "2021"
authors = ["Yuekai Jia <[email protected]>"]
description = "Wrappers and helper functions for physical and virtual addresses"
authors = ["Yuekai Jia <[email protected]>", "aarkegz <[email protected]>"]
license = "GPL-3.0-or-later OR Apache-2.0 OR MulanPSL-2.0"
homepage = "https://github.com/arceos-org/arceos"
# documentation = "let member have their own documentation links"
repository = "https://github.com/arceos-org/memory_addr"
documentation = "https://docs.rs/memory_addr"
keywords = ["arceos", "address", "virtual-memory"]
# keywords = ["let member have their own keywords"]
categories = ["os", "memory-management", "no-std"]

[dependencies]
30 changes: 5 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
# memory_addr
# `memory_addr`

[![Crates.io](https://img.shields.io/crates/v/memory_addr)](https://crates.io/crates/memory_addr)
[![Docs.rs](https://docs.rs/memory_addr/badge.svg)](https://docs.rs/memory_addr)
[![CI](https://github.com/arceos-org/memory_addr/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/arceos-org/memory_addr/actions/workflows/ci.yml)
Structures, functions and traits for physical and virtual memory addresses as well as memory mappings.

Wrappers and helper functions for physical and virtual memory addresses.
See documentations and readmes of the sub-crates for more information.

## Examples
- `memory_addr`([docs](https://docs.rs/memory_addr)|[crates.io](https://crates.io/crates/memory_addr)|[readme](memory_addr/README.md)): Wrappers and helper functions for physical and virtual memory addresses.
- `memory_set`([docs](https://docs.rs/memory_set)|[crates.io](https://crates.io/crates/memory_set)|[readme](memory_set/README.md)): Data structures and operations for managing memory mappings.

```rust
use memory_addr::{pa, va, va_range, PhysAddr, VirtAddr, MemoryAddr};

let phys_addr = PhysAddr::from(0x12345678);
let virt_addr = VirtAddr::from(0x87654321);

assert_eq!(phys_addr.align_down(0x1000usize), pa!(0x12345000));
assert_eq!(phys_addr.align_offset_4k(), 0x678);
assert_eq!(virt_addr.align_up_4k(), va!(0x87655000));
assert!(!virt_addr.is_aligned_4k());
assert!(va!(0xabcedf0).is_aligned(16usize));

let va_range = va_range!(0x87654000..0x87655000);
assert_eq!(va_range.start, va!(0x87654000));
assert_eq!(va_range.size(), 0x1000);
assert!(va_range.contains(virt_addr));
assert!(va_range.contains_range(va_range!(virt_addr..virt_addr + 0x100)));
assert!(!va_range.contains_range(va_range!(virt_addr..virt_addr + 0x1000)));
```
15 changes: 15 additions & 0 deletions memory_addr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "memory_addr"
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
homepage.workspace = true
repository.workspace = true
categories.workspace = true

[dependencies]
29 changes: 29 additions & 0 deletions memory_addr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# memory_addr

[![Crates.io](https://img.shields.io/crates/v/memory_addr)](https://crates.io/crates/memory_addr)
[![Docs.rs](https://docs.rs/memory_addr/badge.svg)](https://docs.rs/memory_addr)
[![CI](https://github.com/arceos-org/memory_addr/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/arceos-org/memory_addr/actions/workflows/ci.yml)

Wrappers and helper functions for physical and virtual memory addresses.

## Examples

```rust
use memory_addr::{pa, va, va_range, PhysAddr, VirtAddr, MemoryAddr};

let phys_addr = PhysAddr::from(0x12345678);
let virt_addr = VirtAddr::from(0x87654321);

assert_eq!(phys_addr.align_down(0x1000usize), pa!(0x12345000));
assert_eq!(phys_addr.align_offset_4k(), 0x678);
assert_eq!(virt_addr.align_up_4k(), va!(0x87655000));
assert!(!virt_addr.is_aligned_4k());
assert!(va!(0xabcedf0).is_aligned(16usize));

let va_range = va_range!(0x87654000..0x87655000);
assert_eq!(va_range.start, va!(0x87654000));
assert_eq!(va_range.size(), 0x1000);
assert!(va_range.contains(virt_addr));
assert!(va_range.contains_range(va_range!(virt_addr..virt_addr + 0x100)));
assert!(!va_range.contains_range(va_range!(virt_addr..virt_addr + 0x1000)));
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 0 additions & 55 deletions memory_set/.github/workflows/ci.yml

This file was deleted.

4 changes: 0 additions & 4 deletions memory_set/.gitignore

This file was deleted.

17 changes: 10 additions & 7 deletions memory_set/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
[package]
name = "memory_set"
version = "0.1.0"
edition = "2021"
authors = ["Yuekai Jia <[email protected]>"]
description = "Data structures and operations for managing memory mappings"
license = "GPL-3.0-or-later OR Apache-2.0 OR MulanPSL-2.0"
homepage = "https://github.com/arceos-org/arceos"
repository = "https://github.com/arceos-org/memory_set"
documentation = "https://docs.rs/memory_set"
keywords = ["arceos", "virtual-memory", "memory-area", "mmap"]
categories = ["os", "memory-management", "no-std"]

version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
categories.workspace = true

[dependencies]
memory_addr = "0.2"
# todo: update it to local one once it gets adapted to the current version
# memory_addr = { path = "../memory_addr", version = "0.2" }
2 changes: 1 addition & 1 deletion memory_set/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Crates.io](https://img.shields.io/crates/v/memory_set)](https://crates.io/crates/memory_set)
[![Docs.rs](https://docs.rs/memory_set/badge.svg)](https://docs.rs/memory_set)
[![CI](https://github.com/arceos-org/memory_set/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/arceos-org/memory_set/actions/workflows/ci.yml)
[![CI](https://github.com/arceos-org/memory_addr/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/arceos-org/memory_addr/actions/workflows/ci.yml)

Data structures and operations for managing memory mappings.

Expand Down

0 comments on commit 40c82cf

Please sign in to comment.