Back to index

glibc  2.9
io.h
Go to the documentation of this file.
00001 /* Copyright (C) 1996, 1999 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef       _SYS_IO_H
00020 
00021 #define       _SYS_IO_H     1
00022 #include <features.h>
00023 
00024 __BEGIN_DECLS
00025 
00026 /* If TURN_ON is TRUE, request for permission to do direct i/o on the
00027    port numbers in the range [FROM,FROM+NUM-1].  Otherwise, turn I/O
00028    permission off for that range.  This call requires root privileges.
00029 
00030    Portability note: not all Linux platforms support this call.  Most
00031    platforms based on the PC I/O architecture probably will, however.
00032    E.g., Linux/Alpha for Alpha PCs supports this.  */
00033 extern int ioperm (unsigned long int __from, unsigned long int __num,
00034                  int __turn_on) __THROW;
00035 
00036 /* Set the I/O privilege level to LEVEL.  If LEVEL>3, permission to
00037    access any I/O port is granted.  This call requires root
00038    privileges. */
00039 extern int iopl (int __level) __THROW;
00040 
00041 /* Return the physical address of the DENSE I/O memory or NULL if none
00042    is available (e.g. on a jensen).  */
00043 extern unsigned long int _bus_base (void) __THROW __attribute__ ((const));
00044 extern unsigned long int bus_base (void) __THROW __attribute__ ((const));
00045 
00046 /* Return the physical address of the SPARSE I/O memory.  */
00047 extern unsigned long _bus_base_sparse (void) __THROW __attribute__ ((const));
00048 extern unsigned long bus_base_sparse (void) __THROW __attribute__ ((const));
00049 
00050 /* Return the HAE shift used by the SPARSE I/O memory.  */
00051 extern int _hae_shift (void) __THROW __attribute__ ((const));
00052 extern int hae_shift (void) __THROW __attribute__ ((const));
00053 
00054 /* Previous three are deprecated in favour of the following, which
00055    knows about multiple PCI "hoses".  Provide the PCI bus and dfn
00056    numbers just as to pciconfig_read/write.  */
00057 
00058 enum __pciconfig_iobase_which
00059 {
00060   IOBASE_HOSE = 0,          /* Return hose index. */
00061   IOBASE_SPARSE_MEM = 1,    /* Return physical memory addresses.  */
00062   IOBASE_DENSE_MEM = 2,
00063   IOBASE_SPARSE_IO = 3,
00064   IOBASE_DENSE_IO = 4
00065 };
00066 
00067 extern long pciconfig_iobase(enum __pciconfig_iobase_which __which,
00068                           unsigned long int __bus,
00069                           unsigned long int __dfn)
00070      __THROW __attribute__ ((const));
00071 
00072 /* Access PCI space protected from machine checks.  */
00073 extern int pciconfig_read (unsigned long int __bus,
00074                         unsigned long int __dfn,
00075                         unsigned long int __off,
00076                         unsigned long int __len,
00077                         unsigned char *__buf) __THROW;
00078 
00079 extern int pciconfig_write (unsigned long int __bus,
00080                          unsigned long int __dfn,
00081                          unsigned long int __off,
00082                          unsigned long int __len,
00083                          unsigned char *__buf) __THROW;
00084 
00085 /* Userspace declarations.  */
00086 extern unsigned int inb (unsigned long __port) __THROW;
00087 extern unsigned int inw (unsigned long __port) __THROW;
00088 extern unsigned int inl (unsigned long __port) __THROW;
00089 extern void outb (unsigned char __b, unsigned long __port) __THROW;
00090 extern void outw (unsigned short __w, unsigned long __port) __THROW;
00091 extern void outl (unsigned int __l, unsigned long __port) __THROW;
00092 
00093 __END_DECLS
00094 
00095 #endif /* _SYS_IO_H */