time.rs 927 B

123456789101112131415161718192021222324252627282930313233343536
  1. use sbi_spec::binary::SbiRet;
  2. #[cfg(target_pointer_width = "64")]
  3. #[inline]
  4. pub(super) fn handle_ecall(function: usize, param0: usize) -> SbiRet {
  5. use crate::timer::*;
  6. use sbi_spec::time::*;
  7. match function {
  8. SET_TIMER => {
  9. if set_timer(param0 as _) {
  10. SbiRet::success(0)
  11. } else {
  12. SbiRet::not_supported()
  13. }
  14. }
  15. _ => SbiRet::not_supported(),
  16. }
  17. }
  18. #[cfg(target_pointer_width = "32")]
  19. #[inline]
  20. pub(super) fn handle_ecall(function: usize, param0: usize, param1: usize) -> SbiRet {
  21. use super::concat_u32;
  22. use crate::timer::*;
  23. use sbi_spec::time::*;
  24. match function {
  25. SET_TIMER => {
  26. if set_timer(concat_u32(param1, param0)) {
  27. SbiRet::success(0)
  28. } else {
  29. SbiRet::not_supported()
  30. }
  31. }
  32. _ => SbiRet::not_supported(),
  33. }
  34. }