SRT1.c revision 1.1 1 /* $NetBSD: SRT1.c,v 1.1 2001/06/14 12:57:13 fredette Exp $ */
2
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Gordon W. Ross.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /* SRT1.c - Stand-alone Run-time startup code, part 1 */
40
41 #include <sys/types.h>
42 #include <machine/mon.h>
43
44 #include "libsa.h"
45 #include "dvma.h"
46
47 int _is2 = 0;
48 int _is3x = 0;
49 struct sunromvec *_romvec = 0;
50 void *chain_to_func = 0;
51
52 /*
53 * These are the function pointers for sun2 vs sun3 vs sun3x stuff.
54 */
55 char * (*dev_mapin_p) __P((int, u_long, int));
56 char * (*dvma_alloc_p) __P((int len));
57 void (*dvma_free_p) __P((char *dvma, int len));
58 char * (*dvma_mapin_p) __P((char *pkt, int len));
59 void (*dvma_mapout_p) __P((char *dmabuf, int len));
60
61 /*
62 * This is called by SRT0.S
63 * to do final prep for main
64 */
65 void
66 _start()
67 {
68 void **vbr;
69 int x;
70
71 /*
72 * Determine sun2 vs sun3 vs sun3x by looking where the
73 * vector base register points. The PROM always
74 * points that somewhere into [MONSTART..MONEND]
75 * which is a different range on each.
76 */
77
78 vbr = getvbr();
79 x = (int)vbr & 0xFFF00000;
80 if (x == SUN3X_MONSTART)
81 _is3x = 1;
82 else if (x == 0)
83 _is2 = 1;
84
85 /* Find the PROM vector. */
86 if (_is3x)
87 x = SUN3X_PROM_BASE;
88 else if (_is2)
89 x = SUN2_PROM_BASE;
90 else
91 x = SUN3_PROM_BASE;
92 _romvec = ((struct sunromvec *) x);
93
94 /* Setup trap 14 for use as a breakpoint. */
95 vbr[32+14] = _romvec->abortEntry;
96
97 /* Initialize sun3 vs sun3x function pointers. */
98 if (_is3x)
99 sun3x_init();
100 else if (_is2)
101 sun2_init();
102 else
103 sun3_init();
104
105 main(0);
106 exit();
107 }
108
109 void
110 breakpoint()
111 {
112 __asm __volatile ("trap #14");
113 }
114
115 void
116 chain_to(func)
117 void *func;
118 {
119
120 /*
121 * If set, this pointer is jumped-to by exit
122 * after carefully restoring the PROM stack.
123 */
124 chain_to_func = func;
125 ICIA();
126 exit();
127 }
128
129 /*
130 * Boot programs in C++ ? Not likely!
131 */
132 void
133 __main() {}
134