io.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Copyright (C) 1996, 1999 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _SYS_IO_H
  16. #define _SYS_IO_H 1
  17. #include <features.h>
  18. __BEGIN_DECLS
  19. /* If TURN_ON is TRUE, request for permission to do direct i/o on the
  20. port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
  21. permission off for that range. This call requires root privileges.
  22. Portability note: not all Linux platforms support this call. Most
  23. platforms based on the PC I/O architecture probably will, however.
  24. E.g., Linux/Alpha for Alpha PCs supports this. */
  25. extern int ioperm (unsigned long int __from, unsigned long int __num,
  26. int __turn_on) __THROW;
  27. /* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
  28. access any I/O port is granted. This call requires root
  29. privileges. */
  30. extern int iopl (int __level) __THROW;
  31. /* Return the physical address of the DENSE I/O memory or NULL if none
  32. is available (e.g. on a jensen). */
  33. extern unsigned long int _bus_base (void) __THROW __attribute__ ((const));
  34. extern unsigned long int bus_base (void) __THROW __attribute__ ((const));
  35. /* Return the physical address of the SPARSE I/O memory. */
  36. extern unsigned long _bus_base_sparse (void) __THROW __attribute__ ((const));
  37. extern unsigned long bus_base_sparse (void) __THROW __attribute__ ((const));
  38. /* Return the HAE shift used by the SPARSE I/O memory. */
  39. extern int _hae_shift (void) __THROW __attribute__ ((const));
  40. extern int hae_shift (void) __THROW __attribute__ ((const));
  41. /* Previous three are deprecated in favour of the following, which
  42. knows about multiple PCI "hoses". Provide the PCI bus and dfn
  43. numbers just as to pciconfig_read/write. */
  44. enum __pciconfig_iobase_which
  45. {
  46. IOBASE_HOSE = 0, /* Return hose index. */
  47. IOBASE_SPARSE_MEM = 1, /* Return physical memory addresses. */
  48. IOBASE_DENSE_MEM = 2,
  49. IOBASE_SPARSE_IO = 3,
  50. IOBASE_DENSE_IO = 4
  51. };
  52. extern long pciconfig_iobase(enum __pciconfig_iobase_which __which,
  53. unsigned long int __bus,
  54. unsigned long int __dfn)
  55. __THROW __attribute__ ((const));
  56. /* Access PCI space protected from machine checks. */
  57. extern int pciconfig_read (unsigned long int __bus,
  58. unsigned long int __dfn,
  59. unsigned long int __off,
  60. unsigned long int __len,
  61. unsigned char *__buf) __THROW;
  62. extern int pciconfig_write (unsigned long int __bus,
  63. unsigned long int __dfn,
  64. unsigned long int __off,
  65. unsigned long int __len,
  66. unsigned char *__buf) __THROW;
  67. /* Userspace declarations. */
  68. extern unsigned int inb (unsigned long __port) __THROW;
  69. extern unsigned int inw (unsigned long __port) __THROW;
  70. extern unsigned int inl (unsigned long __port) __THROW;
  71. extern void outb (unsigned char __b, unsigned long __port) __THROW;
  72. extern void outw (unsigned short __w, unsigned long __port) __THROW;
  73. extern void outl (unsigned int __l, unsigned long __port) __THROW;
  74. __END_DECLS
  75. #endif /* _SYS_IO_H */