1/* $OpenBSD: srt0.S,v 1.4 2014/07/17 13:14:06 miod Exp $ */ 2/* $NetBSD: boot.S,v 1.1 2006/09/01 21:26:18 uwe Exp $ */ 3 4/*- 5 * Copyright (c) 2005 NONAKA Kimihiro 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <machine/asm.h> 31 32ENTRY(start) 33 bra boot_start1 34 nop 35 .balign 4 36ENTRY(boot_magic) 37 .long 0x20041110 38ENTRY(boot_params) 39 .long boot_start1 - boot_params 40 41 . = start + 0x80 42boot_start1: 43 mov r4, r0 44 add #-4, r0 45 mov.l @(0, r0), r0 46 mov.l .L.boot_magic1, r1 47 cmp/eq r0, r1 48 bf 2f 49 mov r4, r0 50 mov.l .L.boot_params_size, r3 51 mov.l @r0, r2 52 mov.l .L.boot_params, r1 53 cmp/hi r3, r2 54 bf 1f 55 mov r3, r2 561: mov.b @r0+, r3 57 mov.b r3, @r1 58 dt r2 59 bf/s 1b 60 add #1, r1 612: 62 mov.l .L._end, r0 /* zero bss */ 63 mov.l .L.__bss_start, r1 64 sub r1, r0 65 shlr2 r0 /* _end and __bss_start are aligned */ 66 mov #0, r2 671: mov.l r2, @r1 68 dt r0 69 bf/s 1b 70 add #4, r1 71 72 mov.l .L.boot, r0 73 jsr @r0 74 mov r5, r4 75 76boot_fail: 77 mov r0, r1 78 mova .L.errtxt, r0 79 mov r0, r4 80 mov #32, r0 81 trapa #0x3f 82 mov r1, r4 83 mov #32, r0 84 trapa #0x3f 85 mova .L.crlf, r0 86 mov r0, r4 87 mov #32, r0 88 trapa #0x3f 8999: bra 99b 90 nop 91 92 93ENTRY(halt) 94 mova .L.pwrctl, r0 95 mov #1, r1 96 mov.b @r1, r0 97 rts 98 nop 99 100ENTRY(reboot) 101ENTRY(_rtt) 102 mov #1, r4 /* reboot */ 103 mov #11, r0 104 trapa #0x3f 105 mov.l .L.start, r0 106 jmp @r0 107 nop 108 109/* 110 * int raise(int sig); 111 */ 112ENTRY(raise) 113 rts 114 nop 115 116/* 117 * int readsects(int dev, uint32_t lba, void *buf, size_t size); 118 */ 119ENTRY(readsects) 120 mov #2, r0 121 trapa #0x3f 122 rts 123 nop 124 125/* 126 * void cache_flush(void); 127 */ 128ENTRY(cache_flush) 129 /* flush cache */ 130 mov #0, r4 131 mov #6, r0 132 trapa #0x3f 133 rts 134 nop 135 136/* 137 * void cache_disable(void); 138 */ 139ENTRY(cache_disable) 140 mov #1, r4 141 mov #6, r0 142 trapa #0x3f 143 rts 144 nop 145 146 .align 2 147.L.boot_magic1: 148 .long 0x20031125 149.L.boot_params: 150 .long boot_params 151.L.boot_params_size: 152 .long boot_start1 - boot_params 153.L._end: 154 .long _end 155.L.__bss_start: 156 .long __bss_start 157.L.boot: 158 .long _C_LABEL(boot) 159.L.start: 160 .long 0xc0000000 161.L.pwrctl: 162 .long 0xb0000003 163 164 .align 2 165.L.errtxt: .asciz ">>BOOT FAILED: " 166 .align 2 167.L.crlf: .asciz "\r\n" 168