root/include/asm-i386/floppy.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. floppy_hardint
  2. vdma_enable_dma
  3. vdma_disable_dma
  4. vdma_request_dma
  5. vdma_nop
  6. vdma_set_dma_mode
  7. vdma_set_dma_addr
  8. vdma_set_dma_count
  9. vdma_get_dma_residue
  10. vdma_request_irq
  11. virtual_dma_init

   1 /*
   2  * Architecture specific parts of the Floppy driver
   3  *
   4  * This file is subject to the terms and conditions of the GNU General Public
   5  * License.  See the file "COPYING" in the main directory of this archive
   6  * for more details.
   7  *
   8  * Copyright (C) 1995
   9  */
  10 #ifndef __ASM_I386_FLOPPY_H
  11 #define __ASM_I386_FLOPPY_H
  12 
  13 
  14 #define SW fd_routine[use_virtual_dma&1]
  15 
  16 
  17 #define fd_inb(port)                    inb_p(port)
  18 #define fd_outb(port,value)             outb_p(port,value)
  19 
  20 #define fd_enable_dma()         SW._enable_dma(FLOPPY_DMA)
  21 #define fd_disable_dma()        SW._disable_dma(FLOPPY_DMA)
  22 #define fd_request_dma()        SW._request_dma(FLOPPY_DMA,"floppy")
  23 #define fd_free_dma()           SW._free_dma(FLOPPY_DMA)
  24 #define fd_clear_dma_ff()       SW._clear_dma_ff(FLOPPY_DMA)
  25 #define fd_set_dma_mode(mode)   SW._set_dma_mode(FLOPPY_DMA,mode)
  26 #define fd_set_dma_addr(addr)   SW._set_dma_addr(FLOPPY_DMA,addr)
  27 #define fd_set_dma_count(count) SW._set_dma_count(FLOPPY_DMA,count)
  28 #define fd_enable_irq()         enable_irq(FLOPPY_IRQ)
  29 #define fd_disable_irq()        disable_irq(FLOPPY_IRQ)
  30 #define fd_cacheflush(addr,size) /* nothing */
  31 #define fd_request_irq()        SW._request_irq(FLOPPY_IRQ, floppy_interrupt, \
  32                                                SA_INTERRUPT|SA_SAMPLE_RANDOM, \
  33                                                "floppy", NULL)
  34 #define fd_free_irq()           free_irq(FLOPPY_IRQ, NULL)
  35 #define fd_get_dma_residue()    SW._get_dma_residue(FLOPPY_DMA)
  36 
  37 static int virtual_dma_count=0;
  38 static int virtual_dma_residue=0;
  39 static unsigned long virtual_dma_addr=0;
  40 static int virtual_dma_mode=0;
  41 static int doing_pdma=0;
  42 
  43 static void floppy_hardint(int irq, void *dev_id, struct pt_regs * regs)
     /* [previous][next][first][last][top][bottom][index][help] */
  44 {
  45         register unsigned char st;
  46 
  47 #undef TRACE_FLPY_INT
  48 #undef NO_FLOPPY_ASSEMBLER
  49 
  50 #ifdef TRACE_FLPY_INT
  51         static int calls=0;
  52         static int bytes=0;
  53         static int dma_wait=0;
  54 #endif
  55         if(!doing_pdma) {
  56                 floppy_interrupt(irq, dev_id, regs);
  57                 return;
  58         }
  59 
  60 #ifdef TRACE_FLPY_INT
  61         if(!calls)
  62                 bytes = virtual_dma_count;
  63 #endif
  64 
  65 #ifndef NO_FLOPPY_ASSEMBLER
  66         __asm__ (
  67        "testl %1,%1
  68         je 3f
  69 1:      inb %w4,%b0
  70         andb $160,%b0
  71         cmpb $160,%b0
  72         jne 2f
  73         incw %w4
  74         testl %3,%3
  75         jne 4f
  76         inb %w4,%b0
  77         movb %0,(%2)
  78         jmp 5f
  79 4:      movb (%2),%0
  80         outb %b0,%w4
  81 5:      decw %w4
  82         outb %0,$0x80
  83         decl %1
  84         incl %2
  85         testl %1,%1
  86         jne 1b
  87 3:      inb %w4,%b0
  88 2:      "
  89        : "=a" ((char) st), 
  90        "=c" ((long) virtual_dma_count), 
  91        "=S" ((long) virtual_dma_addr)
  92        : "b" ((long) virtual_dma_mode),
  93        "d" ((short) virtual_dma_port+4), 
  94        "1" ((long) virtual_dma_count),
  95        "2" ((long) virtual_dma_addr));
  96 #else   
  97         {
  98                 register int lcount;
  99                 register char *lptr;
 100 
 101                 st = 1;
 102                 for(lcount=virtual_dma_count, lptr=(char *)virtual_dma_addr; 
 103                     lcount; lcount--, lptr++) {
 104                         st=inb(virtual_dma_port+4) & 0xa0 ;
 105                         if(st != 0xa0) 
 106                                 break;
 107                         if(virtual_dma_mode)
 108                                 outb_p(*lptr, virtual_dma_port+5);
 109                         else
 110                                 *lptr = inb_p(virtual_dma_port+5);
 111                         st = inb(virtual_dma_port+4);
 112                 }
 113                 virtual_dma_count = lcount;
 114                 virtual_dma_addr = (int) lptr;
 115         }
 116 #endif
 117 
 118 #ifdef TRACE_FLPY_INT
 119         calls++;
 120 #endif
 121         if(st == 0x20)
 122                 return;
 123         if(!(st & 0x20)) {
 124                 virtual_dma_residue += virtual_dma_count;
 125                 virtual_dma_count=0;
 126 #ifdef TRACE_FLPY_INT
 127                 printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n", 
 128                        virtual_dma_count, virtual_dma_residue, calls, bytes,
 129                        dma_wait);
 130                 calls = 0;
 131                 dma_wait=0;
 132 #endif
 133                 doing_pdma = 0;
 134                 floppy_interrupt(irq, dev_id, regs);
 135                 return;
 136         }
 137 #ifdef TRACE_FLPY_INT
 138         if(!virtual_dma_count)
 139                 dma_wait++;
 140 #endif
 141 }
 142 
 143 static void vdma_enable_dma(unsigned int dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 144 {
 145         doing_pdma = 1;
 146 }
 147 
 148 static void vdma_disable_dma(unsigned int dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 149 {
 150         doing_pdma = 0;
 151         virtual_dma_residue += virtual_dma_count;
 152         virtual_dma_count=0;            
 153 }
 154 
 155 static int vdma_request_dma(unsigned int dmanr, const char * device_id)
     /* [previous][next][first][last][top][bottom][index][help] */
 156 {
 157         return 0;
 158 }
 159 
 160 static void vdma_nop(unsigned int dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 161 {
 162 }
 163 
 164 static void vdma_set_dma_mode(unsigned int dummy,char mode)
     /* [previous][next][first][last][top][bottom][index][help] */
 165 {
 166         virtual_dma_mode = (mode  == DMA_MODE_WRITE);
 167 }
 168 
 169 static void vdma_set_dma_addr(unsigned int dummy,unsigned int addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 170 {
 171         virtual_dma_addr = addr;
 172 }
 173 
 174 static void vdma_set_dma_count(unsigned int dummy,unsigned int count)
     /* [previous][next][first][last][top][bottom][index][help] */
 175 {
 176         virtual_dma_count = count;
 177         virtual_dma_residue = 0;
 178 }
 179 
 180 static int vdma_get_dma_residue(unsigned int dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 181 {
 182         return virtual_dma_count + virtual_dma_residue;
 183 }
 184 
 185 
 186 static int vdma_request_irq(unsigned int irq,
     /* [previous][next][first][last][top][bottom][index][help] */
 187                             void (*handler)(int, void *, struct pt_regs *),
 188                             unsigned long flags, 
 189                             const char *device,
 190                             void *dev_id)
 191 {
 192         return request_irq(irq, floppy_hardint,SA_INTERRUPT,device, dev_id);
 193 
 194 }
 195 
 196 
 197 struct fd_routine_l {
 198         void (*_enable_dma)(unsigned int dummy);
 199         void (*_disable_dma)(unsigned int dummy);
 200         int (*_request_dma)(unsigned int dmanr, const char * device_id);
 201         void (*_free_dma)(unsigned int dmanr);
 202         void (*_clear_dma_ff)(unsigned int dummy);
 203         void (*_set_dma_mode)(unsigned int dummy, char mode);
 204         void (*_set_dma_addr)(unsigned int dummy, unsigned int addr);
 205         void (*_set_dma_count)(unsigned int dummy, unsigned int count);
 206         int (*_get_dma_residue)(unsigned int dummy);
 207         int (*_request_irq)(unsigned int irq,
 208                            void (*handler)(int, void *, struct pt_regs *),
 209                            unsigned long flags, 
 210                            const char *device,
 211                            void *dev_id);
 212 } fd_routine[] = {
 213         {
 214                 enable_dma,
 215                 disable_dma,
 216                 request_dma,
 217                 free_dma,
 218                 clear_dma_ff,
 219                 set_dma_mode,
 220                 set_dma_addr,
 221                 set_dma_count,
 222                 get_dma_residue,
 223                 request_irq,
 224         },
 225         {
 226                 vdma_enable_dma,
 227                 vdma_disable_dma,
 228                 vdma_request_dma,
 229                 vdma_nop,
 230                 vdma_nop,
 231                 vdma_set_dma_mode,
 232                 vdma_set_dma_addr,
 233                 vdma_set_dma_count,
 234                 vdma_get_dma_residue,
 235                 vdma_request_irq
 236         }
 237 };
 238 
 239 __inline__ void virtual_dma_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 240 {
 241         /* Nothing to do on an i386 */
 242 }
 243 
 244 static int FDC1 = 0x3f0;
 245 static int FDC2 = -1;
 246 
 247 #define FLOPPY0_TYPE    ((CMOS_READ(0x10) >> 4) & 15)
 248 #define FLOPPY1_TYPE    (CMOS_READ(0x10) & 15)
 249 
 250 #define N_FDC 2
 251 #define N_DRIVE 8
 252 
 253 /*
 254  * The DMA channel used by the floppy controller cannot access data at
 255  * addresses >= 16MB
 256  *
 257  * Went back to the 1MB limit, as some people had problems with the floppy
 258  * driver otherwise. It doesn't matter much for performance anyway, as most
 259  * floppy accesses go through the track buffer.
 260  */
 261 #define CROSS_64KB(a,s) ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64)
 262 
 263 #endif /* __ASM_I386_FLOPPY_H */

/* [previous][next][first][last][top][bottom][index][help] */