2 * Architecture specific parts of the Floppy driver
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
10 * Modifications for Xen are Copyright (c) 2004, Keir Fraser.
12 #ifndef __ASM_XEN_X86_64_FLOPPY_H
13 #define __ASM_XEN_X86_64_FLOPPY_H
15 #include <linux/vmalloc.h>
19 * The DMA channel used by the floppy controller cannot access data at
22 * Went back to the 1MB limit, as some people had problems with the floppy
23 * driver otherwise. It doesn't matter much for performance anyway, as most
24 * floppy accesses go through the track buffer.
26 #define _CROSS_64KB(a,s,vdma) \
27 (!(vdma) && ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64))
29 #include <linux/vmalloc.h>
31 /* XEN: Hit DMA paths on the head. This trick from asm-m68k/floppy.h. */
33 #undef MAX_DMA_ADDRESS
34 #define MAX_DMA_ADDRESS 0
35 #define CROSS_64KB(a,s) (0)
37 #define fd_inb(port) inb_p(port)
38 #define fd_outb(value,port) outb_p(value,port)
40 #define fd_request_dma() (0)
41 #define fd_free_dma() ((void)0)
42 #define fd_enable_irq() enable_irq(FLOPPY_IRQ)
43 #define fd_disable_irq() disable_irq(FLOPPY_IRQ)
44 #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL)
45 #define fd_get_dma_residue() vdma_get_dma_residue(FLOPPY_DMA)
46 #define fd_dma_mem_alloc(size) vdma_mem_alloc(size)
47 #define fd_dma_mem_free(addr, size) vdma_mem_free(addr, size)
48 #define fd_dma_setup(addr, size, mode, io) vdma_dma_setup(addr, size, mode, io)
50 static int virtual_dma_count;
51 static int virtual_dma_residue;
52 static char *virtual_dma_addr;
53 static int virtual_dma_mode;
54 static int doing_pdma;
56 static irqreturn_t floppy_hardint(int irq, void *dev_id, struct pt_regs * regs)
58 register unsigned char st;
65 static int dma_wait=0;
68 return floppy_interrupt(irq, dev_id, regs);
72 bytes = virtual_dma_count;
80 for(lcount=virtual_dma_count, lptr=virtual_dma_addr;
81 lcount; lcount--, lptr++) {
82 st=inb(virtual_dma_port+4) & 0xa0 ;
86 outb_p(*lptr, virtual_dma_port+5);
88 *lptr = inb_p(virtual_dma_port+5);
90 virtual_dma_count = lcount;
91 virtual_dma_addr = lptr;
92 st = inb(virtual_dma_port+4);
101 virtual_dma_residue += virtual_dma_count;
103 #ifdef TRACE_FLPY_INT
104 printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n",
105 virtual_dma_count, virtual_dma_residue, calls, bytes,
111 floppy_interrupt(irq, dev_id, regs);
114 #ifdef TRACE_FLPY_INT
115 if(!virtual_dma_count)
121 static void fd_disable_dma(void)
124 virtual_dma_residue += virtual_dma_count;
128 static int vdma_get_dma_residue(unsigned int dummy)
130 return virtual_dma_count + virtual_dma_residue;
134 static int fd_request_irq(void)
136 return request_irq(FLOPPY_IRQ, floppy_hardint,SA_INTERRUPT,
141 static unsigned long vdma_mem_alloc(unsigned long size)
143 return (unsigned long) vmalloc(size);
147 static void vdma_mem_free(unsigned long addr, unsigned long size)
152 static int vdma_dma_setup(char *addr, unsigned long size, int mode, int io)
155 virtual_dma_port = io;
156 virtual_dma_mode = (mode == DMA_MODE_WRITE);
157 virtual_dma_addr = addr;
158 virtual_dma_count = size;
159 virtual_dma_residue = 0;
163 /* XEN: This trick to force 'virtual DMA' is from include/asm-m68k/floppy.h. */
164 #define FDC1 xen_floppy_init()
165 static int FDC2 = -1;
167 static int xen_floppy_init(void)
170 can_use_virtual_dma = 1;
175 * Floppy types are stored in the rtc's CMOS RAM and so rtc_lock
176 * is needed to prevent corrupted CMOS RAM in case "insmod floppy"
177 * coincides with another rtc CMOS user. Paul G.
179 #define FLOPPY0_TYPE ({ \
180 unsigned long flags; \
182 spin_lock_irqsave(&rtc_lock, flags); \
183 val = (CMOS_READ(0x10) >> 4) & 15; \
184 spin_unlock_irqrestore(&rtc_lock, flags); \
188 #define FLOPPY1_TYPE ({ \
189 unsigned long flags; \
191 spin_lock_irqsave(&rtc_lock, flags); \
192 val = CMOS_READ(0x10) & 15; \
193 spin_unlock_irqrestore(&rtc_lock, flags); \
200 #define FLOPPY_MOTOR_MASK 0xf0
202 #define EXTRA_FLOPPY_PARAMS
204 #endif /* __ASM_XEN_X86_64_FLOPPY_H */