home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2MISC / CSDPMI3S.ZIP / SRC / CWSDPMI / UTILS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-15  |  2.0 KB  |  71 lines

  1. /* Copyright (C) 1995,1996 CW Sandmann (sandmann@clio.rice.edu) 1206 Braelinn, Sugarland, TX 77479
  2. ** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  3. **
  4. ** This file is distributed under the terms listed in the document
  5. ** "copying.cws", available from CW Sandmann at the address above.
  6. ** A copy of "copying.cws" should accompany this file; if not, a copy
  7. ** should be available from where this file was obtained.  This file
  8. ** may not be distributed without a verbatim copy of "copying.cws".
  9. **
  10. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  11. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. */
  13.  
  14. #include <dos.h>
  15. #include "gotypes.h"
  16. #include "tss.h"
  17. #include "gdt.h"
  18. #include "utils.h"
  19. #include "mswitch.h"
  20. #include "exphdlr.h"
  21. #include "control.h"
  22. #include "dpmisim.h"
  23.  
  24. extern void _do_memmov32();
  25.  
  26. TSS *utils_tss = &o_tss;
  27.  
  28. void go_til_stop(int allow_ret)
  29. {
  30.   while (1)
  31.   {
  32.     go32();
  33.     if (!was_exception){
  34.       if(allow_ret && !(word16)tss_ptr->tss_ebx)    /* BX is SP for RAW */
  35.         return;
  36.       do_raw_switch();                /* jmpt ctss with BX non-zero */
  37.     } else if (exception_handler())
  38.       do_faulting_finish_message();
  39.   }
  40. }
  41.  
  42. void memput(word16 umemsel, word32 vaddr, void far *ptr, word16 len)
  43. {
  44.   TSS *old_ptr;
  45.   utils_tss->tss_eip = (word16)_do_memmov32;
  46.   utils_tss->tss_ecx = len;
  47.   utils_tss->tss_es = umemsel;
  48.   utils_tss->tss_edi = vaddr;
  49.   utils_tss->tss_ds = g_core*8;
  50.   utils_tss->tss_esi = (word32)FP_SEG(ptr)*16 + (word32)FP_OFF(ptr);
  51.   old_ptr = tss_ptr;
  52.   tss_ptr = utils_tss;
  53.   go_til_stop(1);
  54.   tss_ptr = old_ptr;
  55. }
  56.  
  57. void memget(word16 umemsel, word32 vaddr, void far *ptr, word16 len)
  58. {
  59.   TSS *old_ptr;
  60.   utils_tss->tss_eip = (word16)_do_memmov32;
  61.   utils_tss->tss_ecx = len;
  62.   utils_tss->tss_es = g_core*8;
  63.   utils_tss->tss_edi = (word32)FP_SEG(ptr)*16 + (word32)FP_OFF(ptr);
  64.   utils_tss->tss_ds = umemsel;
  65.   utils_tss->tss_esi = vaddr;
  66.   old_ptr = tss_ptr;
  67.   tss_ptr = utils_tss;
  68.   go_til_stop(1);
  69.   tss_ptr = old_ptr;
  70. }
  71.