xref: /minix3/lib/csu/arch/alpha/crtfm.c (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /*	$NetBSD: crtfm.c,v 1.1 2013/08/05 13:38:35 matt Exp $	*/
2*84d9c625SLionel Sambuc 
3*84d9c625SLionel Sambuc /*
4*84d9c625SLionel Sambuc  * Copyright (c) 2002 Wasabi Systems, Inc.
5*84d9c625SLionel Sambuc  * All rights reserved.
6*84d9c625SLionel Sambuc  *
7*84d9c625SLionel Sambuc  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8*84d9c625SLionel Sambuc  *
9*84d9c625SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
10*84d9c625SLionel Sambuc  * modification, are permitted provided that the following conditions
11*84d9c625SLionel Sambuc  * are met:
12*84d9c625SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
13*84d9c625SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
14*84d9c625SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
15*84d9c625SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
16*84d9c625SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
17*84d9c625SLionel Sambuc  * 3. All advertising materials mentioning features or use of this software
18*84d9c625SLionel Sambuc  *    must display the following acknowledgement:
19*84d9c625SLionel Sambuc  *	This product includes software developed for the NetBSD Project by
20*84d9c625SLionel Sambuc  *	Wasabi Systems, Inc.
21*84d9c625SLionel Sambuc  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22*84d9c625SLionel Sambuc  *    or promote products derived from this software without specific prior
23*84d9c625SLionel Sambuc  *    written permission.
24*84d9c625SLionel Sambuc  *
25*84d9c625SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26*84d9c625SLionel Sambuc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27*84d9c625SLionel Sambuc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28*84d9c625SLionel Sambuc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29*84d9c625SLionel Sambuc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30*84d9c625SLionel Sambuc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31*84d9c625SLionel Sambuc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32*84d9c625SLionel Sambuc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33*84d9c625SLionel Sambuc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34*84d9c625SLionel Sambuc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35*84d9c625SLionel Sambuc  * POSSIBILITY OF SUCH DAMAGE.
36*84d9c625SLionel Sambuc  */
37*84d9c625SLionel Sambuc 
38*84d9c625SLionel Sambuc /*
39*84d9c625SLionel Sambuc  * Support for the GCC "-ffast-math" option on the Alpha.
40*84d9c625SLionel Sambuc  */
41*84d9c625SLionel Sambuc 
42*84d9c625SLionel Sambuc #include <sys/types.h>
43*84d9c625SLionel Sambuc 
44*84d9c625SLionel Sambuc #include <machine/fpu.h>
45*84d9c625SLionel Sambuc #include <machine/sysarch.h>
46*84d9c625SLionel Sambuc 
47*84d9c625SLionel Sambuc /*
48*84d9c625SLionel Sambuc  * Must provide this wrapper around sysarch(2) so that statically-linked
49*84d9c625SLionel Sambuc  * programs work properly.
50*84d9c625SLionel Sambuc  */
51*84d9c625SLionel Sambuc 
52*84d9c625SLionel Sambuc extern void __alpha_sysarch(int, void *);
53*84d9c625SLionel Sambuc 
54*84d9c625SLionel Sambuc __asm(".ent __alpha_sysarch 0	;\n"
55*84d9c625SLionel Sambuc "__alpha_sysarch:		;\n"
56*84d9c625SLionel Sambuc "	ldiq	$0, 165		;\n" /* v0 = SYS_sysarch */
57*84d9c625SLionel Sambuc "	call_pal 0x0083		;\n" /* PAL_OSF1_callsys */
58*84d9c625SLionel Sambuc "	ret	$31,($26),1	;\n"
59*84d9c625SLionel Sambuc ".end __alpha_sysarch");
60*84d9c625SLionel Sambuc 
61*84d9c625SLionel Sambuc static void __attribute__((__constructor__))
__alpha_set_fast_math(void)62*84d9c625SLionel Sambuc __alpha_set_fast_math(void)
63*84d9c625SLionel Sambuc {
64*84d9c625SLionel Sambuc 	struct alpha_fp_c_args args;
65*84d9c625SLionel Sambuc 
66*84d9c625SLionel Sambuc 	args.fp_c = IEEE_MAP_DMZ|IEEE_MAP_UMZ;
67*84d9c625SLionel Sambuc 	__alpha_sysarch(ALPHA_SET_FP_C, &args);
68*84d9c625SLionel Sambuc }
69