Changeset b366a6f4 in mainline for kernel/generic/src/ddi


Ignore:
Timestamp:
2011-06-24T15:58:01Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7250d2c
Parents:
ee2fa30a
Message:

automatic kernel console lockout

  • kernel automatically relinquishes the access to the kernel console when the uspace maps the respective physical memory area
  • kernel output before uspace initialization is currently broken on Ski (no physical memory area), but this is pending further unification
  • kernel console devices are now independent (there is no system-wide "silent" variable), thus on multiple devices the kernel console and uspace output might be usable at the same time
Location:
kernel/generic/src/ddi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ddi/ddi.c

    ree2fa30a rb366a6f4  
    122122        backend_data.frames = pages;
    123123       
    124         /* Find the zone of the physical memory */
     124        /*
     125         * Check if the memory region is explicitly enabled
     126         * for mapping by any parea structure.
     127         */
     128       
     129        mutex_lock(&parea_lock);
     130        btree_node_t *nodep;
     131        parea_t *parea = (parea_t *) btree_search(&parea_btree,
     132            (btree_key_t) pf, &nodep);
     133       
     134        if ((parea != NULL) && (parea->frames >= pages)) {
     135                if ((!priv) && (!parea->unpriv)) {
     136                        mutex_unlock(&parea_lock);
     137                        return EPERM;
     138                }
     139               
     140                goto map;
     141        }
     142       
     143        parea = NULL;
     144        mutex_unlock(&parea_lock);
     145       
     146        /*
     147         * Check if the memory region is part of physical
     148         * memory generally enabled for mapping.
     149         */
     150       
    125151        irq_spinlock_lock(&zones.lock, true);
    126152        size_t znum = find_zone(ADDR2PFN(pf), pages, 0);
     
    153179        }
    154180       
    155         if (zone_flags_available(zones.info[znum].flags)) {
    156                 /*
    157                  * Frames are part of physical memory, check
    158                  * if the memory region is enabled for mapping.
    159                  */
    160                 irq_spinlock_unlock(&zones.lock, true);
    161                
    162                 mutex_lock(&parea_lock);
    163                 btree_node_t *nodep;
    164                 parea_t *parea = (parea_t *) btree_search(&parea_btree,
    165                     (btree_key_t) pf, &nodep);
    166                
    167                 if ((!parea) || (parea->frames < pages)) {
    168                         mutex_unlock(&parea_lock);
    169                         return ENOENT;
    170                 }
    171                
    172                 if (!priv) {
    173                         if (!parea->unpriv) {
    174                                 mutex_unlock(&parea_lock);
    175                                 return EPERM;
    176                         }
    177                 }
    178                
    179                 mutex_unlock(&parea_lock);
    180                 goto map;
    181         }
    182        
    183181        irq_spinlock_unlock(&zones.lock, true);
    184182        return ENOENT;
     
    188186            AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) {
    189187                /*
    190                  * The address space area could not have been created.
     188                 * The address space area was not created.
    191189                 * We report it using ENOMEM.
    192190                 */
     191               
     192                if (parea != NULL)
     193                        mutex_unlock(&parea_lock);
     194               
    193195                return ENOMEM;
    194196        }
     
    197199         * Mapping is created on-demand during page fault.
    198200         */
    199         return 0;
     201       
     202        if (parea != NULL) {
     203                parea->mapped = true;
     204                mutex_unlock(&parea_lock);
     205        }
     206       
     207        return EOK;
    200208}
    201209
  • kernel/generic/src/ddi/irq.c

    ree2fa30a rb366a6f4  
    275275{
    276276        /*
    277          * If the kernel console is silenced,
    278          * then try first the uspace handlers,
    279          * eventually fall back to kernel handlers.
     277         * If the kernel console override is on,
     278         * then try first the kernel handlers
     279         * and eventually fall back to uspace
     280         * handlers.
    280281         *
    281          * If the kernel console is active,
    282          * then do it the other way around.
     282         * In the usual case the uspace handlers
     283         * have precedence.
    283284         */
    284         if (silent) {
    285                 irq_t *irq = irq_dispatch_and_lock_uspace(inr);
     285       
     286        if (console_override) {
     287                irq_t *irq = irq_dispatch_and_lock_kernel(inr);
    286288                if (irq)
    287289                        return irq;
    288290               
    289                 return irq_dispatch_and_lock_kernel(inr);
    290         }
    291        
    292         irq_t *irq = irq_dispatch_and_lock_kernel(inr);
     291                return irq_dispatch_and_lock_uspace(inr);
     292        }
     293       
     294        irq_t *irq = irq_dispatch_and_lock_uspace(inr);
    293295        if (irq)
    294296                return irq;
    295297       
    296         return irq_dispatch_and_lock_uspace(inr);
     298        return irq_dispatch_and_lock_kernel(inr);
    297299}
    298300
Note: See TracChangeset for help on using the changeset viewer.