home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / doc / ems / disk3 / emm28_c.asm < prev    next >
Assembly Source File  |  1989-11-29  |  6KB  |  111 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM28_C.ASM                                             ;
  3. ;                                                                             ;
  4. ; OS FUNCTION NAME:   get_alt_context_size                                    ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function returns the storage requirements for the  ;
  7. ;                     map hardware context save area referenced by the other  ;
  8. ;                     functions when you want to dynamically allocate this    ; 
  9. ;                     space.                                                  ;
  10. ;                                                                             ;
  11. ;           PASSED:   &context_size:                                          ;
  12. ;                        is a far pointer to the size of the map hardware     ;
  13. ;                        context save area size.                              ;
  14. ;                                                                             ;
  15. ;         RETURNED:   status:                                                 ;
  16. ;                        is the status EMM returns from the call.  All other  ;
  17. ;                        returned results are valid only if the status        ;
  18. ;                        returned is zero.  Otherwise they are undefined.     ;
  19. ;                                                                             ;
  20. ;                     context_size:                                           ;
  21. ;                        is the number of bytes that will be transferred to   ;
  22. ;                        the memory area supplied by an operating system      ;
  23. ;                        whenever an operating system requests the            ;
  24. ;                        get_context or get_set_context functions.            ;
  25. ;                                                                             ;
  26. ;                        Normally, you just supply a CONTEXT_STRUCT structure ;
  27. ;                        which contains an array of the largest space         ;
  28. ;                        possible (currently 255 bytes).  If you want to      ;
  29. ;                        dynamically allocate exactly the amount of storage   ;
  30. ;                        required to save a context, use this function to get ;
  31. ;                        the size needed (see example below).  The size       ;
  32. ;                        depends on how the expanded memory system is         ;
  33. ;                        configured and how the expanded memory manager is    ;
  34. ;                        implemented.                                         ;
  35. ;                                                                             ;
  36. ; C USE CONVENTION:   unsigned int status;                                    ;
  37. ;                     unsigned int context_size;                              ;
  38. ;                     unsigned int alt_reg_set;                               ;
  39. ;                     void         *alt_context;                              ;
  40. ;                                                                             ;
  41. ;                     status = get_alt_context_size (&context_size);          ;
  42. ;                     if (status == PASSED)                                   ;
  43. ;                     {                                                       ;
  44. ;                        alt_context = malloc (context_size);                 ;
  45. ;                        if (context == NULL)                                 ;
  46. ;                           /* error condition (no memory to allocate) */     ;
  47. ;                        else                                                 ; 
  48. ;                        {                                                    ;
  49. ;                           status = set_alt_reg_set (alt_reg_set,            ;
  50. ;                                            (CONTEXT_STRUCT *) alt_context); ;
  51. ;                           if (status == PASSED)                             ;
  52. ;                              /* continue normal code */                     ;
  53. ;                           else                                              ;
  54. ;                              /* error condition */                          ;
  55. ;                        }                                                    ;
  56. ;                     }                                                       ;
  57. ;                     else                                                    ;
  58. ;                        /* error condition */                                ;
  59. ;-----------------------------------------------------------------------------;
  60. .XLIST
  61. PAGE    60,132
  62.  
  63. IFDEF SMALL
  64.    .MODEL SMALL, C
  65. ENDIF
  66. IFDEF MEDIUM
  67.    .MODEL MEDIUM, C
  68. ENDIF
  69. IFDEF LARGE
  70.    .MODEL LARGE, C
  71. ENDIF
  72. IFDEF COMPACT
  73.    .MODEL COMPACT, C
  74. ENDIF
  75. IFDEF HUGE
  76.    .MODEL HUGE, C
  77. ENDIF
  78.  
  79. INCLUDE emmlib.equ
  80. INCLUDE emmlib.str
  81. INCLUDE emmlib.mac
  82. .LIST
  83. .CODE
  84.  
  85. get_alt_context_size    PROC                                                  \
  86.             ptr_alt_context_size:FAR PTR WORD
  87.  
  88.     ;---------------------------------------------------------------------;
  89.     ;   do;                                                               ;
  90.     ;   .   get the size of the current mapping context array;            ;
  91.     ;---------------------------------------------------------------------;
  92.     MOVE        AX, get_alt_map_save_array_size_fcn 
  93.     INT         EMM_int
  94.  
  95.     ;---------------------------------------------------------------------;
  96.     ;   .   pass the size of the current mapping context array back to    ;
  97.     ;   .   the caller;                                                   ;
  98.     ;---------------------------------------------------------------------;
  99.     MOVE        ES:BX, ptr_alt_context_size
  100.     MOVE        ES:[BX], DX
  101.  
  102.     ;---------------------------------------------------------------------;
  103.     ;   .   return (EMM status);                                          ;
  104.     ;   end;                                                              ;
  105.     ;---------------------------------------------------------------------;
  106.     RET_EMM_STAT    AH
  107.  
  108. get_alt_context_size        ENDP
  109.  
  110. END
  111.