1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
|
;/*
;** asm.c - assembly-language routines for Linux/Mac68K booter
;**
;** Based on assembly-language routines in Atari Linux booter
;**
;** This file is subject to the terms and conditions of the GNU General Public
;** License. See the file COPYING in the main directory of this archive
;** for more details.
;**
;** History:
;** 15 Apr 1997 Ported to Mac from Linux 2.0.29 source tree. Rehashed syntax
;** into CodeWarrior format; I only had access to CW3 back then
;** (which lacks asm support), so I couldn't test any of it. (RLP)
;** 15 Jul 1997 Further changes: hand-assembled FPU and MMU instructions, other
;** miscellany. Compiles cleanly on my new copy of CW9 :-) (RLP)
;** 13 Nov 1997 Big changes, code cleanup and new routines, in fact, no
;** routines are left as they were. (MF)
;*/
case on
;#include "asm_setup.h"
;#include "asm_page.h"
;#include "bootstrap_prototypes.h"
;#include "asm_prototypes.h"
CPUB_68040 equ 2
;/*
; * new_copy_and_go
; *
; */
;asm void new_copy_and_go (
; void *kernel_src_log,
; void *kernel_dest_log,
; void *ramdisk_src_log,
; void *ramdisk_dest_log,
; void *kernel_entry_phys,
; unsigned long mmu_type,
; unsigned long kernel_size,
; unsigned long ramdisk_size,
; unsigned long disable_mmu,
; void *reloc_ptr_src,
; void *reloc_ptr_dst,
; unsigned long reloc_size,
; unsigned long v_bootinfo)
;{
new_copy_and_go proc export
machine mc68020
; FRALLOC
;//
;// Load parameters into registers
;//
MOVE.L 4(sp),d4 ;kernel_src_log
MOVE.L 8(sp),d5 ;kernel_dest_log
MOVE.L 12(sp),a2 ;ramdisk_src_log
MOVE.L 16(sp),a3 ;ramdisk_dest_log
MOVE.L 20(sp),a4 ;kernel_entry_phys
MOVE.L 24(sp),d3 ;mmu_type
MOVE.L 28(sp),d2 ;kernel_size
MOVE.L 32(sp),d1 ;ramdisk_size
MOVE.L 36(sp),d6 ;disable_mmu
MOVE.L 40(sp),a0 ;reloc_ptr_src
MOVE.L 44(sp),a1 ;reloc_ptr_dst
MOVE.L 48(sp),d0 ;reloc_size
MOVE.L 52(sp),d7 ;v_bootinfo
LEA STACK,sp ;// setup temporary (local) stack pointer
;//
;// Do we have to relocate the image(s)?
;//
TST.L d0 ;// if reloc_size == 0 -> no relocation
BEQ.S NO_RELOC
BSR.S COPY_MEM ;// registers already setup, A0/A1/D0
NO_RELOC:
;//
;// Should the MMU be disabled?
;//
;#if 0
; TST.L d6
; BEQ.S @MMUDONE
;#endif
;//
;// Check MMU type and disable it
;//
LEA STACK,sp ;// setup temporary stack pointer, for PMOVE's
SUBQ #1,d3
BNE.s TEST_030
IS_020:
machine mc68030 ;// mc68030 machine required to enable PMMU functions
PMOVE tc,(sp) ;DC.L $f0174200 ;// PMOVE TC, (SP)
BCLR #7,(sp)
PMOVE (sp),tc ;DC.L $f0174000 ;// PMOVE (SP), TC
BRA.S MMUDONE
TEST_030:
SUBQ #1,d3
BNE.s IS_040
IS_030:
machine mc68030
PMOVE tc,(sp) ;DC.L $f0174200 ;// PMOVE TC, (SP)
BCLR #7,(sp)
PMOVE (sp),tc ;DC.L $f0174000 ;// PMOVE (SP), TC
LEA STACK,sp ;// restore SP, if it were translated
CLR.L (sp)
PMOVE (sp),tt0 ;DC.L $f0170800 ;// PMOVE (SP), TT0
LEA STACK,sp ;// restore SP, if it were translated
CLR.L (sp)
PMOVE (sp),tt1 ;DC.L $f0170c00 ;// PMOVE (SP), TT1
BRA.S MMUDONE
IS_040:
machine mc68040
MOVEQ.L #0,d0
MOVEC d0,tc ;DC.L $4e7b0003 ;// MOVEC D0, TC
MOVEC d0,itt0 ;DC.L $4e7b0004 ;// MOVEC D0, ITT0
MOVEC d0,itt1 ;DC.L $4e7b0005 ;// MOVEC D0, ITT1
MOVEC d0,dtt0 ;DC.L $4e7b0006 ;// MOVEC D0, DTT0
MOVEC d0,dtt1 ;DC.L $4e7b0007 ;// MOVEC D0, DTT1
MMUDONE:
machine mc68020
;//
;// MMU disabled, now running in physical space
;//
LEA STACK,sp ;// setup temp stack pointer, physical
;//
;// Copy the kernel
;//
MOVE.L d4,a0 ;// src ptr
MOVE.L d5,a1 ;// dst ptr
MOVE.L d2,d0 ;// size
BSR.S COPY_MEM
;//
;// Copy the ramdisk, if any, target at end of memory
;//
MOVEA.L a2,a0 ;// src ptr
MOVEA.L a3,a1 ;// dst ptr
MOVE.L d1,d0 ;// size
BSR.S COPY_MEM
;//
;// Load a magic number into D0 - in case people wanna do funky stuff in head.S
;// to future generations: keep the high-order 3 bytes the same, increment 4th
;// Send 'Pen1' for bootinfo 1.0, 'Pen2' for bootinfo 2.0
;//
CMPI.L #2,d7 ;// version 2.0 bootinfo?
BGE.S IS_V2 ;// yes, take 2
MOVE.L #'Pen1',d0 ;// Let kernel have 'Pen1', default if version not recognized
BRA.S LAUNCH
IS_V2:
MOVE.L #'Pen2',d0 ;// Let kernel have 'Pen2'
LAUNCH:
;//
;// GO KERNEL!
;//
JMP (a4) ;// bye, bye MacOS - hello kernel
;//
;// Safe memory copy routine, handles overlapping memory regions
;// A0.L - src ptr
;// A1.L - dst ptr
;// D0.L - size
COPY_MEM:
CMPA.L a0,a1
BGT.S @CM_REV
BRA.S @CM2
@CM1:
MOVE.B (a0)+,(a1)+
@CM2:
SUBQ.L #1,d0
BGE.S @CM1
RTS
@CM_REV:
ADDA.L d0,a0
ADDA.L d0,a1
BRA.S @CM_REV2
@CM_REV1:
MOVE.B -(a0),-(a1)
@CM_REV2:
SUBQ.L #1,d0
BGE.S @CM_REV1
RTS
;//
;;// Temporary stack pointer, ramdisk will trash current
;// We'll do with 16+8 longs
;//
DC.L 0,0,0,0,0,0,0,0
DC.L 0,0,0,0,0,0,0,0
STACK:
DC.L 0,0,0,0,0,0,0,0
; FRFREE
RTS
endp
;}
;/*
; * disable_interrupts
; *
; * Raise interrupt priority
; *
; */
;asm void disable_interrupts (void) {
disable_interrupts proc export
machine mc68020
; FRALLOC
OR.W #$700, sr
; FRFREE
RTS
endp
;}
;/*
; * disable_cache
; *
; * Disable and flush caches
; *
; */
;asm void disable_cache (unsigned long cputype) {
disable_cache proc export
; FRALLOC
MOVE.L 4(sp),d1 ;cputype
BTST #CPUB_68040,d1
BNE.S is_40
machine mc68020
MOVE.L #$00000808,d0
NOP ;// Synchronize
MOVEC d0,cacr ;DC.L $4E7B0002 ;// MOVEC D0,CACR
BRA.S exit
is_40:
machine mc68040
MOVEQ #0,d0
NOP ;// Synchronize
CPUSHA ic/dc ;DC.W $F4F8 ;// CPUSHA IC/DC
MOVEC d0,cacr ;DC.L $4E7B0002 ;// MOVEC D0,CACR
CINVA ic/dc ;DC.W $F4D8 ;// CINVA IC/DC
machine mc68020
exit:
; FRFREE
RTS
endp
;}
end
|