2
0

iodeva.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef IODEVA_H
  2. #define IODEVA_H
  3. #define _NEGBASE(b) ((0xffffffff << (b)) & 0xffffffff)
  4. #define XDEV_ADDR_BASE _NEGBASE(XDEV_ADDR_SHIFT+XDEV_ADDR_BITS)
  5. #define IODEV_ADDR_BASE _NEGBASE(IODEV_ADDR_SHIFT+IODEV_ADDR_BITS)
  6. /* Address for I/O device d, subregister r, offset o */
  7. #define IODEVA(b,r,o) ((b ## _BASE)+((r) << 2)+(o))
  8. #ifdef __ASSEMBLY__
  9. /*
  10. * The I/O device range is designed so that it can be addressed via
  11. * negative offsets from the zero register. Use (zero) after the
  12. * macro in a load or store instruction.
  13. */
  14. #define IODEVV(d,r) IODEVA(d,r,0)
  15. #define IODEVB0(d,r) IODEVA(d,r,0)
  16. #define IODEVB1(d,r) IODEVA(d,r,1)
  17. #define IODEVB2(d,r) IODEVA(d,r,2)
  18. #define IODEVB3(d,r) IODEVA(d,r,3)
  19. #define IODEVH0(d,r) IODEVA(d,r,0)
  20. #define IODEVH1(d,r) IODEVA(d,r,2)
  21. #define IODEVL(d,r) IODEVA(d,r,0)
  22. #define IODEVRV(d,r) IODEVA(d,r,0)
  23. #define IODEVRB0(d,r) IODEVA(d,r,0)
  24. #define IODEVRB1(d,r) IODEVA(d,r,1)
  25. #define IODEVRB2(d,r) IODEVA(d,r,2)
  26. #define IODEVRB3(d,r) IODEVA(d,r,3)
  27. #define IODEVRH0(d,r) IODEVA(d,r,0)
  28. #define IODEVRH1(d,r) IODEVA(d,r,2)
  29. #define IODEVRL(d,r) IODEVA(d,r,0)
  30. #define PTR(x) x
  31. #else
  32. /* Writable registers */
  33. #define IODEVV(d,r) (*(volatile void *)IODEVA(d,r,0))
  34. #define IODEVB0(d,r) (*(volatile uint8_t *)IODEVA(d,r,0))
  35. #define IODEVB1(d,r) (*(volatile uint8_t *)IODEVA(d,r,1))
  36. #define IODEVB2(d,r) (*(volatile uint8_t *)IODEVA(d,r,2))
  37. #define IODEVB3(d,r) (*(volatile uint8_t *)IODEVA(d,r,3))
  38. #define IODEVH0(d,r) (*(volatile uint16_t *)IODEVA(d,r,0))
  39. #define IODEVH1(d,r) (*(volatile uint16_t *)IODEVA(d,r,2))
  40. #define IODEVL(d,r) (*(volatile uint32_t *)IODEVA(d,r,0))
  41. /* Readonly registers */
  42. #define IODEVRV(d,r) (*(const volatile void *)IODEVA(d,r,0))
  43. #define IODEVRB0(d,r) (*(const volatile uint8_t *)IODEVA(d,r,0))
  44. #define IODEVRB1(d,r) (*(const volatile uint8_t *)IODEVA(d,r,1))
  45. #define IODEVRB2(d,r) (*(const volatile uint8_t *)IODEVA(d,r,2))
  46. #define IODEVRB3(d,r) (*(const volatile uint8_t *)IODEVA(d,r,3))
  47. #define IODEVRH0(d,r) (*(const volatile uint16_t *)IODEVA(d,r,0))
  48. #define IODEVRH1(d,r) (*(const volatile uint16_t *)IODEVA(d,r,2))
  49. #define IODEVRL(d,r) (*(const volatile uint32_t *)IODEVA(d,r,0))
  50. #define PTR(x) (&(x))
  51. #endif /* __ASSEMBLY__ */
  52. #define IODEVB(d,r) IODEVB0(d,r)
  53. #define IODEVH(d,r) IODEVH0(d,r)
  54. #define IODEVRB(d,r) IODEVRB0(d,r)
  55. #define IODEVRH(d,r) IODEVRH0(d,r)
  56. #endif /* IODEVA_H */