]> git.sur5r.net Git - u-boot/blobdiff - arch/x86/cpu/interrupts.c
dm: x86: Drop the weak cpu_irq_init() function
[u-boot] / arch / x86 / cpu / interrupts.c
index 853c82f5a7709105b822309abc2edcd44f6e7635..c40200bf8587e86113888c98b40a23e23b17bb33 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <asm/cache.h>
 #include <asm/control_regs.h>
 #include <asm/interrupt.h>
@@ -19,6 +20,7 @@
 #include <asm/processor-flags.h>
 #include <linux/compiler.h>
 #include <asm/msr.h>
+#include <asm/processor.h>
 #include <asm/u-boot-x86.h>
 #include <asm/i8259.h>
 
@@ -46,7 +48,7 @@ static char *exceptions[] = {
        "Invalid TSS",
        "Segment Not Present",
        "Stack Segment Fault",
-       "Gerneral Protection",
+       "General Protection",
        "Page Fault",
        "Reserved",
        "x87 FPU Floating-Point Error",
@@ -102,6 +104,8 @@ static void dump_regs(struct irq_regs *regs)
 
        printf("EIP: %04x:[<%08lx>] EFLAGS: %08lx\n",
                        (u16)cs, eip, eflags);
+       if (gd->flags & GD_FLG_RELOC)
+               printf("Original EIP :[<%08lx>]\n", eip - gd->reloc_off);
 
        printf("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
                regs->eax, regs->ebx, regs->ecx, regs->edx);
@@ -165,7 +169,6 @@ struct idt_entry {
 struct desc_ptr {
        unsigned short size;
        unsigned long address;
-       unsigned short segment;
 } __packed;
 
 struct idt_entry idt[256] __aligned(16);
@@ -202,14 +205,13 @@ int cpu_init_interrupts(void)
        for (i = 0; i < 256; i++) {
                idt[i].access = 0x8e;
                idt[i].res = 0;
-               idt[i].selector = 0x10;
+               idt[i].selector = X86_GDT_ENTRY_32BIT_CS * X86_GDT_ENTRY_SIZE;
                set_vector(i, irq_entry);
                irq_entry += irq_entry_size;
        }
 
-       idt_ptr.size = 256 * 8;
+       idt_ptr.size = 256 * 8 - 1;
        idt_ptr.address = (unsigned long) idt;
-       idt_ptr.segment = 0x18;
 
        load_idt(&idt_ptr);
 
@@ -243,10 +245,23 @@ int disable_interrupts(void)
 
 int interrupt_init(void)
 {
+       struct udevice *dev;
+       int ret;
+
+       /* Try to set up the interrupt router, but don't require one */
+       ret = uclass_first_device(UCLASS_IRQ, &dev);
+       if (ret && ret != -ENODEV)
+               return ret;
+
+       /*
+        * When running as an EFI application we are not in control of
+        * interrupts and should leave them alone.
+        */
+#ifndef CONFIG_EFI_APP
        /* Just in case... */
        disable_interrupts();
 
-#ifdef CONFIG_SYS_PCAT_INTERRUPTS
+#ifdef CONFIG_I8259_PIC
        /* Initialize the master/slave i8259 pic */
        i8259_init();
 #endif
@@ -254,8 +269,15 @@ int interrupt_init(void)
        /* Initialize core interrupt and exception functionality of CPU */
        cpu_init_interrupts();
 
-       /* It is now safe to enable interrupts */
-       enable_interrupts();
+       /*
+        * It is now safe to enable interrupts.
+        *
+        * TODO(sjg@chromium.org): But we don't handle these correctly when
+        * booted from EFI.
+        */
+       if (ll_boot_init())
+               enable_interrupts();
+#endif
 
        return 0;
 }