2 * The PCI Library -- Compiler-specific wrappers around x86 I/O port access instructions
4 * Copyright (c) 2023 Pali Rohár <pali@kernel.org>
6 * Can be freely distributed and used under the terms of the GNU GPL v2+
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 static inline unsigned char
14 intel_inb(unsigned short int port)
17 asm volatile ("inb %w1, %0" : "=a" (value) : "Nd" (port));
21 static inline unsigned short int
22 intel_inw(unsigned short int port)
25 asm volatile ("inw %w1, %0" : "=a" (value) : "Nd" (port));
29 static inline unsigned int
30 intel_inl(unsigned short int port)
33 asm volatile ("inl %w1, %0" : "=a" (value) : "Nd" (port));
38 intel_outb(unsigned char value, unsigned short int port)
40 asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port));
44 intel_outw(unsigned short int value, unsigned short int port)
46 asm volatile ("outw %w0, %w1" : : "a" (value), "Nd" (port));
50 intel_outl(u32 value, unsigned short int port)
52 asm volatile ("outl %0, %w1" : : "a" (value), "Nd" (port));
55 #elif defined(_MSC_VER)
57 #pragma intrinsic(_outp)
58 #pragma intrinsic(_outpw)
59 #pragma intrinsic(_outpd)
60 #pragma intrinsic(_inp)
61 #pragma intrinsic(_inpw)
62 #pragma intrinsic(_inpd)
64 #define intel_outb(x, y) _outp(y, x)
65 #define intel_outw(x, y) _outpw(y, x)
66 #define intel_outl(x, y) _outpd(y, x)
67 #define intel_inb(x) _inp(x)
68 #define intel_inw(x) _inpw(x)
69 #define intel_inl(x) _inpd(x)
73 #error Do not know how to access I/O ports on this compiler