1 \ DebXO installer script
3 : disk-size ( devspec$ -- #MB )
4 open-dev ?dup 0<> if ( ih )
5 dup " #blocks" rot $call-method ( ih #blocks )
7 \ we're assuming a block size of 512 bytes
8 d# 512 um* ( ih #bytes )
9 d# 1,000,000 um/mod ( ih rem #MB )
10 rot close-dev swap drop ( #MB )
15 \ dup " block-size" rot $call-method ( ih size x )
16 \ rot close-dev drop ( size.lo )
24 : target-big-enough? ( devspec$ -- flag )
26 \ we only support devices >= 1GB
28 " Installation target too small, must be at least 1GB. Aborting..."
36 d# 128 buffer: verifystr
38 : user-verified? ( tgt$ -- flag )
39 \ ensure the user *actually* wanted to reformat the device..
40 " WARNING: this will overwrite all data on " ( tgt$ str$ )
42 " . Are you sure that you want to do this?" ( str2$ )
44 verifystr count ( finalstr$ )
47 " Installation cancelled."
52 : verify-target ( tgt$ devspec$ -- )
53 \ XXX: For some reason refresh isn't called after a dialog-alert
54 \ (or menu item callback). This means the menu display is incorrect
55 \ until go-vertical is called. Calling refresh manually here doesn't
56 \ work... so for now, kill the menu and restart it later.
57 menu-done ( tgt$ devspec$ )
59 target-big-enough? -rot ( flag tgt$ )
63 \ installation cancelled/failed, redisplay menu
70 " the internal NAND storage" " /nandflash" verify-target if
71 " installing!" dialog-alert
77 " the internal MMC device" " int:0" verify-target if
78 " installing!" dialog-alert
84 " this SD card" " ext:0" verify-target if
85 " installing!" dialog-alert
114 : has-target? ( devspec$ -- flag )
118 nr-targets 1+ to nr-targets
125 \ : disk-size ( devspec$ -- #MB )
126 \ open-dev ?dup 0<> if ( ih )
127 \ dup " size" rot $call-method ( ih size.lo size.hi )
128 \ rot close-dev drop ( size.lo )
130 \ \ fuck your signed 32bit division.. d# 100000 / ( #MB ).
136 : debxo-find-targets ( -- help0$ 'func0 'icon0 ... helpk$ 'funck 'iconk )
139 \ check for the existence of nandflash (XO-1)
140 " /nandflash" has-target? if
142 ['] choose-nand-item spi.icon
144 \ check for internal EMMC (XO-1.5, XO-1.75)
145 " int:0" has-target? if
147 " int:0" disk-size decimal ( #MB )
148 <# " MB)" hold$ u#s " Internal MMC (" hold$ u#>
151 ['] choose-emmc-item spi.icon
155 " ext:0" has-target? if
157 " ext:0" disk-size decimal ( #MB )
158 <# " MB)" hold$ u#s " SD Card (" hold$ u#>
161 ['] choose-sd-item sdcard.icon
164 \ check for up to 4 USB drives
166 i <# " /disk" hold$ u# " /usb/scsi@" hold$ u#> string2 pack
170 64 alloc-mem >r ( i )
171 <# u# " USB Disk #" hold$ u#> r@ place
172 string2 count disk-size decimal ( #MB )
173 <# " MB)" hold$ u#s " (" hold$ u#> r@ $cat
176 i <# u# " ['] choose-usb-item-" hold$ u#> evaluate usb.icon
180 \ TODO: multiple usb disks?
181 \ differentiate between installer disk & extra disk..
185 : debxo-installer-menu ( -- )
186 \ populate stack w/ icon/target list
189 \ last entry on the list
190 " Abort installation"
191 ['] quit-item quit.icon
195 nr-targets 1+ to cols
205 ['] debxo-installer-menu to root-menu