sbi_ecall_time.c 927 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2020 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. * Atish Patra <atish.patra@wdc.com>
  9. */
  10. #include <sbi/sbi_error.h>
  11. #include <sbi/sbi_ecall.h>
  12. #include <sbi/sbi_ecall_interface.h>
  13. #include <sbi/sbi_trap.h>
  14. #include <sbi/sbi_timer.h>
  15. static int sbi_ecall_time_handler(unsigned long extid, unsigned long funcid,
  16. const struct sbi_trap_regs *regs,
  17. unsigned long *out_val,
  18. struct sbi_trap_info *out_trap)
  19. {
  20. int ret = 0;
  21. if (funcid == SBI_EXT_TIME_SET_TIMER) {
  22. #if __riscv_xlen == 32
  23. sbi_timer_event_start((((u64)regs->a1 << 32) | (u64)regs->a0));
  24. #else
  25. sbi_timer_event_start((u64)regs->a0);
  26. #endif
  27. } else
  28. ret = SBI_ENOTSUPP;
  29. return ret;
  30. }
  31. struct sbi_ecall_extension ecall_time = {
  32. .extid_start = SBI_EXT_TIME,
  33. .extid_end = SBI_EXT_TIME,
  34. .handle = sbi_ecall_time_handler,
  35. };