io_trapped.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_SH_IO_TRAPPED_H
  3. #define __ASM_SH_IO_TRAPPED_H
  4. #include <linux/list.h>
  5. #include <linux/ioport.h>
  6. #include <asm/page.h>
  7. #define IO_TRAPPED_MAGIC 0xfeedbeef
  8. struct trapped_io {
  9. unsigned int magic;
  10. struct resource *resource;
  11. unsigned int num_resources;
  12. unsigned int minimum_bus_width;
  13. struct list_head list;
  14. void __iomem *virt_base;
  15. } __aligned(PAGE_SIZE);
  16. #ifdef CONFIG_IO_TRAPPED
  17. int register_trapped_io(struct trapped_io *tiop);
  18. int handle_trapped_io(struct pt_regs *regs, unsigned long address);
  19. void __iomem *match_trapped_io_handler(struct list_head *list,
  20. unsigned long offset,
  21. unsigned long size);
  22. #ifdef CONFIG_HAS_IOMEM
  23. extern struct list_head trapped_mem;
  24. static inline void __iomem *
  25. __ioremap_trapped(unsigned long offset, unsigned long size)
  26. {
  27. return match_trapped_io_handler(&trapped_mem, offset, size);
  28. }
  29. #else
  30. #define __ioremap_trapped(offset, size) NULL
  31. #endif
  32. #ifdef CONFIG_HAS_IOPORT_MAP
  33. extern struct list_head trapped_io;
  34. static inline void __iomem *
  35. __ioport_map_trapped(unsigned long offset, unsigned long size)
  36. {
  37. return match_trapped_io_handler(&trapped_io, offset, size);
  38. }
  39. #else
  40. #define __ioport_map_trapped(offset, size) NULL
  41. #endif
  42. #else
  43. #define register_trapped_io(tiop) (-1)
  44. #define handle_trapped_io(tiop, address) 0
  45. #define __ioremap_trapped(offset, size) NULL
  46. #define __ioport_map_trapped(offset, size) NULL
  47. #endif
  48. #endif /* __ASM_SH_IO_TRAPPED_H */