Skip to content

Commit

Permalink
feat: improve introduction of rtc-related crates
Browse files Browse the repository at this point in the history
  • Loading branch information
hky1999 committed Jul 15, 2024
1 parent 1316f25 commit 2c0d539
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 6 deletions.
6 changes: 4 additions & 2 deletions crates/arm_pl031/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
name = "arm_pl031"
version = "0.1.0"
edition = "2021"
authors = ["Keyang Hu <976929993@qq.com>"]
authors = ["Keyang Hu <keyang.hu@qq.com>"]
description = "System Real Time Clock (RTC) Drivers for aarch64 based on PL031."
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/arceos/tree/main/crates/arm_pl031"
documentation = "https://arceos-org.github.io/arceos/arm_pl031/index.html"
documentation = "https://docs.rs/arm_pl031"
keywords = ["arceos", "aarch64", "rtc"]
categories = ["os", "driver", "no-std"]

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

[![Crates.io](https://img.shields.io/crates/v/arm_pl031)](https://crates.io/crates/arm_pl031)

System Real Time Clock (RTC) Drivers for aarch64 based on PL031.

## Examples

```rust
use arm_pl031::Rtc;

let epoch_time = Rtc::new(0x901_0000).get_unix_timestamp();
```

`base_addr` needs to be the device virtual address available for mmio, which can be obtained from the device tree, for example:

```
/ {
interrupt-parent = <0x8002>;
model = "linux,dummy-virt";
#size-cells = <0x02>;
#address-cells = <0x02>;
compatible = "linux,dummy-virt";
pl031@9010000 {
clock-names = "apb_pclk";
clocks = <0x8000>;
interrupts = <0x00 0x02 0x04>;
reg = <0x00 0x9010000 0x00 0x1000>;
compatible = "arm,pl031\0arm,primecell";
};
...
}
```
6 changes: 4 additions & 2 deletions crates/riscv_goldfish/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
name = "riscv_goldfish"
version = "0.1.0"
edition = "2021"
authors = ["Keyang Hu <976929993@qq.com>"]
authors = ["Keyang Hu <keyang.hu@qq.com>"]
description = "System Real Time Clock (RTC) Drivers for riscv based on goldfish."
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/arceos/tree/main/crates/riscv_goldfish"
documentation = "https://arceos-org.github.io/arceos/riscv_goldfish/index.html"
documentation = "https://docs.rs/riscv_goldfish"
keywords = ["arceos", "riscv", "rtc"]
categories = ["os", "driver", "no-std"]

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

[![Crates.io](https://img.shields.io/crates/v/riscv_goldfish)](https://crates.io/crates/riscv_goldfish)

System Real Time Clock (RTC) Drivers for riscv based on goldfish.

## Examples

```rust
use riscv_goldfish::Rtc;

let epoch_time = Rtc::new(0x10_1000).get_unix_timestamp();
```

`base_addr` needs to be the device virtual address available for mmio, which can be obtained from the device tree, for example:

```
soc {
#address-cells = <0x02>;
#size-cells = <0x02>;
compatible = "simple-bus";
ranges;
rtc@101000 {
interrupts = <0x0b>;
interrupt-parent = <0x03>;
reg = <0x00 0x101000 0x00 0x1000>;
compatible = "google,goldfish-rtc";
};
...
}
```
6 changes: 4 additions & 2 deletions crates/x86_rtc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
name = "x86_rtc"
version = "0.1.0"
edition = "2021"
authors = ["Keyang Hu <976929993@qq.com>"]
authors = ["Keyang Hu <keyang.hu@qq.com>"]
description = "System Real Time Clock (RTC) Drivers for x86_64 based on CMOS."
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/arceos/tree/main/crates/x86_rtc"
documentation = "https://arceos-org.github.io/arceos/x86_rtc/index.html"
documentation = "https://docs.rs/x86_rtc"
keywords = ["arceos", "x86_64", "rtc"]
categories = ["os", "driver", "no-std"]

[dependencies]
cfg-if = "1.0"
Expand Down
12 changes: 12 additions & 0 deletions crates/x86_rtc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# x86_rtc

[![Crates.io](https://img.shields.io/crates/v/x86_rtc)](https://crates.io/crates/x86_rtc)

System Real Time Clock (RTC) Drivers for x86_64 based on CMOS.

## Examples

```rust
use x86_rtc::Rtc;
let epoch_time = Rtc::new().get_unix_timestamp();
```

0 comments on commit 2c0d539

Please sign in to comment.