選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

x86_io.c 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <gpxe/io.h>
  19. #include <gpxe/x86_io.h>
  20. /** @file
  21. *
  22. * gPXE I/O API for x86
  23. *
  24. */
  25. /**
  26. * Read 64-bit qword from memory-mapped device
  27. *
  28. * @v io_addr I/O address
  29. * @ret data Value read
  30. *
  31. * This routine uses MMX instructions.
  32. */
  33. static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
  34. uint64_t data;
  35. __asm__ __volatile__ ( "pushl %%edx\n\t"
  36. "pushl %%eax\n\t"
  37. "movq (%1), %%mm0\n\t"
  38. "movq %%mm0, (%%esp)\n\t"
  39. "popl %%eax\n\t"
  40. "popl %%edx\n\t"
  41. "emms\n\t"
  42. : "=A" ( data ) : "r" ( io_addr ) );
  43. return data;
  44. }
  45. /**
  46. * Write 64-bit qword to memory-mapped device
  47. *
  48. * @v data Value to write
  49. * @v io_addr I/O address
  50. *
  51. * This routine uses MMX instructions.
  52. */
  53. static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
  54. __asm__ __volatile__ ( "pushl %%edx\n\t"
  55. "pushl %%eax\n\t"
  56. "movq (%%esp), %%mm0\n\t"
  57. "movq %%mm0, (%1)\n\t"
  58. "popl %%eax\n\t"
  59. "popl %%edx\n\t"
  60. "emms\n\t"
  61. : : "A" ( data ), "r" ( io_addr ) );
  62. }
  63. PROVIDE_IOAPI_INLINE ( x86, phys_to_bus );
  64. PROVIDE_IOAPI_INLINE ( x86, bus_to_phys );
  65. PROVIDE_IOAPI_INLINE ( x86, ioremap );
  66. PROVIDE_IOAPI_INLINE ( x86, iounmap );
  67. PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
  68. PROVIDE_IOAPI_INLINE ( x86, readb );
  69. PROVIDE_IOAPI_INLINE ( x86, readw );
  70. PROVIDE_IOAPI_INLINE ( x86, readl );
  71. PROVIDE_IOAPI ( x86, readq, x86_readq );
  72. PROVIDE_IOAPI_INLINE ( x86, writeb );
  73. PROVIDE_IOAPI_INLINE ( x86, writew );
  74. PROVIDE_IOAPI_INLINE ( x86, writel );
  75. PROVIDE_IOAPI ( x86, writeq, x86_writeq );
  76. PROVIDE_IOAPI_INLINE ( x86, inb );
  77. PROVIDE_IOAPI_INLINE ( x86, inw );
  78. PROVIDE_IOAPI_INLINE ( x86, inl );
  79. PROVIDE_IOAPI_INLINE ( x86, outb );
  80. PROVIDE_IOAPI_INLINE ( x86, outw );
  81. PROVIDE_IOAPI_INLINE ( x86, outl );
  82. PROVIDE_IOAPI_INLINE ( x86, insb );
  83. PROVIDE_IOAPI_INLINE ( x86, insw );
  84. PROVIDE_IOAPI_INLINE ( x86, insl );
  85. PROVIDE_IOAPI_INLINE ( x86, outsb );
  86. PROVIDE_IOAPI_INLINE ( x86, outsw );
  87. PROVIDE_IOAPI_INLINE ( x86, outsl );
  88. PROVIDE_IOAPI_INLINE ( x86, iodelay );
  89. PROVIDE_IOAPI_INLINE ( x86, mb );