1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)srt0.c 7.4 (Berkeley) 01/28/88 7 */ 8 9 #include "../vax/mtpr.h" 10 #define LOCORE 11 #include "../vax/cpu.h" 12 13 /* 14 * Startup code for standalone system 15 * Non-relocating version -- for programs which are loaded by boot 16 * Relocating version for boot* 17 */ 18 19 .globl _end 20 .globl _edata 21 .globl _main 22 .globl __rtt 23 .globl _configure 24 .globl _cpu 25 .globl _openfirst 26 .globl _boothowto 27 .globl _bootdev 28 29 .set HIGH,31 # mask for total disable 30 31 entry: .globl entry 32 nop; nop # .word 0x0101 33 mtpr $HIGH,$IPL # just in case 34 35 #ifdef REL 36 # we need to do special stuff on microvax II 37 mfpr $SID,r0 38 cmpzv $24,$8,r0,$VAX_630 39 bneq 1f 40 41 /* 42 * Were we booted by VMB? If so, r11 is not boothowto, 43 * but rather the address of the `Extended RPB' (see KA630 44 * User's Manual, pp 3-21). These tests were devised by 45 * richl@tektronix, 11/10/87. 46 */ 47 cmpl (r11),r11 # if boothowto, r11 will be small 48 bneq 1f # and these will not fault 49 cmpl 4(r11),$0 50 bneq 1f 51 cmpl 8(r11),$-1 52 bneq 1f 53 tstl 0xc(r11) 54 bneq 1f 55 56 /* 57 * Booted by VMB: get flags from extended rpb. 58 * We can only guess at the boot device (here ra(0,0)). 59 */ 60 movl 0x30(r11),r11 61 movl $9,r10 # device = ra(0,0) 62 1: 63 movl $RELOC,sp 64 #else 65 movl $RELOC-0x2400,sp 66 #endif 67 start: 68 #ifndef REL 69 /* 70 * Clear bss segment 71 */ 72 movl aedata,r0 73 clr: 74 clrl (r0)+ 75 cmpl r0,sp 76 jlss clr 77 #else 78 /* 79 * `entry' below generates a pc-relative reference to the 80 * code, so this works no matter where we are now. 81 * Clear bss segment *after* moving text and data. 82 */ 83 movc3 aedata,entry,(sp) 84 dclr: 85 clrl (r3)+ 86 cmpl r3,$_end 87 jlss dclr 88 /* this loop shouldn't be necessary, but is when booting from an ra81 */ 89 xclr: 90 clrl (r3)+ 91 cmpl r3,$0x100000 92 jlss xclr 93 jmp *abegin 94 begin: 95 #endif 96 movl r11,_boothowto 97 movl r10,_bootdev 98 again: 99 mtpr $0,$SCBB 100 calls $0,_configure 101 movl $1,_openfirst 102 calls $0,_main 103 #ifdef REL 104 jmp again 105 #else 106 ret 107 #endif 108 109 .data 110 #ifdef REL 111 abegin: .long begin 112 aedata: .long _edata-RELOC 113 #else 114 aedata: .long _edata 115 #endif 116 _bootdev: .long 0 117 _boothowto: .long 0 118 .text 119 120 __rtt: 121 .word 0x0 122 #ifdef REL 123 halt 124 #else 125 jmp start 126 #endif 127 128 .globl _badaddr 129 _badaddr: 130 .word 0 131 movl $1,r0 132 movl 4(ap),r3 133 movl 8(ap),r4 134 movl $4,r2 135 movab 9f,(r2) 136 bbc $0,r4,1f; tstb (r3) 137 1: bbc $1,r4,1f; tstw (r3) 138 1: bbc $2,r4,1f; tstl (r3) 139 1: clrl r0 # made it w/o machine checks 140 2: movl $4,r2 141 clrl (r2) 142 ret 143 .align 2 144 9: 145 casel _cpu,$1,$VAX_MAX 146 0: 147 .word 8f-0b # 1 is 780 148 .word 5f-0b # 2 is 750 149 .word 5f-0b # 3 is 730 150 .word 6f-0b # 4 is 8600 151 .word 5f-0b # 5 is 8200 152 .word 1f-0b # 6 is 8800 153 .word 1f-0b # 7 is 610 154 .word 5f-0b # 8 is 630 155 5: 156 mtpr $0xf,$MCESR 157 brb 1f 158 6: 159 mtpr $0,$EHSR 160 brb 1f 161 8: 162 mtpr $0,$SBIFS 163 1: 164 addl2 (sp)+,sp # discard mchchk trash 165 movab 2b,(sp) 166 rei 167 168 /* 169 * Short assembly versions of strcmp, strcpy, and strlen 170 * that do not use special instructions. 171 */ 172 .globl _strcmp 173 _strcmp: 174 .word 0 175 movq 4(ap),r0 176 0: cmpb (r0),(r1)+ 177 bneq 1f 178 tstb (r0)+ 179 bneq 0b 180 clrl r0 181 ret 182 1: cvtbl (r0),r0 183 cvtbl -(r1),r1 184 subl2 r1,r0 185 ret 186 187 .globl _strcpy 188 _strcpy: 189 .word 0 190 movq 4(ap),r0 191 0: movb (r1)+,(r0)+ 192 bneq 0b 193 movl 4(ap),r0 194 ret 195 196 .globl _strlen 197 _strlen: 198 .word 0 199 movl 4(ap),r0 200 0: tstb (r0)+ 201 bneq 0b 202 decl r0 203 subl2 4(ap),r0 204 ret 205