1 .text 2 3 .globl _startit 4 _startit: 5 move.l sp,a3 6 move.l 4,a6 7 lea (start_super,pc),a5 8 jmp (-0x1e,a6) | supervisor-call 9 10 start_super: 11 move.w #0x2700,sr 12 13 | the BSD kernel wants values into the following registers: 14 | a0: fastmem-start 15 | d0: fastmem-size 16 | d1: chipmem-size 17 | d3: Amiga specific flags 18 | d4: E clock frequency 19 | d5: AttnFlags (cpuid) 20 | d7: boothowto 21 | a4: esym location 22 | a2: Inhibit sync flags 23 | All other registers zeroed for possible future requirements. 24 25 lea (_startit,pc),sp | make sure we have a good stack *** 26 27 move.l (4,a3),a1 | loaded kernel 28 move.l (8,a3),d2 | length of loaded kernel 29 | move.l (12,a3),sp | entry point in stack pointer 30 move.l (12,a3),a6 | push entry point *** 31 move.l (16,a3),a0 | fastmem-start 32 move.l (20,a3),d0 | fastmem-size 33 move.l (24,a3),d1 | chipmem-size 34 move.l (28,a3),d7 | boothowto 35 move.l (32,a3),a4 | esym 36 move.l (36,a3),d5 | cpuid 37 move.l (40,a3),d4 | E clock frequency 38 move.l (44,a3),d3 | Amiga flags 39 move.l (48,a3),a2 | Inhibit sync flags 40 move.l (52,a3),d6 | Load to fastmem flag 41 sub.l a5,a5 | target, load to 0 42 43 cmp.b #0x7D,(36,a3) | is it DraCo? 44 beq nott | yes, switch off MMU later 45 46 | no, it is an Amiga: 47 48 | move.w #0xf00,0xdff180 |red 49 | move.b #0,0x200003c8 50 | move.b #63,0x200003c9 51 | move.b #0,0x200003c9 52 | move.b #0,0x200003c9 53 54 move.w #(1<<9),0xdff096 | disable DMA on Amigas. 55 56 | ------ mmu off start ----- 57 58 btst #3,d5 | AFB_68040,SysBase->AttnFlags 59 beq not040 60 61 | Turn off 68040/060 MMU 62 63 sub.l a3,a3 64 .word 0x4e7b,0xb003 | movec a3,tc 65 .word 0x4e7b,0xb806 | movec a3,urp 66 .word 0x4e7b,0xb807 | movec a3,srp 67 .word 0x4e7b,0xb004 | movec a3,itt0 68 .word 0x4e7b,0xb005 | movec a3,itt1 69 .word 0x4e7b,0xb006 | movec a3,dtt0 70 .word 0x4e7b,0xb007 | movec a3,dtt1 71 bra nott 72 73 not040: 74 lea (zero,pc),a3 75 pmove (a3),tc | Turn off MMU 76 lea (nullrp,pc),a3 77 pmove (a3),crp | Turn off MMU some more 78 pmove (a3),srp | Really, really, turn off MMU 79 80 | Turn off 68030 TT registers 81 82 btst #2,d5 | AFB_68030,SysBase->AttnFlags 83 beq nott | Skip TT registers if not 68030 84 lea (zero,pc),a3 85 .word 0xf013,0x0800 | pmove a3@,tt0 (gas only knows about 68851 ops..) 86 .word 0xf013,0x0c00 | pmove a3@,tt1 (gas only knows about 68851 ops..) 87 88 nott: 89 | ---- mmu off end ---- 90 | move.w #0xf60,0xdff180 | orange 91 | move.b #0,0x200003c8 92 | move.b #63,0x200003c9 93 | move.b #24,0x200003c9 94 | move.b #0,0x200003c9 95 96 | ---- copy kernel start ---- 97 98 tst.l d6 | Can we load to fastmem? 99 beq L0 | No, leave destination at 0 100 move.l a0,a5 | Move to start of fastmem chunk 101 add.l a0,a6 | relocate kernel entry point 102 L0: 103 move.l (a1)+,(a5)+ 104 sub.l #4,d2 105 bcc L0 106 107 lea (ckend,pc),a1 108 move.l a5,-(sp) 109 move.l #_startit_end-ckend,d2 110 L2: 111 move.l (a1)+,(a5)+ 112 sub.l #4,d2 113 bcc L2 114 115 btst #3,d5 116 jeq L1 117 .word 0xf4f8 118 L1: 119 moveq.l #0,d2 | switch off cache to ensure we use 120 movec d2,cacr | valid kernel data 121 122 | move.w #0xFF0,0xdff180 | yellow 123 | move.b #0,0x200003c8 124 | move.b #63,0x200003c9 125 | move.b #0,0x200003c9 126 | move.b #0,0x200003c9 127 rts 128 129 | ---- copy kernel end ---- 130 131 ckend: 132 | move.w #0x0ff,0xdff180 | petrol 133 | move.b #0,0x200003c8 134 | move.b #0,0x200003c9 135 | move.b #63,0x200003c9 136 | move.b #63,0x200003c9 137 138 move.l d5,d2 139 rol.l #8,d2 140 cmp.b #0x7D,d2 141 jne noDraCo 142 143 | DraCo: switch off MMU now: 144 145 sub.l a3,a3 146 .word 0x4e7b,0xb003 | movec a3,tc 147 .word 0x4e7b,0xb806 | movec a3,urp 148 .word 0x4e7b,0xb807 | movec a3,srp 149 .word 0x4e7b,0xb004 | movec a3,itt0 150 .word 0x4e7b,0xb005 | movec a3,itt1 151 .word 0x4e7b,0xb006 | movec a3,dtt0 152 .word 0x4e7b,0xb007 | movec a3,dtt1 153 154 noDraCo: 155 moveq #0,d2 | zero out unused registers 156 moveq #0,d6 | (might make future compatibility 157 move.l d6,a1 | would have known contents) 158 move.l d6,a3 159 move.l d6,a5 160 move.l a6,sp | entry point into stack pointer 161 move.l d6,a6 162 163 | move.w #0x0F0,0xdff180 | green 164 | move.b #0,0x200003c8 165 | move.b #0,0x200003c9 166 | move.b #63,0x200003c9 167 | move.b #0,0x200003c9 168 169 jmp (sp) | jump to kernel entry point 170 171 | A do-nothing MMU root pointer (includes the following long as well) 172 173 nullrp: .long 0x7fff0001 174 zero: .long 0 175 176 _startit_end: 177 178 .data 179 .globl _startit_sz 180 _startit_sz: .long _startit_end-_startit 181