2
0

io.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. static __inline void outb(unsigned char __val, unsigned short __port)
  2. {
  3. __asm__ volatile ("outb %0,%1" : : "a" (__val), "dN" (__port));
  4. }
  5. static __inline void outw(unsigned short __val, unsigned short __port)
  6. {
  7. __asm__ volatile ("outw %0,%1" : : "a" (__val), "dN" (__port));
  8. }
  9. static __inline void outl(unsigned int __val, unsigned short __port)
  10. {
  11. __asm__ volatile ("outl %0,%1" : : "a" (__val), "dN" (__port));
  12. }
  13. static __inline unsigned char inb(unsigned short __port)
  14. {
  15. unsigned char __val;
  16. __asm__ volatile ("inb %1,%0" : "=a" (__val) : "dN" (__port));
  17. return __val;
  18. }
  19. static __inline unsigned short inw(unsigned short __port)
  20. {
  21. unsigned short __val;
  22. __asm__ volatile ("inw %1,%0" : "=a" (__val) : "dN" (__port));
  23. return __val;
  24. }
  25. static __inline unsigned int inl(unsigned short __port)
  26. {
  27. unsigned int __val;
  28. __asm__ volatile ("inl %1,%0" : "=a" (__val) : "dN" (__port));
  29. return __val;
  30. }
  31. static __inline void outsb(unsigned short __port, const void *__buf, unsigned long __n)
  32. {
  33. __asm__ volatile ("cld; rep; outsb"
  34. : "+S" (__buf), "+c" (__n)
  35. : "d" (__port));
  36. }
  37. static __inline void outsw(unsigned short __port, const void *__buf, unsigned long __n)
  38. {
  39. __asm__ volatile ("cld; rep; outsw"
  40. : "+S" (__buf), "+c" (__n)
  41. : "d" (__port));
  42. }
  43. static __inline void outsl(unsigned short __port, const void *__buf, unsigned long __n)
  44. {
  45. __asm__ volatile ("cld; rep; outsl"
  46. : "+S" (__buf), "+c"(__n)
  47. : "d" (__port));
  48. }
  49. static __inline void insb(unsigned short __port, void *__buf, unsigned long __n)
  50. {
  51. __asm__ volatile ("cld; rep; insb"
  52. : "+D" (__buf), "+c" (__n)
  53. : "d" (__port));
  54. }
  55. static __inline void insw(unsigned short __port, void *__buf, unsigned long __n)
  56. {
  57. __asm__ volatile ("cld; rep; insw"
  58. : "+D" (__buf), "+c" (__n)
  59. : "d" (__port));
  60. }
  61. static __inline void insl(unsigned short __port, void *__buf, unsigned long __n)
  62. {
  63. __asm__ volatile ("cld; rep; insl"
  64. : "+D" (__buf), "+c" (__n)
  65. : "d" (__port));
  66. }