Changeset da1bafb in mainline for kernel/generic/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/generic/src/ddi/ddi.c

    r666f492 rda1bafb  
    5959static btree_t parea_btree;
    6060
    61 /** Initialize DDI. */
     61/** Initialize DDI.
     62 *
     63 */
    6264void ddi_init(void)
    6365{
     
    9799 *
    98100 */
    99 static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, size_t pages, int flags)
     101static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, size_t pages,
     102    unsigned int flags)
    100103{
    101104        ASSERT(TASK);
     
    114117        backend_data.frames = pages;
    115118       
    116         ipl_t ipl = interrupts_disable();
    117        
    118119        /* Find the zone of the physical memory */
    119         spinlock_lock(&zones.lock);
     120        irq_spinlock_lock(&zones.lock, true);
    120121        size_t znum = find_zone(ADDR2PFN(pf), pages, 0);
    121122       
     
    124125                 * -> assume it is hardware device and allow mapping
    125126                 */
    126                 spinlock_unlock(&zones.lock);
     127                irq_spinlock_unlock(&zones.lock, true);
    127128                goto map;
    128129        }
     
    130131        if (zones.info[znum].flags & ZONE_FIRMWARE) {
    131132                /* Frames are part of firmware */
    132                 spinlock_unlock(&zones.lock);
     133                irq_spinlock_unlock(&zones.lock, true);
    133134                goto map;
    134135        }
    135136       
    136137        if (zone_flags_available(zones.info[znum].flags)) {
    137                 /* Frames are part of physical memory, check if the memory
     138                /*
     139                 * Frames are part of physical memory, check if the memory
    138140                 * region is enabled for mapping.
    139141                 */
    140                 spinlock_unlock(&zones.lock);
     142                irq_spinlock_unlock(&zones.lock, true);
    141143               
    142144                mutex_lock(&parea_lock);
     
    154156        }
    155157       
    156         spinlock_unlock(&zones.lock);
     158        irq_spinlock_unlock(&zones.lock, true);
     159       
    157160err:
    158         interrupts_restore(ipl);
    159161        return ENOENT;
    160162       
    161163map:
    162         interrupts_restore(ipl);
    163 
    164164        if (!as_area_create(TASK->as, flags, pages * PAGE_SIZE, vp,
    165165            AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) {
     
    196196                return EPERM;
    197197       
    198         ipl_t ipl = interrupts_disable();
    199         spinlock_lock(&tasks_lock);
     198        irq_spinlock_lock(&tasks_lock, true);
    200199       
    201200        task_t *task = task_find_by_id(id);
     
    207206                 * context.
    208207                 */
    209                 spinlock_unlock(&tasks_lock);
    210                 interrupts_restore(ipl);
     208                irq_spinlock_unlock(&tasks_lock, true);
    211209                return ENOENT;
    212210        }
    213211       
    214212        /* Lock the task and release the lock protecting tasks_btree. */
    215         spinlock_lock(&task->lock);
    216         spinlock_unlock(&tasks_lock);
     213        irq_spinlock_exchange(&tasks_lock, &task->lock);
    217214       
    218215        int rc = ddi_iospace_enable_arch(task, ioaddr, size);
    219216       
    220         spinlock_unlock(&task->lock);
    221         interrupts_restore(ipl);
     217        irq_spinlock_unlock(&task->lock, true);
    222218       
    223219        return rc;
Note: See TracChangeset for help on using the changeset viewer.