[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] MiNT on Coldfire



V Ne, 11. 07. 2004 v 17:41, Konrad Kokoszkiewicz píše:
> writes should not set these bits"). If there's some better way to
> differentiate 68030 and 68040, I am all ears.

>From linux-m68k Atari bootstrap (written by Arjan Knor, Robert de Vries,
Roman Hodek and Andreas Schwab, GPL):

static int test_cpu_type (void)
{
    int rv;
    static char testarray[4] = { 0, 0, 1, 1 };
    
    __asm__ __volatile__ (
	"movel	0x2c,a0\n\t"		/* save line F vector */
	"movel	sp,a1\n\t"		/* save stack pointer */
	"movew	sr,d2\n\t"		/* save sr */
	"orw	#0x700,sr\n\t"		/* disable interrupts */
	"moveq	#0,%0\n\t"		/* assume 68000 (or 010) */

	"moveq	#1,d1\n\t"
	"tstb	%1@(d1:l:2)\n\t"	/* pre-020 CPU ignores scale and reads
					 * 0, otherwise 1 */
	"beq	1f\n\t"			/* if 0 is 68000, end */
	"moveq	#20,%0\n\t"		/* now assume 68020 */

	"movel	#2f,0x2c\n\t"	 	/* continue if trap */
	"movel	%1,a2\n\t"
	"nop	\n\t"
	".long	0xf0120a00\n\t"		/* pmove tt0,a2@, tt0 only on '030 */
	"nop	\n\t"
	"moveq	#30,%0\n\t"		/* surely is 68030 */
	"bra	1f\n"
	"2:\t"
					/* now could be '020 or '040+ */
	"movel	#1f,0x2c\n\t"	 	/* end if trap */
	"movel	%1,a2\n\t"
	"nop	\n\t"
	".long	0xf622a000\n\t"		/* move16 a2@+,a2@+ only on '040+ */
	"nop	\n\t"
	"moveq	#40,%0\n\t"		/* assume 68040 */

	"nop	\n\t"
	".word	0xf5ca\n\t"		/* plpar a2@, only on '060 */
	"nop	\n\t"
	"moveq	#60,%0\n"		/* surely is 68060 */

	"1:\t"
	"movel	a1,sp\n\t"		/* restore stack */
	"movel	a0,0x2c\n\t"		/* restore line F vector */
	"movew	d2,sr"			/* reenable ints */
	: "=&d" (rv)
	: "a" (testarray)
	: "d1", "d2", "a0", "a1", "a2", "memory" );
    return( rv );
}