summaryrefslogtreecommitdiff
path: root/minix/drivers/storage/ramdisk/rc
blob: fad33a8a6b4811f56820120c0138c18106057d7c (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
set -e

PATH=/sbin:/usr/sbin:/bin:/usr/bin

FSCK=/bin/fsck_mfs
ACPI=/service/acpi

if [ X`sysenv arch` = Xi386 ]
then	if [ -e $ACPI -a -n "`sysenv acpi`" ]
	then
		minix-service -c up $ACPI
	fi
	minix-service -c up /service/pci -dev /dev/pci

	minix-service -c up /service/input -dev /dev/kbdmux
	minix-service -c up /service/pckbd || :

	# Start procfs so we can access /proc/pci
	mount -t procfs none /proc >/dev/null

	# Do we want to use the virtio block device?
	# If not specified, default to yes if the device is found.
	if sysenv virtio_blk >/dev/null
	then	virtio_blk="`sysenv virtio_blk`"
        elif	grep '^[^ ]* [^ ]* 1AF4:1001[^ ]* ' /proc/pci >/dev/null
	then	echo "virtio_blk not set, defaulting to using found virtio device."
		virtio_blk=yes
        fi

	minix-service -cn up /service/floppy -dev /dev/fd0
	if [ X`sysenv ahci` = Xyes ]
	then
		# this is here temporarily, for testing purposes
		minix-service -c up /service/ahci -dev /dev/c0d0 -label ahci_0 -args instance=0
	elif [ X"$virtio_blk" = Xyes ]
	then
		minix-service -c up /service/virtio_blk -dev /dev/c0d0 -label virtio_blk_0 -args instance=0
	else
		minix-service -c up /service/at_wini -dev /dev/c0d0 -label at_wini_0
		minix-service -cr up /service/at_wini -dev /dev/c1d0 -label at_wini_1 -args instance=1 2>/dev/null || :
	fi
	umount /proc >/dev/null
fi

if [ X`sysenv arch` = Xearm ]
then	echo Starting the mmc driver
	minix-service -c up /service/mmc -dev /dev/c0d0
fi

# Load ProcFS from the ramdisk to minimize the chance of a desync with the boot
# image services from which it obtains data structures directly.  As we move to
# the MIB service, this will eventually become obsolete.
minix-service up /service/procfs || echo "WARNING: couldn't start procfs"

if sysenv rootdevname >/dev/null
then	rootdevname=/dev/`sysenv rootdevname`
else
	if ! sysenv cdproberoot >/dev/null && ! sysenv bootramdisk >/dev/null
	then	echo "rootdevname not set"
		exit 1
	fi
fi

if [ "`sysenv bin_img`" = 1 ]
then
    bin_img="-i "
fi

if sysenv cdproberoot >/dev/null
then
	echo
	echo 'Looking for boot CD. This may take a minute.'
	echo 'Please ignore any error messages.'
	echo
	rootdevname=$(cdprobe) || { echo 'No CD found'; exit 1; }
	export rootdevname
elif [ "$rootdevname" = "/dev/ram" ]
then
	ramimagename=/dev/`sysenv ramimagename`
	echo "Loading ramdisk from $ramimagename"
	loadramdisk "$ramimagename" || echo "WARNING: loadramdisk failed"
fi

if sysenv bootramdisk >/dev/null
then
	rootdevname=imgrd
fi

echo "Root device name is $rootdevname"

if ! sysenv cdproberoot >/dev/null
then
	if [ -e $FSCK ]
	then	$FSCK -p $rootdevname
	fi
fi

# Change root from temporary boot ramdisk to the configure root device
if ! sysenv bootramdisk >/dev/null; then
	mount -n $bin_img"$rootdevname" /

	# Reopen standard file descriptors, so that we can unmount the ramdisk.
	# That is essentially a VFS shortcoming that should be fixed, though..
	exec >/dev/log
	exec 2>/dev/log
	exec </dev/console
fi

# Mount the ProcFS instance that was loaded from the ramdisk, on the root FS.
mount -e -n -t procfs none /proc || echo "WARNING: couldn't mount procfs"

# Start the NetBSD rc infrastructure
if ! sysenv bootramdisk >/dev/null; then
	exec sh /etc/rc "$@"
fi