xref: /netbsd/sys/arch/mvmeppc/stand/libsa/exec_mvme.c (revision 6550d01e)
1 /*	$NetBSD: exec_mvme.c,v 1.5 2009/03/14 15:36:11 dsl Exp $	*/
2 
3 /*-
4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Steve C. Woodford.
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  *
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.
30  */
31 
32 /*-
33  * Copyright (c) 1982, 1986, 1990, 1993
34  *	The Regents of the University of California.  All rights reserved.
35  *
36  * Redistribution and use in source and binary forms, with or without
37  * modification, are permitted provided that the following conditions
38  * are met:
39  * 1. Redistributions of source code must retain the above copyright
40  *    notice, this list of conditions and the following disclaimer.
41  * 2. Redistributions in binary form must reproduce the above copyright
42  *    notice, this list of conditions and the following disclaimer in the
43  *    documentation and/or other materials provided with the distribution.
44  * 3. Neither the name of the University nor the names of its contributors
45  *    may be used to endorse or promote products derived from this software
46  *    without specific prior written permission.
47  *
48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58  * SUCH DAMAGE.
59  *
60  * 	@(#)boot.c	8.1 (Berkeley) 6/10/93
61  */
62 
63 #include <sys/param.h>
64 #include <sys/reboot.h>
65 
66 #include <machine/bootinfo.h>
67 
68 #include "loadfile.h"
69 
70 #include "stand.h"
71 #include "libsa.h"
72 
73 /* These must agree with what locore.s expects */
74 #define	KERN_LOADADDR	0x0
75 typedef void (*kentry_t)(u_int, u_int, struct mvmeppc_bootinfo *);
76 
77 
78 /*ARGSUSED*/
79 void
80 exec_mvme(const char *file, int flag, int part)
81 {
82 	kentry_t	entry;
83 	u_long		marks[MARK_MAX];
84 	int		fd;
85 	int		lflags;
86 
87 	lflags = LOAD_KERNEL;
88 #if 0
89 	if ((flag & RB_NOSYM) != 0 )
90 		lflags &= ~LOAD_SYM;
91 #endif
92 
93 	marks[MARK_START] = KERN_LOADADDR;
94 	if ((fd = loadfile(file, marks, lflags)) == -1)
95 		return;
96 	close(fd);
97 
98 	marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) &
99 	    (-sizeof(int));
100 
101 	printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n",
102 	    marks[MARK_ENTRY], marks[MARK_NSYM],
103 	    marks[MARK_SYM], marks[MARK_END]);
104 
105 	entry = (kentry_t) marks[MARK_ENTRY];
106 
107 	(*entry)(marks[MARK_SYM], marks[MARK_END], &bootinfo);
108 
109 	printf("exec: kernel returned!\n");
110 	return;
111 }
112