iodev.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef IODEV_H
  2. #define IODEV_H
  3. /* Address for I/O device d, subregister r */
  4. #define IODEVA(d,r) (0xfffffc00+((d) << 6)+((r) << 2))
  5. #ifdef __ASSEMBLY__
  6. /*
  7. * The I/O device range is designed so that it can be addressed via
  8. * negative offsets from the zero register, so no explicit base
  9. * pointer register is necesary.
  10. */
  11. #define IODEVV(d,r) IODEVA(d,r)(zero)
  12. #define IODEVB(d,r) IODEVV(d,r)
  13. #define IODEVH(d,r) IODEVV(d,r)
  14. #define IODEVL(d,r) IODEVV(d,r)
  15. #else
  16. #include <stdint.h>
  17. /* Writable registers */
  18. #define IODEVV(d,r) (*(volatile void *)IODEVA(d,r))
  19. #define IODEVB(d,r) (*(volatile uint8_t *)IODEVA(d,r))
  20. #define IODEVH(d,r) (*(volatile uint16_t *)IODEVA(d,r))
  21. #define IODEVL(d,r) (*(volatile uint32_t *)IODEVA(d,r))
  22. /* Readonly registers */
  23. #define IODEVRV(d,r) (*(const volatile void *)IODEVA(d,r))
  24. #define IODEVRB(d,r) (*(const volatile uint8_t *)IODEVA(d,r))
  25. #define IODEVRH(d,r) (*(const volatile uint16_t *)IODEVA(d,r))
  26. #define IODEVRL(d,r) (*(const volatile uint32_t *)IODEVA(d,r))
  27. #endif
  28. #define CPU_CLK_HZ 84000000
  29. #define LED IODEVB(0,0)
  30. #define CONSOLE IODEVB(1,0)
  31. #define CON_BAUDDIV IODEVL(1,1)
  32. #define CON_BAUD_BASE (48000000U >> 4)
  33. #endif /* IODEV_H */