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