home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / internal / m68k / m68k-native / supervisor.s < prev    next >
Encoding:
Text File  |  1996-07-16  |  1.7 KB  |  85 lines

  1. |*****************************************************************************
  2. |
  3. |   NAME
  4. |
  5. |    __AROS_LH1(ULONG, Supervisor,
  6. |
  7. |   SYNOPSIS
  8. |    __AROS_LA(ULONG_FUNC, userFunction, A5),
  9. |
  10. |   LOCATION
  11. |    struct ExecBase *, SysBase, 5, Exec)
  12. |
  13. |   FUNCTION
  14. |    Call a routine in supervisor mode. This routine runs on the
  15. |    supervisor stack and must end with a 'rte'. No registers are spilled,
  16. |    i.e. Supervisor() effectively works like a function call.
  17. |
  18. |   INPUTS
  19. |    userFunction - address of the function to be called.
  20. |
  21. |   RESULT
  22. |    whatever the function left in the registers
  23. |
  24. |   NOTES
  25. |    This function is CPU dependant.
  26. |
  27. |   EXAMPLE
  28. |
  29. |   BUGS
  30. |    Context switches that happen during the duration of this call are lost.
  31. |
  32. |   SEE ALSO
  33. |
  34. |   INTERNALS
  35. |
  36. |   HISTORY
  37. |
  38. |******************************************************************************
  39.  
  40.     ThisTask    =    0x114
  41.     tc_TrapCode =    0x32
  42.  
  43.     .globl    _Exec_Supervisor
  44. _Exec_Supervisor:
  45.     | a privileged do-nothing instruction
  46.     orw    #0x0000,sr
  47.     | No trap? Then this was called from supervisor mode. Prepare a rte.
  48.     movew    sr,sp@-
  49.     jmp    a5@
  50.  
  51.     | CPU privilege violation vector points to here
  52.     .globl    _TrapLevel8
  53. _TrapLevel8:
  54.  
  55.     | There's only one legal location which may do a privilege
  56.     | violation - and that's the instruction above.
  57.     cmpl    #_Exec_Supervisor,sp@(2:W)
  58.     jne    pv
  59.     | All OK. Prepare returnaddress and go to the right direction.
  60.     movel    #end,sp@(2:W)
  61.     jmp    a5@
  62. end:    rts
  63.  
  64.     | Store trap number
  65. pv:    movel    #8,sp@-
  66.     jra    _TrapEntry
  67.  
  68.     | And handle the trap
  69. _TrapEntry:
  70.     | Simple disable
  71.     orw    #0x0700,sr
  72.  
  73.     | get some room for destination address
  74.     subqw    #4,sp
  75.  
  76.     | calculate destination address without clobbering any registers
  77.     movel    a0,sp@-
  78.     movel    4,a0
  79.     movel    a0@(ThisTask),a0
  80.     movel    a0@(tc_TrapCode),sp@(4)
  81.     movel    sp@+,a0
  82.  
  83.     | and jump
  84.     rts
  85.