10 #ifndef _ASM_X86_FLOPPY_H
11 #define _ASM_X86_FLOPPY_H
23 #define _CROSS_64KB(a, s, vdma) \
25 ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64))
27 #define CROSS_64KB(a, s) _CROSS_64KB(a, s, use_virtual_dma & 1)
30 #define SW fd_routine[use_virtual_dma & 1]
31 #define CSW fd_routine[can_use_virtual_dma & 1]
34 #define fd_inb(port) inb_p(port)
35 #define fd_outb(value, port) outb_p(value, port)
37 #define fd_request_dma() CSW._request_dma(FLOPPY_DMA, "floppy")
38 #define fd_free_dma() CSW._free_dma(FLOPPY_DMA)
39 #define fd_enable_irq() enable_irq(FLOPPY_IRQ)
40 #define fd_disable_irq() disable_irq(FLOPPY_IRQ)
41 #define fd_free_irq() free_irq(FLOPPY_IRQ, NULL)
42 #define fd_get_dma_residue() SW._get_dma_residue(FLOPPY_DMA)
43 #define fd_dma_mem_alloc(size) SW._dma_mem_alloc(size)
44 #define fd_dma_setup(addr, size, mode, io) SW._dma_setup(addr, size, mode, io)
46 #define FLOPPY_CAN_FALLBACK_ON_NODMA
48 static int virtual_dma_count;
49 static int virtual_dma_residue;
50 static char *virtual_dma_addr;
51 static int virtual_dma_mode;
70 bytes = virtual_dma_count;
78 for (lcount = virtual_dma_count, lptr = virtual_dma_addr;
79 lcount; lcount--, lptr++) {
80 st =
inb(virtual_dma_port + 4) & 0xa0;
84 outb_p(*lptr, virtual_dma_port + 5);
86 *lptr =
inb_p(virtual_dma_port + 5);
88 virtual_dma_count = lcount;
89 virtual_dma_addr = lptr;
90 st =
inb(virtual_dma_port + 4);
99 virtual_dma_residue += virtual_dma_count;
100 virtual_dma_count = 0;
101 #ifdef TRACE_FLPY_INT
103 virtual_dma_count, virtual_dma_residue, calls, bytes,
112 #ifdef TRACE_FLPY_INT
113 if (!virtual_dma_count)
121 if (!(can_use_virtual_dma & 1))
124 virtual_dma_residue += virtual_dma_count;
125 virtual_dma_count = 0;
128 static int vdma_request_dma(
unsigned int dmanr,
const char *
device_id)
133 static void vdma_nop(
unsigned int dummy)
138 static int vdma_get_dma_residue(
unsigned int dummy)
140 return virtual_dma_count + virtual_dma_residue;
146 if (can_use_virtual_dma)
154 static unsigned long dma_mem_alloc(
unsigned long size)
160 static unsigned long vdma_mem_alloc(
unsigned long size)
162 return (
unsigned long)
vmalloc(size);
166 #define nodma_mem_alloc(size) vdma_mem_alloc(size)
168 static void _fd_dma_mem_free(
unsigned long addr,
unsigned long size)
170 if ((
unsigned long)addr >= (
unsigned long)
high_memory)
176 #define fd_dma_mem_free(addr, size) _fd_dma_mem_free(addr, size)
178 static void _fd_chose_dma_mode(
char *
addr,
unsigned long size)
180 if (can_use_virtual_dma == 2) {
181 if ((
unsigned long)addr >= (
unsigned long)
high_memory ||
182 isa_virt_to_bus(addr) >= 0x1000000 ||
188 use_virtual_dma = can_use_virtual_dma & 1;
192 #define fd_chose_dma_mode(addr, size) _fd_chose_dma_mode(addr, size)
195 static int vdma_dma_setup(
char *
addr,
unsigned long size,
int mode,
int io)
198 virtual_dma_port =
io;
200 virtual_dma_addr =
addr;
201 virtual_dma_count =
size;
202 virtual_dma_residue = 0;
206 static int hard_dma_setup(
char *
addr,
unsigned long size,
int mode,
int io)
208 #ifdef FLOPPY_SANITY_CHECK
210 printk(
"DMA crossing 64-K boundary %p-%p\n", addr, addr+size);
216 clear_dma_ff(FLOPPY_DMA);
218 set_dma_addr(FLOPPY_DMA, isa_virt_to_bus(addr));
224 static struct fd_routine_l {
225 int (*_request_dma)(
unsigned int dmanr,
const char *
device_id);
226 void (*_free_dma)(
unsigned int dmanr);
227 int (*_get_dma_residue)(
unsigned int dummy);
228 unsigned long (*_dma_mem_alloc)(
unsigned long size);
241 vdma_get_dma_residue,
248 static int FDC1 = 0x3f0;
249 static int FDC2 = -1;
256 #define FLOPPY0_TYPE \
258 unsigned long flags; \
260 spin_lock_irqsave(&rtc_lock, flags); \
261 val = (CMOS_READ(0x10) >> 4) & 15; \
262 spin_unlock_irqrestore(&rtc_lock, flags); \
266 #define FLOPPY1_TYPE \
268 unsigned long flags; \
270 spin_lock_irqsave(&rtc_lock, flags); \
271 val = CMOS_READ(0x10) & 15; \
272 spin_unlock_irqrestore(&rtc_lock, flags); \
279 #define EXTRA_FLOPPY_PARAMS