floppy-std.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * This file is subject to the terms and conditions of the GNU General Public
  3.  * License.  See the file "COPYING" in the main directory of this archive
  4.  * for more details.
  5.  *
  6.  * Access the floppy hardware on PC style hardware
  7.  *
  8.  * Copyright (C) 1996, 1997, 1998 by Ralf Baechle
  9.  */
  10. #include <linux/delay.h>
  11. #include <linux/init.h>
  12. #include <linux/ioport.h>
  13. #include <linux/sched.h>
  14. #include <linux/kernel.h>
  15. #include <linux/linkage.h>
  16. #include <linux/types.h>
  17. #include <linux/mm.h>
  18. #include <asm/bootinfo.h>
  19. #include <asm/cachectl.h>
  20. #include <asm/dma.h>
  21. #include <asm/floppy.h>
  22. #include <asm/keyboard.h>
  23. #include <asm/io.h>
  24. #include <asm/irq.h>
  25. #include <asm/mc146818rtc.h>
  26. #include <asm/pgtable.h>
  27. /*
  28.  * How to access the FDC's registers.
  29.  */
  30. static unsigned char std_fd_inb(unsigned int port)
  31. {
  32. return inb_p(port);
  33. }
  34. static void std_fd_outb(unsigned char value, unsigned int port)
  35. {
  36. outb_p(value, port);
  37. }
  38. /*
  39.  * How to access the floppy DMA functions.
  40.  */
  41. static void std_fd_enable_dma(int channel)
  42. {
  43. enable_dma(channel);
  44. }
  45. static void std_fd_disable_dma(int channel)
  46. {
  47. disable_dma(channel);
  48. }
  49. static int std_fd_request_dma(int channel)
  50. {
  51. return request_dma(channel, "floppy");
  52. }
  53. static void std_fd_free_dma(int channel)
  54. {
  55. free_dma(channel);
  56. }
  57. static void std_fd_clear_dma_ff(int channel)
  58. {
  59. clear_dma_ff(channel);
  60. }
  61. static void std_fd_set_dma_mode(int channel, char mode)
  62. {
  63. set_dma_mode(channel, mode);
  64. }
  65. static void std_fd_set_dma_addr(int channel, unsigned int addr)
  66. {
  67. set_dma_addr(channel, addr);
  68. }
  69. static void std_fd_set_dma_count(int channel, unsigned int count)
  70. {
  71. set_dma_count(channel, count);
  72. }
  73. static int std_fd_get_dma_residue(int channel)
  74. {
  75. return get_dma_residue(channel);
  76. }
  77. static void std_fd_enable_irq(int irq)
  78. {
  79. enable_irq(irq);
  80. }
  81. static void std_fd_disable_irq(int irq)
  82. {
  83. disable_irq(irq);
  84. }
  85. static unsigned long std_fd_getfdaddr1(void)
  86. {
  87. return 0x3f0;
  88. }
  89. static unsigned long std_fd_dma_mem_alloc(unsigned long size)
  90. {
  91. unsigned long mem;
  92. mem = __get_dma_pages(GFP_KERNEL,get_order(size));
  93. return mem;
  94. }
  95. static void std_fd_dma_mem_free(unsigned long addr, unsigned long size)
  96. {
  97. free_pages(addr, get_order(size));
  98. }
  99. static unsigned long std_fd_drive_type(unsigned long n)
  100. {
  101. if (n == 0)
  102. return 4; /* 3,5", 1.44mb */
  103. return 0;
  104. }
  105. struct fd_ops std_fd_ops = {
  106. /*
  107.  * How to access the floppy controller's ports
  108.  */
  109. std_fd_inb,
  110. std_fd_outb,
  111. /*
  112.  * How to access the floppy DMA functions.
  113.  */
  114. std_fd_enable_dma,
  115. std_fd_disable_dma,
  116. std_fd_request_dma,
  117. std_fd_free_dma,
  118. std_fd_clear_dma_ff,
  119. std_fd_set_dma_mode,
  120. std_fd_set_dma_addr,
  121. std_fd_set_dma_count,
  122. std_fd_get_dma_residue,
  123. std_fd_enable_irq,
  124. std_fd_disable_irq,
  125.         std_fd_getfdaddr1,
  126.         std_fd_dma_mem_alloc,
  127.         std_fd_dma_mem_free,
  128. std_fd_drive_type
  129. };