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