1433d6423SLionel Sambuc#!/bin/sh 2433d6423SLionel Sambucset -e 3433d6423SLionel Sambuc 4c58da9fbSDavid van MoolenbroekPATH=/sbin:/usr/sbin:/bin:/usr/bin 5c58da9fbSDavid van Moolenbroek 6433d6423SLionel SambucFSCK=/bin/fsck_mfs 750a1aef1SLionel SambucACPI=/service/acpi 8433d6423SLionel Sambuc 9325ce30bSDavid van Moolenbroekif [ X`sysenv arch` = Xi386 ] 10433d6423SLionel Sambucthen if [ -e $ACPI -a -n "`sysenv acpi`" ] 11433d6423SLionel Sambuc then 12c58da9fbSDavid van Moolenbroek minix-service -c up $ACPI 13433d6423SLionel Sambuc fi 14c58da9fbSDavid van Moolenbroek minix-service -c up /service/pci -dev /dev/pci 15433d6423SLionel Sambuc 16c58da9fbSDavid van Moolenbroek minix-service -c up /service/input -dev /dev/kbdmux 17c58da9fbSDavid van Moolenbroek minix-service -c up /service/pckbd || : 18433d6423SLionel Sambuc 19433d6423SLionel Sambuc # Start procfs so we can access /proc/pci 20433d6423SLionel Sambuc mount -t procfs none /proc >/dev/null 21433d6423SLionel Sambuc 22433d6423SLionel Sambuc # Do we want to use the virtio block device? 23433d6423SLionel Sambuc # If not specified, default to yes if the device is found. 24325ce30bSDavid van Moolenbroek if sysenv virtio_blk >/dev/null 25325ce30bSDavid van Moolenbroek then virtio_blk="`sysenv virtio_blk`" 269e77ef50SLionel Sambuc elif grep '^[^ ]* [^ ]* 1AF4:1001[^ ]* ' /proc/pci >/dev/null 27433d6423SLionel Sambuc then echo "virtio_blk not set, defaulting to using found virtio device." 28433d6423SLionel Sambuc virtio_blk=yes 29433d6423SLionel Sambuc fi 30433d6423SLionel Sambuc 31c58da9fbSDavid van Moolenbroek minix-service -cn up /service/floppy -dev /dev/fd0 32325ce30bSDavid van Moolenbroek if [ X`sysenv ahci` = Xyes ] 33433d6423SLionel Sambuc then 34433d6423SLionel Sambuc # this is here temporarily, for testing purposes 35c58da9fbSDavid van Moolenbroek minix-service -c up /service/ahci -dev /dev/c0d0 -label ahci_0 -args instance=0 36433d6423SLionel Sambuc elif [ X"$virtio_blk" = Xyes ] 37433d6423SLionel Sambuc then 38c58da9fbSDavid van Moolenbroek minix-service -c up /service/virtio_blk -dev /dev/c0d0 -label virtio_blk_0 -args instance=0 39433d6423SLionel Sambuc else 40c58da9fbSDavid van Moolenbroek minix-service -c up /service/at_wini -dev /dev/c0d0 -label at_wini_0 41c58da9fbSDavid van Moolenbroek minix-service -cr up /service/at_wini -dev /dev/c1d0 -label at_wini_1 -args instance=1 2>/dev/null || : 42433d6423SLionel Sambuc fi 43325ce30bSDavid van Moolenbroek umount /proc >/dev/null 44433d6423SLionel Sambucfi 45433d6423SLionel Sambuc 46325ce30bSDavid van Moolenbroekif [ X`sysenv arch` = Xearm ] 47433d6423SLionel Sambucthen echo Starting the mmc driver 48c58da9fbSDavid van Moolenbroek minix-service -c up /service/mmc -dev /dev/c0d0 49433d6423SLionel Sambucfi 50433d6423SLionel Sambuc 51325ce30bSDavid van Moolenbroek# Load ProcFS from the ramdisk to minimize the chance of a desync with the boot 52325ce30bSDavid van Moolenbroek# image services from which it obtains data structures directly. As we move to 53325ce30bSDavid van Moolenbroek# the MIB service, this will eventually become obsolete. 54c58da9fbSDavid van Moolenbroekminix-service up /service/procfs || echo "WARNING: couldn't start procfs" 55433d6423SLionel Sambuc 56325ce30bSDavid van Moolenbroekif sysenv rootdevname >/dev/null 57325ce30bSDavid van Moolenbroekthen rootdevname=/dev/`sysenv rootdevname` 5869eead77SJean-Baptiste Boricelse 59*8898fa50SDavid van Moolenbroek if ! sysenv cdproberoot >/dev/null && ! sysenv bootramdisk >/dev/null 6069eead77SJean-Baptiste Boric then echo "rootdevname not set" 61433d6423SLionel Sambuc exit 1 62433d6423SLionel Sambuc fi 6369eead77SJean-Baptiste Boricfi 64433d6423SLionel Sambuc 65433d6423SLionel Sambucif [ "`sysenv bin_img`" = 1 ] 66433d6423SLionel Sambucthen 67433d6423SLionel Sambuc bin_img="-i " 68433d6423SLionel Sambucfi 69433d6423SLionel Sambuc 70433d6423SLionel Sambucif sysenv cdproberoot >/dev/null 71433d6423SLionel Sambucthen 72433d6423SLionel Sambuc echo 73433d6423SLionel Sambuc echo 'Looking for boot CD. This may take a minute.' 74433d6423SLionel Sambuc echo 'Please ignore any error messages.' 75433d6423SLionel Sambuc echo 7669eead77SJean-Baptiste Boric rootdevname=$(cdprobe) || { echo 'No CD found'; exit 1; } 7769eead77SJean-Baptiste Boric export rootdevname 78433d6423SLionel Sambucelif [ "$rootdevname" = "/dev/ram" ] 79433d6423SLionel Sambucthen 80325ce30bSDavid van Moolenbroek ramimagename=/dev/`sysenv ramimagename` 81433d6423SLionel Sambuc echo "Loading ramdisk from $ramimagename" 82433d6423SLionel Sambuc loadramdisk "$ramimagename" || echo "WARNING: loadramdisk failed" 83433d6423SLionel Sambucfi 84433d6423SLionel Sambuc 85a7a79fa1SJean-Baptiste Boricif sysenv bootramdisk >/dev/null 86a7a79fa1SJean-Baptiste Boricthen 87a7a79fa1SJean-Baptiste Boric rootdevname=imgrd 88a7a79fa1SJean-Baptiste Boricfi 89a7a79fa1SJean-Baptiste Boric 90433d6423SLionel Sambucecho "Root device name is $rootdevname" 9169eead77SJean-Baptiste Boric 9269eead77SJean-Baptiste Boricif ! sysenv cdproberoot >/dev/null 9369eead77SJean-Baptiste Boricthen 94433d6423SLionel Sambuc if [ -e $FSCK ] 95433d6423SLionel Sambuc then $FSCK -p $rootdevname 96433d6423SLionel Sambuc fi 9769eead77SJean-Baptiste Boricfi 98433d6423SLionel Sambuc 99325ce30bSDavid van Moolenbroek# Change root from temporary boot ramdisk to the configure root device 100325ce30bSDavid van Moolenbroekif ! sysenv bootramdisk >/dev/null; then 101325ce30bSDavid van Moolenbroek mount -n $bin_img"$rootdevname" / 102325ce30bSDavid van Moolenbroek 103325ce30bSDavid van Moolenbroek # Reopen standard file descriptors, so that we can unmount the ramdisk. 104325ce30bSDavid van Moolenbroek # That is essentially a VFS shortcoming that should be fixed, though.. 105325ce30bSDavid van Moolenbroek exec >/dev/log 106325ce30bSDavid van Moolenbroek exec 2>/dev/log 107325ce30bSDavid van Moolenbroek exec </dev/console 108a7a79fa1SJean-Baptiste Boricfi 109433d6423SLionel Sambuc 110325ce30bSDavid van Moolenbroek# Mount the ProcFS instance that was loaded from the ramdisk, on the root FS. 111325ce30bSDavid van Moolenbroekmount -e -n -t procfs none /proc || echo "WARNING: couldn't mount procfs" 112433d6423SLionel Sambuc 113325ce30bSDavid van Moolenbroek# Start the NetBSD rc infrastructure 114325ce30bSDavid van Moolenbroekif ! sysenv bootramdisk >/dev/null; then 115325ce30bSDavid van Moolenbroek exec sh /etc/rc "$@" 116a7a79fa1SJean-Baptiste Boricfi 117