Changeset 9149135 in mainline for arch/ia32/src/smp/apic.c


Ignore:
Timestamp:
2005-11-24T18:43:46Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
78c32b4
Parents:
f701b236
Message:

SMP cleanup continued.
Add nice type for IO APIC ID register.
Replace some magic numbers with more descriptive macros.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/smp/apic.c

    rf701b236 r9149135  
    6565static int apic_poll_errors(void);
    6666
     67#ifdef LAPIC_VERBOSE
    6768static char *delmod_str[] = {
    6869        "Fixed",
     
    105106        "Polarity Low"
    106107};
     108#endif /* LAPIC_VERBOSE */
    107109
    108110/** Initialize APIC on BSP. */
    109111void apic_init(void)
    110112{
    111         __u32 tmp, id, i;
     113        io_apic_id_t idreg;
     114        int i;
    112115
    113116        trap_register(VECTOR_APIC_SPUR, apic_spurious);
     
    124127        io_apic_disable_irqs(0xffff);
    125128        trap_register(VECTOR_CLK, l_apic_timer_interrupt);
    126         for (i=0; i<16; i++) {
     129        for (i = 0; i < IRQ_COUNT; i++) {
    127130                int pin;
    128131       
    129132                if ((pin = smp_irq_to_pin(i)) != -1) {
    130                         io_apic_change_ioredtbl(pin, 0xff, IVT_IRQBASE+i, LOPRI);
     133                        io_apic_change_ioredtbl(pin, DEST_ALL, IVT_IRQBASE+i, LOPRI);
    131134                }
    132135        }
    133136       
    134 
    135137        /*
    136138         * Ensure that io_apic has unique ID.
    137139         */
    138         tmp = io_apic_read(IOAPICID);
    139         id = (tmp >> 24) & 0xf;
    140         if ((1<<id) & apic_id_mask) {
    141                 int i;
    142                
    143                 for (i=0; i<15; i++) {
     140        idreg.value = io_apic_read(IOAPICID);
     141        if ((1<<idreg.apic_id) & apic_id_mask) {        /* see if IO APIC ID is used already */
     142                for (i = 0; i < APIC_ID_COUNT; i++) {
    144143                        if (!((1<<i) & apic_id_mask)) {
    145                                 io_apic_write(IOAPICID, (tmp & (~(0xf<<24))) | (i<<24));
     144                                idreg.apic_id = i;
     145                                io_apic_write(IOAPICID, idreg.value);
    146146                                break;
    147147                        }
     
    153153         */
    154154        l_apic_init();
     155
    155156        l_apic_debug();
    156157}
     
    179180       
    180181        if (esr.send_checksum_error)
    181                 printf("Send CS Error\n");
     182                printf("Send Checksum Error\n");
    182183        if (esr.receive_checksum_error)
    183                 printf("Receive CS Error\n");
     184                printf("Receive Checksum Error\n");
    184185        if (esr.send_accept_error)
    185186                printf("Send Accept Error\n");
     
    217218
    218219        icr.lo = l_apic[ICRlo];
    219         if (icr.lo & SEND_PENDING)
     220        if (icr.delivs == DELIVS_PENDING)
    220221                printf("IPI is pending.\n");
    221222
     
    260261
    261262        icr.lo = l_apic[ICRlo];
    262         if (icr.lo & SEND_PENDING)
     263        if (icr.delivs == DELIVS_PENDING)
    263264                printf("IPI is pending.\n");
    264265
     
    293294        }
    294295       
    295        
    296296        return apic_poll_errors();
    297297}
     
    367367       
    368368        l_apic[ICRT] = t1-t2;
    369        
    370369}
    371370
     
    414413__u8 l_apic_id(void)
    415414{
    416         lapic_id_t lapic_id;
    417        
    418         lapic_id.value = l_apic[L_APIC_ID];
    419         return lapic_id.apic_id;
     415        l_apic_id_t idreg;
     416       
     417        idreg.value = l_apic[L_APIC_ID];
     418        return idreg.apic_id;
    420419}
    421420
     
    491490       
    492491        for (i=0;i<16;i++) {
    493                 if ((irqmask>>i) & 1) {
     492                if (irqmask & (1<<i)) {
    494493                        /*
    495494                         * Mask the signal input in IO APIC if there is a
     
    517516       
    518517        for (i=0;i<16;i++) {
    519                 if ((irqmask>>i) & 1) {
     518                if (irqmask & (1<<i)) {
    520519                        /*
    521520                         * Unmask the signal input in IO APIC if there is a
     
    531530                }
    532531        }
    533 
    534532}
    535533
Note: See TracChangeset for help on using the changeset viewer.