home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff233.lzh / CacheCard / 030Stuff.a < prev    next >
Text File  |  1989-07-29  |  4KB  |  165 lines

  1. ;======================================================================
  2. ;
  3. ;    CacheCard V1.0
  4. ;    Copyright 1989 by Dave Haynie
  5. ;
  6. ;    68030 Assembly Function Module
  7. ;
  8. ;    This module contains MMU access functions.
  9. ;
  10. ;======================================================================
  11.  
  12. ;======================================================================
  13. ;
  14. ;    Macros & constants used herein...
  15. ;
  16. ;======================================================================
  17.  
  18. CALLSYS macro   *
  19.     jsr     LVO\1(A6)
  20.     endm
  21.  
  22. AFB_68030    EQU    2
  23.  
  24. ATNFLGS        EQU    $129
  25.  
  26. LVOSupervisor    EQU    -30
  27. LVOFindTask    EQU    -294
  28.  
  29. ;======================================================================
  30. ;
  31. ;    Need just a little more stuff
  32. ;
  33. ;======================================================================
  34.  
  35.     NOLIST
  36.     include "exec/execbase.i"
  37.     include "exec/tasks.i"
  38.     LIST
  39.  
  40.     machine mc68020
  41.         mc68881
  42.     cseg
  43.  
  44. ;**********************************************************************
  45. ;
  46. ;    This section contains functions that identify and operate on
  47. ;    MMU things.  Unfortunately, there aren't any MMU op-codes in
  48. ;    the Manx assembler yet, so I have to fudge them here.
  49. ;
  50. ;**********************************************************************
  51.  
  52.     public _GetMMUType    ; Returns the type of MMU
  53.     public _GetCRP        ; Gets MMU CRP register
  54.     public _GetTC        ; Gets MMU TC register
  55.  
  56. ;======================================================================
  57. ;
  58. ;    This function returns 0L if the system contains no MMU, 
  59. ;    68851L if the system does contain an 68851, or 68030L if the
  60. ;    system contains a 68030.
  61. ;
  62. ;    This routine seems to lock up on at least some CSA 68020 
  63. ;    boards, though it runs just fine on those from Ronin and 
  64. ;    Commodore, as well as all 68030 boards it's been tested on.
  65. ;
  66. ;    ULONG GetMMUType()
  67. ;
  68. ;======================================================================
  69.  
  70. _GetMMUType:
  71.     move.l    4,a6            ; Get ExecBase
  72.     movem.l    a3/a4/a5,-(sp)        ; Save this stuff
  73.     move.l    #0,a1    
  74.     CALLSYS    FindTask        ; Call FindTask(0L)
  75.     move.l    d0,a3
  76.  
  77.     move.l    TC_TRAPCODE(a3),a4    ; Change the exception vector
  78.     move.l    #2$,TC_TRAPCODE(a3)
  79.     
  80.     move.l    #-1,d0            ; Try to detect undecode FPU
  81.     subq.l    #4,sp            ; Let's try an MMU instruction
  82.     dc.w    $f017            ; Slimey PMOVE tc,(sp)
  83.     dc.w    $4200
  84.     cmpi    #0,d0            ; Any MMU here?
  85.     beq    1$
  86.     cmpi    #-1,d0            ; Hardware bugs?
  87.     beq    1$
  88.     btst.b    #AFB_68030,ATNFLGS(a6)    ; Does the OS think an '030 is here?
  89.     beq    1$
  90.     move.l    #68030,d0
  91.  
  92. 1$
  93.     addq.l    #4,sp            ; Return that local
  94.     move.l    a4,TC_TRAPCODE(a3)    ; Reset exception stuff
  95.     movem.l    (sp)+,a3/a4/a5        ; and return the registers
  96.     rts
  97.  
  98.     ; This is the exception code.  No matter what machine we're on,
  99.     ; we get an exception.  If the MMU's in place, we should get a
  100.     ; privilige violation; if not, an F-Line emulation exception.
  101. 2$
  102.     move.l    (sp)+,d0        ; Get Amiga supplied exception #
  103.     cmpi    #11,d0            ; Is it an F-Line?
  104.     beq    3$            ; If so, go to the fail routine
  105.     move.l    #68851,d0        ; We have MMU
  106.     addq.l    #4,2(sp)        ; Skip the MMU instruction
  107.     rte
  108. 3$
  109.     moveq.l    #0,d0            ; It dinna woik,
  110.     addq.l    #4,2(sp)        ; Skip the MMU instruction
  111.     rte
  112.  
  113. ;======================================================================
  114. ;
  115. ;    This function returns the MMU CRP register.  It assumes a 68020 
  116. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  117. ;    you call this, or you wind up in The Guru Zone).  Note that the
  118. ;    CRP register is two longwords long.
  119. ;
  120. ;    void GetCRP(ULONG *)
  121. ;
  122. ;======================================================================
  123.  
  124. _GetCRP:
  125.     move.l    4(sp),a0        ; Pointer to the CRP storage area
  126.     move.l    4,a6            ; Get ExecBase
  127.     move.l    a5,-(sp)
  128.     lea    2$,a5            ; Get the start of the supervisor code
  129.     CALLSYS    Supervisor
  130.     move.l    (sp)+,a5
  131.     rts
  132. 2$
  133.     dc.w    $f010            ; PMOVE CRP,(a0)
  134.     dc.w    $4e00
  135.     rte
  136.  
  137. ;======================================================================
  138. ;
  139. ;    This function returns the MMU TC register.  It assumes a 68020 
  140. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  141. ;    you call this, or you wind up in The Guru Zone).  
  142. ;
  143. ;    ULONG GetTC()
  144. ;
  145. ;======================================================================
  146.  
  147. _GetTC:
  148.     move.l    4,a6            ; Get ExecBase
  149.     move.l    a5,-(sp)
  150.     subq.l    #4,sp            ; Make a place to dump TC
  151.     move.l    sp,a0
  152.     lea    2$,a5            ; Get the start of the supervisor code
  153.     CALLSYS    Supervisor
  154.     move.l    (sp),d0            ; Here's the result
  155.     addq.l    #4,sp
  156.     move.l    (sp)+,a5
  157.     rts
  158. 2$
  159.     dc.w    $f010            ; PMOVE TC,(a0)
  160.     dc.w    $4200
  161.     rte
  162.  
  163.     end
  164.  
  165.