1
/* Copyright (C) 1996, 2000, 2002, 2004 Free Software Foundation, Inc.
2
This file is part of the GNU C Library.
4
The GNU C Library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
9
The GNU C Library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Lesser General Public License for more details.
14
You should have received a copy of the GNU Lesser General Public
15
License along with the GNU C Library; if not, write to the Free
16
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
#ifdef _MACHINE_CPUFUNC_H_
23
#error "This header must not be used in combination with <machine/cpufunc.h>."
30
/* If TURN_ON is TRUE, request for permission to do direct i/o on the
31
port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
32
permission off for that range. This call requires root privileges.
34
Portability note: not all kFreeBSD platforms support this call. Most
35
platforms based on the PC I/O architecture probably will, however. */
36
extern int ioperm (unsigned long int __from, unsigned long int __num,
37
int __turn_on) __THROW;
39
/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
40
access any I/O port is granted. This call requires root
42
extern int iopl (int __level) __THROW;
44
#if defined __GNUC__ && __GNUC__ >= 2
46
static __inline unsigned char
47
inb (unsigned short int port)
51
__asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port));
55
static __inline unsigned char
56
inb_p (unsigned short int port)
60
__asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port));
64
static __inline unsigned short int
65
inw (unsigned short int port)
69
__asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port));
73
static __inline unsigned short int
74
inw_p (unsigned short int port)
76
unsigned short int _v;
78
__asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port));
82
static __inline unsigned int
83
inl (unsigned short int port)
87
__asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port));
91
static __inline unsigned int
92
inl_p (unsigned short int port)
95
__asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port));
100
outb (unsigned char value, unsigned short int port)
102
__asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port));
106
outb_p (unsigned char value, unsigned short int port)
108
__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (value),
113
outw (unsigned short int value, unsigned short int port)
115
__asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port));
120
outw_p (unsigned short int value, unsigned short int port)
122
__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (value),
127
outl (unsigned int value, unsigned short int port)
129
__asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port));
133
outl_p (unsigned int value, unsigned short int port)
135
__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (value),
140
insb (unsigned short int port, void *addr, unsigned long int count)
142
__asm__ __volatile__ ("cld ; rep ; insb":"=D" (addr),
143
"=c" (count):"d" (port), "0" (addr), "1" (count));
147
insw (unsigned short int port, void *addr, unsigned long int count)
149
__asm__ __volatile__ ("cld ; rep ; insw":"=D" (addr),
150
"=c" (count):"d" (port), "0" (addr), "1" (count));
154
insl (unsigned short int port, void *addr, unsigned long int count)
156
__asm__ __volatile__ ("cld ; rep ; insl":"=D" (addr),
157
"=c" (count):"d" (port), "0" (addr), "1" (count));
161
outsb (unsigned short int port, const void *addr, unsigned long int count)
163
__asm__ __volatile__ ("cld ; rep ; outsb":"=S" (addr),
164
"=c" (count):"d" (port), "0" (addr), "1" (count));
168
outsw (unsigned short int port, const void *addr, unsigned long int count)
170
__asm__ __volatile__ ("cld ; rep ; outsw":"=S" (addr),
171
"=c" (count):"d" (port), "0" (addr), "1" (count));
175
outsl (unsigned short int port, const void *addr, unsigned long int count)
177
__asm__ __volatile__ ("cld ; rep ; outsl":"=S" (addr),
178
"=c" (count):"d" (port), "0" (addr), "1" (count));
184
#endif /* _SYS_IO_H */