Subversion Repositories HelenOS

Rev

Rev 2071 | Rev 2218 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2071 Rev 2101
Line 144... Line 144...
144
 
144
 
145
/** Initialize APIC on BSP. */
145
/** Initialize APIC on BSP. */
146
void apic_init(void)
146
void apic_init(void)
147
{
147
{
148
    io_apic_id_t idreg;
148
    io_apic_id_t idreg;
149
    int i;
149
    unsigned int i;
150
 
150
 
151
    exc_register(VECTOR_APIC_SPUR, "apic_spurious", (iroutine) apic_spurious);
151
    exc_register(VECTOR_APIC_SPUR, "apic_spurious", (iroutine) apic_spurious);
152
 
152
 
153
    enable_irqs_function = io_apic_enable_irqs;
153
    enable_irqs_function = io_apic_enable_irqs;
154
    disable_irqs_function = io_apic_disable_irqs;
154
    disable_irqs_function = io_apic_disable_irqs;
Line 170... Line 170...
170
   
170
   
171
    for (i = 0; i < IRQ_COUNT; i++) {
171
    for (i = 0; i < IRQ_COUNT; i++) {
172
        int pin;
172
        int pin;
173
   
173
   
174
        if ((pin = smp_irq_to_pin(i)) != -1)
174
        if ((pin = smp_irq_to_pin(i)) != -1)
175
            io_apic_change_ioredtbl(pin, DEST_ALL, IVT_IRQBASE+i, LOPRI);
175
            io_apic_change_ioredtbl(pin, DEST_ALL, IVT_IRQBASE + i, LOPRI);
176
    }
176
    }
177
   
177
   
178
    /*
178
    /*
179
     * Ensure that io_apic has unique ID.
179
     * Ensure that io_apic has unique ID.
180
     */
180
     */
Line 532... Line 532...
532
 * @param irqmask Bitmask of IRQs to be masked (0 = do not mask, 1 = mask).
532
 * @param irqmask Bitmask of IRQs to be masked (0 = do not mask, 1 = mask).
533
 */
533
 */
534
void io_apic_disable_irqs(uint16_t irqmask)
534
void io_apic_disable_irqs(uint16_t irqmask)
535
{
535
{
536
    io_redirection_reg_t reg;
536
    io_redirection_reg_t reg;
-
 
537
    unsigned int i;
537
    int i, pin;
538
    int pin;
538
   
539
   
539
    for (i=0;i<16;i++) {
540
    for (i = 0; i < 16; i++) {
540
        if (irqmask & (1<<i)) {
541
        if (irqmask & (1 << i)) {
541
            /*
542
            /*
542
             * Mask the signal input in IO APIC if there is a
543
             * Mask the signal input in IO APIC if there is a
543
             * mapping for the respective IRQ number.
544
             * mapping for the respective IRQ number.
544
             */
545
             */
545
            pin = smp_irq_to_pin(i);
546
            pin = smp_irq_to_pin(i);
546
            if (pin != -1) {
547
            if (pin != -1) {
547
                reg.lo = io_apic_read(IOREDTBL + pin*2);
548
                reg.lo = io_apic_read(IOREDTBL + pin * 2);
548
                reg.masked = true;
549
                reg.masked = true;
549
                io_apic_write(IOREDTBL + pin*2, reg.lo);
550
                io_apic_write(IOREDTBL + pin * 2, reg.lo);
550
            }
551
            }
551
           
552
           
552
        }
553
        }
553
    }
554
    }
554
}
555
}
Line 557... Line 558...
557
 *
558
 *
558
 * @param irqmask Bitmask of IRQs to be unmasked (0 = do not unmask, 1 = unmask).
559
 * @param irqmask Bitmask of IRQs to be unmasked (0 = do not unmask, 1 = unmask).
559
 */
560
 */
560
void io_apic_enable_irqs(uint16_t irqmask)
561
void io_apic_enable_irqs(uint16_t irqmask)
561
{
562
{
-
 
563
    unsigned int i;
562
    int i, pin;
564
    int pin;
563
    io_redirection_reg_t reg;  
565
    io_redirection_reg_t reg;  
564
   
566
   
565
    for (i=0;i<16;i++) {
567
    for (i = 0;i < 16; i++) {
566
        if (irqmask & (1<<i)) {
568
        if (irqmask & (1 << i)) {
567
            /*
569
            /*
568
             * Unmask the signal input in IO APIC if there is a
570
             * Unmask the signal input in IO APIC if there is a
569
             * mapping for the respective IRQ number.
571
             * mapping for the respective IRQ number.
570
             */
572
             */
571
            pin = smp_irq_to_pin(i);
573
            pin = smp_irq_to_pin(i);
572
            if (pin != -1) {
574
            if (pin != -1) {
573
                reg.lo = io_apic_read(IOREDTBL + pin*2);
575
                reg.lo = io_apic_read(IOREDTBL + pin * 2);
574
                reg.masked = false;
576
                reg.masked = false;
575
                io_apic_write(IOREDTBL + pin*2, reg.lo);
577
                io_apic_write(IOREDTBL + pin * 2, reg.lo);
576
            }
578
            }
577
           
579
           
578
        }
580
        }
579
    }
581
    }
580
}
582
}