summaryrefslogtreecommitdiff
path: root/sys/src/9/boot/boot.c
blob: d4950f4753989899926c777b4aace442c04d1dee (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
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#include "../boot/boot.h"

char	cputype[64];
int	mflag;
int	fflag;
int	kflag;

void
boot(int argc, char *argv[])
{
	char buf[32];

	fmtinstall('r', errfmt);

	bind("#c", "/dev", MBEFORE);
	open("/dev/cons", OREAD);
	open("/dev/cons", OWRITE);
	open("/dev/cons", OWRITE);
	/*
	 * init will reinitialize its namespace.
	 * #ec gets us plan9.ini settings (*var variables).
	 */
	bind("#ec", "/env", MREPL);
	bind("#e", "/env", MBEFORE|MCREATE);
	bind("#s", "/srv", MREPL|MCREATE);

	if(Debug){
		int i;

		print("argc=%d\n", argc);
		for(i = 0; i < argc; i++)
			print("%lux %s ", (ulong)argv[i], argv[i]);
		print("\n");
	}

	ARGBEGIN{
	case 'k':
		kflag = 1;
		break;
	case 'm':
		mflag = 1;
		break;
	case 'f':
		fflag = 1;
		break;
	}ARGEND

	readfile("#e/cputype", cputype, sizeof(cputype));
	setenv("bootdisk", bootdisk, 0);
	setenv("cpuflag", cpuflag ? "1" : "0", 0);

	/* setup the boot namespace */
	bind("/boot", "/bin", MAFTER);
	run("/bin/paqfs", "-q", "-c", "8", "-m" "/root", "/boot/bootfs.paq", nil);
	bind("/root", "/", MAFTER);
	snprint(buf, sizeof(buf), "/%s/bin", cputype);
	bind(buf, "/bin", MAFTER);
	bind("/rc/bin", "/bin", MAFTER);
	run("/bin/bootrc", nil);
}