xref: /openbsd/sys/arch/i386/stand/libsa/exec_i386.c (revision db3296cf)
1 /*	$OpenBSD: exec_i386.c,v 1.28 2003/06/03 20:22:11 mickey Exp $	*/
2 
3 /*
4  * Copyright (c) 1997-1998 Michael Shalayeff
5  * Copyright (c) 1997 Tobias Weingartner
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  */
30 
31 #include <sys/param.h>
32 #include <dev/cons.h>
33 #include <stand/boot/bootarg.h>
34 #include <machine/biosvar.h>
35 #include <sys/disklabel.h>
36 #include "disk.h"
37 #include "libsa.h"
38 #include <lib/libsa/loadfile.h>
39 
40 typedef void (*startfuncp)(int, int, int, int, int, int, int, int)
41 	__attribute__ ((noreturn));
42 
43 void
44 run_loadfile(u_long *marks, int howto)
45 {
46 	u_long entry;
47 #ifndef _TEST
48 #ifdef EXEC_DEBUG
49 	extern int debug;
50 #endif
51 	dev_t bootdev = bootdev_dip->bootdev;
52 	size_t ac = BOOTARG_LEN;
53 	caddr_t av = (caddr_t)BOOTARG_OFF;
54 	bios_consdev_t cd;
55 	extern int com_speed; /* from bioscons.c */
56 
57 	cd.consdev = cn_tab->cn_dev;
58 	cd.conspeed = com_speed;
59 	addbootarg(BOOTARG_CONSDEV, sizeof(cd), &cd);
60 
61 	/* Pass memory map to the kernel */
62 	mem_pass();
63 
64 	makebootargs(av, &ac);
65 
66 	entry = marks[MARK_ENTRY] & 0x0fffffff;
67 
68 	printf("entry point at 0x%x\n", (int) entry);
69 	/* stack and the gung is ok at this point, so, no need for asm setup */
70 	(*(startfuncp)entry)(howto, bootdev, BOOTARG_APIVER,
71 		marks[MARK_END], extmem, cnvmem, ac, (int)av);
72 	/* not reached */
73 #endif
74 }
75