home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / mslang / vm / src / load.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-15  |  1.6 KB  |  68 lines

  1. /***
  2. *load.c - Load allocated space
  3. *
  4. *       Copyright (c) 1989-1992, Microsoft Corporation.  All rights reserved.
  5. *
  6. *******************************************************************************/
  7.  
  8. #include <version.h>
  9. #include <vmassert.h>
  10. #include <stdlib.h>
  11. #include <vmm.h>
  12. #include <vmbm.h>
  13.  
  14. /*** PVmLoadHbk
  15. *
  16. * Purpose:  loads in the allocated space
  17. *
  18. * Input:
  19. *   hbk     The handle load.
  20. *
  21. * Output:
  22. *  Returns:
  23. *           A physical pointer to the memory, or a NULL on error.
  24. *
  25. * Exceptions:
  26. *
  27. * Notes:
  28. *
  29. *   There is an implicit assumption that if the memory is already loaded,
  30. *   a load will take you to the same physical place!
  31. *
  32. *
  33. *************************************************************************/
  34. PVOID   VMFUNC __PVmLoadHbk(
  35. HBK     hbk,
  36. int     fDirty
  37. ) {
  38.    PHDB phdb;
  39.    
  40.    Assert( hbk != NULL);
  41.  
  42.    if (!_fVmInit || (unsigned long)hbk < (unsigned long)_hbkMin || (unsigned long)hbk >= (unsigned long)_hbkMax)
  43.       return NULL;
  44.  
  45.    phdb = __PVmLoadVp((VPVOID) hbk, fDirty);
  46.    Assert( phdb != NULL );
  47.  
  48.    if (!phdb || phdb->fFree)
  49.       return NULL;
  50.  
  51.    Assert( phdb->fFree == FALSE );
  52.  
  53.    // if there is more than one page, then we need to load more pages
  54.    if(phdb->fByPage  &&  phdb->cPage > 1)
  55.    {
  56.       phdb = __PVmLoadVpCb((VPVOID) hbk, phdb->cPage * (unsigned long) cbVmPage,
  57.                      fDirty);
  58.    }
  59.    else if( VpPageOfVp((VPVOID) hbk) !=
  60.          VpPageOfVp(((VPVOID) hbk) + CbGetSize(phdb->cbSize) - 1) )
  61.    {
  62.        phdb = __PVmLoadVpCb((VPVOID) hbk, CbGetSize(phdb->cbSize), fDirty);
  63.    }
  64.  
  65.    // return the vm pointer
  66.    return((PVOID) ((phdb != NULL) ? ++phdb : NULL));
  67. }
  68.