xref: /minix3/usr.sbin/installboot/arch/sun68k.c (revision 9f8e6353e54579f3834bed052b7960946fc4bb01)
1*9f8e6353SEvgeniy Ivanov /*	$NetBSD: sun68k.c,v 1.21 2008/04/28 20:24:16 martin Exp $ */
2*9f8e6353SEvgeniy Ivanov 
3*9f8e6353SEvgeniy Ivanov /*-
4*9f8e6353SEvgeniy Ivanov  * Copyright (c) 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 Luke Mewburn.
9*9f8e6353SEvgeniy Ivanov  *
10*9f8e6353SEvgeniy Ivanov  * Redistribution and use in source and binary forms, with or without
11*9f8e6353SEvgeniy Ivanov  * modification, are permitted provided that the following conditions
12*9f8e6353SEvgeniy Ivanov  * are met:
13*9f8e6353SEvgeniy Ivanov  * 1. Redistributions of source code must retain the above copyright
14*9f8e6353SEvgeniy Ivanov  *    notice, this list of conditions and the following disclaimer.
15*9f8e6353SEvgeniy Ivanov  * 2. Redistributions in binary form must reproduce the above copyright
16*9f8e6353SEvgeniy Ivanov  *    notice, this list of conditions and the following disclaimer in the
17*9f8e6353SEvgeniy Ivanov  *    documentation and/or other materials provided with the distribution.
18*9f8e6353SEvgeniy Ivanov  *
19*9f8e6353SEvgeniy Ivanov  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*9f8e6353SEvgeniy Ivanov  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*9f8e6353SEvgeniy Ivanov  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*9f8e6353SEvgeniy Ivanov  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*9f8e6353SEvgeniy Ivanov  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*9f8e6353SEvgeniy Ivanov  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*9f8e6353SEvgeniy Ivanov  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*9f8e6353SEvgeniy Ivanov  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*9f8e6353SEvgeniy Ivanov  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*9f8e6353SEvgeniy Ivanov  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*9f8e6353SEvgeniy Ivanov  * POSSIBILITY OF SUCH DAMAGE.
30*9f8e6353SEvgeniy Ivanov  */
31*9f8e6353SEvgeniy Ivanov 
32*9f8e6353SEvgeniy Ivanov #if HAVE_NBTOOL_CONFIG_H
33*9f8e6353SEvgeniy Ivanov #include "nbtool_config.h"
34*9f8e6353SEvgeniy Ivanov #endif
35*9f8e6353SEvgeniy Ivanov 
36*9f8e6353SEvgeniy Ivanov #include <sys/cdefs.h>
37*9f8e6353SEvgeniy Ivanov #if !defined(__lint)
38*9f8e6353SEvgeniy Ivanov __RCSID("$NetBSD: sun68k.c,v 1.21 2008/04/28 20:24:16 martin Exp $");
39*9f8e6353SEvgeniy Ivanov #endif	/* !__lint */
40*9f8e6353SEvgeniy Ivanov 
41*9f8e6353SEvgeniy Ivanov #include <sys/param.h>
42*9f8e6353SEvgeniy Ivanov 
43*9f8e6353SEvgeniy Ivanov #include <assert.h>
44*9f8e6353SEvgeniy Ivanov #include <err.h>
45*9f8e6353SEvgeniy Ivanov #include <stdio.h>
46*9f8e6353SEvgeniy Ivanov 
47*9f8e6353SEvgeniy Ivanov #include "installboot.h"
48*9f8e6353SEvgeniy Ivanov 
49*9f8e6353SEvgeniy Ivanov static int sun68k_clearboot(ib_params *);
50*9f8e6353SEvgeniy Ivanov static int sun68k_setboot(ib_params *);
51*9f8e6353SEvgeniy Ivanov 
52*9f8e6353SEvgeniy Ivanov struct ib_mach ib_mach_sun2 =
53*9f8e6353SEvgeniy Ivanov 	{ "sun2", sun68k_setboot, sun68k_clearboot, no_editboot,
54*9f8e6353SEvgeniy Ivanov 		IB_STAGE2START };
55*9f8e6353SEvgeniy Ivanov 
56*9f8e6353SEvgeniy Ivanov struct ib_mach ib_mach_sun3 =
57*9f8e6353SEvgeniy Ivanov 	{ "sun3", sun68k_setboot, sun68k_clearboot, no_editboot,
58*9f8e6353SEvgeniy Ivanov 		IB_STAGE2START };
59*9f8e6353SEvgeniy Ivanov 
60*9f8e6353SEvgeniy Ivanov static struct bbinfo_params bbparams = {
61*9f8e6353SEvgeniy Ivanov 	SUN68K_BBINFO_MAGIC,
62*9f8e6353SEvgeniy Ivanov 	SUN68K_BOOT_BLOCK_OFFSET,
63*9f8e6353SEvgeniy Ivanov 	SUN68K_BOOT_BLOCK_BLOCKSIZE,
64*9f8e6353SEvgeniy Ivanov 	SUN68K_BOOT_BLOCK_MAX_SIZE,
65*9f8e6353SEvgeniy Ivanov 	0,
66*9f8e6353SEvgeniy Ivanov 	BBINFO_BIG_ENDIAN,
67*9f8e6353SEvgeniy Ivanov };
68*9f8e6353SEvgeniy Ivanov 
69*9f8e6353SEvgeniy Ivanov static int
sun68k_clearboot(ib_params * params)70*9f8e6353SEvgeniy Ivanov sun68k_clearboot(ib_params *params)
71*9f8e6353SEvgeniy Ivanov {
72*9f8e6353SEvgeniy Ivanov 
73*9f8e6353SEvgeniy Ivanov 	assert(params != NULL);
74*9f8e6353SEvgeniy Ivanov 
75*9f8e6353SEvgeniy Ivanov 	return (shared_bbinfo_clearboot(params, &bbparams, NULL));
76*9f8e6353SEvgeniy Ivanov }
77*9f8e6353SEvgeniy Ivanov 
78*9f8e6353SEvgeniy Ivanov static int
sun68k_setboot(ib_params * params)79*9f8e6353SEvgeniy Ivanov sun68k_setboot(ib_params *params)
80*9f8e6353SEvgeniy Ivanov {
81*9f8e6353SEvgeniy Ivanov 
82*9f8e6353SEvgeniy Ivanov 	assert(params != NULL);
83*9f8e6353SEvgeniy Ivanov 
84*9f8e6353SEvgeniy Ivanov 	return (shared_bbinfo_setboot(params, &bbparams, NULL));
85*9f8e6353SEvgeniy Ivanov }
86