home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / msj / msjv3_1 / lim4 / map_call.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-02  |  3.7 KB  |  107 lines

  1. /*
  2.  
  3. Figure 8
  4. ========
  5.  
  6.  
  7. /* THIS IS THE  MAIN PROGRAM FOR MAPCALL */
  8.  
  9. #include <c:\msc\include\dos.h>
  10. #include <c:\msc\include\memory.h>
  11. #include <c:\msc\include\stdio.h>
  12. #include <c:\emm\demo\emm.h>
  13.  
  14. /* set up size and base of video ram */
  15.  
  16. union REGS    inregs,    outregs;
  17. struct SREGS     segregs ;
  18.  
  19. unsigned int emm_handle ;
  20. char emm_device_name[] = "EMMXXXX0";      /* Device Name of EMM */
  21. char far emm_handle_name[8] ="mapcall";   /* name for handle */
  22. char far mod1_name[] =
  23.      "c:\\emm\\demo\\module1.exe\0";      /* name of modules to be */                                                      
  24. char far mod2_name[] =                    /* to be loaded */
  25.      "c:\\emm\\demo\\module2.exe\0";
  26. char far *emm_ptr ;
  27. char far *(*page_ptr) ;
  28. int pages_needed = 16 ;
  29.  
  30. struct log_phys {
  31.   int log_page_number;
  32.   int phys_page_number;
  33.        } ;
  34.  
  35. struct log_phys far current_pages[4];
  36.  
  37. struct log_phys far map_call_pages ;
  38.  
  39. int  result;      
  40.  
  41. main ()
  42. {
  43.  
  44.  
  45.    /***************************************************************/
  46.    /* Check for a expanded memory manager of 4.0 or greater.      */
  47.    /***************************************************************/
  48.  
  49.    check_emm_version_number();
  50.    
  51.    /***************************************************************/
  52.    /* Cet four pages of expanded memory.                          */
  53.    /***************************************************************/
  54.  
  55.    result = get_expanded_meory(&emm_ptr, pages_needed, &emm_handle,
  56.                                emm_handle_name);
  57.    if (result != 0) exit(1);
  58.  
  59.    /***************************************************************/
  60.    /* Map in needed pages                                         */
  61.    /***************************************************************/
  62.  
  63.    result = map_unmap_multiple_pages (current_pages, emm_handle, 1);
  64.    
  65.    /***************************************************************/
  66.    /* Load map and calls executeables into expanded memory        */
  67.    /***************************************************************/
  68.  
  69.    *page_ptr = emm_ptr;   /* Module 1 will be loaded into logical */
  70.    load_overlay(mod1_name, page_ptr, 0);   /* and physical page 0 */
  71.  
  72.    /***************************************************************/
  73.    /* Load module 2 into logical page 1 and physical page 1.      */
  74.    /***************************************************************/
  75.  
  76.    load_overlay(mod2_name, page_ptr, 1);
  77.    
  78.    /***************************************************************/
  79.    /* Unmap all pages. The map and call will map in the pages     */
  80.    /* requested and restore the present mapping.                  */
  81.    /***************************************************************/
  82.  
  83.    result = map_unmap_multiple_pages (current_pages, emm_handle, 0);
  84.    
  85.    /***************************************************************/
  86.    /* Do map and call to module in logical page 1. Map logical    */
  87.    /* page to physical page 0 and have current mapping context    */
  88.    /* restored on the return from the map and call.               */
  89.    /***************************************************************/
  90.  
  91.     map_call_pages.log_page_number  = 0;
  92.     map_call_pages.phys_page_number = 0;
  93.     
  94.     map_and_call(&map_call_pages, 1, ¤t_pages, 0, emm_handle);
  95.    
  96.    /***************************************************************/
  97.    /* release handle befor exiting.  This also ummaps any pages   */
  98.    /* that are mapped.                                            */
  99.    /***************************************************************/
  100.  
  101.    inregs.h.ah = DEALLOCATE_PAGES ;
  102.    inregs.x.dx = emm_handle ;
  103.    int86(EMM_INT, &inregs, &outregs);
  104.    
  105.    exit(0);
  106. }
  107.