revert between 56095 -> 55830 in arch
[AROS.git] / arch / m68k-amiga / boot / rom_init.S
blob4d0c86776e45ee036b2859f1058ca9261d7a33e5
1 /*
2  * Copyright (C) 2013, The AROS Development Team
3  * All right reserved.
4  * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
5  *
6  * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
7  * 
8  * $Id$
9  */
11 #include <aros/m68k/asm.h>
12 #include <aros/config.h>
14         .text
15         .chip 68000
16         .align 4 
18         .globl __MemoryTest
19         .globl rom_init
20 rom_init:
21         bra.w normal_init
22         bra.w arosbootstrap_init
24 normal_init:
26         /* Wait a bit for reset to finish.
27          * Simulate ROM checksum check.
28          */
29         lea             0x00f80000,%a0
30         move.l  #524288/4,%d0
31         moveq   #0,%d1
32 0:      add.l   (%a0)+,%d1
33         bcc.s   1f
34         addq.l  #1,%d1
35 1:      subq.l  #1,%d0
36         bne.s   0b
38         /* Check for cartridge ROM */
39         lea     0xf00000,%a0
40         move.w  %a0@(0),%d0     /* Get the ROM ID (0x1111) */
41         cmp.w   #0x1111,%d0
42         bne.s   0f              /* Must be 0x1111 */
43         lea %pc@(0),%a1
44         move.l %a1,%d0
45         clr.w %d0
46         cmp.l %d0,%a0
47         beq.s 0f /* skip if we booted at 0xF00000 */
48         lea     0x40000,%sp     /* Safe stack at Chip Mem 128K */
49         lea     0f,%a5
50         jmp     %a0@(2)
53         /* Disable the overlay, power led off. */
54         moveq   #0,%d0
55         move.b  %d0,0xbfe001
56         moveq   #0x3,%d0
57         move.b  %d0,0xbfe201
59 arosbootstrap_init:
61         /* Initial Custom chipset setup. Does same writes as AOS.
62          * It is possible some bus snooping hardware assumes this.
63          */
64         lea.l   0xdff000,%a0
65         move.w  #0x7fff,%d0
66         move.w  %d0,0x9a(%a0)   /* Interrupt disable */
67         move.w  %d0,0x9c(%a0)   /* Clear interrupts */
68         move.w  %d0,0x96(%a0)   /* Stop DMA */
69         move.w  #0x0174,0x032(%a0)      /* SERPER */
70         move.w  #0x0200,0x100(%a0)      /* BPLCON0 */
71         move.w  #0x0000,0x110(%a0)      /* BPL1DAT */
72         move.w  #0x0111,0x180(%a0)      /* COLOR00 */
74         /* temp system stack */
75         lea.l   _ss_end,%sp             /* System stack */
76         /* Put the memory bank array at the bottom of the stack, reserve space for extra memory bank */
77         lea.l   _ss,%a5
79         /* Do we have a Gayle? */
80         sub.l   %a6,%a6
81         jsr     AROS_SLIB_ENTRY(ReadGayle,Exec,136)
82         moveq   #0,%d6
83         tst.b   %d0
84         beq.s   .nopcmcia
85         moveq   #1,%d6
86         /* Disable PCMCIA slot */
87         move.b  #1,0xda8000
88 .nopcmcia:
89         swap    %d6
91         move.l  %a5,%a4 /* Space for CPU/FPU data array */
92         lea             16(%a5),%a5     /* Space also reserved for extra membank */
93         move.l  %a4,%a0
94         jsr     _cpu_detect
95         /* High word = gayle flag, low word = AttnFlags */
96         move.w  %a4@(2),%d6
98         btst    #2,%d6          /* AttnFlags AFB_68030? */
99         bne.s   .is32bit
100         btst    #1,%d6          /* AttnFlags AFB_68020? */
101         beq.s   .test32bit
102         /* 32-bit CPU check only, no memory tested */
103         move.l  #0x08000000,%a0
104         move.l  #0x08000000,%a1
105         move.l  #0x00100000,%d0
106         jsr     __MemoryTest
107         bmi.s   .test32bit
108 .is32bit:
109         /* set AttnFlags AFB_ADDR32 */
110         or.w    #0x2000,%a4@(2)
111 .test32bit:
113         /* Memory region array is put into the
114          * system stack from the bottom up, so
115          * we check the non-autoconfig memory areas
116          * in order of fastest to slowest, going
117          * up the system stack in A5.
118          */
120         /* slow ram */
121         move.l  #0x00c00000,%a0
122         move.l  #0x00d80000,%a1
123         /* Limit max size if Gayle */
124         btst #16,%d6
125         bne.s   0f
126         move.l  #0x00dc0000,%a1
127 0:      move.l  #0x00040000,%d0
128         jsr     __MemoryTest
129         
130         /* chip ram */
131         sub.l   %a0,%a0
132         move.l  #0x00200000,%a1
133         move.l  #0x00040000,%d0
134         jsr     __MemoryTest
135         beq     chipfault
137         /* end of memory region list */
138         clr.l   %a5@+
139         clr.l   %a5@
141         lea.l   _ss,%a5
142         move.l  %a5,%sp@-       /* CPU/FPU data array */
143         lea             16(%a5),%a5
144         move.l  %a5,%sp@-       /* memory bank array */
145         jsr             exec_boot
147 chipfault:
148         move.w  #0x0f0,0xdff180
149 looping:
150         nop
151         bra.s   looping
153 #define STACK_OFFSET (6*4)
154         .globl Early_Exception
155 Early_Exception:
156         or.w    #0x0700,%sr
157 #if AROS_SERIAL_DEBUG
158         movem.l %d0-%d2/%a0-%a2,-(%sp)
160         lea             DebugPutHex,%a2
162         move.l  STACK_OFFSET+2(%sp),-(%sp)
163         pea             .earlystr1(%pc)
164         jsr             (%a2)
165         addq.l  #8,%sp
166         
167         moveq   #0,%d0
168         move.w  STACK_OFFSET+6(%sp),%d0
169         move.l  %d0,-(%sp)
170         pea             .earlystr2(%pc)
171         jsr             (%a2)
172         addq.l  #8,%sp
174         move.l  STACK_OFFSET+8(%sp),-(%sp)
175         pea             .earlystr3(%pc)
176         jsr             (%a2)
177         addq.l  #8,%sp
179         movem.l (%sp)+,%d0-%d2/%a0-%a2
180 #endif
181         jmp             Early_TrapHandler
183         .section .rodata
184 .earlystr1:
185         .string "Early Exception!\nPC"
186 .earlystr2:
187         .string "Vector"
188 .earlystr3:
189         .string "Address"