1 /* $OpenBSD: exec_i386.c,v 1.32 2007/07/27 17:46:56 tom 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 char *bootmac = NULL;
44
45 void
46 run_loadfile(u_long *marks, int howto)
47 {
48 u_long entry;
49 #ifndef _TEST
50 dev_t bootdev = bootdev_dip->bootdev;
51 size_t ac = BOOTARG_LEN;
52 caddr_t av = (caddr_t)BOOTARG_OFF;
53 bios_consdev_t cd;
54 extern int com_speed; /* from bioscons.c */
55
56 if (sa_cleanup != NULL)
57 (*sa_cleanup)();
58
59 cd.consdev = cn_tab->cn_dev;
60 cd.conspeed = com_speed;
61 addbootarg(BOOTARG_CONSDEV, sizeof(cd), &cd);
62
63 if (bootmac != NULL)
64 addbootarg(BOOTARG_BOOTMAC, sizeof(bios_bootmac_t), bootmac);
65
66 /* Pass memory map to the kernel */
67 mem_pass();
68
69 makebootargs(av, &ac);
70
71 entry = marks[MARK_ENTRY] & 0x0fffffff;
72
73 printf("entry point at 0x%x\n", (int) entry);
74 /* stack and the gung is ok at this point, so, no need for asm setup */
75 (*(startfuncp)entry)(howto, bootdev, BOOTARG_APIVER,
76 marks[MARK_END], extmem, cnvmem, ac, (int)av);
77 /* not reached */
78 #endif
79 }