tg-clock 0.1.0

Clock helper library for rCore tutorial bare-metal experiments in RISC-V S-mode.
Documentation
  • Coverage
  • 0%
    0 out of 4 items documented0 out of 3 items with examples
  • Size
  • Source code size: 4.19 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 479.52 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • rcore-os/tg-rcore-tutorial-ch1
    0 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ljh-sys
tg-clock-0.1.0 has been yanked.

tg-clock

A tiny no_std clock helper crate for bare-metal RISC-V S-mode experiments.

It provides a minimal timer setup flow used in rCore tutorial style kernels:

  • enable S-mode timer interrupts
  • read current time CSR
  • schedule next timer event via SBI

Installation

[dependencies]
tg-clock = "0.1.0"

Minimal Example

#![no_std]

use tg_clock::{clock_set_next_event, get_time, init};

pub fn kernel_init() {
    init();
}

pub fn on_timer_interrupt() {
    let _now = get_time();
    clock_set_next_event();
}

API Summary

  • init()
    • enables sstatus.SIE and sie.STIE
    • schedules the first timer event
  • clock_set_next_event()
    • programs next timer interrupt through SBI set_timer
  • get_time() -> usize
    • reads current value from RISC-V time CSR

Notes

  • Target: riscv64gc-unknown-none-elf
  • Runtime: bare-metal / no_std
  • Requires SBI implementation compatible with tg-rcore-tutorial-sbi