summaryrefslogtreecommitdiff
path: root/sys/arch/i386/stand/libsa/exec_i386.c
blob: f9eb127a3b9b385d1bd7315ed39dde554f8b6308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

/* $OpenBSD: exec_i386.c,v 1.2 1997/03/31 05:52:25 weingart Exp $ */

#include <sys/param.h>
#include <sys/exec.h>
#include <sys/reboot.h>
#include <libsa.h>


void
machdep_start(startaddr, howto, loadaddr, ssym, esym)
	char *startaddr, *loadaddr, *ssym, *esym;
	int howto;
{
	static int argv[9];
	struct exec *x;


#ifdef DEBUG
	x = (void *)loadaddr;
	printf("exec {\n");
	printf("  a_midmag = %lx\n", x->a_midmag);
	printf("  a_text = %lx\n", x->a_text);
	printf("  a_data = %lx\n", x->a_data);
	printf("  a_bss = %lx\n", x->a_bss);
	printf("  a_syms = %lx\n", x->a_syms);
	printf("  a_entry = %lx\n", x->a_entry);
	printf("  a_trsize = %lx\n", x->a_trsize);
	printf("  a_drsize = %lx\n", x->a_drsize);
	printf("}\n");

	getchar();
#endif

	(int)startaddr &= 0xffffff;

	/*
	 *  We now pass the various bootstrap parameters to the loaded
	 *  image via the argument list
	 *
	 *  arg0 = 8 (magic)
	 *  arg1 = boot flags
	 *  arg2 = boot device
	 *  arg3 = Cylinder offset (XXX - used to be ssym)
	 *  arg4 = end of symbol table (0 if not loaded)
	 *  arg5 = transfer address from image
	 *  arg6 = transfer address for next image pointer
	 *  arg7 = conventional memory size (640)
	 *  arg8 = extended memory size (8196)
	 */
	argv[0] = 8;
	argv[1] = howto;
	argv[2] = bootdev;		/* Boot device */
	argv[3] = 0;			/* Cyl offset */
	argv[4] = 0;
	argv[5] = (int)startaddr;
	argv[6] = 0;
	argv[7] = memsize(0);
	argv[8] = memsize(1);

#ifdef DEBUG
	{ int i;
		for(i = 0; i <= argv[0]; i++)
			printf("argv[%d] = %x\n", i, argv[i]);

		getchar();
	}
#endif

	/****************************************************************/
	/* copy that first page and overwrite any BIOS variables        */
	/****************************************************************/
	printf("entry point at 0x%x\n", (int)startaddr);
	startprog(startaddr, argv);
}