muimaster.library: update minor version
[AROS.git] / arch / m68k-amiga / boot / cpu_detect.S
blob2c4cb00622c794d0394e0ca2c6fdc596fdeedd55
1         .text
2         .chip 68060
3         .align 4 
5 /* Detect CPU and FPU type */
7         .globl _cpu_detect
8 _cpu_detect:
9         move.l  %a0,%a2
10         clr.l   %a2@(4)
11         lea             %pc@(cpu_detect_trap_illg),%a1
12         move.l  %a1,4*4.w       /* illegal instruction */
13         lea             %pc@(fpu_detect_trap_f),%a1
14         move.l  %a1,11*4.w      /* f-line */
15         bsr             cpu_detect_asm
16         move.w  %d0,%d2
17         bsr             cpu_detect_fpu_asm
18         swap    %d2
19         move.w  %d0,%d2
20         swap    %d2
21         move.l  %d2,%a2@
22         rts
24 cpu_detect_fpu_asm:
25         move.l  %sp,%a1
26         lea             %sp@(-60),%sp
27         move.l  %sp,%a0
28         clr.w   (%a0)
29         fnop
30         fsave   (%a0)
31         move.w  #0x8000,%d0
32         move.b  1(%a0),%d0
33         move.l  %a1,%sp
34         rts             /* return to cpu_detect */
36 fpu_detect_trap_f:
37         move.l  %a1,%sp
38         moveq   #0,%d0
39         rts             /* return to cpu_detect */
41 cpu_detect_asm:
42         move.l  %sp,%a1
43         moveq   #0,%d0
44         /* VBR is 68010+ */
45         movec   %d0,%vbr
46         move.w  #0x0001,%d0
47         /* CACR is 68020+ */
48         movec   %cacr,%d0
49         /* 68020+ or better */
50         move.l  #0x00008000,%d0
51         /* enable 68040/060 code cache */
52         movec   %d0,%cacr
53         movec   %cacr,%d0
54         /* bit 15 still set? */
55         tst.w   %d0
56         /* yes, it is 68040 or 68060 */
57         bmi.s   0f
58         /* enable 68020/030 code cache and 68030 data cache */
59         move.l  #0x0101,%d0
60         movec   %d0,%cacr
61         movec   %cacr,%d0
62         /* disable caches */
63         moveq   #0,%d1
64         movec   %d1,%cacr
65         /* data cache bit still set? */
66         btst    #8,%d0
67         bne.s   1f /* yes, it is 68030 */
68         /* 68020 */
69         move.w  #0x0003,%d0
70         bra cpu_detect_trap_illg
71         /* 68030 */
73         move.w  #0x0007,%d0
74         bra cpu_detect_trap_illg
75         /* 68040 or 68060 */
77         moveq   #0,%d0
78         /* disable caches */
79         movec   %d0,%cacr
80         /* data cache must be invalidated after reset */
81         cinva %dc
82         /* set transparent translation registers,
83          * allow data caching only in 32-bit fast,
84          * code caching allowed everywhere */
85         movec   %d0,%itt1
86         move.l  #0x0000e040,%d0
87         movec   %d0,%dtt0
88         move.l  #0x00ffe000,%d0
89         movec   %d0,%dtt1
90         movec   %d0,%itt0
91         move.w  #0x000f,%d0
92         /* PCR is 68060 only */
93         movec   %pcr,%d1
94         /* 68060 */
95         moveq   #0,%d0
96         cmp.w   #0x0600,%d1
97         bcc.s   2f
98         /* rev5 or older 68060 revision
99          * enable I14 and I15 errata workaround
100          */
101         bset    #5,%d0
102 2:      /* Also enables FPU */
103         movec   %d0,%pcr
104         movec   %pcr,%d0
105         move.l  %d0,%a2@(4) // save PCR
106         move.w  #0x008f,%d0
107 cpu_detect_trap_illg:
108         move.l %a1,%sp  /* remove exception stack frame */
109         rts                             /* return to cpu_detect() */