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