asm.h 829 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef __ASM_H
  2. #define __ASM_H
  3. #define REG_READ(name, offset) \
  4. .section .text.__read_ ## name; \
  5. .global __read_ ## name; \
  6. __read_ ## name: \
  7. csrrs a0, offset, x0; \
  8. ret
  9. #define REG_WRITE(name, offset) \
  10. .section .text.__write_ ## name; \
  11. .global __write_ ## name; \
  12. __write_ ## name: \
  13. csrrw x0, offset, a0; \
  14. ret
  15. #define REG_SET(name, offset) \
  16. .section .text.__set_ ## name; \
  17. .global __set_ ## name; \
  18. __set_ ## name: \
  19. csrrs x0, offset, a0; \
  20. ret
  21. #define REG_CLEAR(name, offset) \
  22. .section .text.__clear_ ## name; \
  23. .global __clear_ ## name; \
  24. __clear_ ## name: \
  25. csrrc x0, offset, a0; \
  26. ret
  27. #define REG_READ_WRITE(name, offset) REG_READ(name, offset); REG_WRITE(name, offset)
  28. #define REG_SET_CLEAR(name, offset) REG_SET(name, offset); REG_CLEAR(name, offset)
  29. #endif /* __ASM_H */