Removed autodocs of arch specific variants of ROM modules.
[AROS.git] / arch / m68k-amiga / boot / rom_init.S
blob70bc57e0cf8db8e11a32b3ee66ca98c650180a30
2 #include <aros/m68k/asm.h>
3 #include <aros/config.h>
5         .text
6         .chip 68000
7         .align 4 
9         .globl rom_init
10 rom_init:
11         bra.w normal_init
12         bra.w arosbootstrap_init
14 normal_init:
16         /* Wait a bit for reset to finish.
17          * Simulate ROM checksum check.
18          */
19         lea             0x00f80000,%a0
20         move.l  #524288/4,%d0
21         moveq   #0,%d1
22 0:      add.l   (%a0)+,%d1
23         bcc.s   1f
24         addq.l  #1,%d1
25 1:      subq.l  #1,%d0
26         bne.s   0b
28         /* Check for cartridge ROM */
29         lea     0xf00000,%a0
30         move.w  %a0@(0),%d0     /* Get the ROM ID (0x1111) */
31         cmp.w   #0x1111,%d0
32         bne.s   0f              /* Must be 0x1111 */
33         lea %pc@(0),%a1
34         move.l %a1,%d0
35         clr.w %d0
36         cmp.l %d0,%a0
37         beq.s 0f /* skip if we booted at 0xF00000 */
38         lea     0x40000,%sp     /* Safe stack at Chip Mem 128K */
39         lea     0f,%a5
40         jmp     %a0@(2)
43         /* Disable the overlay, power led off. */
44         moveq   #0,%d0
45         move.b  %d0,0xbfe001
46         moveq   #0x3,%d0
47         move.b  %d0,0xbfe201
49 arosbootstrap_init:
51         /* Initial Custom chipset setup. Does same writes as AOS.
52          * It is possible some bus snooping hardware assumes this.
53          */
54         lea.l   0xdff000,%a0
55         move.w  #0x7fff,%d0
56         move.w  %d0,0x9a(%a0)   /* Interrupt disable */
57         move.w  %d0,0x9c(%a0)   /* Clear interrupts */
58         move.w  %d0,0x96(%a0)   /* Stop DMA */
59         move.w  #0x0174,0x032(%a0)      /* SERPER */
60         move.w  #0x0200,0x100(%a0)      /* BPLCON0 */
61         move.w  #0x0000,0x110(%a0)      /* BPL1DAT */
62         move.w  #0x0111,0x180(%a0)      /* COLOR00 */
64         /* temp system stack */
65         lea.l   _ss_end,%sp             /* System stack */
66         /* Put the memory bank array at the bottom of the stack, reserve space for extra memory bank */
67         lea.l   _ss,%a5
69         /* Do we have a Gayle? */
70         sub.l   %a6,%a6
71         jsr     AROS_SLIB_ENTRY(ReadGayle,Exec,136)
72         moveq   #0,%d6
73         tst.b   %d0
74         beq.s   .nopcmcia
75         moveq   #1,%d6
76         /* Disable PCMCIA slot */
77         move.b  #1,0xda8000
78 .nopcmcia:
79         swap    %d6
81         move.l  %a5,%a4 /* Space for CPU/FPU data array */
82         lea             16(%a5),%a5     /* Space also reserved for extra membank */
83         move.l  %a4,%a0
84         jsr     _cpu_detect
85         /* High word = gayle flag, low word = AttnFlags */
86         move.w  %a4@(2),%d6
88         btst    #2,%d6          /* AttnFlags AFB_68030? */
89         bne.s   .is32bit
90         btst    #1,%d6          /* AttnFlags AFB_68020? */
91         beq.s   .test32bit
92         /* 32-bit CPU check only, no memory tested */
93         move.l  #0x08000000,%a0
94         move.l  #0x08000000,%a1
95         move.l  #0x00100000,%d0
96         bsr             .L_memtest
97         bmi.s   .test32bit
98 .is32bit:
99         /* set AttnFlags AFB_ADDR32 */
100         or.w    #0x4000,%a4@(2)
101 .test32bit:
103         /* Memory region array is put into the
104          * system stack from the bottom up, so
105          * we check the non-autoconfig memory areas
106          * in order of fastest to slowest, going
107          * up the system stack in A5.
108          */
110         /* slow ram */
111         move.l  #0x00c00000,%a0
112         move.l  #0x00d80000,%a1
113         /* Limit max size if Gayle */
114         btst #16,%d6
115         bne.s   0f
116         move.l  #0x00dc0000,%a1
117 0:      move.l  #0x00040000,%d0
118         bsr             .L_memtest
119         
120         /* chip ram */
121         sub.l   %a0,%a0
122         move.l  #0x00200000,%a1
123         move.l  #0x00040000,%d0
124         bsr             .L_memtest
125         beq     chipfault
127         /* end of memory region list */
128         clr.l   %a5@+
129         clr.l   %a5@
131         lea.l   _ss,%a5
132         move.l  %a5,%sp@-       /* CPU/FPU data array */
133         lea             16(%a5),%a5
134         move.l  %a5,%sp@-       /* memory bank array */
135         jsr             exec_boot
137 chipfault:
138         move.w  #0x0f0,0xdff180
139 looping:
140         nop
141         bra.s   looping
143         .globl MemoryTest
144 MemoryTest:
145         movem.l %d2-%d5/%a2-%a3/%a5,%sp@-
146         move.w  0xdff01c,%sp@-  /* save INTENA */
147         subq.l  #8,%sp
148         move.l  %sp,%a5
149         bsr.s   .L_memtest
150         addq.l  #8,%sp
151         move.w  %sp@+,%d1
152         or.w    #0x8000,%d1
153         move.w  %d1,0xdff09a    /* restore INTENA */
154         movem.l %sp@+,%d2-%d5/%a2-%a3/%a5
155         rts
157         /******** Memory tester *******/
158          * IN: A0 - Address, A1 - Max end address, A5 - outtable
159          * IN: D0 = block size
160          * OUT: D0 - Detected size
161          * TRASH: D1, D2, D3, D4, D5, A1, A2, A3
162          */
163 .L_memtest:
164         move.l  %d0,%d5
165         move.l  %a0,%a5@                        /* write start address */
166         move.l  %a1,%d0
167         sub.l   %a0,%d0                         /* max size */
169         move.l  %a0,%d1
170         and.l   #0xff000000,%d1
171         beq.s   .L_memtest_24bitaddr
172         /* test if 32bit address mirrors address zero */
173         move.l  %d1,%a1
174         move.l  0.w,%d2                         /* save old */
175         move.l  0x100.w,%d3
176         move.l  #0xfecaf00d,%d1
177         move.l  %d1,0.w
178         nop
179         not.w   %d1
180         move.l  %d1,0x100.w                     /* write something else, some bus types "remember" old value */
181         not.w   %d1
182         nop                                                     /* force 68040/060 bus cycle to finish */
183         cmp.l   %a1@,%d1
184         bne.s   .L_memtest_32bitok      /* different? no mirror */
185         move.l  #0xcafed00d,%d1
186         move.l  %d1,0.w
187         nop
188         not.w   %d1
189         move.l  %d1,0x100.w
190         not.w   %d1
191         nop
192         cmp.l   %a1@,%d1
193         bne.s   .L_memtest_32bitok      /* check again, maybe 0 already had our test value */
194         move.l  %d2,0.w                         /* restore saved value */
195         move.l  %d3,0x100.w
196         moveq   #-1,%d1
197         bra             .L_memtest_none         /* 24-bit CPU, do not test this range */
198 .L_memtest_32bitok:
199         move.l  %d2,0.w                         /* restore saved value */
200         move.l  %d3,0x100.w
201 .L_memtest_24bitaddr:
203         /* a0 = tested address, d0 = max size, d1 = current size */
205         clr.l   %d1
206 .L_memtest_loop:
207         cmp.l   %d0,%d1
208         bge             .L_memtest_done
210         move.l  %a0,%d2
211         and.l   #0xff000000,%d2
212         bne.s   .L_memtest_chipcheck_done       /* no chiptest if 32bit address */
213         move.w  #0x7fff,0xdff09a
214         nop
215         tst.w   %a0@(0x1c,%d1)                          /* If non-zero, this is not INTENAR */
216         bne.s   .L_memtest_chipcheck_done
217         /* It was zero ... */
218         move.w  #0xc000,0xdff09a                        /* Try the master enable */
219         nop
220         tst.w   %a0@(0x1c,%d1)                          /* If still zero, not INTENAR */
221         bne     .L_memtest_done                         /* It was a custom chip. */
222 .L_memtest_chipcheck_done:
224         move.l  %a0,%a2
225         add.l   %d1,%a2
226         cmp.l   #.L_memtest,%a2         /* Make sure we don't modify our own test code */
227         bcs.s   .L_memtest_nottestcode
228         cmp.l   #.L_memtest_end,%a2
229         bcs.s   .L_memtest_next
230 .L_memtest_nottestcode:
232         move.l  %a0@(%d1),%d3           /* read old value */
233         move.l  %a0@,%a2                        /* save mirror test contents */
234         move.l  #0xfecaf00d,%a0@        /* write mirror test value */
235         nop
236         move.l  #0xcafed00d,%d2
237         move.l  %d2,%a0@(%d1)           /* write test pattern */
238         nop
239         tst.l   %d1                                     /* first test addrress? */
240         beq.s   .L_memtest_nomirror
241         cmp.l   %a0@,%d2                        /* no, check mirrorirng */
242         bne.s   .L_memtest_nomirror
243         move.l  %a2,%a0@                        /* restore mirror test contents */
244         bra.s   .L_memtest_done
245 .L_memtest_nomirror:
247         not.l   %d2
248         move.l  %a0@(4,%d1),%a3         /* read temp address */
249         move.l  %d2,%a0@(4,%d1)         /* fill bus with something else */
250         not.l   %d2
251         nop
252         move.l  %a0@(%d1),%d4           /* read test pattern */
253         move.l  %a3,%a0@(4,%d1)         /* restore */
255         cmp.l   %d4,%d2                         /* pattern match? */
256         bne.s   .L_memtest_done
257         neg.l   %d2                                     /* test pattern 2 */
259         move.l  %d2,%a0@(%d1)           /* write test pattern */
260         nop
261         not.l   %d2
262         move.l  %a0@(4,%d1),%a3         /* read temp address */
263         move.l  %d2,%a0@(4,%d1)         /* fill bus with something else */
264         not.l   %d2
265         nop
266         move.l  %a0@(%d1),%d4           /* read test pattern */
267         move.l  %a3,%a0@(4,%d1)         /* restore */
269         cmp.l   %d4,%d2
270         bne.s   .L_memtest_done
271         not.l   %d2
272         move.l  %d3,%a0@(%d1)           /* write old value back */
274         move.l  %a2,%a0@                        /* restore mirror test contents */
275 .L_memtest_next:
276         add.l   %d5,%d1                         /* next block */
277         bra             .L_memtest_loop
279 .L_memtest_done:
280         tst.l   %d1                                     /* nothing found? */
281         beq.s   .L_memtest_none
282         addq.l  #4,%a5
283         move.l  %d1,%a5@+
284 .L_memtest_none:
285         move.l  %d1,%d0
286         rts
287 .L_memtest_end:
289 #define STACK_OFFSET (6*4)
290         .globl Early_Exception
291 Early_Exception:
292         or.w    #0x0700,%sr
293 #if AROS_SERIAL_DEBUG
294         movem.l %d0-%d2/%a0-%a2,-(%sp)
296         lea             DebugPutHex,%a2
298         move.l  STACK_OFFSET+2(%sp),-(%sp)
299         pea             .earlystr1(%pc)
300         jsr             (%a2)
301         addq.l  #8,%sp
302         
303         moveq   #0,%d0
304         move.w  STACK_OFFSET+6(%sp),%d0
305         move.l  %d0,-(%sp)
306         pea             .earlystr2(%pc)
307         jsr             (%a2)
308         addq.l  #8,%sp
310         move.l  STACK_OFFSET+8(%sp),-(%sp)
311         pea             .earlystr3(%pc)
312         jsr             (%a2)
313         addq.l  #8,%sp
315         movem.l (%sp)+,%d0-%d2/%a0-%a2
316 #endif
317         jmp             Early_TrapHandler
319         .section .rodata
320 .earlystr1:
321         .string "Early Exception!\nPC"
322 .earlystr2:
323         .string "Vector"
324 .earlystr3:
325         .string "Address"