xref: /netbsd/sys/arch/vax/boot/common/srt0.S (revision bf9ec67e)
1/*	$NetBSD: srt0.S,v 1.2 2002/03/31 00:11:14 matt Exp $ */
2/*
3 * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 *    must display the following acknowledgement:
16 *     This product includes software developed at Ludd, University of Lule}.
17 * 4. The name of the author may not be used to endorse or promote products
18 *    derived from this software without specific prior written permission
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /* All bugs are subject to removal without further notice */
33
34#include "../include/asm.h"
35
36/*
37 * Auto-moving startup code for standalone programs. Can be loaded
38 * (almost) anywhere in memory but moves itself to the position
39 * it is linked for. Must be started at first position, recommended
40 * is phys addr 0 (boot loads programs at 0, but starts them at the
41 * position set in a.out header.
42 */
43
44	.globl	nisse		# pass -e nisse to ld gives OK start addr
45	.set	nisse,0
46
47ALTENTRY(start)
48	nop;nop;
49	movl	$_C_LABEL(start), %sp	# Probably safe place for stack
50	pushr	$0x1fff		# save for later usage
51
52	subl3	$_C_LABEL(start), $_C_LABEL(edata), %r0
53	movab	_C_LABEL(start), %r1 # get where we are
54	movl	$_C_LABEL(start), %r3 # get where we want to be
55	cmpl	%r1,%r3		# are we where we want to be?
56	beql	relocated	# already relocated, skip copy
57	movc3	%r0,(%r1),(%r3)	# copy
58	subl3	$_C_LABEL(edata), $_C_LABEL(end), %r2
59	movc5	$0,(%r3),$0,%r2,(%r3) # Zero bss
60
61	movpsl	-(%sp)
62	pushl	$relocated
63	rei
64relocated:	                # now relocation is done !!!
65	movl	%sp,_C_LABEL(bootregs)	# *bootregs
66	calls	$0, _C_LABEL(Xmain)	# Were here!
67	halt			# no return
68
69ENTRY(machdep_start, 0)
70	calls	$0,_C_LABEL(niclose)	# Evil hack to shutdown DEBNA.
71	mtpr	$0x1f,$0x12	# Block all interrupts
72	mtpr	$0,$0x18	# stop real time interrupt clock
73	movl	4(%ap), %r6
74	movl	20(%ap), %r9	# end of symbol table
75	pushl	8(%ap)		# number of symbols
76	pushl	16(%ap)		# start of symbols
77	movab	_C_LABEL(bootrpb),%r10	# get RPB address
78	pushl	%r10		# argument for new boot
79	ashl	$9,76(%r10),%r8	# memory size (COMPAT)
80	movl	$3,%r11		# ask boot (COMPAT)
81	clrl	%r10		# no boot dev (COMPAT)
82
83	calls	$3,(%r6)
84	halt
85