wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 1 | /* |
Graeme Russ | 45fc1d8 | 2011-04-13 19:43:26 +1000 | [diff] [blame] | 2 | * (C) Copyright 2008-2011 |
| 3 | * Graeme Russ, <graeme.russ@gmail.com> |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 4 | * |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 5 | * (C) Copyright 2002 |
Albert ARIBAUD | 60fbc8d | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 6 | * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se> |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 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 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <common.h> |
Simon Glass | 754f55e | 2016-01-19 21:32:26 -0700 | [diff] [blame] | 15 | #include <dm.h> |
Stefan Reinauer | 2acf848 | 2012-12-02 04:49:50 +0000 | [diff] [blame] | 16 | #include <asm/cache.h> |
| 17 | #include <asm/control_regs.h> |
Bin Meng | d538c36 | 2016-05-22 01:45:33 -0700 | [diff] [blame] | 18 | #include <asm/i8259.h> |
Graeme Russ | 0c8c62e | 2008-12-07 10:29:01 +1100 | [diff] [blame] | 19 | #include <asm/interrupt.h> |
Graeme Russ | 6869980 | 2011-02-12 15:11:28 +1100 | [diff] [blame] | 20 | #include <asm/io.h> |
Bin Meng | d538c36 | 2016-05-22 01:45:33 -0700 | [diff] [blame] | 21 | #include <asm/lapic.h> |
Vadim Bendebury | 6ab0258 | 2012-12-03 13:59:20 +0000 | [diff] [blame] | 22 | #include <asm/msr.h> |
Bin Meng | d538c36 | 2016-05-22 01:45:33 -0700 | [diff] [blame] | 23 | #include <asm/processor-flags.h> |
Simon Glass | c4b9ef8 | 2015-07-31 09:31:32 -0600 | [diff] [blame] | 24 | #include <asm/processor.h> |
Vadim Bendebury | 6ab0258 | 2012-12-03 13:59:20 +0000 | [diff] [blame] | 25 | #include <asm/u-boot-x86.h> |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 26 | |
Simon Glass | bb6306c | 2013-04-17 16:13:33 +0000 | [diff] [blame] | 27 | DECLARE_GLOBAL_DATA_PTR; |
| 28 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 29 | #define DECLARE_INTERRUPT(x) \ |
| 30 | ".globl irq_"#x"\n" \ |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 31 | ".hidden irq_"#x"\n" \ |
| 32 | ".type irq_"#x", @function\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 33 | "irq_"#x":\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 34 | "pushl $"#x"\n" \ |
| 35 | "jmp irq_common_entry\n" |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 36 | |
Bin Meng | fdebed8 | 2015-07-10 10:51:23 +0800 | [diff] [blame] | 37 | static char *exceptions[] = { |
| 38 | "Divide Error", |
| 39 | "Debug", |
| 40 | "NMI Interrupt", |
| 41 | "Breakpoint", |
| 42 | "Overflow", |
| 43 | "BOUND Range Exceeded", |
| 44 | "Invalid Opcode (Undefined Opcode)", |
| 45 | "Device Not Avaiable (No Math Coprocessor)", |
| 46 | "Double Fault", |
| 47 | "Coprocessor Segment Overrun", |
| 48 | "Invalid TSS", |
| 49 | "Segment Not Present", |
| 50 | "Stack Segment Fault", |
Simon Glass | c4b9ef8 | 2015-07-31 09:31:32 -0600 | [diff] [blame] | 51 | "General Protection", |
Bin Meng | fdebed8 | 2015-07-10 10:51:23 +0800 | [diff] [blame] | 52 | "Page Fault", |
| 53 | "Reserved", |
| 54 | "x87 FPU Floating-Point Error", |
| 55 | "Alignment Check", |
| 56 | "Machine Check", |
| 57 | "SIMD Floating-Point Exception", |
| 58 | "Virtualization Exception", |
| 59 | "Reserved", |
| 60 | "Reserved", |
| 61 | "Reserved", |
| 62 | "Reserved", |
| 63 | "Reserved", |
| 64 | "Reserved", |
| 65 | "Reserved", |
| 66 | "Reserved", |
| 67 | "Reserved", |
| 68 | "Reserved", |
| 69 | "Reserved" |
| 70 | }; |
| 71 | |
Simon Glass | 8337433 | 2014-11-06 13:20:08 -0700 | [diff] [blame] | 72 | static void dump_regs(struct irq_regs *regs) |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 73 | { |
Bin Meng | 9ff054b | 2015-07-10 10:38:32 +0800 | [diff] [blame] | 74 | unsigned long cs, eip, eflags; |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 75 | unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L; |
| 76 | unsigned long d0, d1, d2, d3, d6, d7; |
Graeme Russ | 6869980 | 2011-02-12 15:11:28 +1100 | [diff] [blame] | 77 | unsigned long sp; |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 78 | |
Bin Meng | 9ff054b | 2015-07-10 10:38:32 +0800 | [diff] [blame] | 79 | /* |
| 80 | * Some exceptions cause an error code to be saved on the current stack |
| 81 | * after the EIP value. We should extract CS/EIP/EFLAGS from different |
| 82 | * position on the stack based on the exception number. |
| 83 | */ |
| 84 | switch (regs->irq_id) { |
| 85 | case EXC_DF: |
| 86 | case EXC_TS: |
| 87 | case EXC_NP: |
| 88 | case EXC_SS: |
| 89 | case EXC_GP: |
| 90 | case EXC_PF: |
| 91 | case EXC_AC: |
| 92 | cs = regs->context.ctx2.xcs; |
| 93 | eip = regs->context.ctx2.eip; |
| 94 | eflags = regs->context.ctx2.eflags; |
| 95 | /* We should fix up the ESP due to error code */ |
| 96 | regs->esp += 4; |
| 97 | break; |
| 98 | default: |
| 99 | cs = regs->context.ctx1.xcs; |
| 100 | eip = regs->context.ctx1.eip; |
| 101 | eflags = regs->context.ctx1.eflags; |
| 102 | break; |
| 103 | } |
| 104 | |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 105 | printf("EIP: %04x:[<%08lx>] EFLAGS: %08lx\n", |
Bin Meng | 9ff054b | 2015-07-10 10:38:32 +0800 | [diff] [blame] | 106 | (u16)cs, eip, eflags); |
Simon Glass | 79dd434 | 2015-08-10 22:02:54 -0600 | [diff] [blame] | 107 | if (gd->flags & GD_FLG_RELOC) |
| 108 | printf("Original EIP :[<%08lx>]\n", eip - gd->reloc_off); |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 109 | |
| 110 | printf("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n", |
| 111 | regs->eax, regs->ebx, regs->ecx, regs->edx); |
| 112 | printf("ESI: %08lx EDI: %08lx EBP: %08lx ESP: %08lx\n", |
| 113 | regs->esi, regs->edi, regs->ebp, regs->esp); |
| 114 | printf(" DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x\n", |
Graeme Russ | fdee8b1 | 2011-11-08 02:33:13 +0000 | [diff] [blame] | 115 | (u16)regs->xds, (u16)regs->xes, (u16)regs->xfs, |
| 116 | (u16)regs->xgs, (u16)regs->xss); |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 117 | |
| 118 | cr0 = read_cr0(); |
| 119 | cr2 = read_cr2(); |
| 120 | cr3 = read_cr3(); |
| 121 | cr4 = read_cr4(); |
| 122 | |
| 123 | printf("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", |
| 124 | cr0, cr2, cr3, cr4); |
| 125 | |
| 126 | d0 = get_debugreg(0); |
| 127 | d1 = get_debugreg(1); |
| 128 | d2 = get_debugreg(2); |
| 129 | d3 = get_debugreg(3); |
| 130 | |
| 131 | printf("DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n", |
| 132 | d0, d1, d2, d3); |
| 133 | |
| 134 | d6 = get_debugreg(6); |
| 135 | d7 = get_debugreg(7); |
| 136 | printf("DR6: %08lx DR7: %08lx\n", |
| 137 | d6, d7); |
Graeme Russ | 6869980 | 2011-02-12 15:11:28 +1100 | [diff] [blame] | 138 | |
| 139 | printf("Stack:\n"); |
| 140 | sp = regs->esp; |
| 141 | |
| 142 | sp += 64; |
| 143 | |
| 144 | while (sp > (regs->esp - 16)) { |
| 145 | if (sp == regs->esp) |
| 146 | printf("--->"); |
| 147 | else |
| 148 | printf(" "); |
| 149 | printf("0x%8.8lx : 0x%8.8lx\n", sp, (ulong)readl(sp)); |
| 150 | sp -= 4; |
| 151 | } |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 152 | } |
| 153 | |
Bin Meng | fdebed8 | 2015-07-10 10:51:23 +0800 | [diff] [blame] | 154 | static void do_exception(struct irq_regs *regs) |
| 155 | { |
| 156 | printf("%s\n", exceptions[regs->irq_id]); |
| 157 | dump_regs(regs); |
| 158 | hang(); |
| 159 | } |
| 160 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 161 | struct idt_entry { |
| 162 | u16 base_low; |
| 163 | u16 selector; |
| 164 | u8 res; |
| 165 | u8 access; |
| 166 | u16 base_high; |
Graeme Russ | fdee8b1 | 2011-11-08 02:33:13 +0000 | [diff] [blame] | 167 | } __packed; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 168 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 169 | struct desc_ptr { |
| 170 | unsigned short size; |
| 171 | unsigned long address; |
Graeme Russ | fdee8b1 | 2011-11-08 02:33:13 +0000 | [diff] [blame] | 172 | } __packed; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 173 | |
Graeme Russ | af3f2c8 | 2011-12-19 14:26:18 +1100 | [diff] [blame] | 174 | struct idt_entry idt[256] __aligned(16); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 175 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 176 | struct desc_ptr idt_ptr; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 177 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 178 | static inline void load_idt(const struct desc_ptr *dtr) |
| 179 | { |
Graeme Russ | fdee8b1 | 2011-11-08 02:33:13 +0000 | [diff] [blame] | 180 | asm volatile("cs lidt %0" : : "m" (*dtr)); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 181 | } |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 182 | |
Graeme Russ | 77290ee | 2009-02-24 21:13:40 +1100 | [diff] [blame] | 183 | void set_vector(u8 intnum, void *routine) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 184 | { |
Graeme Russ | 078395c | 2009-11-24 20:04:21 +1100 | [diff] [blame] | 185 | idt[intnum].base_high = (u16)((u32)(routine) >> 16); |
| 186 | idt[intnum].base_low = (u16)((u32)(routine) & 0xffff); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 187 | } |
| 188 | |
Graeme Russ | fdee8b1 | 2011-11-08 02:33:13 +0000 | [diff] [blame] | 189 | /* |
| 190 | * Ideally these would be defined static to avoid a checkpatch warning, but |
| 191 | * the compiler cannot see them in the inline asm and complains that they |
| 192 | * aren't defined |
| 193 | */ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 194 | void irq_0(void); |
| 195 | void irq_1(void); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 196 | |
Graeme Russ | 77290ee | 2009-02-24 21:13:40 +1100 | [diff] [blame] | 197 | int cpu_init_interrupts(void) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 198 | { |
| 199 | int i; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 200 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 201 | int irq_entry_size = irq_1 - irq_0; |
| 202 | void *irq_entry = (void *)irq_0; |
| 203 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 204 | /* Setup the IDT */ |
Graeme Russ | fdee8b1 | 2011-11-08 02:33:13 +0000 | [diff] [blame] | 205 | for (i = 0; i < 256; i++) { |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 206 | idt[i].access = 0x8e; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 207 | idt[i].res = 0; |
Simon Glass | c4b9ef8 | 2015-07-31 09:31:32 -0600 | [diff] [blame] | 208 | idt[i].selector = X86_GDT_ENTRY_32BIT_CS * X86_GDT_ENTRY_SIZE; |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 209 | set_vector(i, irq_entry); |
| 210 | irq_entry += irq_entry_size; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Simon Glass | c4b9ef8 | 2015-07-31 09:31:32 -0600 | [diff] [blame] | 213 | idt_ptr.size = 256 * 8 - 1; |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 214 | idt_ptr.address = (unsigned long) idt; |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 215 | |
| 216 | load_idt(&idt_ptr); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 217 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 218 | return 0; |
| 219 | } |
| 220 | |
Simon Glass | 98d7e98 | 2015-04-28 20:25:16 -0600 | [diff] [blame] | 221 | void *x86_get_idt(void) |
| 222 | { |
| 223 | return &idt_ptr; |
| 224 | } |
| 225 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 226 | void __do_irq(int irq) |
| 227 | { |
| 228 | printf("Unhandled IRQ : %d\n", irq); |
| 229 | } |
| 230 | void do_irq(int irq) __attribute__((weak, alias("__do_irq"))); |
| 231 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 232 | void enable_interrupts(void) |
| 233 | { |
| 234 | asm("sti\n"); |
| 235 | } |
| 236 | |
| 237 | int disable_interrupts(void) |
| 238 | { |
| 239 | long flags; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 240 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 241 | asm volatile ("pushfl ; popl %0 ; cli\n" : "=g" (flags) : ); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 242 | |
Graeme Russ | fdee8b1 | 2011-11-08 02:33:13 +0000 | [diff] [blame] | 243 | return flags & X86_EFLAGS_IF; |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 244 | } |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 245 | |
Bin Meng | cb9d9cb | 2014-11-20 16:11:16 +0800 | [diff] [blame] | 246 | int interrupt_init(void) |
| 247 | { |
Simon Glass | 754f55e | 2016-01-19 21:32:26 -0700 | [diff] [blame] | 248 | struct udevice *dev; |
| 249 | int ret; |
| 250 | |
| 251 | /* Try to set up the interrupt router, but don't require one */ |
Simon Glass | c7298e7 | 2016-02-11 13:23:26 -0700 | [diff] [blame] | 252 | ret = uclass_first_device_err(UCLASS_IRQ, &dev); |
Simon Glass | 754f55e | 2016-01-19 21:32:26 -0700 | [diff] [blame] | 253 | if (ret && ret != -ENODEV) |
| 254 | return ret; |
| 255 | |
Ben Stoltz | ab76a47 | 2015-08-04 12:33:46 -0600 | [diff] [blame] | 256 | /* |
| 257 | * When running as an EFI application we are not in control of |
| 258 | * interrupts and should leave them alone. |
| 259 | */ |
| 260 | #ifndef CONFIG_EFI_APP |
Bin Meng | cb9d9cb | 2014-11-20 16:11:16 +0800 | [diff] [blame] | 261 | /* Just in case... */ |
| 262 | disable_interrupts(); |
| 263 | |
Bin Meng | b29a08c | 2015-10-22 19:13:30 -0700 | [diff] [blame] | 264 | #ifdef CONFIG_I8259_PIC |
Bin Meng | cb9d9cb | 2014-11-20 16:11:16 +0800 | [diff] [blame] | 265 | /* Initialize the master/slave i8259 pic */ |
| 266 | i8259_init(); |
| 267 | #endif |
| 268 | |
Bin Meng | d538c36 | 2016-05-22 01:45:33 -0700 | [diff] [blame] | 269 | lapic_setup(); |
| 270 | |
Bin Meng | cb9d9cb | 2014-11-20 16:11:16 +0800 | [diff] [blame] | 271 | /* Initialize core interrupt and exception functionality of CPU */ |
| 272 | cpu_init_interrupts(); |
| 273 | |
Simon Glass | 2b6d80b | 2015-08-04 12:34:00 -0600 | [diff] [blame] | 274 | /* |
| 275 | * It is now safe to enable interrupts. |
| 276 | * |
| 277 | * TODO(sjg@chromium.org): But we don't handle these correctly when |
| 278 | * booted from EFI. |
| 279 | */ |
| 280 | if (ll_boot_init()) |
| 281 | enable_interrupts(); |
Ben Stoltz | ab76a47 | 2015-08-04 12:33:46 -0600 | [diff] [blame] | 282 | #endif |
Bin Meng | cb9d9cb | 2014-11-20 16:11:16 +0800 | [diff] [blame] | 283 | |
| 284 | return 0; |
| 285 | } |
| 286 | |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 287 | /* IRQ Low-Level Service Routine */ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame] | 288 | void irq_llsr(struct irq_regs *regs) |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 289 | { |
| 290 | /* |
| 291 | * For detailed description of each exception, refer to: |
Albert ARIBAUD | 60fbc8d | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 292 | * Intel® 64 and IA-32 Architectures Software Developer's Manual |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 293 | * Volume 1: Basic Architecture |
| 294 | * Order Number: 253665-029US, November 2008 |
| 295 | * Table 6-1. Exceptions and Interrupts |
| 296 | */ |
Bin Meng | fdebed8 | 2015-07-10 10:51:23 +0800 | [diff] [blame] | 297 | if (regs->irq_id < 32) { |
| 298 | /* Architecture defined exception */ |
| 299 | do_exception(regs); |
| 300 | } else { |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 301 | /* Hardware or User IRQ */ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame] | 302 | do_irq(regs->irq_id); |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | |
| 306 | /* |
| 307 | * OK - This looks really horrible, but it serves a purpose - It helps create |
| 308 | * fully relocatable code. |
| 309 | * - The call to irq_llsr will be a relative jump |
| 310 | * - The IRQ entries will be guaranteed to be in order |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 311 | * Interrupt entries are now very small (a push and a jump) but they are |
| 312 | * now slower (all registers pushed on stack which provides complete |
| 313 | * crash dumps in the low level handlers |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame] | 314 | * |
| 315 | * Interrupt Entry Point: |
| 316 | * - Interrupt has caused eflags, CS and EIP to be pushed |
| 317 | * - Interrupt Vector Handler has pushed orig_eax |
| 318 | * - pt_regs.esp needs to be adjusted by 40 bytes: |
| 319 | * 12 bytes pushed by CPU (EFLAGSF, CS, EIP) |
| 320 | * 4 bytes pushed by vector handler (irq_id) |
| 321 | * 24 bytes pushed before SP (SS, GS, FS, ES, DS, EAX) |
| 322 | * NOTE: Only longs are pushed on/popped off the stack! |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 323 | */ |
| 324 | asm(".globl irq_common_entry\n" \ |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 325 | ".hidden irq_common_entry\n" \ |
| 326 | ".type irq_common_entry, @function\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 327 | "irq_common_entry:\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 328 | "cld\n" \ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame] | 329 | "pushl %ss\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 330 | "pushl %gs\n" \ |
| 331 | "pushl %fs\n" \ |
| 332 | "pushl %es\n" \ |
| 333 | "pushl %ds\n" \ |
| 334 | "pushl %eax\n" \ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame] | 335 | "movl %esp, %eax\n" \ |
| 336 | "addl $40, %eax\n" \ |
| 337 | "pushl %eax\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 338 | "pushl %ebp\n" \ |
| 339 | "pushl %edi\n" \ |
| 340 | "pushl %esi\n" \ |
| 341 | "pushl %edx\n" \ |
| 342 | "pushl %ecx\n" \ |
| 343 | "pushl %ebx\n" \ |
| 344 | "mov %esp, %eax\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 345 | "call irq_llsr\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 346 | "popl %ebx\n" \ |
| 347 | "popl %ecx\n" \ |
| 348 | "popl %edx\n" \ |
| 349 | "popl %esi\n" \ |
| 350 | "popl %edi\n" \ |
| 351 | "popl %ebp\n" \ |
| 352 | "popl %eax\n" \ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame] | 353 | "popl %eax\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 354 | "popl %ds\n" \ |
| 355 | "popl %es\n" \ |
| 356 | "popl %fs\n" \ |
| 357 | "popl %gs\n" \ |
Graeme Russ | 4326153 | 2010-10-07 20:03:23 +1100 | [diff] [blame] | 358 | "popl %ss\n" \ |
Graeme Russ | c39acb4 | 2010-04-24 00:05:38 +1000 | [diff] [blame] | 359 | "add $4, %esp\n" \ |
Graeme Russ | d11b085 | 2009-11-24 20:04:18 +1100 | [diff] [blame] | 360 | "iret\n" \ |
| 361 | DECLARE_INTERRUPT(0) \ |
| 362 | DECLARE_INTERRUPT(1) \ |
| 363 | DECLARE_INTERRUPT(2) \ |
| 364 | DECLARE_INTERRUPT(3) \ |
| 365 | DECLARE_INTERRUPT(4) \ |
| 366 | DECLARE_INTERRUPT(5) \ |
| 367 | DECLARE_INTERRUPT(6) \ |
| 368 | DECLARE_INTERRUPT(7) \ |
| 369 | DECLARE_INTERRUPT(8) \ |
| 370 | DECLARE_INTERRUPT(9) \ |
| 371 | DECLARE_INTERRUPT(10) \ |
| 372 | DECLARE_INTERRUPT(11) \ |
| 373 | DECLARE_INTERRUPT(12) \ |
| 374 | DECLARE_INTERRUPT(13) \ |
| 375 | DECLARE_INTERRUPT(14) \ |
| 376 | DECLARE_INTERRUPT(15) \ |
| 377 | DECLARE_INTERRUPT(16) \ |
| 378 | DECLARE_INTERRUPT(17) \ |
| 379 | DECLARE_INTERRUPT(18) \ |
| 380 | DECLARE_INTERRUPT(19) \ |
| 381 | DECLARE_INTERRUPT(20) \ |
| 382 | DECLARE_INTERRUPT(21) \ |
| 383 | DECLARE_INTERRUPT(22) \ |
| 384 | DECLARE_INTERRUPT(23) \ |
| 385 | DECLARE_INTERRUPT(24) \ |
| 386 | DECLARE_INTERRUPT(25) \ |
| 387 | DECLARE_INTERRUPT(26) \ |
| 388 | DECLARE_INTERRUPT(27) \ |
| 389 | DECLARE_INTERRUPT(28) \ |
| 390 | DECLARE_INTERRUPT(29) \ |
| 391 | DECLARE_INTERRUPT(30) \ |
| 392 | DECLARE_INTERRUPT(31) \ |
| 393 | DECLARE_INTERRUPT(32) \ |
| 394 | DECLARE_INTERRUPT(33) \ |
| 395 | DECLARE_INTERRUPT(34) \ |
| 396 | DECLARE_INTERRUPT(35) \ |
| 397 | DECLARE_INTERRUPT(36) \ |
| 398 | DECLARE_INTERRUPT(37) \ |
| 399 | DECLARE_INTERRUPT(38) \ |
| 400 | DECLARE_INTERRUPT(39) \ |
| 401 | DECLARE_INTERRUPT(40) \ |
| 402 | DECLARE_INTERRUPT(41) \ |
| 403 | DECLARE_INTERRUPT(42) \ |
| 404 | DECLARE_INTERRUPT(43) \ |
| 405 | DECLARE_INTERRUPT(44) \ |
| 406 | DECLARE_INTERRUPT(45) \ |
| 407 | DECLARE_INTERRUPT(46) \ |
| 408 | DECLARE_INTERRUPT(47) \ |
| 409 | DECLARE_INTERRUPT(48) \ |
| 410 | DECLARE_INTERRUPT(49) \ |
| 411 | DECLARE_INTERRUPT(50) \ |
| 412 | DECLARE_INTERRUPT(51) \ |
| 413 | DECLARE_INTERRUPT(52) \ |
| 414 | DECLARE_INTERRUPT(53) \ |
| 415 | DECLARE_INTERRUPT(54) \ |
| 416 | DECLARE_INTERRUPT(55) \ |
| 417 | DECLARE_INTERRUPT(56) \ |
| 418 | DECLARE_INTERRUPT(57) \ |
| 419 | DECLARE_INTERRUPT(58) \ |
| 420 | DECLARE_INTERRUPT(59) \ |
| 421 | DECLARE_INTERRUPT(60) \ |
| 422 | DECLARE_INTERRUPT(61) \ |
| 423 | DECLARE_INTERRUPT(62) \ |
| 424 | DECLARE_INTERRUPT(63) \ |
| 425 | DECLARE_INTERRUPT(64) \ |
| 426 | DECLARE_INTERRUPT(65) \ |
| 427 | DECLARE_INTERRUPT(66) \ |
| 428 | DECLARE_INTERRUPT(67) \ |
| 429 | DECLARE_INTERRUPT(68) \ |
| 430 | DECLARE_INTERRUPT(69) \ |
| 431 | DECLARE_INTERRUPT(70) \ |
| 432 | DECLARE_INTERRUPT(71) \ |
| 433 | DECLARE_INTERRUPT(72) \ |
| 434 | DECLARE_INTERRUPT(73) \ |
| 435 | DECLARE_INTERRUPT(74) \ |
| 436 | DECLARE_INTERRUPT(75) \ |
| 437 | DECLARE_INTERRUPT(76) \ |
| 438 | DECLARE_INTERRUPT(77) \ |
| 439 | DECLARE_INTERRUPT(78) \ |
| 440 | DECLARE_INTERRUPT(79) \ |
| 441 | DECLARE_INTERRUPT(80) \ |
| 442 | DECLARE_INTERRUPT(81) \ |
| 443 | DECLARE_INTERRUPT(82) \ |
| 444 | DECLARE_INTERRUPT(83) \ |
| 445 | DECLARE_INTERRUPT(84) \ |
| 446 | DECLARE_INTERRUPT(85) \ |
| 447 | DECLARE_INTERRUPT(86) \ |
| 448 | DECLARE_INTERRUPT(87) \ |
| 449 | DECLARE_INTERRUPT(88) \ |
| 450 | DECLARE_INTERRUPT(89) \ |
| 451 | DECLARE_INTERRUPT(90) \ |
| 452 | DECLARE_INTERRUPT(91) \ |
| 453 | DECLARE_INTERRUPT(92) \ |
| 454 | DECLARE_INTERRUPT(93) \ |
| 455 | DECLARE_INTERRUPT(94) \ |
| 456 | DECLARE_INTERRUPT(95) \ |
| 457 | DECLARE_INTERRUPT(97) \ |
| 458 | DECLARE_INTERRUPT(96) \ |
| 459 | DECLARE_INTERRUPT(98) \ |
| 460 | DECLARE_INTERRUPT(99) \ |
| 461 | DECLARE_INTERRUPT(100) \ |
| 462 | DECLARE_INTERRUPT(101) \ |
| 463 | DECLARE_INTERRUPT(102) \ |
| 464 | DECLARE_INTERRUPT(103) \ |
| 465 | DECLARE_INTERRUPT(104) \ |
| 466 | DECLARE_INTERRUPT(105) \ |
| 467 | DECLARE_INTERRUPT(106) \ |
| 468 | DECLARE_INTERRUPT(107) \ |
| 469 | DECLARE_INTERRUPT(108) \ |
| 470 | DECLARE_INTERRUPT(109) \ |
| 471 | DECLARE_INTERRUPT(110) \ |
| 472 | DECLARE_INTERRUPT(111) \ |
| 473 | DECLARE_INTERRUPT(112) \ |
| 474 | DECLARE_INTERRUPT(113) \ |
| 475 | DECLARE_INTERRUPT(114) \ |
| 476 | DECLARE_INTERRUPT(115) \ |
| 477 | DECLARE_INTERRUPT(116) \ |
| 478 | DECLARE_INTERRUPT(117) \ |
| 479 | DECLARE_INTERRUPT(118) \ |
| 480 | DECLARE_INTERRUPT(119) \ |
| 481 | DECLARE_INTERRUPT(120) \ |
| 482 | DECLARE_INTERRUPT(121) \ |
| 483 | DECLARE_INTERRUPT(122) \ |
| 484 | DECLARE_INTERRUPT(123) \ |
| 485 | DECLARE_INTERRUPT(124) \ |
| 486 | DECLARE_INTERRUPT(125) \ |
| 487 | DECLARE_INTERRUPT(126) \ |
| 488 | DECLARE_INTERRUPT(127) \ |
| 489 | DECLARE_INTERRUPT(128) \ |
| 490 | DECLARE_INTERRUPT(129) \ |
| 491 | DECLARE_INTERRUPT(130) \ |
| 492 | DECLARE_INTERRUPT(131) \ |
| 493 | DECLARE_INTERRUPT(132) \ |
| 494 | DECLARE_INTERRUPT(133) \ |
| 495 | DECLARE_INTERRUPT(134) \ |
| 496 | DECLARE_INTERRUPT(135) \ |
| 497 | DECLARE_INTERRUPT(136) \ |
| 498 | DECLARE_INTERRUPT(137) \ |
| 499 | DECLARE_INTERRUPT(138) \ |
| 500 | DECLARE_INTERRUPT(139) \ |
| 501 | DECLARE_INTERRUPT(140) \ |
| 502 | DECLARE_INTERRUPT(141) \ |
| 503 | DECLARE_INTERRUPT(142) \ |
| 504 | DECLARE_INTERRUPT(143) \ |
| 505 | DECLARE_INTERRUPT(144) \ |
| 506 | DECLARE_INTERRUPT(145) \ |
| 507 | DECLARE_INTERRUPT(146) \ |
| 508 | DECLARE_INTERRUPT(147) \ |
| 509 | DECLARE_INTERRUPT(148) \ |
| 510 | DECLARE_INTERRUPT(149) \ |
| 511 | DECLARE_INTERRUPT(150) \ |
| 512 | DECLARE_INTERRUPT(151) \ |
| 513 | DECLARE_INTERRUPT(152) \ |
| 514 | DECLARE_INTERRUPT(153) \ |
| 515 | DECLARE_INTERRUPT(154) \ |
| 516 | DECLARE_INTERRUPT(155) \ |
| 517 | DECLARE_INTERRUPT(156) \ |
| 518 | DECLARE_INTERRUPT(157) \ |
| 519 | DECLARE_INTERRUPT(158) \ |
| 520 | DECLARE_INTERRUPT(159) \ |
| 521 | DECLARE_INTERRUPT(160) \ |
| 522 | DECLARE_INTERRUPT(161) \ |
| 523 | DECLARE_INTERRUPT(162) \ |
| 524 | DECLARE_INTERRUPT(163) \ |
| 525 | DECLARE_INTERRUPT(164) \ |
| 526 | DECLARE_INTERRUPT(165) \ |
| 527 | DECLARE_INTERRUPT(166) \ |
| 528 | DECLARE_INTERRUPT(167) \ |
| 529 | DECLARE_INTERRUPT(168) \ |
| 530 | DECLARE_INTERRUPT(169) \ |
| 531 | DECLARE_INTERRUPT(170) \ |
| 532 | DECLARE_INTERRUPT(171) \ |
| 533 | DECLARE_INTERRUPT(172) \ |
| 534 | DECLARE_INTERRUPT(173) \ |
| 535 | DECLARE_INTERRUPT(174) \ |
| 536 | DECLARE_INTERRUPT(175) \ |
| 537 | DECLARE_INTERRUPT(176) \ |
| 538 | DECLARE_INTERRUPT(177) \ |
| 539 | DECLARE_INTERRUPT(178) \ |
| 540 | DECLARE_INTERRUPT(179) \ |
| 541 | DECLARE_INTERRUPT(180) \ |
| 542 | DECLARE_INTERRUPT(181) \ |
| 543 | DECLARE_INTERRUPT(182) \ |
| 544 | DECLARE_INTERRUPT(183) \ |
| 545 | DECLARE_INTERRUPT(184) \ |
| 546 | DECLARE_INTERRUPT(185) \ |
| 547 | DECLARE_INTERRUPT(186) \ |
| 548 | DECLARE_INTERRUPT(187) \ |
| 549 | DECLARE_INTERRUPT(188) \ |
| 550 | DECLARE_INTERRUPT(189) \ |
| 551 | DECLARE_INTERRUPT(190) \ |
| 552 | DECLARE_INTERRUPT(191) \ |
| 553 | DECLARE_INTERRUPT(192) \ |
| 554 | DECLARE_INTERRUPT(193) \ |
| 555 | DECLARE_INTERRUPT(194) \ |
| 556 | DECLARE_INTERRUPT(195) \ |
| 557 | DECLARE_INTERRUPT(196) \ |
| 558 | DECLARE_INTERRUPT(197) \ |
| 559 | DECLARE_INTERRUPT(198) \ |
| 560 | DECLARE_INTERRUPT(199) \ |
| 561 | DECLARE_INTERRUPT(200) \ |
| 562 | DECLARE_INTERRUPT(201) \ |
| 563 | DECLARE_INTERRUPT(202) \ |
| 564 | DECLARE_INTERRUPT(203) \ |
| 565 | DECLARE_INTERRUPT(204) \ |
| 566 | DECLARE_INTERRUPT(205) \ |
| 567 | DECLARE_INTERRUPT(206) \ |
| 568 | DECLARE_INTERRUPT(207) \ |
| 569 | DECLARE_INTERRUPT(208) \ |
| 570 | DECLARE_INTERRUPT(209) \ |
| 571 | DECLARE_INTERRUPT(210) \ |
| 572 | DECLARE_INTERRUPT(211) \ |
| 573 | DECLARE_INTERRUPT(212) \ |
| 574 | DECLARE_INTERRUPT(213) \ |
| 575 | DECLARE_INTERRUPT(214) \ |
| 576 | DECLARE_INTERRUPT(215) \ |
| 577 | DECLARE_INTERRUPT(216) \ |
| 578 | DECLARE_INTERRUPT(217) \ |
| 579 | DECLARE_INTERRUPT(218) \ |
| 580 | DECLARE_INTERRUPT(219) \ |
| 581 | DECLARE_INTERRUPT(220) \ |
| 582 | DECLARE_INTERRUPT(221) \ |
| 583 | DECLARE_INTERRUPT(222) \ |
| 584 | DECLARE_INTERRUPT(223) \ |
| 585 | DECLARE_INTERRUPT(224) \ |
| 586 | DECLARE_INTERRUPT(225) \ |
| 587 | DECLARE_INTERRUPT(226) \ |
| 588 | DECLARE_INTERRUPT(227) \ |
| 589 | DECLARE_INTERRUPT(228) \ |
| 590 | DECLARE_INTERRUPT(229) \ |
| 591 | DECLARE_INTERRUPT(230) \ |
| 592 | DECLARE_INTERRUPT(231) \ |
| 593 | DECLARE_INTERRUPT(232) \ |
| 594 | DECLARE_INTERRUPT(233) \ |
| 595 | DECLARE_INTERRUPT(234) \ |
| 596 | DECLARE_INTERRUPT(235) \ |
| 597 | DECLARE_INTERRUPT(236) \ |
| 598 | DECLARE_INTERRUPT(237) \ |
| 599 | DECLARE_INTERRUPT(238) \ |
| 600 | DECLARE_INTERRUPT(239) \ |
| 601 | DECLARE_INTERRUPT(240) \ |
| 602 | DECLARE_INTERRUPT(241) \ |
| 603 | DECLARE_INTERRUPT(242) \ |
| 604 | DECLARE_INTERRUPT(243) \ |
| 605 | DECLARE_INTERRUPT(244) \ |
| 606 | DECLARE_INTERRUPT(245) \ |
| 607 | DECLARE_INTERRUPT(246) \ |
| 608 | DECLARE_INTERRUPT(247) \ |
| 609 | DECLARE_INTERRUPT(248) \ |
| 610 | DECLARE_INTERRUPT(249) \ |
| 611 | DECLARE_INTERRUPT(250) \ |
| 612 | DECLARE_INTERRUPT(251) \ |
| 613 | DECLARE_INTERRUPT(252) \ |
| 614 | DECLARE_INTERRUPT(253) \ |
| 615 | DECLARE_INTERRUPT(254) \ |
| 616 | DECLARE_INTERRUPT(255)); |