1*95e1ffb1Schristos /* $NetBSD: exec.c,v 1.5 2005/12/11 12:17:19 christos Exp $ */
2c8e4daf6Sgmcgarry
3c8e4daf6Sgmcgarry /*-
4c8e4daf6Sgmcgarry * Copyright (c) 1982, 1986, 1990, 1993
5c8e4daf6Sgmcgarry * The Regents of the University of California. All rights reserved.
6c8e4daf6Sgmcgarry *
7c8e4daf6Sgmcgarry * Redistribution and use in source and binary forms, with or without
8c8e4daf6Sgmcgarry * modification, are permitted provided that the following conditions
9c8e4daf6Sgmcgarry * are met:
10c8e4daf6Sgmcgarry * 1. Redistributions of source code must retain the above copyright
11c8e4daf6Sgmcgarry * notice, this list of conditions and the following disclaimer.
12c8e4daf6Sgmcgarry * 2. Redistributions in binary form must reproduce the above copyright
13c8e4daf6Sgmcgarry * notice, this list of conditions and the following disclaimer in the
14c8e4daf6Sgmcgarry * documentation and/or other materials provided with the distribution.
15aad01611Sagc * 3. Neither the name of the University nor the names of its contributors
16c8e4daf6Sgmcgarry * may be used to endorse or promote products derived from this software
17c8e4daf6Sgmcgarry * without specific prior written permission.
18c8e4daf6Sgmcgarry *
19c8e4daf6Sgmcgarry * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20c8e4daf6Sgmcgarry * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21c8e4daf6Sgmcgarry * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22c8e4daf6Sgmcgarry * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23c8e4daf6Sgmcgarry * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24c8e4daf6Sgmcgarry * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25c8e4daf6Sgmcgarry * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26c8e4daf6Sgmcgarry * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27c8e4daf6Sgmcgarry * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28c8e4daf6Sgmcgarry * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29c8e4daf6Sgmcgarry * SUCH DAMAGE.
30c8e4daf6Sgmcgarry *
31c8e4daf6Sgmcgarry * @(#)boot.c 8.1 (Berkeley) 6/10/93
32c8e4daf6Sgmcgarry */
33c8e4daf6Sgmcgarry
34c8e4daf6Sgmcgarry #include <sys/param.h>
35c8e4daf6Sgmcgarry
36c8e4daf6Sgmcgarry #include <machine/bootinfo.h>
37c8e4daf6Sgmcgarry
38212f884fStsutsui #include <lib/libsa/stand.h>
39c8e4daf6Sgmcgarry #include <lib/libsa/loadfile.h>
40c8e4daf6Sgmcgarry
41c8e4daf6Sgmcgarry #include <hp300/stand/common/samachdep.h>
42c8e4daf6Sgmcgarry
43c8e4daf6Sgmcgarry #define round_to_size(x) \
44c8e4daf6Sgmcgarry (((x) + sizeof(u_long) - 1) & ~(sizeof(u_long) - 1))
45c8e4daf6Sgmcgarry
46c8e4daf6Sgmcgarry void
exec_hp300(char * file,u_long loadaddr,int howto)47d3dc0553Stsutsui exec_hp300(char *file, u_long loadaddr, int howto)
48c8e4daf6Sgmcgarry {
49c8e4daf6Sgmcgarry u_long marks[MARK_MAX];
50c8e4daf6Sgmcgarry struct btinfo_magic *bt;
51c8e4daf6Sgmcgarry int fd;
52c8e4daf6Sgmcgarry
53c8e4daf6Sgmcgarry marks[MARK_START] = loadaddr;
54c8e4daf6Sgmcgarry if ((fd = loadfile(file, marks, LOAD_KERNEL)) == -1)
55c8e4daf6Sgmcgarry return;
56c8e4daf6Sgmcgarry
57c8e4daf6Sgmcgarry marks[MARK_END] = round_to_size(marks[MARK_END] - loadaddr);
58c8e4daf6Sgmcgarry printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n",
59c8e4daf6Sgmcgarry marks[MARK_ENTRY], marks[MARK_NSYM],
60c8e4daf6Sgmcgarry marks[MARK_SYM], marks[MARK_END]);
61c8e4daf6Sgmcgarry
62c8e4daf6Sgmcgarry bt = (struct btinfo_magic *)loadaddr;
63c8e4daf6Sgmcgarry bt->common.type = BTINFO_MAGIC;
64c8e4daf6Sgmcgarry bt->magic1 = BOOTINFO_MAGIC1;
65c8e4daf6Sgmcgarry bt->magic2 = BOOTINFO_MAGIC2;
66c8e4daf6Sgmcgarry
67c8e4daf6Sgmcgarry machdep_start((char *)marks[MARK_ENTRY], howto,
68c8e4daf6Sgmcgarry (char *)loadaddr, (char *)marks[MARK_SYM],
69c8e4daf6Sgmcgarry (char *)marks[MARK_END]);
70c8e4daf6Sgmcgarry }
71