home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / disks / disk400.lzh / SetCPU / control.a < prev    next >
Text File  |  1990-11-03  |  6KB  |  217 lines

  1. ;======================================================================
  2. ;
  3. ;    SetCPU V1.60
  4. ;    by Dave Haynie, April 13, 1990
  5. ;    Released to the Public Domain
  6. ;
  7. ;    CONTROL.A MODULE
  8. ;
  9. ;    This module contains functions that access various control
  10. ;    registers in the 32 bit CPUs and MMUs.
  11. ;
  12. ;======================================================================
  13.  
  14.     include "setcpu.i"
  15.  
  16.     cseg
  17.  
  18. ;**********************************************************************
  19. ;
  20. ;    These functions work with the CPU control registers.
  21. ;
  22. **********************************************************************
  23.  
  24.     xdef    _SetCACR    ; Set CACR register
  25.     xdef    _GetCACR    ; Get CACR register
  26.     xdef    _GetVBR        ; Get the Vector Base Register
  27.  
  28. ;======================================================================
  29. ;
  30. ;    This function sets the value of the 68020/68030 CACR register.  
  31. ;    It assumes a 68020 or 68030 based system.
  32. ;
  33. ;    void SetCACR(cacr)
  34. ;    ULONG cacr;
  35. ;
  36. ;======================================================================
  37.  
  38. _SetCACR:
  39.     move.l    4(sp),d0        ; New CACR is on stack
  40.      move.l    4,a6            ; Get ExecBase
  41.  
  42.     move.w    LIB_VERSION(a6),d1    ; Are we in 2.0?
  43.     cmp.w    #36,d1            ; If so, use the 2.0 function
  44.     blt    MySetCACR
  45.  
  46.     move.l    #$ffffffff,d1
  47.     CALLSYS    CacheControl
  48.     rts    
  49.  
  50. MySetCACR:
  51.     move.l    a5,-(sp)        ; Save this register
  52.     lea.l    1$,a5            ; Get the start of the supervisor code
  53.     CALLSYS    Supervisor
  54.     move.l    (sp)+,a5        ; Give it back
  55.     rts
  56. 1$
  57.     MOVEC_    d0,cacr            ; Set the CACR
  58.     rte
  59.  
  60. ;======================================================================
  61. ;
  62. ;    This function returns the 68020/68030 CACR register.  It assumes
  63. ;    a 68020 or better system.
  64. ;
  65. ;    ULONG GetCACR()
  66. ;
  67. ;======================================================================
  68.  
  69. _GetCACR:
  70.     move.l    4,a6            ; Get ExecBase
  71.  
  72.     move.w    LIB_VERSION(a6),d1    ; Are we in 2.0?
  73.     cmp.w    #36,d1            ; If so, use the 2.0 function
  74.     blt    MyGetCACR
  75.  
  76.     moveq.l    #0,d0
  77.     move.l    d0,d1
  78.     CALLSYS    CacheControl
  79.     rts
  80.  
  81. MyGetCACR:
  82.     move.l    a5,-(sp)        ; Save this register
  83.     lea.l    1$,a5            ; Get the start of the supervisor code
  84.     CALLSYS    Supervisor
  85.     move.l    (sp)+,a5        ; Give back register
  86.     rts
  87. 1$
  88.     MOVEC_    cacr,d0            ; Make CACR the return value
  89.     rte
  90.  
  91. ;======================================================================
  92. ;
  93. ;    This function returns the value of the Vector Base Register;
  94. ;    all exceptions are referenced from this.  This function assumes
  95. ;    we're on a CPU with a VBR (eg, no 68000's need apply).
  96. ;
  97. ;    ULONG *GetVBR()
  98. ;
  99. ;======================================================================
  100.  
  101. _GetVBR:
  102.     move.l    4,a6            ; Get ExecBase
  103.     move.l    a5,-(sp)        ; Save this register
  104.     lea.l    1$,a5            ; Get the start of the supervisor code
  105.     CALLSYS    Supervisor
  106.     move.l    (sp)+,a5        ; Give back register
  107.     rts
  108. 1$
  109.     MOVEC_    vbr,d0            ; Make CACR the return value
  110.     rte
  111.  
  112. ;**********************************************************************
  113. ;
  114. ;    These functions access MMU registers
  115. ;
  116. ;**********************************************************************
  117.  
  118.     xdef    _GetCRP        ; Gets MMU CRP register
  119.     xdef    _SetCRP        ; Sets MMU CRP register
  120.     xdef    _GetTC        ; Gets MMU TC register
  121.     xdef    _SetTC        ; Gets MMU TC register
  122.  
  123. ;======================================================================
  124. ;
  125. ;    This function returns the MMU CRP register.  It assumes a 68020 
  126. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  127. ;    you call this, or you wind up in The Guru Zone).  Note that the
  128. ;    CRP register is two longwords long.
  129. ;
  130. ;    void GetCRP(ULONG *)
  131. ;
  132. ;======================================================================
  133.  
  134. _GetCRP:
  135.     move.l    4(sp),a0        ; Pointer to the CRP storage area
  136.     move.l    4,a6            ; Get ExecBase
  137.     move.l    a5,-(sp)
  138.     lea.l    2$,a5            ; Get the start of the supervisor code
  139.     CALLSYS    Supervisor
  140.     move.l    (sp)+,a5
  141.     rts
  142. 2$
  143.     PMOVE_    crp,(a0)        ; Just get the CRP register
  144.     rte
  145.  
  146. ;======================================================================
  147. ;
  148. ;    This function sets the MMU CRP register.  It assumes a 68020 
  149. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  150. ;    you call this, or you wind up in The Guru Zone).  Note that the
  151. ;    CRP register is two longwords long.
  152. ;
  153. ;    void SetCRP(ULONG *)
  154. ;
  155. ;======================================================================
  156.  
  157. _SetCRP:
  158.     move.l    4(sp),a0        ; Pointer to the CRP storage area
  159.     move.l    4,a6            ; Get ExecBase
  160.     move.l    a5,-(sp)
  161.     lea.l    1$,a5            ; Get the start of the supervisor code
  162.     CALLSYS    Supervisor
  163.     movem.l    (sp)+,a5        ; Give back registers
  164.     rts
  165. 1$
  166.     PMOVE_    (a0),crp        ; Just load the CRP register
  167.     rte
  168.  
  169. ;======================================================================
  170. ;
  171. ;    This function returns the MMU TC register.  It assumes a 68020 
  172. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  173. ;    you call this, or you wind up in The Guru Zone).  
  174. ;
  175. ;    ULONG GetTC()
  176. ;
  177. ;======================================================================
  178.  
  179. _GetTC:
  180.     move.l    4,a6            ; Get ExecBase
  181.     move.l    a5,-(sp)
  182.     subq.l    #4,sp            ; Make a place to dump TC
  183.     move.l    sp,a0
  184.     lea.l    1$,a5            ; Get the start of the supervisor code
  185.     CALLSYS    Supervisor
  186.     move.l    (sp),d0            ; Here's the result
  187.     addq.l    #4,sp
  188.     move.l    (sp)+,a5
  189.     rts
  190. 1$
  191.     PMOVE_    tc,(a0)            ; Just get the TC register
  192.     rte
  193.  
  194. ;======================================================================
  195. ;
  196. ;    This function sets the MMU TC register.  It assumes a 68020 
  197. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  198. ;    you call this, or you wind up in The Guru Zone).  
  199. ;
  200. ;    void SetTC(ULONG)
  201. ;
  202. ;======================================================================
  203.  
  204. _SetTC:
  205.     lea.l    4(sp),a0        ; Get address of our new TC value
  206.     move.l    4,a6            ; Get ExecBase
  207.     move.l    a5,-(sp)
  208.     lea.l    1$,a5            ; Get the start of the supervisor code
  209.      CALLSYS    Supervisor
  210.     move.l    (sp)+,a5
  211.     rts
  212. 1$
  213.     PMOVE_    (a0),tc            ; Just set the TC register
  214.     rte
  215.  
  216.     end
  217.