1/* $NetBSD: srt0.S,v 1.3 2024/01/07 07:58:33 isaki Exp $ */ 2 3/*- 4 * Copyright (c) 2001 Minoura Makoto 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#include <m68k/asm.h> 30 31ASENTRY(start) 32 bra start0 33 .ascii BOOT 34 .byte 0x20 35 .asciz BOOT_VERS 36 .even 37 38/* 39 * via stack: (firstpa, physsize, esym) 40 * via regs: %d6: bootdev 41 * %d7: boothowto 42 * for /boot, only %d6 is used. 43 */ 44start0: 45 moveml %sp@+,%d0-%d2 46 lea %pc@(start),%sp 47 48 movl %d6,%sp@- 49 jbsr _C_LABEL(bootmain) 50 51ENTRY_NOPROFILE(_rtt) 52 pea %pc@(reboot_msg) 53 jbsr _C_LABEL(printf) 54 jbsr _C_LABEL(getchar) 55 trap #10 56 57reboot_msg: .asciz "\n[Hit key to reboot]" 58 .even 59 60/* 61 * Detect MPU type. From locore.s. 62 * Note we've already confirmed it is not 68000/010. 63 */ 64ENTRY_NOPROFILE(detectmpu) 65 movl #0x200,%d0 | data freeze bit 66 movc %d0,%cacr | only exists on 68030 67 movc %cacr,%d0 | read it back 68 tstl %d0 | zero? 69 jeq Lnot68030 | yes, we have 68020/68040/68060 70 moveq #3,%d0 71 jra Lgo | no, we have 68030 72Lnot68030: 73 bset #31,%d0 | data cache enable bit 74 movc %d0,%cacr | only exists on 68040/68060 75 movc %cacr,%d0 | read it back 76 tstl %d0 | zero? 77 jeq Lis68020 | yes, we have 68020 78 moveq #0,%d0 | now turn it back off 79 movec %d0,%cacr | before we access any data 80 .word 0xf4d8 | cinva bc - invalidate caches XXX 81 bset #30,%d0 | data cache no allocate mode bit 82 movc %d0,%cacr | only exists on 68060 83 movc %cacr,%d0 | read it back 84 tstl %d0 | zero? 85 jeq Lis68040 | yes, we have 68040 86 moveq #6,%d0 87 jra Lgo 88Lis68040: 89 moveq #4,%d0 90 jra Lgo 91Lis68020: 92 movl #2,%d0 | and a 68020 CPU 93Lgo: 94 rts 95 96/* 97 * Check if the given address is valid for byte read. 98 * From boot_ufs/boot.S. 99 */ 100ENTRY_NOPROFILE(badbaddr) 101 lea 0x0008:W,%a1 | MPU Bus Error vector 102 moveq #1,%d0 103 lea %pc@(badr1),%a0 104 movew %sr,%sp@- 105 oriw #0x0700,%sr | keep out interrupts 106 movel %a1@,%sp@- 107 movel %a0,%a1@ | set bus error vector 108 movel %sp,%d1 | save sp 109 moveal %sp@(10),%a0 110 tstb %a0@ | try read... 111 moveq #0,%d0 | this is skipped on bus error 112badr1: moveal %d1,%sp | restore sp 113 movel %sp@+,%a1@ 114 movew %sp@+,%sr 115 rts 116