Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / sun68k / stand / libsa / SRT1.c
blobceaa800251580d7c889c8d0362909be971e2734d
1 /* $NetBSD: SRT1.c,v 1.7 2008/04/28 20:23:39 martin Exp $ */
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Gordon W. Ross.
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 /* SRT1.c - Stand-alone Run-time startup code, part 1 */
34 #include <sys/types.h>
35 #include <sun68k/mon.h>
37 #include "libsa.h"
38 #include "dvma.h"
40 int _is2 = 0;
41 int _is3x = 0;
42 struct sunromvec *_romvec = 0;
43 void *chain_to_func = 0;
46 * These are the function pointers for sun2 vs sun3 vs sun3x stuff.
48 char * (*dev_mapin_p)(int, u_long, int);
49 char * (*dvma_alloc_p)(int);
50 void (*dvma_free_p)(char *, int);
51 char * (*dvma_mapin_p)(char *, int);
52 void (*dvma_mapout_p)(char *, int);
55 * This is called by SRT0.S
56 * to do final prep for main
58 void
59 _start(void)
61 void **vbr;
62 int x;
65 * Determine sun2 vs sun3 vs sun3x by looking where the
66 * vector base register points. The PROM always
67 * points that somewhere into [MONSTART..MONEND]
68 * which is a different range on each.
71 vbr = getvbr();
72 x = (int)vbr & 0xFFF00000;
73 if (x == SUN3X_MONSTART)
74 _is3x = 1;
75 else if (x == 0)
76 _is2 = 1;
78 /* Find the PROM vector. */
79 if (_is3x)
80 x = SUN3X_PROM_BASE;
81 else if (_is2)
82 x = SUN2_PROM_BASE;
83 else
84 x = SUN3_PROM_BASE;
85 _romvec = ((struct sunromvec *) x);
87 /* Setup trap 14 for use as a breakpoint. */
88 vbr[32+14] = _romvec->abortEntry;
90 /* Initialize sun3 vs sun3x function pointers. */
91 if (_is3x)
92 sun3x_init();
93 else if (_is2)
94 sun2_init();
95 else
96 sun3_init();
98 main();
99 exit(0);
102 void
103 breakpoint(void)
105 __asm volatile ("trap #14");
108 void
109 chain_to(void *func)
113 * If set, this pointer is jumped-to by exit
114 * after carefully restoring the PROM stack.
116 chain_to_func = func;
117 ICIA();
118 exit(0);