io.h 774 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef BOOT_IO_H
  3. #define BOOT_IO_H
  4. #include <asm/shared/io.h>
  5. #undef inb
  6. #undef inw
  7. #undef inl
  8. #undef outb
  9. #undef outw
  10. #undef outl
  11. struct port_io_ops {
  12. u8 (*f_inb)(u16 port);
  13. void (*f_outb)(u8 v, u16 port);
  14. void (*f_outw)(u16 v, u16 port);
  15. };
  16. extern struct port_io_ops pio_ops;
  17. /*
  18. * Use the normal I/O instructions by default.
  19. * TDX guests override these to use hypercalls.
  20. */
  21. static inline void init_default_io_ops(void)
  22. {
  23. pio_ops.f_inb = __inb;
  24. pio_ops.f_outb = __outb;
  25. pio_ops.f_outw = __outw;
  26. }
  27. /*
  28. * Redirect port I/O operations via pio_ops callbacks.
  29. * TDX guests override these callbacks with TDX-specific helpers.
  30. */
  31. #define inb pio_ops.f_inb
  32. #define outb pio_ops.f_outb
  33. #define outw pio_ops.f_outw
  34. #endif