Changeset 9149135 in mainline


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.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/include/interrupt.h

    rf701b236 r9149135  
    3535#define IVT_ITEMS               IDT_ITEMS
    3636
     37#define EXC_COUNT       32
     38#define IRQ_COUNT       16
     39
    3740#define IVT_EXCBASE             0
    38 #define EXCLAST                 31
    39 
    40 #define IVT_IRQBASE             (IVT_EXCBASE+EXCLAST+1)
    41 #define IRQLAST                 15
    42 
    43 #define IVT_FREEBASE            (IVT_IRQBASE+IRQLAST+1)
     41#define IVT_IRQBASE             (IVT_EXCBASE+EXC_COUNT)
     42#define IVT_FREEBASE            (IVT_IRQBASE+IRQ_COUNT)
    4443
    4544#define IRQ_CLK         0
  • arch/ia32/include/smp/apic.h

    rf701b236 r9149135  
    3636#define LOPRI           (1<<0)
    3737
     38#define APIC_ID_COUNT   16
     39
    3840/* local APIC macros */
    3941#define IPI_INIT        0
     
    8688#define TIMER_PERIODIC  0x1
    8789
    88 #define SEND_PENDING    (1<<12)
     90/** Delivery status. */
     91#define DELIVS_IDLE     0x0
     92#define DELIVS_PENDING  0x1
     93
     94/** Destination masks. */
     95#define DEST_ALL        0xff
    8996
    9097/** Interrupt Command Register. */
     
    225232/** Local APIC ID Register. */
    226233#define L_APIC_ID       (0x020/sizeof(__u32))
    227 union lapic_id {
     234union l_apic_id {
    228235        __u32 value;
    229236        struct {
     
    232239        } __attribute__ ((packed));
    233240};
    234 typedef union lapic_id lapic_id_t;
     241typedef union l_apic_id l_apic_id_t;
    235242
    236243/* Local APIC Version Register */
     
    285292       
    286293} __attribute__ ((packed));
    287 
    288294typedef struct io_redirection_reg io_redirection_reg_t;
     295
     296
     297/** IO APIC Identification Register. */
     298union io_apic_id {
     299        __u32 value;
     300        struct {
     301                unsigned : 24;          /**< Reserved. */
     302                unsigned apic_id : 4;   /**< IO APIC ID. */
     303                unsigned : 4;           /**< Reserved. */
     304        } __attribute__ ((packed));
     305};
     306typedef union io_apic_id io_apic_id_t;
    289307
    290308extern volatile __u32 *l_apic;
  • 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
  • genarch/include/acpi/madt.h

    rf701b236 r9149135  
    8080        __u8 bus;
    8181        __u8 source;
    82         __u32 global_intr;
     82        __u32 global_int;
    8383        __u16 flags;
    8484} __attribute__ ((packed));
  • genarch/src/acpi/matd.c

    rf701b236 r9149135  
    227227{
    228228        ASSERT(override->source < sizeof(isa_irq_map)/sizeof(int));
    229         printf("Remapping irq%d to IO APIC pin%d\n",  override->source, override->global_intr);
    230         isa_irq_map[override->source] = override->global_intr;
    231        
     229        printf("MADT: ignoring %s entry: bus=%d, source=%d, global_int=%d, flags=%W\n",
     230                entry[override->header.type], override->bus, override->source,
     231                override->global_int, override->flags);
    232232}
    233233
Note: See TracChangeset for help on using the changeset viewer.