Changeset da1bafb in mainline for kernel/arch/amd64/src/ddi/ddi.c


Ignore:
Timestamp:
2010-05-24T18:57:31Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0095368
Parents:
666f492
Message:

major code revision

  • replace spinlocks taken with interrupts disabled with irq_spinlocks
  • change spacing (not indendation) to be tab-size independent
  • use unsigned integer types where appropriate (especially bit flags)
  • visual separation
  • remove argument names in function prototypes
  • string changes
  • correct some formating directives
  • replace various cryptic single-character variables (t, a, m, c, b, etc.) with proper identifiers (thread, task, timeout, as, itm, itc, etc.)
  • unify some assembler constructs
  • unused page table levels are now optimized out in compile time
  • replace several ints (with boolean semantics) with bools
  • use specifically sized types instead of generic types where appropriate (size_t, uint32_t, btree_key_t)
  • improve comments
  • split asserts with conjuction into multiple independent asserts
File:
1 edited

Legend:

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

    r666f492 rda1bafb  
    4949 * Interrupts are disabled and task is locked.
    5050 *
    51  * @param task Task.
     51 * @param task   Task.
    5252 * @param ioaddr Startign I/O space address.
    53  * @param size Size of the enabled I/O range.
     53 * @param size   Size of the enabled I/O range.
    5454 *
    5555 * @return 0 on success or an error code from errno.h.
     56 *
    5657 */
    5758int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
    5859{
    59         size_t bits;
    60        
    61         bits = ioaddr + size;
     60        size_t bits = ioaddr + size;
    6261        if (bits > IO_PORTS)
    6362                return ENOENT;
    6463       
    6564        if (task->arch.iomap.bits < bits) {
    66                 bitmap_t oldiomap;
    67                 uint8_t *newmap;
    68                
    6965                /*
    7066                 * The I/O permission bitmap is too small and needs to be grown.
    7167                 */
    7268               
    73                 newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);
     69                uint8_t *newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);
    7470                if (!newmap)
    7571                        return ENOMEM;
    7672               
     73                bitmap_t oldiomap;
    7774                bitmap_initialize(&oldiomap, task->arch.iomap.map,
    7875                    task->arch.iomap.bits);
     
    115112 *
    116113 * Interrupts must be disabled prior this call.
     114 *
    117115 */
    118116void io_perm_bitmap_install(void)
    119117{
    120         size_t bits;
    121         ptr_16_64_t cpugdtr;
    122         descriptor_t *gdt_p;
    123         tss_descriptor_t *tss_desc;
    124         size_t ver;
    125        
    126118        /* First, copy the I/O Permission Bitmap. */
    127         spinlock_lock(&TASK->lock);
    128         ver = TASK->arch.iomapver;
    129         if ((bits = TASK->arch.iomap.bits)) {
     119        irq_spinlock_lock(&TASK->lock, false);
     120        size_t ver = TASK->arch.iomapver;
     121        size_t bits = TASK->arch.iomap.bits;
     122        if (bits) {
     123                ASSERT(TASK->arch.iomap.map);
     124               
    130125                bitmap_t iomap;
    131        
    132                 ASSERT(TASK->arch.iomap.map);
    133126                bitmap_initialize(&iomap, CPU->arch.tss->iomap,
    134127                    TSS_IOMAP_SIZE * 8);
    135128                bitmap_copy(&iomap, &TASK->arch.iomap, TASK->arch.iomap.bits);
     129               
    136130                /*
    137131                 * It is safe to set the trailing eight bits because of the
     
    140134                bitmap_set_range(&iomap, ALIGN_UP(TASK->arch.iomap.bits, 8), 8);
    141135        }
    142         spinlock_unlock(&TASK->lock);
     136        irq_spinlock_unlock(&TASK->lock, false);
    143137       
    144138        /*
     
    146140         * Take the extra ending byte will all bits set into account.
    147141         */
     142        ptr_16_64_t cpugdtr;
    148143        gdtr_store(&cpugdtr);
    149         gdt_p = (descriptor_t *) cpugdtr.base;
     144       
     145        descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base;
    150146        gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits));
    151147        gdtr_load(&cpugdtr);
     
    155151         * type must be changed to describe inactive TSS.
    156152         */
    157         tss_desc = (tss_descriptor_t *) &gdt_p[TSS_DES];
     153        tss_descriptor_t *tss_desc = (tss_descriptor_t *) &gdt_p[TSS_DES];
    158154        tss_desc->type = AR_TSS;
    159155        tr_load(gdtselector(TSS_DES));
Note: See TracChangeset for help on using the changeset viewer.