Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/ddi/ddi.c

    r7de18418 r9d58539  
    5959int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
    6060{
    61         size_t elements = ioaddr + size;
    62         if (elements > IO_PORTS)
     61        size_t bits = ioaddr + size;
     62        if (bits > IO_PORTS)
    6363                return ENOENT;
    6464       
    65         if (task->arch.iomap.elements < elements) {
     65        if (task->arch.iomap.bits < bits) {
    6666                /*
    6767                 * The I/O permission bitmap is too small and needs to be grown.
    6868                 */
    6969               
    70                 void *store = malloc(bitmap_size(elements, 0), FRAME_ATOMIC);
    71                 if (!store)
     70                uint8_t *newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);
     71                if (!newmap)
    7272                        return ENOMEM;
    7373               
    7474                bitmap_t oldiomap;
    75                 bitmap_initialize(&oldiomap, task->arch.iomap.elements, 0,
     75                bitmap_initialize(&oldiomap, task->arch.iomap.map,
    7676                    task->arch.iomap.bits);
    77                
    78                 bitmap_initialize(&task->arch.iomap, elements, 0, store);
     77                bitmap_initialize(&task->arch.iomap, newmap, bits);
    7978               
    8079                /*
    8180                 * Mark the new range inaccessible.
    8281                 */
    83                 bitmap_set_range(&task->arch.iomap, oldiomap.elements,
    84                     elements - oldiomap.elements);
     82                bitmap_set_range(&task->arch.iomap, oldiomap.bits,
     83                    bits - oldiomap.bits);
    8584               
    8685                /*
     
    9089                if (oldiomap.bits) {
    9190                        bitmap_copy(&task->arch.iomap, &oldiomap,
    92                             oldiomap.elements);
    93                        
    94                         free(oldiomap.bits);
     91                            oldiomap.bits);
     92                        free(oldiomap.map);
    9593                }
    9694        }
     
    9997         * Enable the range and we are done.
    10098         */
    101         bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size);
     99        bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, (size_t) size);
    102100       
    103101        /*
     
    121119        /* First, copy the I/O Permission Bitmap. */
    122120        irq_spinlock_lock(&TASK->lock, false);
    123        
    124121        size_t ver = TASK->arch.iomapver;
    125         size_t elements = TASK->arch.iomap.elements;
    126        
    127         if (elements > 0) {
    128                 ASSERT(TASK->arch.iomap.bits);
     122        size_t bits = TASK->arch.iomap.bits;
     123        if (bits) {
     124                ASSERT(TASK->arch.iomap.map);
    129125               
    130126                bitmap_t iomap;
    131                 bitmap_initialize(&iomap, TSS_IOMAP_SIZE * 8, 0,
    132                     CPU->arch.tss->iomap);
    133                 bitmap_copy(&iomap, &TASK->arch.iomap, elements);
     127                bitmap_initialize(&iomap, CPU->arch.tss->iomap,
     128                    TSS_IOMAP_SIZE * 8);
     129                bitmap_copy(&iomap, &TASK->arch.iomap, bits);
    134130               
    135131                /*
     
    137133                 * I/O access.
    138134                 */
    139                 bitmap_set_range(&iomap, elements,
    140                     ALIGN_UP(elements, 8) - elements);
    141                
     135                bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits);
    142136                /*
    143137                 * It is safe to set the trailing eight bits because of the
    144138                 * extra convenience byte in TSS_IOMAP_SIZE.
    145139                 */
    146                 bitmap_set_range(&iomap, ALIGN_UP(elements, 8), 8);
     140                bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8);
    147141        }
    148        
    149142        irq_spinlock_unlock(&TASK->lock, false);
    150143       
     
    157150       
    158151        descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base;
    159         size_t size = bitmap_size(elements, 0);
    160         gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + size);
     152        gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits));
    161153        gdtr_load(&cpugdtr);
    162154       
Note: See TracChangeset for help on using the changeset viewer.