Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | #ifndef _ASM_IRQ_H #define _ASM_IRQ_H /* * linux/include/asm/irq.h * * (C) 1992, 1993 Linus Torvalds * * IRQ/IPI changes taken from work by Thomas Radke <tomsoft@informatik.tu-chemnitz.de> */ #include <linux/linkage.h> #include <asm/segment.h> #define NR_IRQS 16 extern void disable_irq(unsigned int); extern void enable_irq(unsigned int); #define __STR(x) #x #define STR(x) __STR(x) #define SAVE_ALL \ "cld\n\t" \ "push %gs\n\t" \ "push %fs\n\t" \ "push %es\n\t" \ "push %ds\n\t" \ "pushl %eax\n\t" \ "pushl %ebp\n\t" \ "pushl %edi\n\t" \ "pushl %esi\n\t" \ "pushl %edx\n\t" \ "pushl %ecx\n\t" \ "pushl %ebx\n\t" \ "movl $" STR(KERNEL_DS) ",%edx\n\t" \ "mov %dx,%ds\n\t" \ "mov %dx,%es\n\t" \ "movl $" STR(USER_DS) ",%edx\n\t" \ "mov %dx,%fs\n\t" \ "movl $0,%edx\n\t" \ "movl %edx,%db7\n\t" /* * SAVE_MOST/RESTORE_MOST is used for the faster version of IRQ handlers, * installed by using the SA_INTERRUPT flag. These kinds of IRQ's don't * call the routines that do signal handling etc on return, and can have * more relaxed register-saving etc. They are also atomic, and are thus * suited for small, fast interrupts like the serial lines or the harddisk * drivers, which don't actually need signal handling etc. * * Also note that we actually save only those registers that are used in * C subroutines (%eax, %edx and %ecx), so if you do something weird, * you're on your own. The only segments that are saved (not counting the * automatic stack and code segment handling) are %ds and %es, and they * point to kernel space. No messing around with %fs here. */ #define SAVE_MOST \ "cld\n\t" \ "push %es\n\t" \ "push %ds\n\t" \ "pushl %eax\n\t" \ "pushl %edx\n\t" \ "pushl %ecx\n\t" \ "movl $" STR(KERNEL_DS) ",%edx\n\t" \ "mov %dx,%ds\n\t" \ "mov %dx,%es\n\t" #define RESTORE_MOST \ "popl %ecx\n\t" \ "popl %edx\n\t" \ "popl %eax\n\t" \ "pop %ds\n\t" \ "pop %es\n\t" \ "iret" /* * The "inb" instructions are not needed, but seem to change the timings * a bit - without them it seems that the harddisk driver won't work on * all hardware. Arghh. */ #define ACK_FIRST(mask) \ "inb $0x21,%al\n\t" \ "jmp 1f\n" \ "1:\tjmp 1f\n" \ "1:\torb $" #mask ","SYMBOL_NAME_STR(cache_21)"\n\t" \ "movb "SYMBOL_NAME_STR(cache_21)",%al\n\t" \ "outb %al,$0x21\n\t" \ "jmp 1f\n" \ "1:\tjmp 1f\n" \ "1:\tmovb $0x20,%al\n\t" \ "outb %al,$0x20\n\t" #define ACK_SECOND(mask) \ "inb $0xA1,%al\n\t" \ "jmp 1f\n" \ "1:\tjmp 1f\n" \ "1:\torb $" #mask ","SYMBOL_NAME_STR(cache_A1)"\n\t" \ "movb "SYMBOL_NAME_STR(cache_A1)",%al\n\t" \ "outb %al,$0xA1\n\t" \ "jmp 1f\n" \ "1:\tjmp 1f\n" \ "1:\tmovb $0x20,%al\n\t" \ "outb %al,$0xA0\n\t" \ "jmp 1f\n" \ "1:\tjmp 1f\n" \ "1:\toutb %al,$0x20\n\t" #define UNBLK_FIRST(mask) \ "inb $0x21,%al\n\t" \ "jmp 1f\n" \ "1:\tjmp 1f\n" \ "1:\tandb $~(" #mask "),"SYMBOL_NAME_STR(cache_21)"\n\t" \ "movb "SYMBOL_NAME_STR(cache_21)",%al\n\t" \ "outb %al,$0x21\n\t" #define UNBLK_SECOND(mask) \ "inb $0xA1,%al\n\t" \ "jmp 1f\n" \ "1:\tjmp 1f\n" \ "1:\tandb $~(" #mask "),"SYMBOL_NAME_STR(cache_A1)"\n\t" \ "movb "SYMBOL_NAME_STR(cache_A1)",%al\n\t" \ "outb %al,$0xA1\n\t" #define IRQ_NAME2(nr) nr##_interrupt(void) #define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr) #define FAST_IRQ_NAME(nr) IRQ_NAME2(fast_IRQ##nr) #define BAD_IRQ_NAME(nr) IRQ_NAME2(bad_IRQ##nr) #ifdef CONFIG_SMP #define GET_PROCESSOR_ID \ "movl "SYMBOL_NAME_STR(apic_reg)", %edx\n\t" \ "movl 32(%edx), %eax\n\t" \ "shrl $24,%eax\n\t" \ "andb $0x0F,%al\n" #define ENTER_KERNEL \ "pushl %eax\n\t" \ "pushl %edx\n\t" \ "pushfl\n\t" \ "cli\n\t" \ GET_PROCESSOR_ID \ "1: " \ "lock\n\t" \ "btsl $0, "SYMBOL_NAME_STR(kernel_flag)"\n\t" \ "jnc 3f\n\t" \ "cmpb "SYMBOL_NAME_STR(active_kernel_processor)", %al\n\t" \ "je 4f\n\t" \ "2: " \ "incl "SYMBOL_NAME_STR(smp_spins)"\n\t" \ "btl %al, "SYMBOL_NAME_STR(smp_invalidate_needed)"\n\t" \ "jnc 5f\n\t" \ "lock\n\t" \ "btrl %al, "SYMBOL_NAME_STR(smp_invalidate_needed)"\n\t" \ "jnc 5f\n\t" \ "movl %cr3,%edx\n\t" \ "movl %edx,%cr3\n" \ "5: btl $0, "SYMBOL_NAME_STR(kernel_flag)"\n\t" \ "jc 2b\n\t" \ "jmp 1b\n\t" \ "3: " \ "movb %al, "SYMBOL_NAME_STR(active_kernel_processor)"\n\t" \ "4: " \ "incl "SYMBOL_NAME_STR(kernel_counter)"\n\t" \ "popfl\n\t" \ "popl %edx\n\t" \ "popl %eax\n\t" #define LEAVE_KERNEL \ "pushfl\n\t" \ "cli\n\t" \ "decl "SYMBOL_NAME_STR(kernel_counter)"\n\t" \ "jnz 1f\n\t" \ "movb $" STR (NO_PROC_ID) ", "SYMBOL_NAME_STR(active_kernel_processor)"\n\t" \ "lock\n\t" \ "btrl $0, "SYMBOL_NAME_STR(kernel_flag)"\n\t" \ "1: " \ "popfl\n\t" /* * the syscall count inc is a gross hack because ret_from_syscall is used by both irq and * syscall return paths (urghh). */ #define BUILD_IRQ(chip,nr,mask) \ asmlinkage void IRQ_NAME(nr); \ asmlinkage void FAST_IRQ_NAME(nr); \ asmlinkage void BAD_IRQ_NAME(nr); \ __asm__( \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(IRQ) #nr "_interrupt:\n\t" \ "pushl $-"#nr"-2\n\t" \ SAVE_ALL \ ENTER_KERNEL \ ACK_##chip(mask) \ "incl "SYMBOL_NAME_STR(intr_count)"\n\t"\ "sti\n\t" \ "movl %esp,%ebx\n\t" \ "pushl %ebx\n\t" \ "pushl $" #nr "\n\t" \ "call "SYMBOL_NAME_STR(do_IRQ)"\n\t" \ "addl $8,%esp\n\t" \ "cli\n\t" \ UNBLK_##chip(mask) \ "decl "SYMBOL_NAME_STR(intr_count)"\n\t" \ "incl "SYMBOL_NAME_STR(syscall_count)"\n\t" \ "jmp ret_from_sys_call\n" \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(fast_IRQ) #nr "_interrupt:\n\t" \ SAVE_MOST \ ENTER_KERNEL \ ACK_##chip(mask) \ "incl "SYMBOL_NAME_STR(intr_count)"\n\t" \ "pushl $" #nr "\n\t" \ "call "SYMBOL_NAME_STR(do_fast_IRQ)"\n\t" \ "addl $4,%esp\n\t" \ "cli\n\t" \ UNBLK_##chip(mask) \ "decl "SYMBOL_NAME_STR(intr_count)"\n\t" \ LEAVE_KERNEL \ RESTORE_MOST \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(bad_IRQ) #nr "_interrupt:\n\t" \ SAVE_MOST \ ENTER_KERNEL \ ACK_##chip(mask) \ LEAVE_KERNEL \ RESTORE_MOST); /* * Message pass must be a fast IRQ.. */ #define BUILD_MSGIRQ(chip,nr,mask) \ asmlinkage void IRQ_NAME(nr); \ asmlinkage void FAST_IRQ_NAME(nr); \ asmlinkage void BAD_IRQ_NAME(nr); \ __asm__( \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(IRQ) #nr "_interrupt:\n\t" \ "pushl $-"#nr"-2\n\t" \ SAVE_ALL \ ENTER_KERNEL \ ACK_##chip(mask) \ "incl "SYMBOL_NAME_STR(intr_count)"\n\t"\ "sti\n\t" \ "movl %esp,%ebx\n\t" \ "pushl %ebx\n\t" \ "pushl $" #nr "\n\t" \ "call "SYMBOL_NAME_STR(do_IRQ)"\n\t" \ "addl $8,%esp\n\t" \ "cli\n\t" \ UNBLK_##chip(mask) \ "decl "SYMBOL_NAME_STR(intr_count)"\n\t" \ "incl "SYMBOL_NAME_STR(syscall_count)"\n\t" \ "jmp ret_from_sys_call\n" \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(fast_IRQ) #nr "_interrupt:\n\t" \ SAVE_MOST \ ACK_##chip(mask) \ "incl "SYMBOL_NAME_STR(ipi_count)"\n\t" \ "pushl $" #nr "\n\t" \ "call "SYMBOL_NAME_STR(do_fast_IRQ)"\n\t" \ "addl $4,%esp\n\t" \ "cli\n\t" \ UNBLK_##chip(mask) \ RESTORE_MOST \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(bad_IRQ) #nr "_interrupt:\n\t" \ SAVE_MOST \ ACK_##chip(mask) \ RESTORE_MOST); #define BUILD_RESCHEDIRQ(nr) \ asmlinkage void IRQ_NAME(nr); \ __asm__( \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(IRQ) #nr "_interrupt:\n\t" \ "pushl $-"#nr"-2\n\t" \ SAVE_ALL \ ENTER_KERNEL \ "incl "SYMBOL_NAME_STR(intr_count)"\n\t"\ "sti\n\t" \ "movl %esp,%ebx\n\t" \ "pushl %ebx\n\t" \ "pushl $" #nr "\n\t" \ "call "SYMBOL_NAME_STR(smp_reschedule_irq)"\n\t" \ "addl $8,%esp\n\t" \ "cli\n\t" \ "decl "SYMBOL_NAME_STR(intr_count)"\n\t" \ "incl "SYMBOL_NAME_STR(syscall_count)"\n\t" \ "jmp ret_from_sys_call\n"); #else #define BUILD_IRQ(chip,nr,mask) \ asmlinkage void IRQ_NAME(nr); \ asmlinkage void FAST_IRQ_NAME(nr); \ asmlinkage void BAD_IRQ_NAME(nr); \ __asm__( \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(IRQ) #nr "_interrupt:\n\t" \ "pushl $-"#nr"-2\n\t" \ SAVE_ALL \ ACK_##chip(mask) \ "incl "SYMBOL_NAME_STR(intr_count)"\n\t"\ "sti\n\t" \ "movl %esp,%ebx\n\t" \ "pushl %ebx\n\t" \ "pushl $" #nr "\n\t" \ "call "SYMBOL_NAME_STR(do_IRQ)"\n\t" \ "addl $8,%esp\n\t" \ "cli\n\t" \ UNBLK_##chip(mask) \ "decl "SYMBOL_NAME_STR(intr_count)"\n\t" \ "jmp ret_from_sys_call\n" \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(fast_IRQ) #nr "_interrupt:\n\t" \ SAVE_MOST \ ACK_##chip(mask) \ "incl "SYMBOL_NAME_STR(intr_count)"\n\t" \ "pushl $" #nr "\n\t" \ "call "SYMBOL_NAME_STR(do_fast_IRQ)"\n\t" \ "addl $4,%esp\n\t" \ "cli\n\t" \ UNBLK_##chip(mask) \ "decl "SYMBOL_NAME_STR(intr_count)"\n\t" \ RESTORE_MOST \ "\n"__ALIGN_STR"\n" \ SYMBOL_NAME_STR(bad_IRQ) #nr "_interrupt:\n\t" \ SAVE_MOST \ ACK_##chip(mask) \ RESTORE_MOST); #endif #endif |