11.3Sisaki/* $NetBSD: srt0.S,v 1.3 2024/01/07 07:58:33 isaki Exp $ */ 21.1Sminoura 31.1Sminoura/*- 41.1Sminoura * Copyright (c) 2001 Minoura Makoto 51.1Sminoura * All rights reserved. 61.1Sminoura * 71.1Sminoura * Redistribution and use in source and binary forms, with or without 81.1Sminoura * modification, are permitted provided that the following conditions 91.1Sminoura * are met: 101.1Sminoura * 1. Redistributions of source code must retain the above copyright 111.1Sminoura * notice, this list of conditions and the following disclaimer. 121.1Sminoura * 2. Redistributions in binary form must reproduce the above copyright 131.1Sminoura * notice, this list of conditions and the following disclaimer in the 141.1Sminoura * documentation and/or other materials provided with the distribution. 151.1Sminoura * 161.1Sminoura * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 171.1Sminoura * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 181.1Sminoura * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191.1Sminoura * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 201.1Sminoura * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 211.1Sminoura * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 221.1Sminoura * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231.1Sminoura * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 241.1Sminoura * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251.1Sminoura * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261.1Sminoura * SUCH DAMAGE. 271.1Sminoura */ 281.1Sminoura 291.3Sisaki#include <m68k/asm.h> 301.1Sminoura 311.1SminouraASENTRY(start) 321.1Sminoura bra start0 331.1Sminoura .ascii BOOT 341.1Sminoura .byte 0x20 351.1Sminoura .asciz BOOT_VERS 361.1Sminoura .even 371.1Sminoura 381.1Sminoura/* 391.1Sminoura * via stack: (firstpa, physsize, esym) 401.1Sminoura * via regs: %d6: bootdev 411.1Sminoura * %d7: boothowto 421.1Sminoura * for /boot, only %d6 is used. 431.1Sminoura */ 441.1Sminourastart0: 451.1Sminoura moveml %sp@+,%d0-%d2 461.1Sminoura lea %pc@(start),%sp 471.1Sminoura 481.1Sminoura movl %d6,%sp@- 491.1Sminoura jbsr _C_LABEL(bootmain) 501.1Sminoura 511.2StsutsuiENTRY_NOPROFILE(_rtt) 521.1Sminoura pea %pc@(reboot_msg) 531.1Sminoura jbsr _C_LABEL(printf) 541.1Sminoura jbsr _C_LABEL(getchar) 551.1Sminoura trap #10 561.1Sminoura 571.1Sminourareboot_msg: .asciz "\n[Hit key to reboot]" 581.1Sminoura .even 591.1Sminoura 601.1Sminoura/* 611.1Sminoura * Detect MPU type. From locore.s. 621.1Sminoura * Note we've already confirmed it is not 68000/010. 631.1Sminoura */ 641.1SminouraENTRY_NOPROFILE(detectmpu) 651.1Sminoura movl #0x200,%d0 | data freeze bit 661.1Sminoura movc %d0,%cacr | only exists on 68030 671.1Sminoura movc %cacr,%d0 | read it back 681.1Sminoura tstl %d0 | zero? 691.1Sminoura jeq Lnot68030 | yes, we have 68020/68040/68060 701.1Sminoura moveq #3,%d0 711.1Sminoura jra Lgo | no, we have 68030 721.1SminouraLnot68030: 731.1Sminoura bset #31,%d0 | data cache enable bit 741.1Sminoura movc %d0,%cacr | only exists on 68040/68060 751.1Sminoura movc %cacr,%d0 | read it back 761.1Sminoura tstl %d0 | zero? 771.1Sminoura jeq Lis68020 | yes, we have 68020 781.1Sminoura moveq #0,%d0 | now turn it back off 791.1Sminoura movec %d0,%cacr | before we access any data 801.1Sminoura .word 0xf4d8 | cinva bc - invalidate caches XXX 811.1Sminoura bset #30,%d0 | data cache no allocate mode bit 821.1Sminoura movc %d0,%cacr | only exists on 68060 831.1Sminoura movc %cacr,%d0 | read it back 841.1Sminoura tstl %d0 | zero? 851.1Sminoura jeq Lis68040 | yes, we have 68040 861.1Sminoura moveq #6,%d0 871.1Sminoura jra Lgo 881.1SminouraLis68040: 891.1Sminoura moveq #4,%d0 901.1Sminoura jra Lgo 911.1SminouraLis68020: 921.1Sminoura movl #2,%d0 | and a 68020 CPU 931.1SminouraLgo: 941.1Sminoura rts 951.1Sminoura 961.1Sminoura/* 971.1Sminoura * Check if the given address is valid for byte read. 981.1Sminoura * From boot_ufs/boot.S. 991.1Sminoura */ 1001.1SminouraENTRY_NOPROFILE(badbaddr) 1011.1Sminoura lea 0x0008:W,%a1 | MPU Bus Error vector 1021.1Sminoura moveq #1,%d0 1031.1Sminoura lea %pc@(badr1),%a0 1041.1Sminoura movew %sr,%sp@- 1051.1Sminoura oriw #0x0700,%sr | keep out interrupts 1061.1Sminoura movel %a1@,%sp@- 1071.1Sminoura movel %a0,%a1@ | set bus error vector 1081.1Sminoura movel %sp,%d1 | save sp 1091.1Sminoura moveal %sp@(10),%a0 1101.1Sminoura tstb %a0@ | try read... 1111.1Sminoura moveq #0,%d0 | this is skipped on bus error 1121.1Sminourabadr1: moveal %d1,%sp | restore sp 1131.1Sminoura movel %sp@+,%a1@ 1141.1Sminoura movew %sp@+,%sr 1151.1Sminoura rts 116