xref: /minix3/usr.sbin/installboot/arch/emips.c (revision 9f8e6353e54579f3834bed052b7960946fc4bb01)
1*9f8e6353SEvgeniy Ivanov /*	$NetBSD: emips.c,v 1.1 2011/01/26 01:18:55 pooka Exp $	*/
2*9f8e6353SEvgeniy Ivanov 
3*9f8e6353SEvgeniy Ivanov /*-
4*9f8e6353SEvgeniy Ivanov  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
5*9f8e6353SEvgeniy Ivanov  * All rights reserved.
6*9f8e6353SEvgeniy Ivanov  *
7*9f8e6353SEvgeniy Ivanov  * This code is derived from software contributed to The NetBSD Foundation
8*9f8e6353SEvgeniy Ivanov  * by Simon Burge.
9*9f8e6353SEvgeniy Ivanov  *
10*9f8e6353SEvgeniy Ivanov  * This code is derived from software contributed to The NetBSD Foundation
11*9f8e6353SEvgeniy Ivanov  * by Luke Mewburn of Wasabi Systems.
12*9f8e6353SEvgeniy Ivanov  *
13*9f8e6353SEvgeniy Ivanov  * Redistribution and use in source and binary forms, with or without
14*9f8e6353SEvgeniy Ivanov  * modification, are permitted provided that the following conditions
15*9f8e6353SEvgeniy Ivanov  * are met:
16*9f8e6353SEvgeniy Ivanov  * 1. Redistributions of source code must retain the above copyright
17*9f8e6353SEvgeniy Ivanov  *    notice, this list of conditions and the following disclaimer.
18*9f8e6353SEvgeniy Ivanov  * 2. Redistributions in binary form must reproduce the above copyright
19*9f8e6353SEvgeniy Ivanov  *    notice, this list of conditions and the following disclaimer in the
20*9f8e6353SEvgeniy Ivanov  *    documentation and/or other materials provided with the distribution.
21*9f8e6353SEvgeniy Ivanov  * 3. All advertising materials mentioning features or use of this software
22*9f8e6353SEvgeniy Ivanov  *    must display the following acknowledgement:
23*9f8e6353SEvgeniy Ivanov  *	This product includes software developed by the NetBSD
24*9f8e6353SEvgeniy Ivanov  *	Foundation, Inc. and its contributors.
25*9f8e6353SEvgeniy Ivanov  * 4. Neither the name of The NetBSD Foundation nor the names of its
26*9f8e6353SEvgeniy Ivanov  *    contributors may be used to endorse or promote products derived
27*9f8e6353SEvgeniy Ivanov  *    from this software without specific prior written permission.
28*9f8e6353SEvgeniy Ivanov  *
29*9f8e6353SEvgeniy Ivanov  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
30*9f8e6353SEvgeniy Ivanov  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
31*9f8e6353SEvgeniy Ivanov  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32*9f8e6353SEvgeniy Ivanov  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
33*9f8e6353SEvgeniy Ivanov  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34*9f8e6353SEvgeniy Ivanov  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35*9f8e6353SEvgeniy Ivanov  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36*9f8e6353SEvgeniy Ivanov  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37*9f8e6353SEvgeniy Ivanov  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38*9f8e6353SEvgeniy Ivanov  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39*9f8e6353SEvgeniy Ivanov  * POSSIBILITY OF SUCH DAMAGE.
40*9f8e6353SEvgeniy Ivanov  */
41*9f8e6353SEvgeniy Ivanov 
42*9f8e6353SEvgeniy Ivanov /*
43*9f8e6353SEvgeniy Ivanov  * Copyright (c) 1999 Ross Harvey.  All rights reserved.
44*9f8e6353SEvgeniy Ivanov  *
45*9f8e6353SEvgeniy Ivanov  * Redistribution and use in source and binary forms, with or without
46*9f8e6353SEvgeniy Ivanov  * modification, are permitted provided that the following conditions
47*9f8e6353SEvgeniy Ivanov  * are met:
48*9f8e6353SEvgeniy Ivanov  * 1. Redistributions of source code must retain the above copyright
49*9f8e6353SEvgeniy Ivanov  *    notice, this list of conditions and the following disclaimer.
50*9f8e6353SEvgeniy Ivanov  * 2. Redistributions in binary form must reproduce the above copyright
51*9f8e6353SEvgeniy Ivanov  *    notice, this list of conditions and the following disclaimer in the
52*9f8e6353SEvgeniy Ivanov  *    documentation and/or other materials provided with the distribution.
53*9f8e6353SEvgeniy Ivanov  * 3. All advertising materials mentioning features or use of this software
54*9f8e6353SEvgeniy Ivanov  *    must display the following acknowledgement:
55*9f8e6353SEvgeniy Ivanov  *      This product includes software developed by Ross Harvey
56*9f8e6353SEvgeniy Ivanov  *	for the NetBSD Project.
57*9f8e6353SEvgeniy Ivanov  * 4. The name of the author may not be used to endorse or promote products
58*9f8e6353SEvgeniy Ivanov  *    derived from this software without specific prior written permission
59*9f8e6353SEvgeniy Ivanov  *
60*9f8e6353SEvgeniy Ivanov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
61*9f8e6353SEvgeniy Ivanov  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
62*9f8e6353SEvgeniy Ivanov  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
63*9f8e6353SEvgeniy Ivanov  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
64*9f8e6353SEvgeniy Ivanov  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
65*9f8e6353SEvgeniy Ivanov  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
66*9f8e6353SEvgeniy Ivanov  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
67*9f8e6353SEvgeniy Ivanov  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
68*9f8e6353SEvgeniy Ivanov  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
69*9f8e6353SEvgeniy Ivanov  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70*9f8e6353SEvgeniy Ivanov  */
71*9f8e6353SEvgeniy Ivanov 
72*9f8e6353SEvgeniy Ivanov /*
73*9f8e6353SEvgeniy Ivanov  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
74*9f8e6353SEvgeniy Ivanov  *
75*9f8e6353SEvgeniy Ivanov  * Redistribution and use in source and binary forms, with or without
76*9f8e6353SEvgeniy Ivanov  * modification, are permitted provided that the following conditions
77*9f8e6353SEvgeniy Ivanov  * are met:
78*9f8e6353SEvgeniy Ivanov  * 1. Redistributions of source code must retain the above copyright
79*9f8e6353SEvgeniy Ivanov  *    notice, this list of conditions and the following disclaimer.
80*9f8e6353SEvgeniy Ivanov  * 2. Redistributions in binary form must reproduce the above copyright
81*9f8e6353SEvgeniy Ivanov  *    notice, this list of conditions and the following disclaimer in the
82*9f8e6353SEvgeniy Ivanov  *    documentation and/or other materials provided with the distribution.
83*9f8e6353SEvgeniy Ivanov  * 3. All advertising materials mentioning features or use of this software
84*9f8e6353SEvgeniy Ivanov  *    must display the following acknowledgement:
85*9f8e6353SEvgeniy Ivanov  *      This product includes software developed by Christopher G. Demetriou
86*9f8e6353SEvgeniy Ivanov  *	for the NetBSD Project.
87*9f8e6353SEvgeniy Ivanov  * 4. The name of the author may not be used to endorse or promote products
88*9f8e6353SEvgeniy Ivanov  *    derived from this software without specific prior written permission
89*9f8e6353SEvgeniy Ivanov  *
90*9f8e6353SEvgeniy Ivanov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
91*9f8e6353SEvgeniy Ivanov  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
92*9f8e6353SEvgeniy Ivanov  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
93*9f8e6353SEvgeniy Ivanov  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
94*9f8e6353SEvgeniy Ivanov  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
95*9f8e6353SEvgeniy Ivanov  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
96*9f8e6353SEvgeniy Ivanov  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
97*9f8e6353SEvgeniy Ivanov  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
98*9f8e6353SEvgeniy Ivanov  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
99*9f8e6353SEvgeniy Ivanov  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
100*9f8e6353SEvgeniy Ivanov  */
101*9f8e6353SEvgeniy Ivanov 
102*9f8e6353SEvgeniy Ivanov #if HAVE_NBTOOL_CONFIG_H
103*9f8e6353SEvgeniy Ivanov #include "nbtool_config.h"
104*9f8e6353SEvgeniy Ivanov #endif
105*9f8e6353SEvgeniy Ivanov 
106*9f8e6353SEvgeniy Ivanov #include <sys/cdefs.h>
107*9f8e6353SEvgeniy Ivanov #if !defined(__lint)
108*9f8e6353SEvgeniy Ivanov __RCSID("$NetBSD: emips.c,v 1.1 2011/01/26 01:18:55 pooka Exp $");
109*9f8e6353SEvgeniy Ivanov #endif	/* !__lint */
110*9f8e6353SEvgeniy Ivanov 
111*9f8e6353SEvgeniy Ivanov #include <sys/param.h>
112*9f8e6353SEvgeniy Ivanov 
113*9f8e6353SEvgeniy Ivanov #include <assert.h>
114*9f8e6353SEvgeniy Ivanov #include <err.h>
115*9f8e6353SEvgeniy Ivanov #include <stddef.h>
116*9f8e6353SEvgeniy Ivanov #include <stdio.h>
117*9f8e6353SEvgeniy Ivanov #include <stdlib.h>
118*9f8e6353SEvgeniy Ivanov #include <string.h>
119*9f8e6353SEvgeniy Ivanov #include <unistd.h>
120*9f8e6353SEvgeniy Ivanov 
121*9f8e6353SEvgeniy Ivanov #include <sys/exec_elf.h>
122*9f8e6353SEvgeniy Ivanov 
123*9f8e6353SEvgeniy Ivanov #include "installboot.h"
124*9f8e6353SEvgeniy Ivanov 
125*9f8e6353SEvgeniy Ivanov static int emips_clearboot(ib_params *);
126*9f8e6353SEvgeniy Ivanov static int emips_setboot(ib_params *);
127*9f8e6353SEvgeniy Ivanov 
128*9f8e6353SEvgeniy Ivanov struct ib_mach ib_mach_emips =
129*9f8e6353SEvgeniy Ivanov 	{ "emips", emips_setboot, emips_clearboot, no_editboot,
130*9f8e6353SEvgeniy Ivanov 		IB_STAGE1START | IB_APPEND | IB_SUNSUM };
131*9f8e6353SEvgeniy Ivanov 
132*9f8e6353SEvgeniy Ivanov 
133*9f8e6353SEvgeniy Ivanov static int
emips_clearboot(ib_params * params)134*9f8e6353SEvgeniy Ivanov emips_clearboot(ib_params *params)
135*9f8e6353SEvgeniy Ivanov {
136*9f8e6353SEvgeniy Ivanov 	/* Nothing to do */
137*9f8e6353SEvgeniy Ivanov 	return (1);
138*9f8e6353SEvgeniy Ivanov }
139*9f8e6353SEvgeniy Ivanov 
140*9f8e6353SEvgeniy Ivanov static int
emips_setboot(ib_params * params)141*9f8e6353SEvgeniy Ivanov emips_setboot(ib_params *params)
142*9f8e6353SEvgeniy Ivanov {
143*9f8e6353SEvgeniy Ivanov 	/* Nothing to do */
144*9f8e6353SEvgeniy Ivanov 	return (1);
145*9f8e6353SEvgeniy Ivanov }
146