Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/acpi/madt.c

    r99718a2e rfe32163  
    9595        /*
    9696         * FIXME: The current local APIC driver limits usable
    97          * CPU IDs to 8.
     97         * APIC IDs to 8.
    9898         *
    9999         */
    100         if (i > 7)
     100        if (madt_cpu_apic_id(i) > 7)
    101101                return false;
    102102       
     
    111111        return ((struct madt_l_apic *)
    112112            madt_entries_index[madt_l_apic_entry_index + i])->apic_id ==
    113             bsp_l_apic;
     113            l_apic_id();
    114114}
    115115
     
    131131};
    132132
    133 static int madt_cmp(void *a, void *b, void *arg)
    134 {
    135         uint8_t typea = (*((struct madt_apic_header **) a))->type;
    136         uint8_t typeb = (*((struct madt_apic_header **) b))->type;
     133static int madt_cmp(void *a, void *b)
     134{
     135        uint8_t typea = ((struct madt_apic_header *) a)->type;
     136        uint8_t typeb = ((struct madt_apic_header *) b)->type;
    137137       
    138138        if (typea > typeb)
     
    147147static void madt_l_apic_entry(struct madt_l_apic *la, size_t i)
    148148{
    149         if (madt_l_apic_entry_cnt == 0)
     149        if (!madt_l_apic_entry_cnt++)
    150150                madt_l_apic_entry_index = i;
    151        
    152         madt_l_apic_entry_cnt++;
    153151       
    154152        if (!(la->flags & 0x1)) {
     
    162160static void madt_io_apic_entry(struct madt_io_apic *ioa, size_t i)
    163161{
    164         if (madt_io_apic_entry_cnt == 0) {
     162        if (!madt_io_apic_entry_cnt++) {
    165163                /* Remember index of the first io apic entry */
    166164                madt_io_apic_entry_index = i;
     
    169167                /* Currently not supported */
    170168        }
    171        
    172         madt_io_apic_entry_cnt++;
    173169}
    174170
     
    194190        /* Count MADT entries */
    195191        unsigned int madt_entries_index_cnt = 0;
    196         for (hdr = acpi_madt->apic_header; hdr < end;
     192        for (hdr = &acpi_madt->apic_header[0]; hdr < end;
    197193            hdr = (struct madt_apic_header *) (((uint8_t *) hdr) + hdr->length))
    198194                madt_entries_index_cnt++;
     
    200196        /* Create MADT APIC entries index array */
    201197        madt_entries_index = (struct madt_apic_header **)
    202             malloc(madt_entries_index_cnt * sizeof(struct madt_apic_header *),
     198            malloc(madt_entries_index_cnt * sizeof(struct madt_apic_header **),
    203199            FRAME_ATOMIC);
    204200        if (!madt_entries_index)
     
    207203        size_t i = 0;
    208204       
    209         for (hdr = acpi_madt->apic_header; hdr < end;
    210             hdr = (struct madt_apic_header *) (((uint8_t *) hdr) + hdr->length)) {
    211                 madt_entries_index[i] = hdr;
    212                 i++;
    213         }
     205        for (hdr = &acpi_madt->apic_header[0]; hdr < end;
     206            hdr = (struct madt_apic_header *) (((uint8_t *) hdr) + hdr->length))
     207                madt_entries_index[i++] = hdr;
    214208       
    215209        /* Sort MADT index structure */
    216         if (!gsort(madt_entries_index, madt_entries_index_cnt,
    217             sizeof(struct madt_apic_header *), madt_cmp, NULL))
    218                 panic("Sorting error.");
     210        qsort(madt_entries_index, madt_entries_index_cnt, sizeof(uintptr_t),
     211            &madt_cmp);
    219212       
    220213        /* Parse MADT entries */
Note: See TracChangeset for help on using the changeset viewer.