1 /* $NetBSD: boot.c,v 1.5 2009/03/14 15:36:11 dsl Exp $ */
4 * Copyright (C) 1999 Tsubai Masanari. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/param.h>
30 #include <sys/sysctl.h>
31 #include <machine/cpu.h>
37 #include <lib/libsa/loadfile.h>
40 # define DPRINTF printf
42 # define DPRINTF while (0) printf
45 void LoadAndReset(void *);
47 char *netbsd
= "/netbsd";
50 main(int argc
, char *argv
[])
52 u_long marks
[MARK_MAX
];
59 /* use the specified kernel if any */
63 DPRINTF("loading %s...\n", netbsd
);
65 /* count kernel size */
66 marks
[MARK_START
] = 0;
67 fd
= loadfile(netbsd
, marks
, COUNT_ALL
);
69 err(0, "loadfile(1)");
72 sz
= marks
[MARK_END
] - marks
[MARK_START
];
73 start
= marks
[MARK_START
];
74 entry
= marks
[MARK_ENTRY
];
76 DPRINTF("size = 0x%x\n", sz
);
77 DPRINTF("start = 0x%lx\n", start
);
79 ap
= malloc(sz
+ 2 * sizeof(long));
85 marks
[MARK_START
] = (u_long
)image
- start
;
86 fd
= loadfile(netbsd
, marks
, LOAD_ALL
);
88 err(0, "loadfile(2)");
91 /* ssym = marks[MARK_SYM]; */
92 /* esym = marks[MARK_END]; */
96 for (i
= 0; i
< sz
/ sizeof(cksum
); i
++)
103 printf("LoadAndReset returned...\n");
109 LoadAndReset(void *image
)
114 mib
[0] = CTL_MACHDEP
;
115 mib
[1] = CPU_LOADANDRESET
;
118 sysctl(mib
, 2, NULL
, NULL
, &val
, sizeof(val
));