xref: /third_party/musl/arch/i386/bits/io.h (revision 570af302)
1570af302Sopenharmony_cistatic __inline void outb(unsigned char __val, unsigned short __port)
2570af302Sopenharmony_ci{
3570af302Sopenharmony_ci	__asm__ volatile ("outb %0,%1" : : "a" (__val), "dN" (__port));
4570af302Sopenharmony_ci}
5570af302Sopenharmony_ci
6570af302Sopenharmony_cistatic __inline void outw(unsigned short __val, unsigned short __port)
7570af302Sopenharmony_ci{
8570af302Sopenharmony_ci	__asm__ volatile ("outw %0,%1" : : "a" (__val), "dN" (__port));
9570af302Sopenharmony_ci}
10570af302Sopenharmony_ci
11570af302Sopenharmony_cistatic __inline void outl(unsigned int __val, unsigned short __port)
12570af302Sopenharmony_ci{
13570af302Sopenharmony_ci	__asm__ volatile ("outl %0,%1" : : "a" (__val), "dN" (__port));
14570af302Sopenharmony_ci}
15570af302Sopenharmony_ci
16570af302Sopenharmony_cistatic __inline unsigned char inb(unsigned short __port)
17570af302Sopenharmony_ci{
18570af302Sopenharmony_ci	unsigned char __val;
19570af302Sopenharmony_ci	__asm__ volatile ("inb %1,%0" : "=a" (__val) : "dN" (__port));
20570af302Sopenharmony_ci	return __val;
21570af302Sopenharmony_ci}
22570af302Sopenharmony_ci
23570af302Sopenharmony_cistatic __inline unsigned short inw(unsigned short __port)
24570af302Sopenharmony_ci{
25570af302Sopenharmony_ci	unsigned short __val;
26570af302Sopenharmony_ci	__asm__ volatile ("inw %1,%0" : "=a" (__val) : "dN" (__port));
27570af302Sopenharmony_ci	return __val;
28570af302Sopenharmony_ci}
29570af302Sopenharmony_ci
30570af302Sopenharmony_cistatic __inline unsigned int inl(unsigned short __port)
31570af302Sopenharmony_ci{
32570af302Sopenharmony_ci	unsigned int __val;
33570af302Sopenharmony_ci	__asm__ volatile ("inl %1,%0" : "=a" (__val) : "dN" (__port));
34570af302Sopenharmony_ci	return __val;
35570af302Sopenharmony_ci}
36570af302Sopenharmony_ci
37570af302Sopenharmony_cistatic __inline void outsb(unsigned short __port, const void *__buf, unsigned long __n)
38570af302Sopenharmony_ci{
39570af302Sopenharmony_ci	__asm__ volatile ("cld; rep; outsb"
40570af302Sopenharmony_ci		      : "+S" (__buf), "+c" (__n)
41570af302Sopenharmony_ci		      : "d" (__port));
42570af302Sopenharmony_ci}
43570af302Sopenharmony_ci
44570af302Sopenharmony_cistatic __inline void outsw(unsigned short __port, const void *__buf, unsigned long __n)
45570af302Sopenharmony_ci{
46570af302Sopenharmony_ci	__asm__ volatile ("cld; rep; outsw"
47570af302Sopenharmony_ci		      : "+S" (__buf), "+c" (__n)
48570af302Sopenharmony_ci		      : "d" (__port));
49570af302Sopenharmony_ci}
50570af302Sopenharmony_ci
51570af302Sopenharmony_cistatic __inline void outsl(unsigned short __port, const void *__buf, unsigned long __n)
52570af302Sopenharmony_ci{
53570af302Sopenharmony_ci	__asm__ volatile ("cld; rep; outsl"
54570af302Sopenharmony_ci		      : "+S" (__buf), "+c"(__n)
55570af302Sopenharmony_ci		      : "d" (__port));
56570af302Sopenharmony_ci}
57570af302Sopenharmony_ci
58570af302Sopenharmony_cistatic __inline void insb(unsigned short __port, void *__buf, unsigned long __n)
59570af302Sopenharmony_ci{
60570af302Sopenharmony_ci	__asm__ volatile ("cld; rep; insb"
61570af302Sopenharmony_ci		      : "+D" (__buf), "+c" (__n)
62570af302Sopenharmony_ci		      : "d" (__port));
63570af302Sopenharmony_ci}
64570af302Sopenharmony_ci
65570af302Sopenharmony_cistatic __inline void insw(unsigned short __port, void *__buf, unsigned long __n)
66570af302Sopenharmony_ci{
67570af302Sopenharmony_ci	__asm__ volatile ("cld; rep; insw"
68570af302Sopenharmony_ci		      : "+D" (__buf), "+c" (__n)
69570af302Sopenharmony_ci		      : "d" (__port));
70570af302Sopenharmony_ci}
71570af302Sopenharmony_ci
72570af302Sopenharmony_cistatic __inline void insl(unsigned short __port, void *__buf, unsigned long __n)
73570af302Sopenharmony_ci{
74570af302Sopenharmony_ci	__asm__ volatile ("cld; rep; insl"
75570af302Sopenharmony_ci		      : "+D" (__buf), "+c" (__n)
76570af302Sopenharmony_ci		      : "d" (__port));
77570af302Sopenharmony_ci}
78