spl.c 572 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <ureg.h>
  4. #include "encoding.h"
  5. /* these are declared in this file as we do not want them externally visible.
  6. * inline assembly is not allowed in harvey.
  7. */
  8. int64_t _splhi(void);
  9. int64_t _spllo(void);
  10. // splhi and spllo return 1 if we were at splhi. This is used in splx, below.
  11. int splhi(void)
  12. {
  13. uint64_t cur;
  14. cur = read_csr(sstatus);
  15. _splhi();
  16. return !(cur & 2);
  17. }
  18. int spllo(void)
  19. {
  20. uint64_t cur;
  21. cur = read_csr(sstatus);
  22. _spllo();
  23. return !(cur & 2);
  24. }
  25. void splx(int s)
  26. {
  27. if (s)
  28. _splhi();
  29. else
  30. _spllo();
  31. }