[WebOS Software Development] silvioster:
actual bootup code

/sbin/mkbootfs.sh -- or/and -- /sbin/tcpostflash.sh
for initrd...
cp /sbin/boot-init /sbin/init

/sbin/boot-init
echo "Mounting proc filesystem"
mount -t proc none /proc
echo "Mounting sysfs filesystem"
mount -t sysfs none /sys
echo "Creating /dev"
mount -t tmpfs -o mode=0755 none /dev
echo "Creating/Mounting /dev/pts"
mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 none /dev/pts

mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/fb c 29 0
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty10 c 4 10
mknod /dev/tty11 c 4 11
mknod /dev/tty12 c 4 12
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/ttyS3 c 4 67

mknod /dev/urandom c 1 9
mknod /dev/mmcblk0 b 179 0
mknod /dev/mmcblk0p1 b 179 1
mknod /dev/mmcblk0p2 b 179 2
mknod /dev/mmcblk0p3 b 179 3
mknod /dev/mmcblk0p4 b 179 4
mknod /dev/mmcblk0p5 b 179 5
mknod /dev/mmcblk0p6 b 179 6
mknod /dev/mmcblk0p7 b 179 7
mknod /dev/mmcblk0p8 b 179 8
mknod /dev/mmcblk0p9 b 179 9
mknod /dev/mmcblk0p10 b 179 10
mknod /dev/mmcblk0p11 b 179 11
mknod /dev/mmcblk0p12 b 179 12
mknod /dev/mmcblk0p13 b 179 13
mknod /dev/mmcblk0p14 b 179 14
mknod /dev/mmcblk0p15 b 179 15

lvm.static vgscan --ignorelockingfailure
lvm.static lvchange -ay --ignorelockingfailure /dev/mapper/store-root

mount -o ro /dev/mapper/store-root /realroot

/sbin/pivot_root /realroot /realroot/boot

umount /boot/dev/pts
umount /boot/dev
umount /boot/proc
umount /boot/sys

export EARLY_BOOT_STOP=`date -U`

exec /sbin/init

/sbin/init
/sbin/upstart -s /usr/sbin/setcpushares-upstart
(setcpusharesupstart sets up cgroup for every new task,
based with /etc/default/cpushareholder)
upstart config from dir <- /etc/event.d
upstart emits "startup" ->
/etc/event.d/rcS is started
telinit 2 -> emit "runlevel 2"
emit "stopping/stopped rcS"
"runlevel 2" -> /etc/event.d/banner
/etc/init.d/banner start
echo "Please wait: booting..." > $vtmaster
emit "stopping/stopped banner"
"stopped banner" -> /etc/event.d/sysfs
/etc/init.d/sysfs.sh start
mount -t proc proc /proc
mount sysfs /sys -t sysfs
echo 1 > /proc/sys/vm/oom_dump_tasks
emit "stopping/stopped sysfs"
"stopped sysfs" -> /etc/event.d/udev
/etc/init.d/udev start
mountpoint -q /dev/
echo "Starting the hotplug events dispatcher" "udevd"
## not loading as no /etc/event.d/udevd
# udevd --daemon
mkdir -p /dev/.udev/ /dev/.udev/db/ /dev/.udev/queue/ /dev/.udevdb/
make_extra_nodes (based on /etc/udev/links.conf)
echo "Synthesizing the initial hotplug events"
udevtrigger --subsystem-nomatch=platform --subsystem-nomatch=backlight
echo "Waiting for /dev to be fully populated"
udevsettle --timeout=$udevd_timeout
chmod 1777 /dev/shm
emit "stopping/stopped udev"
"stopped udev" -> /etc/event.d/alignment
echo "3" > /proc/cpu/alignment
emit "stopping/stopped alignment"
"stopped alignment" -> /etc/event.d/modutils
/etc/init.d/modutils.sh start
echo "Calculating module dependencies ..."
depmod -Ae
echo -n "Loading modules: "
foreach $module $args in /etc/modules
modprobe $module $args
emit "stopping/stopped modutils"
"stopped modutils" -> /etc/event.d/cgroups
. /etc/default/cpushareholder
cpushareholder_init
mkdir -p /dev/cpuacct
mount -t cgroup -o cpu,cpuacct none /dev/cpuacct
mkdir -p /dev/cpuacct/UX/APP
mkdir -p /dev/cpuacct/REST/BG
...
echo 7500 > /dev/cpuacct/UX/cpu.shares
echo 2500 > /dev/cpuacct/REST/cpu.shares
for $taskid in /dev/cpuacct/tasks
echo $taskid > /dev/cpuacct/REST/DAEMONS
emit "stopping/stopped cgroups"
"stopped cgroups" -> /etc/event.d/mountall
/etc/init.d/mountall.sh start
. /etc/default/rcS
. /etc/default/mount_checks
MOUNT_STAMP=/var/umount.stamp
WIPE_FLAGS_FILE=/var/.flags/on_mount
echo "$0: Mounting local filesystems..."
lvm.static vgscan --ignorelockingfailure
lvm.static vgchange -ay --ignorelockingfailure
echo "$0: vgscan/vgchange done" > /dev/kmsg
fsck -y -v /dev/mapper/store-root/var 2>&1 #/var with /dev/store
#fsck -y -v /dev/mmcblk0p3 2>&1 #/var without /dev/store
echo "$0: fsck of /var done" > /dev/kmsg
mount -a -t nonfs,vfat,ext3,tmpfs
# means NOnfs,NOvfat,NOext3,NOtmpfs: man mount
mount /var
if "mount /var" errors, do fixup:
/usr/sbin/fixup_partition.sh --mountpoint /var
umount -f /dev/mapper/store-var # up to 5 times in a loop
fsck -y /dev/mapper/store-var
mount /dev/mapper/store-var
echo "$0: /var mounted" > /dev/kmsg
clock_from_var.sh
hwclock -s -u #only do the following updates if hardware time is wrong
if (hw_time is wrong)
#date -S -s `date -d $(cat /etc/version) "+%s"`
date -S -s `cat /var/preferences/com.palm.power/time_saver`
echo "$0: set clock from $TIME_SRC: $(date)" > /dev/kmsg
hwclock -w -u
else
echo "$0: using /dev/rtc time: $(date)" > /dev/kmsg
lunaprop -n com.palm.system -m -s last_umount_clean [0|1 :/var/umount.stamp exists]

check that all /var/* are directories
if not_dir($path) rm -f $path;mkdir -p $path
if no_clean_mount() fixup_partition.sh --mountpoint /var/log --force-fsck
if exists /var/.rootfs_fsck fixup_partition.sh --device=/dev/mapper/store-media --force-fsck
rm -f /media/internal/FSCK*.REC # FAT lost blocks
rm -f /var/tmp; mkdir -p /var/tmp #reset /var/tmp as a directory and not a symlink
mount -a -t vfat,ext3,tmpfs #mount the automounted fs
echo "$0: rest mounted" > /dev/kmsg
check if everything mounted nicely. if not: fixup_partition.sh them
echo "$0: filesystem checking done" > /dev/kmsg
setup_cryptofs # based on /etc/cryptofs.conf, http://reboot78.re.funpic.de/cryptofs/
mkdir /media/internal/.palm
mountcfs -s /media/internal/.palm/.cryptofs -m /media/cryptofs -k /media/internal/.palm
cryptofs -o nonempty -o allow_other -s -r [params].. # based on .cryptofs
echo "$0: setup_cryptofs done" > /dev/kmsg
lunaprop -n com.palm.system -m -s media_fixed_how 1 # result from fixup_partitions on media partition
report reboot reasons: lines that start with "reason" in /var/umount.stamp
echo $REASON | rdx_reporter -F -C "rebooter" -c "rebooter" -d "$0"
rm -rf /var/lock/*
if any errors on "fsck /var"
echo "encountered error running fsck on /var: $VARFSCKRES $VARFSCK" \ ## res=error code, varfsck=output
| rdx_reporter -F -C "Fsck Error" -c "Fsck Error" -d "$Fsck error"
if error=4 (MAJOR ERROR) -> echo $error >/var/log/.fsck_error
date > /var/log/var_fsck.log
echo $VARFSCK >> /var/log/var_fsck.log ## last fsck output
... skipped developer-only rw rootfs stuff, reboting for rw-check and rm'ing /boot/uImage if error
touch /var/log/var_fsck.log /var/log/root_fsck.log
cat /var/log/var_fsck.log /var/log/root_fsck.log > /var/log/fsck.log
echo "$0: done reporting fsck results" > /dev/kmsg
run-parts /etc/init.d/postmountall.d:
check_initctl
if not_pipe(/dev/initctl) -> rm -f /dev/initctl; mknod -m 600 /dev/initctl p
keep_klog
cd /var/log
mv klog_1.txt.gz klog_2.txt.gz
klog last |gzip -c > klog_1.txt.gz # klog buffer from previous boot
dmesg -s 100000 | gzip -c > dmesg.txt.gz
kernel_lastboot
rdx_reporter $args ## nothing to report in clean case
lnsasetup
. /etc/default/lnsa.sh
mkdir -p /var/palm/system-services
mkdir -p /var/palm/ls2/roles
mkdir -p /var/palm/event.d
echo 'exec /bin/true' >/tmp/lnsa_marker
cp /tmp/lnsa_marker /var/palm/event.d/;msa_marker # actually, cp to tmp, sync, mv tmp real
rm /tmp/lnsa_marker
initctl newdir /var/palm/event.d ## add dir other than /etc/init.d to list, could trigger
logmods
mkdir -p /dev/logdir
mmc_protect
no "mmc_protect" binary => does nothing
report_lostandfound
for each path=("lost+found" dir) found on any mounted partition,
ls -lA $path | rdx_reporter ...
touch $path/_landf_rdxd_reported_marker_ ## so it doesn't report again
rm_varlogtmp
rm -rf /var/log/temp
runlevel
touch /var/run/utmp
runlevel --set 2 ## might trigger something, but probably doesn't
scaling
echo ondemandtcl >/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

kill -USR1 1 ## for bootloggerd ?
echo "$0 done" > /dev/kmsg
mkdir -p /var/preferences
chown root /var/preferences
chmod 777 /var/preferences
mkdir -p /var/home/root
mkdir -p /var/tmp
emit "stopping/stopped mountall"
"stopped mountall" -> swaphack, tokens, timezone, watchdogd
-> /etc/event.d/swaphack
/etc/init.d/swaphack.sh
if /var/swap -> rm /var/swap # using /dev/store/swap now !
if !/dev/store/swap
dd if=/dev/zero of=/dev/store/swap bs=100663296 count=1 # 96MB of swap
mkswap /dev/store/swap
echo cfq > /sys/block/mmcblk0/queue/scheduler
echo 6000 > /proc/sys/vm/dirty_expire_centisecs
swapon /dev/store/swap
emit "stopping/stopped swaphack" -> compcache
/etc/event.d/compcache
swapoff -a
sleep 1
modprobe xvmalloc
modprobe ramzswap memlimit_kb=25600 backing_swap=/dev/store/swap
sleep 3
swapon /dev/ramzswap0 -p 100
emit "stopping/stopped compcache" -> no listeners

-> /etc/event.d/timezone
no /usr/bin/tzset -> do nothing
emit "stopping/stopped timezone" -> no listeners

-> /etc/event.d/watchdogd
/sbin/watchdogd	#respawn
talks to /dev/watchdog, pings every X seconds
emit "stopping/stopped watchdogd" -> no listeners

-> /etc/event.d/tokens
/sbin/tokens --mount #trenchcoat=storage flasher + tokens=fs-tokens supports omap24xx,omap34xx,msm,tegra
source: http://subversion.palm.com/main/nova/palm/trenchcoat/submissions/132.4/trenchcoat.c
reads /dev/tokens -> OEM Data:
ProductName,Modem,RAMSize,FlashSize,HwoRev,BToADDR,WIFIoADDR,ProdSN,ProductSKU
emit "stopping/stopped tokens" -> /etc/event.d/populate-volatile
/etc/init.d/populate-volatile.sh start
/sbin/popvol < /etc/default/popvol.d/* # actually, for file in `ls`...
/etc/default/popvol.d/00_core
mkdir|/var/backups|0|0|0755
mkdir|/var/cache|0|0|0755
mkdir|/var/lib|0|0|0755
mkdir|/var/lib/ipkg|0|0|0755
mkdir|/var/lib/misc|0|0|0755
mkdir|/var/lib/software|0|0|0755
mkdir|/var/lib/software/ModemFiles|0|0|0755
mkdir|/var/lib/software/SessionFiles|0|0|0755
mkdir|/var/lib/software/tmp|0|0|0755
mkdir|/var/lib/update|0|0|0755
mkdir|/var/local|0|0|02755
mkdir|/var/lock|0|0|01777
mkdir|/var/lock/subsys|0|0|0755
mkdir|/var/log|0|0|0755
mkdir|/var/run|0|0|0755
mkdir|/var/spool|0|0|0755
mkdir|/tmp|0|0|01777
touch|/var/run/utmp|0|0|0644
touch|/var/log/wtmp|0|0|0644
mknod|/dev/heap|0|0|1|5|020644
/etc/default/popvol.d/01_pulse
mkdir|/var/run/pulse|31|31|0755
/etc/default/popvol.d/02_jail
mkdir|/var/palm|0|0|0755
mkdir|/var/palm/jail|0|0|0755
mkdir|/var/palm/data|0|0|0755
emit "stopping/stopped populate-volatile" -> devpts, minicore2
-> /etc/event.d/minicore2 # everything disabled, so doing nothing much
echo "" > /proc/sys/kernel/minicore_pattern
echo "" > /proc/sys/kernel/core_pattern
emit "stopping/stopped minicore2" -> no listeners

-> /etc/init.d/devpts.sh start
mknod -m 666 /dev/ptmx c 5 2
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts -ogid=5,mode=620 ## 5="tty", 600='mesg n' default
emit "stopping/stopped devpts" -> hostname
-> /etc/init.d/hostname.sh start
hostname -F /etc/hostname # "webos-device"
emit "stopping/stopped hostname" -> pmsyslogd, pmklogd, urandom, usbctrl
-> /etc/event.d/pmsyslogd #PmLogDaemon, logs to /var/log/messages
/usr/bin/pmsyslogd -z -f 6 -m # UTZ/C tstamp, usec resolution, monotonic
emit "stopping/stopped pmsyslogd" -> no listeners
-> /etc/event.d/pmklogd # logs to /var/log/pmklogd.log
/usr/bin/pmklogd -n -d 1 #startup delay=1sec, "-n"=run in foreground??
emit "stopping/stopped pmklogd" -> no listeners
-> /etc/event.d/urandom
/etc/init.d/urandom start
echo "Initializing random number generator..."
cat /var/lib/urandom/random-seed >/dev/urandom
emit "stopping/stopped urandom" -> no listeners
-> /etc/event.d/usbctrl
if usbnet enabled
/sbin/modprobe -q g_composite product=0x101 #0x103 for armv6l
else if novacom enabled
/sbin/modprobe -q g_composite product=0x8002 #0x8012 for armv6l
else #(normal)
/sbin/modprobe -q g_composite product=0x8004 #0x8012 for armv6l
emit "stopping/stopped usbctrl" -> networking
-> /etc/event.d/networking
/etc/init.d/networking start
ifup -a -f # /etc/network/interfaces - auto=lo,usb0:1
echo "done."
emit "stopping/stopped networking" -> bootmisc

=========== AT THIS STAGE, ONLY BOOTMISC THREAD EXECUTION CONTINUES ============
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

-> /etc/init.d/bootmisc.sh start
if "OMAP3430" matches /proc/cpuinfo
echo 600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
## needs to be set twice, board bug
chmod 666 /dev/tty[p-za-e][0-9a-f]
chown root:tty /dev/tty[p-za-e][0-9a-f]
if /etc/ld.so.cache symlinks to /var/cache/ld.so.cache
/sbin/ldconfig -C /var/cache/ld.so.cache
else
rm -f /var/cache/ld.so.cache
emit "stopping/stopped bootmisc" -> novacomd, ls-hubd_private, ttyS2

-> /etc/event.d/ttyS2
/sbin/getty console 115200 vt100

-> /etc/event.d/novacomd
#no /var/gadget/novacom_enabled => do nothing
#otherwise: mkdir /dev/gadget; mount -tgadgetfs /dev/gadget; /sbin/novacomd
emit "stopping/stopped novacomd"

-> /etc/event.d/ls-hubd_private #ls=LunaService
/usr/bin/ls-hubd --conf /etc/ls2/ls-private.conf --pmloglib
# /home/reviewdaemon/projects/nova/oe/BUILD-mantaray/work/luna-service2-2.0.0-131.2/131.2/src/hub/conf.c
#/usr/bin/ls-monitor /usr/bin/LunaSysMgr js, using /tmp/com.palm.private_hub
# UGLY HACK!!!!: /sbin/initctl emit --no-wait %s-ready
/sbin/initctl emit --no-wait ls-hubd_private-ready
..emit "ls-hubd_private-ready" -> /etc/event.d/ls-hubd_public

"ls-hubd_private-ready" ->
-> /etc/event.d/ls-hubd_public
/usr/bin/ls-hubd --public --conf /etc/ls2/ls-public.conf --pmloglib
/sbin/initctl emit --no-wait ls-hubd_private-ready
..emit "ls-hubd_public-ready" -> finish, node_fork_server

..at some point.. emit "stopping/stopped ls-hubd_public" -> ls-hubd_public_watchdog
-> /etc/event.d/ls-hubd_public_watchdog
/usr/sbin/reboot_ls-hubd_if.sh ${EXIT_STATUS} ls-hubd_public

..at some point.. emit "stopping/stopped ls-hubd_private" -> ls-hubd_private_watchdog
-> /etc/event.d/ls-hubd_private_watchdog
/usr/sbin/reboot_ls-hubd_if.sh ${EXIT_STATUS} ls-hubd_private

=========== AT THIS STAGE, PRV/PUB LS ARE RUNNING AND ONLY ONE UPSTART SIGNAL thread REMAINS ============