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