[comp.sys.amiga.tech] 020 & 030 CACR

lkoop@pnet01.cts.com (Lamonte Koop) (10/03/90)

Now that I finally have some working code for reading/setting the
68020..030...???  CACR, I have ONE question.  I realize it would be a good
idea to disable task switching and such when SETTING the CACR, but how 'bout
reading it?  I know you CAN do either one with task switching uninhibited (or
interrupts for that matter), but just how necessary is it?  (I don't like to
inhibit the system unneccessarily).  Any thoughts?
 
--LaMonte

"The MOST original .sig yet: A non-existant one!"

UUCP: {hplabs!hp-sdd ucsd nosc}!crash!pnet01!lkoop
ARPA: crash!pnet01!lkoop@nosc.mil
INET: lkoop@pnet01.cts.com

peter@dbaccess.com (Peter A. Castro) (10/05/90)

in article <4788@crash.cts.com>, lkoop@pnet01.cts.com (Lamonte Koop) says:
+ 
+ Now that I finally have some working code for reading/setting the
+ 68020..030...???  CACR, I have ONE question.  I realize it would be a good
+ idea to disable task switching and such when SETTING the CACR, but how 'bout
+ reading it?  I know you CAN do either one with task switching uninhibited (or
+ interrupts for that matter), but just how necessary is it?  (I don't like to
+ inhibit the system unneccessarily).  Any thoughts?

   Um, how often are you planning on reading it?  Really, you should treat it
   as if it were an EXEC system list.  This means Disabling and Enabling.
   After all, if you are traversing this list and it should be changed while
   you were swapped out, well... you'll get to visit the Guru almost certainly.
+  
+ --LaMonte
+ 
+ "The MOST original .sig yet: A non-existant one!"
+ 
+ UUCP: {hplabs!hp-sdd ucsd nosc}!crash!pnet01!lkoop
+ ARPA: crash!pnet01!lkoop@nosc.mil
+ INET: lkoop@pnet01.cts.com

Peter A. Castro                   INTERNET: peter@dbaccess.com        // //|
c/o DB/Access Inc.                UUCP: {uunet,mips}!troi!peter      // //||
2900 Gordon Avenue, Suite 101     FAX: (408) 735-0328            \\ // //-||-
Santa Clara, CA 95051-0718        TEL: (408) 735-7545             \// //  ||
-- 
Peter A. Castro                   INTERNET: peter@dbaccess.com        // //|
c/o DB/Access Inc.                UUCP: {uunet,mips}!troi!peter      // //||
2900 Gordon Avenue, Suite 101     FAX: (408) 735-0328            \\ // //-||-
Santa Clara, CA 95051-0718        TEL: (408) 735-7545             \// //  ||

daveh@cbmvax.commodore.com (Dave Haynie) (10/05/90)

In article <4788@crash.cts.com> lkoop@pnet01.cts.com (Lamonte Koop) writes:
>Now that I finally have some working code for reading/setting the
>68020..030...???  CACR, I have ONE question.  I realize it would be a good
>idea to disable task switching and such when SETTING the CACR, but how 'bout
>reading it?  

You have no choice.  In order to execute the MOVEC instruction, you must be
in Supervisor mode.  Tasks don't swap in Supervisor mode.  As for directly
using the MOVEC op-code, you're taking a bit of risk, it's non-portable.  For
example, if you use MOVEC to modify some cache parameters in 2.0, you will
soon find them set back to their original state by the OS.  The SetCPU V1.6
source code has SetCACR() and GetCACR() functions, which work under 1.3 and
under 2.0.  And once you move to a 68040 processor, the bit assignments in
the CACR work differently.

In general, if you think you need to modify the cache parameters yourself,
you probably need to rethink what you're doing.  Cache clearing is required
by device drivers for DMA devices.  Other than that, there are only a few
real applications that should be using these calls -- they are a rather large
speed penalty.  Cache control is really an OS function, and should only be
done by programs that are doing OS style things, like the aforementioned
device drivers.  And you have to be careful about switching things off.  For
example, if you simply switch off the I and/or D caches via CACR, you're safe
for awhile.  But when you turn them back on, the caches are still valid, though
they can very easily be, in reality, stale.  So it's always a good idea to 
clear any cache you turn on.  

>--LaMonte


-- 
Dave Haynie Commodore-Amiga (Amiga 3000) "The Crew That Never Rests"
   {uunet|pyramid|rutgers}!cbmvax!daveh      PLINK: hazy     BIX: hazy
	Standing on the shoulders of giants leaves me cold	-REM