Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

void kldrDyldModUnloadPrerequisites ( PKLDRDYLDMOD  pMod  ) 

This is the heart of the unload code.

It will recursivly (using the load list) initiate module unloading of all affected modules.

This function will cause a state transition to PENDING_DESTROY, PENDING_GC or PENDING_TERMINATION depending on the module state. There is one exception to this, and that's INITIALIZATION_FAILED, where the state will not be changed.

Parameters:
pMod The module which prerequisites should be unloaded.

Definition at line 685 of file kLdrDyldMod.c.

References KLDRDYLDMOD::cDepRefs, KLDRDYLDMOD::cDynRefs, KLDRDYLDMOD::cRefs, KLDRDYLDMOD::enmState, kLdrDyldHead, KLDRDYLDMOD_ASSERT, kldrDyldModUnloadPrerequisitesOne(), KLDRSTATE_GOOD, KLDRSTATE_LOADED_PREREQUISITES, KLDRSTATE_PENDING_TERMINATION, KLDRDYLDMOD::Load, KLDRDYLDMOD::papPrereqs, and KLDRDYLDMOD::pNext.

Referenced by kldrDyldDoModuleTerminationAndGarabageCollection(), kldrDyldModDynamicUnload(), kldrDyldModRemoveDep(), and kldrDyldStackCleanupOne().

{
    KU32            cToUnload;

    /* sanity */
#ifdef KLDRDYLD_STRICT
    {
    PKLDRDYLDMOD pMod2;
    for (pMod2 = kLdrDyldHead; pMod2; pMod2 = pMod2->Load.pNext)
        KLDRDYLDMOD_ASSERT(pMod2->enmState != KLDRSTATE_GOOD || pMod2->cRefs);
    }
#endif
    KLDRDYLDMOD_ASSERT(pMod->papPrereqs);

    /*
     * Unload prereqs of the module we're called on first.
     */
    cToUnload = kldrDyldModUnloadPrerequisitesOne(pMod);

    /*
     * Iterate the load list in a cyclic manner until there are no more
     * modules that can be pushed on into unloading.
     */
    while (cToUnload)
    {
        cToUnload = 0;
        for (pMod = kLdrDyldHead; pMod; pMod = pMod->Load.pNext)
        {
            if (    pMod->cDepRefs
                ||  pMod->cDynRefs
                ||  pMod->enmState >= KLDRSTATE_PENDING_TERMINATION
                ||  pMod->enmState < KLDRSTATE_LOADED_PREREQUISITES)
                continue;
            cToUnload += kldrDyldModUnloadPrerequisitesOne(pMod);
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index