Changeset 8491c48 in mainline


Ignore:
Timestamp:
2005-09-11T12:19:35Z (19 years ago)
Author:
Sergey Bondari <bondari@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3156582
Parents:
a1493d9
Message:

Generic quicksort and bubble sort implementation.
ACPI MADT parser now uses qsort() for index sorting

Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/acpi/madt.c

    ra1493d9 r8491c48  
    3939#include <mm/heap.h>
    4040#include <memstr.h>
     41#include <sort.h>
    4142
    4243struct acpi_madt *acpi_madt = NULL;
     
    4647static void madt_l_apic_entry(struct madt_l_apic *la, __u32 index);
    4748static void madt_io_apic_entry(struct madt_io_apic *ioa, __u32 index);
     49static int madt_cmp(void * a, void * b);
    4850
    4951struct madt_l_apic *madt_l_apic_entries = NULL;
     
    109111}
    110112
     113int madt_cmp(void * a, void * b)
     114{
     115    return
     116        (((struct madt_apic_header *) a)->type > ((struct madt_apic_header *) b)->type) ?
     117        1 :
     118        ((((struct madt_apic_header *) a)->type < ((struct madt_apic_header *) b)->type) ? -1 : 0);
     119}
     120       
    111121void acpi_madt_parse(void)
    112122{
     123
     124
    113125        struct madt_apic_header *end = (struct madt_apic_header *) (((__u8 *) acpi_madt) + acpi_madt->header.length);
    114126        struct madt_apic_header *h;
     
    132144
    133145
    134         /* Bublesort madt index. Quicksort later. */
    135         bool done = false;
    136 
    137         while (!done) {
    138                 done = true;
    139                 for (index = 0; index < madt_entries_index_cnt - 1; index++) {
    140                         if (madt_entries_index[index]->type > madt_entries_index[index + 1]->type) {
    141                                 h = madt_entries_index[index];
    142                                 madt_entries_index[index] = madt_entries_index[index + 1];
    143                                 madt_entries_index[index + 1] = h;
    144                                 done = false;
    145                         }
    146                 }
    147        
    148         }
    149                
     146        /* Quicksort MADT index structure */
     147        qsort(madt_entries_index, madt_entries_index_cnt, sizeof(__address), &madt_cmp);
    150148
    151149        /* Parse MADT entries */       
  • src/Makefile

    ra1493d9 r8491c48  
    1818        lib/memstr.c \
    1919        lib/the.c \
     20        lib/sort.c \
    2021        debug/print.c \
    2122        debug/symtab.c \
  • src/lib/func.c

    ra1493d9 r8491c48  
    7777        return 1;
    7878}
     79
Note: See TracChangeset for help on using the changeset viewer.