home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Portable Patmos 1.1 / patmos-src / src / patch0.c < prev    next >
Encoding:
Text File  |  1996-01-19  |  1.4 KB  |  73 lines  |  [TEXT/KAHL]

  1.      {
  2. #ifdef MMU68040
  3.     cpusha();
  4. #endif
  5.     pflusha();
  6.     /* save the current context */
  7.          {
  8.          struct userregs save;
  9.         asm { 
  10.             movem.l    d0-d7/a0-a5,save.save
  11.             move.l    (a6),save.save[14]
  12.             move.w    4(a6),save.flags
  13.             move.l    6(a6),save.pc
  14.             };
  15.         SetCurrentA5();
  16.         save.save[15] = usp();
  17.         memcpy(system_vectors, supervisor_vectors, vec_patch_size);
  18. #ifdef PROTECTED
  19.         if (virtual)
  20.          asm
  21.             {
  22.             move.w    save.flags,sr
  23.             }
  24. #endif
  25. #if 0
  26.         SetCursor(*nxt[7&++ccnt]);
  27. #endif
  28.         if (0x2000&~save.flags)
  29.             {
  30.             crp->registers = save;
  31.             crp->state = 'D';
  32.             }
  33.         else if (crp) crp->state = 'R';
  34.         }
  35. #if 0
  36.             kprintf("Saved PC = %X USP = %X URP = %X\n", 
  37.                 crp->registers.pc, 
  38.                 crp->registers.save[15], 
  39.                 (long)crp);
  40. #endif
  41.     sched();
  42. #if 0
  43.             kprintf("Restored PC = %X USP = %X URP = %X\n", 
  44.                 crp->registers.pc, 
  45.                 crp->registers.save[15], 
  46.                 (long)crp);
  47. #endif
  48.     /* restore the chosen context */
  49.          {
  50.          struct userregs save = crp->registers;
  51. #ifdef PROTECTED
  52.          put_user_root((long)crp);
  53.          if (virtual) EnterSupervisorMode();
  54. #endif
  55.         put_usp(save.save[15]);
  56. #ifdef PROTECTED
  57.         if (!virtual) upper_space(crp, crp->stack_limit-save.save[15]+stack_headroom);
  58. #endif
  59.         memcpy(system_vectors, user_vectors, vec_patch_size);
  60.         cpusha();
  61.         pflusha();
  62.         asm
  63.             {
  64.             move.l    save.save[14],(a6)
  65.             move.w    save.flags,4(a6)
  66.             move.l    save.pc,6(a6)
  67.             movem.l    save.save,d0-d7/a0-a5
  68.             unlk    a6
  69.              rte 
  70.              };
  71.         }
  72.      }
  73.