wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 1 | /* |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 2 | * (C) Copyright 2008 |
| 3 | * Graeme Russ, graeme.russ@gmail.com. |
| 4 | * |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 5 | * (C) Copyright 2002 |
| 6 | * Daniel Engström, Omicron Ceti AB, daniel@omicron.se. |
| 7 | * |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 8 | * Portions of this file are derived from the Linux kernel source |
| 9 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 10 | * |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 11 | * See file CREDITS for list of people who contributed to this |
| 12 | * project. |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License as |
| 16 | * published by the Free Software Foundation; either version 2 of |
| 17 | * the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 27 | * MA 02111-1307 USA |
| 28 | */ |
| 29 | |
| 30 | #include <common.h> |
Graeme Russ | 0c8c62e | 2008-12-07 10:29:01 +1100 | [diff] [blame] | 31 | #include <asm/interrupt.h> |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 32 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 33 | #define DECLARE_INTERRUPT(x) \ |
| 34 | ".globl irq_"#x"\n" \ |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 35 | ".hidden irq_"#x"\n" \ |
| 36 | ".type irq_"#x", @function\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 37 | "irq_"#x":\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 38 | "pushl $"#x"\n" \ |
| 39 | "jmp irq_common_entry\n" |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 40 | |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 41 | /* |
| 42 | * Volatile isn't enough to prevent the compiler from reordering the |
| 43 | * read/write functions for the control registers and messing everything up. |
| 44 | * A memory clobber would solve the problem, but would prevent reordering of |
| 45 | * all loads stores around it, which can hurt performance. Solution is to |
| 46 | * use a variable and mimic reads and writes to it to enforce serialization |
| 47 | */ |
| 48 | static unsigned long __force_order; |
| 49 | |
| 50 | static inline unsigned long read_cr0(void) |
| 51 | { |
| 52 | unsigned long val; |
| 53 | asm volatile("mov %%cr0,%0\n\t" : "=r" (val), "=m" (__force_order)); |
| 54 | return val; |
| 55 | } |
| 56 | |
| 57 | static inline unsigned long read_cr2(void) |
| 58 | { |
| 59 | unsigned long val; |
| 60 | asm volatile("mov %%cr2,%0\n\t" : "=r" (val), "=m" (__force_order)); |
| 61 | return val; |
| 62 | } |
| 63 | |
| 64 | static inline unsigned long read_cr3(void) |
| 65 | { |
| 66 | unsigned long val; |
| 67 | asm volatile("mov %%cr3,%0\n\t" : "=r" (val), "=m" (__force_order)); |
| 68 | return val; |
| 69 | } |
| 70 | |
| 71 | static inline unsigned long read_cr4(void) |
| 72 | { |
| 73 | unsigned long val; |
| 74 | asm volatile("mov %%cr4,%0\n\t" : "=r" (val), "=m" (__force_order)); |
| 75 | return val; |
| 76 | } |
| 77 | |
| 78 | static inline unsigned long get_debugreg(int regno) |
| 79 | { |
| 80 | unsigned long val = 0; /* Damn you, gcc! */ |
| 81 | |
| 82 | switch (regno) { |
| 83 | case 0: |
| 84 | asm("mov %%db0, %0" :"=r" (val)); |
| 85 | break; |
| 86 | case 1: |
| 87 | asm("mov %%db1, %0" :"=r" (val)); |
| 88 | break; |
| 89 | case 2: |
| 90 | asm("mov %%db2, %0" :"=r" (val)); |
| 91 | break; |
| 92 | case 3: |
| 93 | asm("mov %%db3, %0" :"=r" (val)); |
| 94 | break; |
| 95 | case 6: |
| 96 | asm("mov %%db6, %0" :"=r" (val)); |
| 97 | break; |
| 98 | case 7: |
| 99 | asm("mov %%db7, %0" :"=r" (val)); |
| 100 | break; |
| 101 | default: |
| 102 | val = 0; |
| 103 | } |
| 104 | return val; |
| 105 | } |
| 106 | |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame^] | 107 | void dump_regs(struct irq_regs *regs) |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 108 | { |
| 109 | unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L; |
| 110 | unsigned long d0, d1, d2, d3, d6, d7; |
| 111 | |
| 112 | printf("EIP: %04x:[<%08lx>] EFLAGS: %08lx\n", |
| 113 | (u16)regs->xcs, regs->eip, regs->eflags); |
| 114 | |
| 115 | printf("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n", |
| 116 | regs->eax, regs->ebx, regs->ecx, regs->edx); |
| 117 | printf("ESI: %08lx EDI: %08lx EBP: %08lx ESP: %08lx\n", |
| 118 | regs->esi, regs->edi, regs->ebp, regs->esp); |
| 119 | printf(" DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x\n", |
| 120 | (u16)regs->xds, (u16)regs->xes, (u16)regs->xfs, (u16)regs->xgs, (u16)regs->xss); |
| 121 | |
| 122 | cr0 = read_cr0(); |
| 123 | cr2 = read_cr2(); |
| 124 | cr3 = read_cr3(); |
| 125 | cr4 = read_cr4(); |
| 126 | |
| 127 | printf("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", |
| 128 | cr0, cr2, cr3, cr4); |
| 129 | |
| 130 | d0 = get_debugreg(0); |
| 131 | d1 = get_debugreg(1); |
| 132 | d2 = get_debugreg(2); |
| 133 | d3 = get_debugreg(3); |
| 134 | |
| 135 | printf("DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n", |
| 136 | d0, d1, d2, d3); |
| 137 | |
| 138 | d6 = get_debugreg(6); |
| 139 | d7 = get_debugreg(7); |
| 140 | printf("DR6: %08lx DR7: %08lx\n", |
| 141 | d6, d7); |
| 142 | } |
| 143 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 144 | struct idt_entry { |
| 145 | u16 base_low; |
| 146 | u16 selector; |
| 147 | u8 res; |
| 148 | u8 access; |
| 149 | u16 base_high; |
| 150 | } __attribute__ ((packed)); |
| 151 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 152 | struct desc_ptr { |
| 153 | unsigned short size; |
| 154 | unsigned long address; |
| 155 | unsigned short segment; |
| 156 | } __attribute__((packed)); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 157 | |
| 158 | struct idt_entry idt[256]; |
| 159 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 160 | struct desc_ptr idt_ptr; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 161 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 162 | static inline void load_idt(const struct desc_ptr *dtr) |
| 163 | { |
| 164 | asm volatile("cs lidt %0"::"m" (*dtr)); |
| 165 | } |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 166 | |
Graeme Russ | 77290ee | 2009-02-24 21:13:40 +1100 | [diff] [blame] | 167 | void set_vector(u8 intnum, void *routine) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 168 | { |
Graeme Russ | 078395c | 2009-11-24 20:04:21 +1100 | [diff] [blame] | 169 | idt[intnum].base_high = (u16)((u32)(routine) >> 16); |
| 170 | idt[intnum].base_low = (u16)((u32)(routine) & 0xffff); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 173 | void irq_0(void); |
| 174 | void irq_1(void); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 175 | |
Graeme Russ | 77290ee | 2009-02-24 21:13:40 +1100 | [diff] [blame] | 176 | int cpu_init_interrupts(void) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 177 | { |
| 178 | int i; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 179 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 180 | int irq_entry_size = irq_1 - irq_0; |
| 181 | void *irq_entry = (void *)irq_0; |
| 182 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 183 | /* Just in case... */ |
| 184 | disable_interrupts(); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 185 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 186 | /* Setup the IDT */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 187 | for (i=0;i<256;i++) { |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 188 | idt[i].access = 0x8e; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 189 | idt[i].res = 0; |
| 190 | idt[i].selector = 0x10; |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 191 | set_vector(i, irq_entry); |
| 192 | irq_entry += irq_entry_size; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 193 | } |
| 194 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 195 | idt_ptr.size = 256 * 8; |
| 196 | idt_ptr.address = (unsigned long) idt; |
| 197 | idt_ptr.segment = 0x18; |
| 198 | |
| 199 | load_idt(&idt_ptr); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 200 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 201 | /* It is now safe to enable interrupts */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 202 | enable_interrupts(); |
| 203 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 204 | return 0; |
| 205 | } |
| 206 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 207 | void __do_irq(int irq) |
| 208 | { |
| 209 | printf("Unhandled IRQ : %d\n", irq); |
| 210 | } |
| 211 | void do_irq(int irq) __attribute__((weak, alias("__do_irq"))); |
| 212 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 213 | void enable_interrupts(void) |
| 214 | { |
| 215 | asm("sti\n"); |
| 216 | } |
| 217 | |
| 218 | int disable_interrupts(void) |
| 219 | { |
| 220 | long flags; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 221 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 222 | asm volatile ("pushfl ; popl %0 ; cli\n" : "=g" (flags) : ); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 223 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 224 | return (flags&0x200); /* IE flags is bit 9 */ |
| 225 | } |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 226 | |
| 227 | /* IRQ Low-Level Service Routine */ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame^] | 228 | void irq_llsr(struct irq_regs *regs) |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 229 | { |
| 230 | /* |
| 231 | * For detailed description of each exception, refer to: |
| 232 | * Intel® 64 and IA-32 Architectures Software Developer's Manual |
| 233 | * Volume 1: Basic Architecture |
| 234 | * Order Number: 253665-029US, November 2008 |
| 235 | * Table 6-1. Exceptions and Interrupts |
| 236 | */ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame^] | 237 | switch (regs->irq_id) { |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 238 | case 0x00: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 239 | printf("Divide Error (Division by zero)\n"); |
| 240 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 241 | while(1); |
| 242 | break; |
| 243 | case 0x01: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 244 | printf("Debug Interrupt (Single step)\n"); |
| 245 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 246 | break; |
| 247 | case 0x02: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 248 | printf("NMI Interrupt\n"); |
| 249 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 250 | break; |
| 251 | case 0x03: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 252 | printf("Breakpoint\n"); |
| 253 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 254 | break; |
| 255 | case 0x04: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 256 | printf("Overflow\n"); |
| 257 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 258 | while(1); |
| 259 | break; |
| 260 | case 0x05: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 261 | printf("BOUND Range Exceeded\n"); |
| 262 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 263 | while(1); |
| 264 | break; |
| 265 | case 0x06: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 266 | printf("Invalid Opcode (UnDefined Opcode)\n"); |
| 267 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 268 | while(1); |
| 269 | break; |
| 270 | case 0x07: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 271 | printf("Device Not Available (No Math Coprocessor)\n"); |
| 272 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 273 | while(1); |
| 274 | break; |
| 275 | case 0x08: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 276 | printf("Double fault\n"); |
| 277 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 278 | while(1); |
| 279 | break; |
| 280 | case 0x09: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 281 | printf("Co-processor segment overrun\n"); |
| 282 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 283 | while(1); |
| 284 | break; |
| 285 | case 0x0a: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 286 | printf("Invalid TSS\n"); |
| 287 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 288 | break; |
| 289 | case 0x0b: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 290 | printf("Segment Not Present\n"); |
| 291 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 292 | while(1); |
| 293 | break; |
| 294 | case 0x0c: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 295 | printf("Stack Segment Fault\n"); |
| 296 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 297 | while(1); |
| 298 | break; |
| 299 | case 0x0d: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 300 | printf("General Protection\n"); |
| 301 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 302 | break; |
| 303 | case 0x0e: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 304 | printf("Page fault\n"); |
| 305 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 306 | while(1); |
| 307 | break; |
| 308 | case 0x0f: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 309 | printf("Floating-Point Error (Math Fault)\n"); |
| 310 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 311 | break; |
| 312 | case 0x10: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 313 | printf("Alignment check\n"); |
| 314 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 315 | break; |
| 316 | case 0x11: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 317 | printf("Machine Check\n"); |
| 318 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 319 | break; |
| 320 | case 0x12: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 321 | printf("SIMD Floating-Point Exception\n"); |
| 322 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 323 | break; |
| 324 | case 0x13: |
| 325 | case 0x14: |
| 326 | case 0x15: |
| 327 | case 0x16: |
| 328 | case 0x17: |
| 329 | case 0x18: |
| 330 | case 0x19: |
| 331 | case 0x1a: |
| 332 | case 0x1b: |
| 333 | case 0x1c: |
| 334 | case 0x1d: |
| 335 | case 0x1e: |
| 336 | case 0x1f: |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 337 | printf("Reserved Exception\n"); |
| 338 | dump_regs(regs); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 339 | break; |
| 340 | |
| 341 | default: |
| 342 | /* Hardware or User IRQ */ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame^] | 343 | do_irq(regs->irq_id); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | |
| 347 | /* |
| 348 | * OK - This looks really horrible, but it serves a purpose - It helps create |
| 349 | * fully relocatable code. |
| 350 | * - The call to irq_llsr will be a relative jump |
| 351 | * - The IRQ entries will be guaranteed to be in order |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 352 | * Interrupt entries are now very small (a push and a jump) but they are |
| 353 | * now slower (all registers pushed on stack which provides complete |
| 354 | * crash dumps in the low level handlers |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame^] | 355 | * |
| 356 | * Interrupt Entry Point: |
| 357 | * - Interrupt has caused eflags, CS and EIP to be pushed |
| 358 | * - Interrupt Vector Handler has pushed orig_eax |
| 359 | * - pt_regs.esp needs to be adjusted by 40 bytes: |
| 360 | * 12 bytes pushed by CPU (EFLAGSF, CS, EIP) |
| 361 | * 4 bytes pushed by vector handler (irq_id) |
| 362 | * 24 bytes pushed before SP (SS, GS, FS, ES, DS, EAX) |
| 363 | * NOTE: Only longs are pushed on/popped off the stack! |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 364 | */ |
| 365 | asm(".globl irq_common_entry\n" \ |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 366 | ".hidden irq_common_entry\n" \ |
| 367 | ".type irq_common_entry, @function\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 368 | "irq_common_entry:\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 369 | "cld\n" \ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame^] | 370 | "pushl %ss\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 371 | "pushl %gs\n" \ |
| 372 | "pushl %fs\n" \ |
| 373 | "pushl %es\n" \ |
| 374 | "pushl %ds\n" \ |
| 375 | "pushl %eax\n" \ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame^] | 376 | "movl %esp, %eax\n" \ |
| 377 | "addl $40, %eax\n" \ |
| 378 | "pushl %eax\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 379 | "pushl %ebp\n" \ |
| 380 | "pushl %edi\n" \ |
| 381 | "pushl %esi\n" \ |
| 382 | "pushl %edx\n" \ |
| 383 | "pushl %ecx\n" \ |
| 384 | "pushl %ebx\n" \ |
| 385 | "mov %esp, %eax\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 386 | "call irq_llsr\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 387 | "popl %ebx\n" \ |
| 388 | "popl %ecx\n" \ |
| 389 | "popl %edx\n" \ |
| 390 | "popl %esi\n" \ |
| 391 | "popl %edi\n" \ |
| 392 | "popl %ebp\n" \ |
| 393 | "popl %eax\n" \ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame^] | 394 | "popl %eax\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 395 | "popl %ds\n" \ |
| 396 | "popl %es\n" \ |
| 397 | "popl %fs\n" \ |
| 398 | "popl %gs\n" \ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame^] | 399 | "popl %ss\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 400 | "add $4, %esp\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 401 | "iret\n" \ |
| 402 | DECLARE_INTERRUPT(0) \ |
| 403 | DECLARE_INTERRUPT(1) \ |
| 404 | DECLARE_INTERRUPT(2) \ |
| 405 | DECLARE_INTERRUPT(3) \ |
| 406 | DECLARE_INTERRUPT(4) \ |
| 407 | DECLARE_INTERRUPT(5) \ |
| 408 | DECLARE_INTERRUPT(6) \ |
| 409 | DECLARE_INTERRUPT(7) \ |
| 410 | DECLARE_INTERRUPT(8) \ |
| 411 | DECLARE_INTERRUPT(9) \ |
| 412 | DECLARE_INTERRUPT(10) \ |
| 413 | DECLARE_INTERRUPT(11) \ |
| 414 | DECLARE_INTERRUPT(12) \ |
| 415 | DECLARE_INTERRUPT(13) \ |
| 416 | DECLARE_INTERRUPT(14) \ |
| 417 | DECLARE_INTERRUPT(15) \ |
| 418 | DECLARE_INTERRUPT(16) \ |
| 419 | DECLARE_INTERRUPT(17) \ |
| 420 | DECLARE_INTERRUPT(18) \ |
| 421 | DECLARE_INTERRUPT(19) \ |
| 422 | DECLARE_INTERRUPT(20) \ |
| 423 | DECLARE_INTERRUPT(21) \ |
| 424 | DECLARE_INTERRUPT(22) \ |
| 425 | DECLARE_INTERRUPT(23) \ |
| 426 | DECLARE_INTERRUPT(24) \ |
| 427 | DECLARE_INTERRUPT(25) \ |
| 428 | DECLARE_INTERRUPT(26) \ |
| 429 | DECLARE_INTERRUPT(27) \ |
| 430 | DECLARE_INTERRUPT(28) \ |
| 431 | DECLARE_INTERRUPT(29) \ |
| 432 | DECLARE_INTERRUPT(30) \ |
| 433 | DECLARE_INTERRUPT(31) \ |
| 434 | DECLARE_INTERRUPT(32) \ |
| 435 | DECLARE_INTERRUPT(33) \ |
| 436 | DECLARE_INTERRUPT(34) \ |
| 437 | DECLARE_INTERRUPT(35) \ |
| 438 | DECLARE_INTERRUPT(36) \ |
| 439 | DECLARE_INTERRUPT(37) \ |
| 440 | DECLARE_INTERRUPT(38) \ |
| 441 | DECLARE_INTERRUPT(39) \ |
| 442 | DECLARE_INTERRUPT(40) \ |
| 443 | DECLARE_INTERRUPT(41) \ |
| 444 | DECLARE_INTERRUPT(42) \ |
| 445 | DECLARE_INTERRUPT(43) \ |
| 446 | DECLARE_INTERRUPT(44) \ |
| 447 | DECLARE_INTERRUPT(45) \ |
| 448 | DECLARE_INTERRUPT(46) \ |
| 449 | DECLARE_INTERRUPT(47) \ |
| 450 | DECLARE_INTERRUPT(48) \ |
| 451 | DECLARE_INTERRUPT(49) \ |
| 452 | DECLARE_INTERRUPT(50) \ |
| 453 | DECLARE_INTERRUPT(51) \ |
| 454 | DECLARE_INTERRUPT(52) \ |
| 455 | DECLARE_INTERRUPT(53) \ |
| 456 | DECLARE_INTERRUPT(54) \ |
| 457 | DECLARE_INTERRUPT(55) \ |
| 458 | DECLARE_INTERRUPT(56) \ |
| 459 | DECLARE_INTERRUPT(57) \ |
| 460 | DECLARE_INTERRUPT(58) \ |
| 461 | DECLARE_INTERRUPT(59) \ |
| 462 | DECLARE_INTERRUPT(60) \ |
| 463 | DECLARE_INTERRUPT(61) \ |
| 464 | DECLARE_INTERRUPT(62) \ |
| 465 | DECLARE_INTERRUPT(63) \ |
| 466 | DECLARE_INTERRUPT(64) \ |
| 467 | DECLARE_INTERRUPT(65) \ |
| 468 | DECLARE_INTERRUPT(66) \ |
| 469 | DECLARE_INTERRUPT(67) \ |
| 470 | DECLARE_INTERRUPT(68) \ |
| 471 | DECLARE_INTERRUPT(69) \ |
| 472 | DECLARE_INTERRUPT(70) \ |
| 473 | DECLARE_INTERRUPT(71) \ |
| 474 | DECLARE_INTERRUPT(72) \ |
| 475 | DECLARE_INTERRUPT(73) \ |
| 476 | DECLARE_INTERRUPT(74) \ |
| 477 | DECLARE_INTERRUPT(75) \ |
| 478 | DECLARE_INTERRUPT(76) \ |
| 479 | DECLARE_INTERRUPT(77) \ |
| 480 | DECLARE_INTERRUPT(78) \ |
| 481 | DECLARE_INTERRUPT(79) \ |
| 482 | DECLARE_INTERRUPT(80) \ |
| 483 | DECLARE_INTERRUPT(81) \ |
| 484 | DECLARE_INTERRUPT(82) \ |
| 485 | DECLARE_INTERRUPT(83) \ |
| 486 | DECLARE_INTERRUPT(84) \ |
| 487 | DECLARE_INTERRUPT(85) \ |
| 488 | DECLARE_INTERRUPT(86) \ |
| 489 | DECLARE_INTERRUPT(87) \ |
| 490 | DECLARE_INTERRUPT(88) \ |
| 491 | DECLARE_INTERRUPT(89) \ |
| 492 | DECLARE_INTERRUPT(90) \ |
| 493 | DECLARE_INTERRUPT(91) \ |
| 494 | DECLARE_INTERRUPT(92) \ |
| 495 | DECLARE_INTERRUPT(93) \ |
| 496 | DECLARE_INTERRUPT(94) \ |
| 497 | DECLARE_INTERRUPT(95) \ |
| 498 | DECLARE_INTERRUPT(97) \ |
| 499 | DECLARE_INTERRUPT(96) \ |
| 500 | DECLARE_INTERRUPT(98) \ |
| 501 | DECLARE_INTERRUPT(99) \ |
| 502 | DECLARE_INTERRUPT(100) \ |
| 503 | DECLARE_INTERRUPT(101) \ |
| 504 | DECLARE_INTERRUPT(102) \ |
| 505 | DECLARE_INTERRUPT(103) \ |
| 506 | DECLARE_INTERRUPT(104) \ |
| 507 | DECLARE_INTERRUPT(105) \ |
| 508 | DECLARE_INTERRUPT(106) \ |
| 509 | DECLARE_INTERRUPT(107) \ |
| 510 | DECLARE_INTERRUPT(108) \ |
| 511 | DECLARE_INTERRUPT(109) \ |
| 512 | DECLARE_INTERRUPT(110) \ |
| 513 | DECLARE_INTERRUPT(111) \ |
| 514 | DECLARE_INTERRUPT(112) \ |
| 515 | DECLARE_INTERRUPT(113) \ |
| 516 | DECLARE_INTERRUPT(114) \ |
| 517 | DECLARE_INTERRUPT(115) \ |
| 518 | DECLARE_INTERRUPT(116) \ |
| 519 | DECLARE_INTERRUPT(117) \ |
| 520 | DECLARE_INTERRUPT(118) \ |
| 521 | DECLARE_INTERRUPT(119) \ |
| 522 | DECLARE_INTERRUPT(120) \ |
| 523 | DECLARE_INTERRUPT(121) \ |
| 524 | DECLARE_INTERRUPT(122) \ |
| 525 | DECLARE_INTERRUPT(123) \ |
| 526 | DECLARE_INTERRUPT(124) \ |
| 527 | DECLARE_INTERRUPT(125) \ |
| 528 | DECLARE_INTERRUPT(126) \ |
| 529 | DECLARE_INTERRUPT(127) \ |
| 530 | DECLARE_INTERRUPT(128) \ |
| 531 | DECLARE_INTERRUPT(129) \ |
| 532 | DECLARE_INTERRUPT(130) \ |
| 533 | DECLARE_INTERRUPT(131) \ |
| 534 | DECLARE_INTERRUPT(132) \ |
| 535 | DECLARE_INTERRUPT(133) \ |
| 536 | DECLARE_INTERRUPT(134) \ |
| 537 | DECLARE_INTERRUPT(135) \ |
| 538 | DECLARE_INTERRUPT(136) \ |
| 539 | DECLARE_INTERRUPT(137) \ |
| 540 | DECLARE_INTERRUPT(138) \ |
| 541 | DECLARE_INTERRUPT(139) \ |
| 542 | DECLARE_INTERRUPT(140) \ |
| 543 | DECLARE_INTERRUPT(141) \ |
| 544 | DECLARE_INTERRUPT(142) \ |
| 545 | DECLARE_INTERRUPT(143) \ |
| 546 | DECLARE_INTERRUPT(144) \ |
| 547 | DECLARE_INTERRUPT(145) \ |
| 548 | DECLARE_INTERRUPT(146) \ |
| 549 | DECLARE_INTERRUPT(147) \ |
| 550 | DECLARE_INTERRUPT(148) \ |
| 551 | DECLARE_INTERRUPT(149) \ |
| 552 | DECLARE_INTERRUPT(150) \ |
| 553 | DECLARE_INTERRUPT(151) \ |
| 554 | DECLARE_INTERRUPT(152) \ |
| 555 | DECLARE_INTERRUPT(153) \ |
| 556 | DECLARE_INTERRUPT(154) \ |
| 557 | DECLARE_INTERRUPT(155) \ |
| 558 | DECLARE_INTERRUPT(156) \ |
| 559 | DECLARE_INTERRUPT(157) \ |
| 560 | DECLARE_INTERRUPT(158) \ |
| 561 | DECLARE_INTERRUPT(159) \ |
| 562 | DECLARE_INTERRUPT(160) \ |
| 563 | DECLARE_INTERRUPT(161) \ |
| 564 | DECLARE_INTERRUPT(162) \ |
| 565 | DECLARE_INTERRUPT(163) \ |
| 566 | DECLARE_INTERRUPT(164) \ |
| 567 | DECLARE_INTERRUPT(165) \ |
| 568 | DECLARE_INTERRUPT(166) \ |
| 569 | DECLARE_INTERRUPT(167) \ |
| 570 | DECLARE_INTERRUPT(168) \ |
| 571 | DECLARE_INTERRUPT(169) \ |
| 572 | DECLARE_INTERRUPT(170) \ |
| 573 | DECLARE_INTERRUPT(171) \ |
| 574 | DECLARE_INTERRUPT(172) \ |
| 575 | DECLARE_INTERRUPT(173) \ |
| 576 | DECLARE_INTERRUPT(174) \ |
| 577 | DECLARE_INTERRUPT(175) \ |
| 578 | DECLARE_INTERRUPT(176) \ |
| 579 | DECLARE_INTERRUPT(177) \ |
| 580 | DECLARE_INTERRUPT(178) \ |
| 581 | DECLARE_INTERRUPT(179) \ |
| 582 | DECLARE_INTERRUPT(180) \ |
| 583 | DECLARE_INTERRUPT(181) \ |
| 584 | DECLARE_INTERRUPT(182) \ |
| 585 | DECLARE_INTERRUPT(183) \ |
| 586 | DECLARE_INTERRUPT(184) \ |
| 587 | DECLARE_INTERRUPT(185) \ |
| 588 | DECLARE_INTERRUPT(186) \ |
| 589 | DECLARE_INTERRUPT(187) \ |
| 590 | DECLARE_INTERRUPT(188) \ |
| 591 | DECLARE_INTERRUPT(189) \ |
| 592 | DECLARE_INTERRUPT(190) \ |
| 593 | DECLARE_INTERRUPT(191) \ |
| 594 | DECLARE_INTERRUPT(192) \ |
| 595 | DECLARE_INTERRUPT(193) \ |
| 596 | DECLARE_INTERRUPT(194) \ |
| 597 | DECLARE_INTERRUPT(195) \ |
| 598 | DECLARE_INTERRUPT(196) \ |
| 599 | DECLARE_INTERRUPT(197) \ |
| 600 | DECLARE_INTERRUPT(198) \ |
| 601 | DECLARE_INTERRUPT(199) \ |
| 602 | DECLARE_INTERRUPT(200) \ |
| 603 | DECLARE_INTERRUPT(201) \ |
| 604 | DECLARE_INTERRUPT(202) \ |
| 605 | DECLARE_INTERRUPT(203) \ |
| 606 | DECLARE_INTERRUPT(204) \ |
| 607 | DECLARE_INTERRUPT(205) \ |
| 608 | DECLARE_INTERRUPT(206) \ |
| 609 | DECLARE_INTERRUPT(207) \ |
| 610 | DECLARE_INTERRUPT(208) \ |
| 611 | DECLARE_INTERRUPT(209) \ |
| 612 | DECLARE_INTERRUPT(210) \ |
| 613 | DECLARE_INTERRUPT(211) \ |
| 614 | DECLARE_INTERRUPT(212) \ |
| 615 | DECLARE_INTERRUPT(213) \ |
| 616 | DECLARE_INTERRUPT(214) \ |
| 617 | DECLARE_INTERRUPT(215) \ |
| 618 | DECLARE_INTERRUPT(216) \ |
| 619 | DECLARE_INTERRUPT(217) \ |
| 620 | DECLARE_INTERRUPT(218) \ |
| 621 | DECLARE_INTERRUPT(219) \ |
| 622 | DECLARE_INTERRUPT(220) \ |
| 623 | DECLARE_INTERRUPT(221) \ |
| 624 | DECLARE_INTERRUPT(222) \ |
| 625 | DECLARE_INTERRUPT(223) \ |
| 626 | DECLARE_INTERRUPT(224) \ |
| 627 | DECLARE_INTERRUPT(225) \ |
| 628 | DECLARE_INTERRUPT(226) \ |
| 629 | DECLARE_INTERRUPT(227) \ |
| 630 | DECLARE_INTERRUPT(228) \ |
| 631 | DECLARE_INTERRUPT(229) \ |
| 632 | DECLARE_INTERRUPT(230) \ |
| 633 | DECLARE_INTERRUPT(231) \ |
| 634 | DECLARE_INTERRUPT(232) \ |
| 635 | DECLARE_INTERRUPT(233) \ |
| 636 | DECLARE_INTERRUPT(234) \ |
| 637 | DECLARE_INTERRUPT(235) \ |
| 638 | DECLARE_INTERRUPT(236) \ |
| 639 | DECLARE_INTERRUPT(237) \ |
| 640 | DECLARE_INTERRUPT(238) \ |
| 641 | DECLARE_INTERRUPT(239) \ |
| 642 | DECLARE_INTERRUPT(240) \ |
| 643 | DECLARE_INTERRUPT(241) \ |
| 644 | DECLARE_INTERRUPT(242) \ |
| 645 | DECLARE_INTERRUPT(243) \ |
| 646 | DECLARE_INTERRUPT(244) \ |
| 647 | DECLARE_INTERRUPT(245) \ |
| 648 | DECLARE_INTERRUPT(246) \ |
| 649 | DECLARE_INTERRUPT(247) \ |
| 650 | DECLARE_INTERRUPT(248) \ |
| 651 | DECLARE_INTERRUPT(249) \ |
| 652 | DECLARE_INTERRUPT(250) \ |
| 653 | DECLARE_INTERRUPT(251) \ |
| 654 | DECLARE_INTERRUPT(252) \ |
| 655 | DECLARE_INTERRUPT(253) \ |
| 656 | DECLARE_INTERRUPT(254) \ |
| 657 | DECLARE_INTERRUPT(255)); |