/** * * @brief initialize the MVIC IO APIC and local APIC register sets. * * This routine initializes the Quark D2000 Interrupt Controller (MVIC). * This routine replaces the standard Local APIC / IO APIC init routines. * * @returns: N/A */ int _mvic_init(struct device *unused) { ARG_UNUSED(unused); int32_t ix; /* Interrupt line register index */ uint32_t rteValue; /* value to copy into interrupt line register */ /* * The platform must define the CONFIG_IOAPIC_NUM_RTES macro to indicate the number * of redirection table entries supported by the IOAPIC on the board. * * By default mask all interrupt lines and set default sensitivity to edge. * */ rteValue = IOAPIC_EDGE | IOAPIC_INT_MASK; for (ix = 0; ix < CONFIG_IOAPIC_NUM_RTES; ix++) { _mvic_rte_set(ix, rteValue); } /* enable the MVIC Local APIC */ _loapic_enable(); /* reset the TPR, and TIMER_ICR */ *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_TPR) = (int)0x0; *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_TIMER_ICR) = (int)0x0; /* program Local Vector Table for the Virtual Wire Mode */ /* lock the MVIC timer interrupt, set which IRQ line should be * used for timer interrupts (this is unlike LOAPIC where the * vector is programmed instead). */ __ASSERT_NO_MSG(CONFIG_LOAPIC_TIMER_IRQ <= 15); *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_TIMER) = LOAPIC_LVT_MASKED | CONFIG_LOAPIC_TIMER_IRQ; /* discard a pending interrupt if any */ *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_EOI) = 0; return 0; }
void _mvic_init(void) { int32_t ix; /* Interrupt line register index */ uint32_t rteValue; /* value to copy into interrupt line register */ /* * The BSP must define the IOAPIC_NUM_RTES macro to indicate the number * of redirection table entries supported by the IOAPIC on the board. * * By default mask all interrupt lines and set default sensitivity to edge. * */ rteValue = IOAPIC_EDGE | IOAPIC_INT_MASK; for (ix = 0; ix < IOAPIC_NUM_RTES; ix++) { MvicRteSet(ix, rteValue); } /* enable the MVIC Local APIC */ _loapic_enable(); /* reset the TPR, and TIMER_ICR */ *(volatile int *)(LOAPIC_BASE_ADRS + LOAPIC_TPR) = (int)0x0; *(volatile int *)(LOAPIC_BASE_ADRS + LOAPIC_TIMER_ICR) = (int)0x0; /* program Local Vector Table for the Virtual Wire Mode */ /* lock the MVIC timer interrupt */ *(volatile int *)(LOAPIC_BASE_ADRS + LOAPIC_TIMER) = LOAPIC_LVT_MASKED; /* discard a pending interrupt if any */ *(volatile int *)(LOAPIC_BASE_ADRS + LOAPIC_EOI) = 0; }
int _loapic_init(struct device *unused) { ARG_UNUSED(unused); int32_t loApicMaxLvt; /* local APIC Max LVT */ /* enable the Local APIC */ _loapic_enable(); loApicMaxLvt = (*(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_VER) & LOAPIC_MAXLVT_MASK) >> 16; /* reset the DFR, TPR, TIMER_CONFIG, and TIMER_ICR */ *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_DFR) = (int)0xffffffff; *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_TPR) = (int)0x0; *(volatile int *) (CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_TIMER_CONFIG) = (int)0x0; *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_TIMER_ICR) = (int)0x0; /* program Local Vector Table for the Virtual Wire Mode */ /* set LINT0: extInt, high-polarity, edge-trigger, not-masked */ *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_LINT0) = (*(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_LINT0) & ~(LOAPIC_MODE | LOAPIC_LOW | LOAPIC_LEVEL | LOAPIC_LVT_MASKED)) | (LOAPIC_EXT | LOAPIC_HIGH | LOAPIC_EDGE); /* set LINT1: NMI, high-polarity, edge-trigger, not-masked */ *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_LINT1) = (*(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_LINT1) & ~(LOAPIC_MODE | LOAPIC_LOW | LOAPIC_LEVEL | LOAPIC_LVT_MASKED)) | (LOAPIC_NMI | LOAPIC_HIGH | LOAPIC_EDGE); /* lock the Local APIC interrupts */ *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_TIMER) = LOAPIC_LVT_MASKED; *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_ERROR) = LOAPIC_LVT_MASKED; if (loApicMaxLvt >= LOAPIC_LVT_P6) *(volatile int *) (CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_PMC) = LOAPIC_LVT_MASKED; if (loApicMaxLvt >= LOAPIC_LVT_PENTIUM4) *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_THERMAL) = LOAPIC_LVT_MASKED; #if CONFIG_LOAPIC_SPURIOUS_VECTOR *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_SVR) = (*(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_SVR) & 0xFFFFFF00) | (LOAPIC_SPURIOUS_VECTOR_ID & 0xFF); #endif /* discard a pending interrupt if any */ _loapic_eoi(); return 0; }