Check-in [752b75eff6]
Overview
Comment:Added start of "init" script
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 752b75eff6c0c295e26f1788cba1fd0aa44f2b5a
User & Date: rkeene on 2012-08-04 08:09:12
Other Links: manifest | tags
Context
2012-08-04
19:23
Added images for logo check-in: 242ee5e43e user: rkeene tags: trunk
08:09
Added start of "init" script check-in: 752b75eff6 user: rkeene tags: trunk
07:16
More work towards describing what needs to be done check-in: c5886554f0 user: rkeene tags: trunk
Changes

Added components/init-earlyboot/init version [ecdb2e7262].























































































































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
117
118
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /tclkit

proc load_modules {path} {
	catch {
		set fd [open [file join $path load]]
		set modules [split [read $fd] "\n"]
		close $fd
	}

	foreach module $modules {
		if {![file exists $module]} {
			puts stderr "\[module\] File not found: $module"
			continue
		}

		if {[catch {
			system::syscall::insmod $module
		} err]} {
			puts stderr "\[module\] Failed to load $module: $err"
		}
	}
}

proc locate_config_partition {} {
	foreach dev [glob -nocomplain /dev/*] {
		unset -nocomplain devinfo
		catch {
			file stat $dev devinfo
		}

		if {![info exists devinfo(type)]} {
			continue
		}

		if {$devinfo(type) != "blockSpecial"} {
			continue
		}

		unset -nocomplain fd
		catch {
			set fd [open $dev]
			fconfigure $fd -translation binary
		}

		if {![info exists fd]} {
			continue
		}

		set magic [read $fd 32]
		binary scan $magic H* magic

		if {$magic != "1daa459b9772ef5d7d58c814458246c69dbd1d53fa75f396462910250bf7a4b6"} {
			continue
		}

		return $dev
	}

	return ""
}

proc boot {} {
	package require system

	# 1. Load kernel modules
	load_modules /modules

	# 2. Mount devfs
	file mkdir /dev
	system::syscall::mount devfs /dev devfs [list]

	# 3. Locate Config partition
	set dev [locate_config_partition]

	if {$dev == ""} {
		## XXX: Install to tmpfs
		## XXX: Offer to do installation
	} else {
		# 4. Mount config partition
		mount_config_partition $dev /config

		# 5. Load kernel modules
		load_modules /config/modules

		# 5. Mount /system (from fstab) 
		## XXX: TODO
	}

	# 6. Mount /system/config and populate
	system::syscall::mount tmpfs /system/config tmpfs [list]

	# 7. Unmount devfs
	system::syscall::umount /dev
	file rmdir /dev

	# 8. Pass control to later boot init
	system::syscall::execve init /system/apps/appbox-core/default/sbin/init
}

if {[catch {
	boot
} err]} {
	puts stderr "\[boot\] Boot failed: $err"
}

while 1 {
	puts -nonewline "> "
	flush stdout

	gets stdin line
	set ret [catch {
		eval $line
	}]

	if {$ret != ""} {
		puts $ret
	}
}

Added components/init-lateboot/functions version [10517d63e1].








1
2
3
4
5
6
7
+
+
+
+
+
+
+
Mount /system/proc
Mount /system/dev
Mount /system/sys
Mount /data
Symlink /apps
Perform boot-up:
	1. Start daemons