home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 575.lha / Personal040DevelopSoft / 040stuff1.a < prev    next >
Text File  |  1991-11-05  |  12KB  |  467 lines

  1. *======================================================================
  2. *
  3. *    FastROM 040 V1.0 by Greg Tibbs Rev a.01 1 Nov 91
  4. *       From SetCpu V1.4
  5. *    by Dave Haynie (released to the public domain)
  6. *
  7. *    68040 Assembly Function Module
  8. *
  9. *    This module contains functions that access functions in the 68040.
  10. *
  11. *======================================================================
  12.  
  13. *======================================================================
  14. *
  15. *    Macros & constants used herein...
  16. *
  17. *======================================================================
  18.  
  19.  
  20. CALLSYS macro   *
  21.     jsr     LVO\1(A6)
  22.     endm
  23.  
  24.  
  25. AFB_68040    EQU    3
  26.  
  27. ATNFLGS        EQU    $129
  28.  
  29. LVOSupervisor    EQU    -30
  30.  
  31.     cseg
  32.  
  33.     XDEF    _GetCPUType    * ID the CPU
  34.     XDEF    _GetCACR    * Get 040 CACR register
  35.     XDEF    _SetCACR    * Set 040 CACR register
  36.     XDEF    _GetCRP        * Gets MMU URP register
  37.         XDEF    _GetSRP        * Gets MMU SRP register
  38.     XDEF    _SetCRP        * Sets MMU SRP & URP register
  39.     XDEF    _GetTC        * Gets MMU TC register
  40.     XDEF    _SetTC        * Gets MMU TC register
  41.     XDEF    _DumpCache    * Dumps All 040 Caches
  42.     XDEF    _GetDTT0    * Gets data translation reg 0
  43.     XDEF    _GetDTT1    * Gets data translation reg 1
  44.     XDEF    _GetITT0    * Gets instruction translation reg 0  
  45.     XDEF    _GetITT1    * Gets instruction translation reg 1
  46.     XDEF    _SetDTT0    * Save data translation reg 0
  47.     XDEF    _SetDTT1    * Save data translation reg 1
  48.     XDEF    _SetITT0    * Save instruction translation reg 0  
  49.     XDEF    _SetITT1    * Save instruction translation reg 1
  50.         XDEF    _GetVBR        * Get the Vector Base Register
  51.         XDEF    _SetVBR        * Set the Vector Base Register
  52.         XDEF    _GetMMUStatus   * Get MMU Status Register
  53.  
  54. *======================================================================
  55. *
  56. *    This function returns the type of the CPU in the system if it is
  57. *    a 68040, 0 otherwise. Expects Exec to have 040 flag set (DOS 2.0+)
  58. *
  59. *    ULONG GetCPUType()
  60. *
  61. *======================================================================
  62.  
  63. _GetCPUType:
  64.     movem.l    a4/a5,-(sp)        * Save this register
  65.     move.l    4,a6            * Get ExecBase
  66.     btst.b    #AFB_68040,ATNFLGS(a6)    * Does the OS think an '040 is here?
  67.     beq    0$
  68.     move.l    #68040,d0        * Sure does...
  69.     movem.l    (sp)+,a4/a5
  70.     rts
  71.  
  72. 0$    move.l    #0,d0            * Not an '040
  73.     movem.l    (sp)+,a4/a5
  74.     rts
  75.  
  76. *======================================================================
  77. *
  78. *    This function returns the 68040 CACR register.  
  79. *
  80. *    ULONG GetCACR()
  81. *
  82. *======================================================================
  83.  
  84. _GetCACR:
  85.     move.l    4,a6            * Get ExecBase
  86.     move.l    a5,-(sp)        * Save this register
  87.     lea    1$,a5            * Get the start of the supervisor code
  88.     CALLSYS    Supervisor
  89.     move.l    (sp)+,a5        * Give back registers
  90.     rts
  91. 1$
  92. *    movec    cacr,d0            * Make CACR the return value
  93.         dc.w    $4e7a
  94.         dc.w    $0002
  95.     rte
  96.  
  97. *======================================================================
  98. *
  99. *    This function sets the value of the 68040 CACR register.  
  100. *
  101. *    void SetCACR(cacr)
  102. *    ULONG cacr
  103. *
  104. *======================================================================
  105.  
  106. _SetCACR:
  107.     move.l    4(sp),d0        * New CACR is on stack
  108.     move.l    4,a6            * Get ExecBase
  109.     move.l    a5,-(sp)        * Save this register
  110.     lea    2$,a5            * Get the start of the supervisor code
  111.     CALLSYS    Supervisor
  112.     move.l    (sp)+,a5        * Give back register
  113.     rts
  114. 2$
  115. *    movec    d0,cacr            * Set the CACR
  116.        dc.w    $4e7b
  117.     dc.w    $0002
  118.     rte
  119.  
  120. *======================================================================
  121. *
  122. *    This function returns the MMU URP register.  It assumes a 68040 
  123. *    Note that the CRP register is two longwords long. This code
  124. *       assumes that the SRP and URP point to the same table.
  125. *
  126. *    ULONG GetCRP()
  127. *
  128. *======================================================================
  129.  
  130. _GetCRP:
  131.     move.l    4,a6            * Get ExecBase
  132.     move.l    a5,-(sp)
  133.     lea    3$,a5            * Get the start of the supervisor code
  134.     CALLSYS    Supervisor
  135.     move.l    (sp)+,a5
  136.     rts
  137. 3$
  138.     dc.w    $4E7A            * MOVEC URP,D0
  139.     dc.w    $0806
  140.     rte
  141. *======================================================================
  142. *
  143. *    This function returns the MMU SRP register.  It assumes a 68040 
  144. *    Note that the CRP register is two longwords long. This code
  145. *       assumes that the SRP and URP point to the same table.
  146. *
  147. *    ULONG GetCRP()
  148. *
  149. *======================================================================
  150.  
  151. _GetSRP:
  152.     move.l    4,a6            * Get ExecBase
  153.     move.l    a5,-(sp)
  154.     lea    3$,a5            * Get the start of the supervisor code
  155.     CALLSYS    Supervisor
  156.     move.l    (sp)+,a5
  157.     rts
  158. 3$
  159.     dc.w    $4E7A            * MOVEC SRP,D0
  160.     dc.w    $0807
  161.     rte
  162.  
  163. *======================================================================
  164. *
  165. *    This function sets both the MMU SRP and URP registers.  It 
  166. *    assumes a 68040 based system  Note that the 68030 CRP register is 
  167. *    two longwords long but that the 040 SRP & URP are only one longword long.
  168. *
  169. *    void SetCRP(ULONG)
  170. *
  171. *======================================================================
  172.  
  173. _SetCRP:
  174.     move.l    4(sp),d0        * Load URP data
  175.     move.l    4,a6            * Get ExecBase
  176.     move.l    a5,-(sp)
  177.     lea    4$,a5            * Get the start of the supervisor code
  178.     CALLSYS    Supervisor
  179.     move.l    (sp)+,a5        * Give back registers
  180.     rts
  181. 4$
  182.     dc.w    $4e7b            * MOVEC D0,URP
  183.     dc.w    $0806
  184.         dc.w    $4e7b            * MOVEC D0,SRP
  185.         dc.w    $0807
  186.     rte                
  187.  
  188. *======================================================================
  189. *
  190. *    This function returns the MMU TC register.  It assumes a 68040 
  191. *    system.  
  192. *
  193. *    ULONG GetTC()
  194. *
  195. *======================================================================
  196.  
  197. _GetTC:
  198.     move.l    4,a6            * Get ExecBase
  199.     move.l    a5,-(sp)
  200.     lea    5$,a5            * Get the start of the supervisor code
  201.     CALLSYS    Supervisor
  202.     move.l    (sp)+,a5
  203.     rts
  204. 5$
  205.     dc.w    $4e7a            * 040 MOVEC TC,D0 
  206.     dc.w    $0003
  207.     rte
  208.  
  209. *======================================================================
  210. *
  211. *    This function sets the MMU TC register.  It assumes a 68040. 
  212. *
  213. *    void SetTC(ULONG)
  214. *
  215. *======================================================================
  216.  
  217. _SetTC:
  218.     move.l    4(sp),d0        * Get address of our new TC value
  219.     move.l    4,a6            * Get ExecBase
  220.     move.l    a5,-(sp)
  221.     lea    6$,a5            * Get the start of the supervisor code
  222.      CALLSYS    Supervisor
  223.     move.l    (sp)+,a5
  224.     rts
  225. 6$
  226.     dc.w    $4e7b            * 040 MOVEC D0,TC 
  227.     dc.w    $0003
  228.     rte
  229.  
  230. *======================================================================
  231. *
  232. *    This function Dumps the Data, Instruction and Address Translation
  233. *       Caches  It assumes a 68040 system. You should have all caches turned  
  234. *     off first before calling this function or they will refill before
  235. *       you can reprogram the MMU!
  236. *
  237. *    void DumpCache()
  238. *
  239. *======================================================================
  240.  
  241. _DumpCache:
  242.     move.l    4,a6            * Get ExecBase
  243.     move.l    a5,-(sp)
  244.     lea    6$,a5            * Get the start of the supervisor code
  245.      CALLSYS    Supervisor
  246.     move.l    (sp)+,a5
  247.     rts
  248. 6$
  249.     dc.w    $f518            * PFLUSHA (BC) - Invalidate ATC
  250.         dc.w    $f4f8            * CPUSHA (BC) - Force Cache flush
  251.     dc.w    $f4d8            * CINVA (BC) - Invalidate I & D Caches
  252.     rte
  253. *======================================================================
  254. *
  255. *    ULONG GetITT0()
  256. *
  257. *======================================================================
  258.  
  259. _GetITT0:
  260.     move.l    4,a6            * Get ExecBase
  261.     move.l    a5,-(sp)        * Save this register
  262.     lea    7$,a5            * Get the start of the supervisor code
  263.     CALLSYS    Supervisor
  264.     move.l    (sp)+,a5        * Give back registers
  265.     rts
  266. 7$
  267. *    movec    itt0,d0            * Make ITT0 the return value
  268.         dc.w    $4e7a
  269.         dc.w    $0004
  270.     rte
  271.  
  272. *======================================================================
  273. *
  274. *    ULONG GetITT1()
  275. *
  276. *======================================================================
  277.  
  278. _GetITT1:
  279.     move.l    4,a6            * Get ExecBase
  280.     move.l    a5,-(sp)        * Save this register
  281.     lea    8$,a5            * Get the start of the supervisor code
  282.     CALLSYS    Supervisor
  283.     move.l    (sp)+,a5        * Give back registers
  284.     rts
  285. 8$
  286. *    movec    itt1,d0            * Make ITT1 the return value
  287.         dc.w    $4e7a
  288.         dc.w    $0005
  289.     rte
  290.  
  291. *======================================================================
  292. *
  293. *    ULONG GetDTT0()
  294. *
  295. *======================================================================
  296.  
  297. _GetDTT0:
  298.     move.l    4,a6            * Get ExecBase
  299.     move.l    a5,-(sp)        * Save this register
  300.     lea    9$,a5            * Get the start of the supervisor code
  301.     CALLSYS    Supervisor
  302.     move.l    (sp)+,a5        * Give back registers
  303.     rts
  304. 9$
  305. *    movec    dtt0,d0            * Make DTT0 the return value
  306.         dc.w    $4e7a
  307.         dc.w    $0006
  308.     rte
  309.  
  310. *======================================================================
  311. *
  312. *    ULONG GetDTT1()
  313. *
  314. *======================================================================
  315.  
  316. _GetDTT1:
  317.     move.l    4,a6            * Get ExecBase
  318.     move.l    a5,-(sp)        * Save this register
  319.     lea    10$,a5            * Get the start of the supervisor code
  320.     CALLSYS    Supervisor
  321.     move.l    (sp)+,a5        * Give back registers
  322.     rts
  323. 10$
  324. *    movec    dtt1,d0            * Make DTT1 the return value
  325.         dc.w    $4e7a
  326.         dc.w    $0007
  327.     rte
  328.  
  329. *======================================================================
  330. *
  331. *    void SetITT0(ULONG)
  332. *
  333. *======================================================================
  334.  
  335. _SetITT0:
  336.     move.l    4(sp),d0        * Load ITT0 data
  337.     move.l    4,a6            * Get ExecBase
  338.     move.l    a5,-(sp)
  339.     lea    11$,a5            * Get the start of the supervisor code
  340.     CALLSYS    Supervisor
  341.     move.l    (sp)+,a5        * Give back registers
  342.     rts
  343. 11$
  344.     dc.w    $4e7b            * MOVEC D0,ITT0
  345.     dc.w    $0004
  346.     rte                
  347.  
  348. *======================================================================
  349. *
  350. *    void SetITT1(ULONG)
  351. *
  352. *======================================================================
  353.  
  354. _SetITT1:
  355.     move.l    4(sp),d0        * Load ITT1 data
  356.     move.l    4,a6            * Get ExecBase
  357.     move.l    a5,-(sp)
  358.     lea    12$,a5            * Get the start of the supervisor code
  359.     CALLSYS    Supervisor
  360.     move.l    (sp)+,a5        * Give back registers
  361.     rts
  362. 12$
  363.     dc.w    $4e7b            * MOVEC D0,ITT1
  364.     dc.w    $0005
  365.     rte                
  366.  
  367. *======================================================================
  368. *
  369. *    void SetDTT0(ULONG)
  370. *
  371. *======================================================================
  372.  
  373. _SetDTT0:
  374.     move.l    4(sp),d0        * Load DTT0 data
  375.     move.l    4,a6            * Get ExecBase
  376.     move.l    a5,-(sp)
  377.     lea    13$,a5            * Get the start of the supervisor code
  378.     CALLSYS    Supervisor
  379.     move.l    (sp)+,a5        * Give back registers
  380.     rts
  381. 13$
  382.     dc.w    $4e7b            * MOVEC D0,DTT0
  383.     dc.w    $0006
  384.     rte                
  385.  
  386. *======================================================================
  387. *
  388. *    void SetDTT1(ULONG)
  389. *
  390. *======================================================================
  391.  
  392. _SetDTT1:
  393.     move.l    4(sp),d0        * Load DTT1 data
  394.     move.l    4,a6            * Get ExecBase
  395.     move.l    a5,-(sp)
  396.     lea    14$,a5            * Get the start of the supervisor code
  397.     CALLSYS    Supervisor
  398.     move.l    (sp)+,a5        * Give back registers
  399.     rts
  400. 14$
  401.     dc.w    $4e7b            * MOVEC D0,DTT1
  402.     dc.w    $0007
  403.     rte                
  404. *======================================================================
  405. *
  406. *    This function returns the VBR register.  It assumes > 68000 
  407. *    system.  
  408. *
  409. *    ULONG GetTC()
  410. *
  411. *======================================================================
  412.  
  413. _GetVBR:
  414.     move.l    4,a6            * Get ExecBase
  415.     move.l    a5,-(sp)
  416.     lea    15$,a5            * Get the start of the supervisor code
  417.     CALLSYS    Supervisor
  418.     move.l    (sp)+,a5
  419.     rts
  420. 15$
  421.     dc.w    $4e7a            * 040 MOVEC VBR,D0 
  422.     dc.w    $0801
  423.     rte
  424.  
  425. *======================================================================
  426. *
  427. *    This function sets the VBR register.  It assumes > 68000. 
  428. *
  429. *    void SetTC(ULONG)
  430. *
  431. *======================================================================
  432.  
  433. _SetVBR:
  434.     move.l    4(sp),d0        * Get address of our new TC value
  435.     move.l    4,a6            * Get ExecBase
  436.     move.l    a5,-(sp)
  437.     lea    16$,a5            * Get the start of the supervisor code
  438.      CALLSYS    Supervisor
  439.     move.l    (sp)+,a5
  440.     rts
  441. 16$
  442.     dc.w    $4e7b            * 040 MOVEC D0,VBR 
  443.     dc.w    $0801
  444.     rte
  445. *======================================================================
  446. *
  447. *    This function returns the MMU TC register.  It assumes a 68040 
  448. *    system.  
  449. *
  450. *    ULONG GetMMUStatus()
  451. *
  452. *======================================================================
  453.  
  454. _GetMMUStatus:
  455.     move.l    4,a6            * Get ExecBase
  456.     move.l    a5,-(sp)
  457.     lea    17$,a5            * Get the start of the supervisor code
  458.     CALLSYS    Supervisor
  459.     move.l    (sp)+,a5
  460.     rts
  461. 17$
  462.     dc.w    $4e7a            * 040 MOVEC MMUSR,D0 
  463.     dc.w    $0805
  464.     rte
  465.  
  466.         END
  467.