diff options
Diffstat (limited to 'include/asm-x86/floppy.h')
-rw-r--r-- | include/asm-x86/floppy.h | 87 |
1 files changed, 45 insertions, 42 deletions
diff --git a/include/asm-x86/floppy.h b/include/asm-x86/floppy.h index a48d7153c097..438b3033a250 100644 --- a/include/asm-x86/floppy.h +++ b/include/asm-x86/floppy.h | |||
@@ -20,20 +20,21 @@ | |||
20 | * driver otherwise. It doesn't matter much for performance anyway, as most | 20 | * driver otherwise. It doesn't matter much for performance anyway, as most |
21 | * floppy accesses go through the track buffer. | 21 | * floppy accesses go through the track buffer. |
22 | */ | 22 | */ |
23 | #define _CROSS_64KB(a,s,vdma) \ | 23 | #define _CROSS_64KB(a, s, vdma) \ |
24 | (!(vdma) && ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64)) | 24 | (!(vdma) && \ |
25 | ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64)) | ||
25 | 26 | ||
26 | #define CROSS_64KB(a,s) _CROSS_64KB(a,s,use_virtual_dma & 1) | 27 | #define CROSS_64KB(a, s) _CROSS_64KB(a, s, use_virtual_dma & 1) |
27 | 28 | ||
28 | 29 | ||
29 | #define SW fd_routine[use_virtual_dma&1] | 30 | #define SW fd_routine[use_virtual_dma & 1] |
30 | #define CSW fd_routine[can_use_virtual_dma & 1] | 31 | #define CSW fd_routine[can_use_virtual_dma & 1] |
31 | 32 | ||
32 | 33 | ||
33 | #define fd_inb(port) inb_p(port) | 34 | #define fd_inb(port) inb_p(port) |
34 | #define fd_outb(value,port) outb_p(value,port) | 35 | #define fd_outb(value, port) outb_p(value, port) |
35 | 36 | ||
36 | #define fd_request_dma() CSW._request_dma(FLOPPY_DMA,"floppy") | 37 | #define fd_request_dma() CSW._request_dma(FLOPPY_DMA, "floppy") |
37 | #define fd_free_dma() CSW._free_dma(FLOPPY_DMA) | 38 | #define fd_free_dma() CSW._free_dma(FLOPPY_DMA) |
38 | #define fd_enable_irq() enable_irq(FLOPPY_IRQ) | 39 | #define fd_enable_irq() enable_irq(FLOPPY_IRQ) |
39 | #define fd_disable_irq() disable_irq(FLOPPY_IRQ) | 40 | #define fd_disable_irq() disable_irq(FLOPPY_IRQ) |
@@ -57,15 +58,15 @@ static irqreturn_t floppy_hardint(int irq, void *dev_id) | |||
57 | #undef TRACE_FLPY_INT | 58 | #undef TRACE_FLPY_INT |
58 | 59 | ||
59 | #ifdef TRACE_FLPY_INT | 60 | #ifdef TRACE_FLPY_INT |
60 | static int calls=0; | 61 | static int calls; |
61 | static int bytes=0; | 62 | static int bytes; |
62 | static int dma_wait=0; | 63 | static int dma_wait; |
63 | #endif | 64 | #endif |
64 | if (!doing_pdma) | 65 | if (!doing_pdma) |
65 | return floppy_interrupt(irq, dev_id); | 66 | return floppy_interrupt(irq, dev_id); |
66 | 67 | ||
67 | #ifdef TRACE_FLPY_INT | 68 | #ifdef TRACE_FLPY_INT |
68 | if(!calls) | 69 | if (!calls) |
69 | bytes = virtual_dma_count; | 70 | bytes = virtual_dma_count; |
70 | #endif | 71 | #endif |
71 | 72 | ||
@@ -74,42 +75,42 @@ static irqreturn_t floppy_hardint(int irq, void *dev_id) | |||
74 | register char *lptr; | 75 | register char *lptr; |
75 | 76 | ||
76 | st = 1; | 77 | st = 1; |
77 | for(lcount=virtual_dma_count, lptr=virtual_dma_addr; | 78 | for (lcount = virtual_dma_count, lptr = virtual_dma_addr; |
78 | lcount; lcount--, lptr++) { | 79 | lcount; lcount--, lptr++) { |
79 | st=inb(virtual_dma_port+4) & 0xa0 ; | 80 | st = inb(virtual_dma_port + 4) & 0xa0; |
80 | if(st != 0xa0) | 81 | if (st != 0xa0) |
81 | break; | 82 | break; |
82 | if(virtual_dma_mode) | 83 | if (virtual_dma_mode) |
83 | outb_p(*lptr, virtual_dma_port+5); | 84 | outb_p(*lptr, virtual_dma_port + 5); |
84 | else | 85 | else |
85 | *lptr = inb_p(virtual_dma_port+5); | 86 | *lptr = inb_p(virtual_dma_port + 5); |
86 | } | 87 | } |
87 | virtual_dma_count = lcount; | 88 | virtual_dma_count = lcount; |
88 | virtual_dma_addr = lptr; | 89 | virtual_dma_addr = lptr; |
89 | st = inb(virtual_dma_port+4); | 90 | st = inb(virtual_dma_port + 4); |
90 | } | 91 | } |
91 | 92 | ||
92 | #ifdef TRACE_FLPY_INT | 93 | #ifdef TRACE_FLPY_INT |
93 | calls++; | 94 | calls++; |
94 | #endif | 95 | #endif |
95 | if(st == 0x20) | 96 | if (st == 0x20) |
96 | return IRQ_HANDLED; | 97 | return IRQ_HANDLED; |
97 | if(!(st & 0x20)) { | 98 | if (!(st & 0x20)) { |
98 | virtual_dma_residue += virtual_dma_count; | 99 | virtual_dma_residue += virtual_dma_count; |
99 | virtual_dma_count=0; | 100 | virtual_dma_count = 0; |
100 | #ifdef TRACE_FLPY_INT | 101 | #ifdef TRACE_FLPY_INT |
101 | printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n", | 102 | printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n", |
102 | virtual_dma_count, virtual_dma_residue, calls, bytes, | 103 | virtual_dma_count, virtual_dma_residue, calls, bytes, |
103 | dma_wait); | 104 | dma_wait); |
104 | calls = 0; | 105 | calls = 0; |
105 | dma_wait=0; | 106 | dma_wait = 0; |
106 | #endif | 107 | #endif |
107 | doing_pdma = 0; | 108 | doing_pdma = 0; |
108 | floppy_interrupt(irq, dev_id); | 109 | floppy_interrupt(irq, dev_id); |
109 | return IRQ_HANDLED; | 110 | return IRQ_HANDLED; |
110 | } | 111 | } |
111 | #ifdef TRACE_FLPY_INT | 112 | #ifdef TRACE_FLPY_INT |
112 | if(!virtual_dma_count) | 113 | if (!virtual_dma_count) |
113 | dma_wait++; | 114 | dma_wait++; |
114 | #endif | 115 | #endif |
115 | return IRQ_HANDLED; | 116 | return IRQ_HANDLED; |
@@ -117,14 +118,14 @@ static irqreturn_t floppy_hardint(int irq, void *dev_id) | |||
117 | 118 | ||
118 | static void fd_disable_dma(void) | 119 | static void fd_disable_dma(void) |
119 | { | 120 | { |
120 | if(! (can_use_virtual_dma & 1)) | 121 | if (!(can_use_virtual_dma & 1)) |
121 | disable_dma(FLOPPY_DMA); | 122 | disable_dma(FLOPPY_DMA); |
122 | doing_pdma = 0; | 123 | doing_pdma = 0; |
123 | virtual_dma_residue += virtual_dma_count; | 124 | virtual_dma_residue += virtual_dma_count; |
124 | virtual_dma_count=0; | 125 | virtual_dma_count = 0; |
125 | } | 126 | } |
126 | 127 | ||
127 | static int vdma_request_dma(unsigned int dmanr, const char * device_id) | 128 | static int vdma_request_dma(unsigned int dmanr, const char *device_id) |
128 | { | 129 | { |
129 | return 0; | 130 | return 0; |
130 | } | 131 | } |
@@ -142,7 +143,7 @@ static int vdma_get_dma_residue(unsigned int dummy) | |||
142 | 143 | ||
143 | static int fd_request_irq(void) | 144 | static int fd_request_irq(void) |
144 | { | 145 | { |
145 | if(can_use_virtual_dma) | 146 | if (can_use_virtual_dma) |
146 | return request_irq(FLOPPY_IRQ, floppy_hardint, | 147 | return request_irq(FLOPPY_IRQ, floppy_hardint, |
147 | IRQF_DISABLED, "floppy", NULL); | 148 | IRQF_DISABLED, "floppy", NULL); |
148 | else | 149 | else |
@@ -152,13 +153,13 @@ static int fd_request_irq(void) | |||
152 | 153 | ||
153 | static unsigned long dma_mem_alloc(unsigned long size) | 154 | static unsigned long dma_mem_alloc(unsigned long size) |
154 | { | 155 | { |
155 | return __get_dma_pages(GFP_KERNEL|__GFP_NORETRY,get_order(size)); | 156 | return __get_dma_pages(GFP_KERNEL|__GFP_NORETRY, get_order(size)); |
156 | } | 157 | } |
157 | 158 | ||
158 | 159 | ||
159 | static unsigned long vdma_mem_alloc(unsigned long size) | 160 | static unsigned long vdma_mem_alloc(unsigned long size) |
160 | { | 161 | { |
161 | return (unsigned long) vmalloc(size); | 162 | return (unsigned long)vmalloc(size); |
162 | 163 | ||
163 | } | 164 | } |
164 | 165 | ||
@@ -166,7 +167,7 @@ static unsigned long vdma_mem_alloc(unsigned long size) | |||
166 | 167 | ||
167 | static void _fd_dma_mem_free(unsigned long addr, unsigned long size) | 168 | static void _fd_dma_mem_free(unsigned long addr, unsigned long size) |
168 | { | 169 | { |
169 | if((unsigned long) addr >= (unsigned long) high_memory) | 170 | if ((unsigned long)addr >= (unsigned long)high_memory) |
170 | vfree((void *)addr); | 171 | vfree((void *)addr); |
171 | else | 172 | else |
172 | free_pages(addr, get_order(size)); | 173 | free_pages(addr, get_order(size)); |
@@ -176,10 +177,10 @@ static void _fd_dma_mem_free(unsigned long addr, unsigned long size) | |||
176 | 177 | ||
177 | static void _fd_chose_dma_mode(char *addr, unsigned long size) | 178 | static void _fd_chose_dma_mode(char *addr, unsigned long size) |
178 | { | 179 | { |
179 | if(can_use_virtual_dma == 2) { | 180 | if (can_use_virtual_dma == 2) { |
180 | if((unsigned long) addr >= (unsigned long) high_memory || | 181 | if ((unsigned long)addr >= (unsigned long)high_memory || |
181 | isa_virt_to_bus(addr) >= 0x1000000 || | 182 | isa_virt_to_bus(addr) >= 0x1000000 || |
182 | _CROSS_64KB(addr, size, 0)) | 183 | _CROSS_64KB(addr, size, 0)) |
183 | use_virtual_dma = 1; | 184 | use_virtual_dma = 1; |
184 | else | 185 | else |
185 | use_virtual_dma = 0; | 186 | use_virtual_dma = 0; |
@@ -195,7 +196,7 @@ static int vdma_dma_setup(char *addr, unsigned long size, int mode, int io) | |||
195 | { | 196 | { |
196 | doing_pdma = 1; | 197 | doing_pdma = 1; |
197 | virtual_dma_port = io; | 198 | virtual_dma_port = io; |
198 | virtual_dma_mode = (mode == DMA_MODE_WRITE); | 199 | virtual_dma_mode = (mode == DMA_MODE_WRITE); |
199 | virtual_dma_addr = addr; | 200 | virtual_dma_addr = addr; |
200 | virtual_dma_count = size; | 201 | virtual_dma_count = size; |
201 | virtual_dma_residue = 0; | 202 | virtual_dma_residue = 0; |
@@ -213,18 +214,18 @@ static int hard_dma_setup(char *addr, unsigned long size, int mode, int io) | |||
213 | /* actual, physical DMA */ | 214 | /* actual, physical DMA */ |
214 | doing_pdma = 0; | 215 | doing_pdma = 0; |
215 | clear_dma_ff(FLOPPY_DMA); | 216 | clear_dma_ff(FLOPPY_DMA); |
216 | set_dma_mode(FLOPPY_DMA,mode); | 217 | set_dma_mode(FLOPPY_DMA, mode); |
217 | set_dma_addr(FLOPPY_DMA,isa_virt_to_bus(addr)); | 218 | set_dma_addr(FLOPPY_DMA, isa_virt_to_bus(addr)); |
218 | set_dma_count(FLOPPY_DMA,size); | 219 | set_dma_count(FLOPPY_DMA, size); |
219 | enable_dma(FLOPPY_DMA); | 220 | enable_dma(FLOPPY_DMA); |
220 | return 0; | 221 | return 0; |
221 | } | 222 | } |
222 | 223 | ||
223 | static struct fd_routine_l { | 224 | static struct fd_routine_l { |
224 | int (*_request_dma)(unsigned int dmanr, const char * device_id); | 225 | int (*_request_dma)(unsigned int dmanr, const char *device_id); |
225 | void (*_free_dma)(unsigned int dmanr); | 226 | void (*_free_dma)(unsigned int dmanr); |
226 | int (*_get_dma_residue)(unsigned int dummy); | 227 | int (*_get_dma_residue)(unsigned int dummy); |
227 | unsigned long (*_dma_mem_alloc) (unsigned long size); | 228 | unsigned long (*_dma_mem_alloc)(unsigned long size); |
228 | int (*_dma_setup)(char *addr, unsigned long size, int mode, int io); | 229 | int (*_dma_setup)(char *addr, unsigned long size, int mode, int io); |
229 | } fd_routine[] = { | 230 | } fd_routine[] = { |
230 | { | 231 | { |
@@ -252,7 +253,8 @@ static int FDC2 = -1; | |||
252 | * is needed to prevent corrupted CMOS RAM in case "insmod floppy" | 253 | * is needed to prevent corrupted CMOS RAM in case "insmod floppy" |
253 | * coincides with another rtc CMOS user. Paul G. | 254 | * coincides with another rtc CMOS user. Paul G. |
254 | */ | 255 | */ |
255 | #define FLOPPY0_TYPE ({ \ | 256 | #define FLOPPY0_TYPE \ |
257 | ({ \ | ||
256 | unsigned long flags; \ | 258 | unsigned long flags; \ |
257 | unsigned char val; \ | 259 | unsigned char val; \ |
258 | spin_lock_irqsave(&rtc_lock, flags); \ | 260 | spin_lock_irqsave(&rtc_lock, flags); \ |
@@ -261,7 +263,8 @@ static int FDC2 = -1; | |||
261 | val; \ | 263 | val; \ |
262 | }) | 264 | }) |
263 | 265 | ||
264 | #define FLOPPY1_TYPE ({ \ | 266 | #define FLOPPY1_TYPE \ |
267 | ({ \ | ||
265 | unsigned long flags; \ | 268 | unsigned long flags; \ |
266 | unsigned char val; \ | 269 | unsigned char val; \ |
267 | spin_lock_irqsave(&rtc_lock, flags); \ | 270 | spin_lock_irqsave(&rtc_lock, flags); \ |