PageRenderTime 27ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/sys/boot/forth/beastie.4th

https://github.com/oza/FreeBSD-7.3-dyntick
Forth | 295 lines | 276 code | 17 blank | 2 comment | 6 complexity | 7d9bbe99ae36f6bfea9e05262ceea3a1 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. \ Copyright (c) 2003 Scott Long <scottl@freebsd.org>
  2. \ Copyright (c) 2003 Aleksander Fafula <alex@fafula.com>
  3. \ All rights reserved.
  4. \
  5. \ Redistribution and use in source and binary forms, with or without
  6. \ modification, are permitted provided that the following conditions
  7. \ are met:
  8. \ 1. Redistributions of source code must retain the above copyright
  9. \ notice, this list of conditions and the following disclaimer.
  10. \ 2. Redistributions in binary form must reproduce the above copyright
  11. \ notice, this list of conditions and the following disclaimer in the
  12. \ documentation and/or other materials provided with the distribution.
  13. \
  14. \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15. \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. \ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18. \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20. \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21. \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22. \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23. \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. \ SUCH DAMAGE.
  25. \
  26. \ $FreeBSD: src/sys/boot/forth/beastie.4th,v 1.12.12.1 2010/02/10 00:26:20 kensmith Exp $
  27. marker task-beastie.4th
  28. include /boot/screen.4th
  29. include /boot/frames.4th
  30. hide
  31. variable menuidx
  32. variable menubllt
  33. variable menuX
  34. variable menuY
  35. variable promptwidth
  36. variable bootkey
  37. variable bootacpikey
  38. variable bootsafekey
  39. variable bootverbosekey
  40. variable bootsinglekey
  41. variable escapekey
  42. variable rebootkey
  43. 46 constant dot
  44. \ The BSD Daemon. He is 19 rows high and 34 columns wide
  45. : beastie-logo ( x y -- )
  46. 2dup at-xy ." , ," 1+
  47. 2dup at-xy ." /( )`" 1+
  48. 2dup at-xy ." \ \___ / |" 1+
  49. 2dup at-xy ." /- _ `-/ '" 1+
  50. 2dup at-xy ." (/\/ \ \ /\" 1+
  51. 2dup at-xy ." / / | ` \" 1+
  52. 2dup at-xy ." O O ) / |" 1+
  53. 2dup at-xy ." `-^--'`< '" 1+
  54. 2dup at-xy ." (_.) _ ) /" 1+
  55. 2dup at-xy ." `.___/` / " 1+
  56. 2dup at-xy ." `-----' /" 1+
  57. 2dup at-xy ." <----. __ / __ \" 1+
  58. 2dup at-xy ." <----|====O)))==) \) /====|" 1+
  59. 2dup at-xy ." <----' `--' `.__,' \" 1+
  60. 2dup at-xy ." | |" 1+
  61. 2dup at-xy ." \ / /\" 1+
  62. 2dup at-xy ." ______( (_ / \______/" 1+
  63. 2dup at-xy ." ,' ,-----' |" 1+
  64. at-xy ." `--{__________) "
  65. ;
  66. : beastiebw-logo ( x y -- )
  67. 2dup at-xy ." , ," 1+
  68. 2dup at-xy ." /( )`" 1+
  69. 2dup at-xy ." \ \___ / |" 1+
  70. 2dup at-xy ." /- _ `-/ '" 1+
  71. 2dup at-xy ." (/\/ \ \ /\" 1+
  72. 2dup at-xy ." / / | ` \" 1+
  73. 2dup at-xy ." O O ) / |" 1+
  74. 2dup at-xy ." `-^--'`< '" 1+
  75. 2dup at-xy ." (_.) _ ) /" 1+
  76. 2dup at-xy ." `.___/` /" 1+
  77. 2dup at-xy ." `-----' /" 1+
  78. 2dup at-xy ." <----. __ / __ \" 1+
  79. 2dup at-xy ." <----|====O)))==) \) /====" 1+
  80. 2dup at-xy ." <----' `--' `.__,' \" 1+
  81. 2dup at-xy ." | |" 1+
  82. 2dup at-xy ." \ / /\" 1+
  83. 2dup at-xy ." ______( (_ / \______/" 1+
  84. 2dup at-xy ." ,' ,-----' |" 1+
  85. at-xy ." `--{__________)"
  86. ;
  87. : fbsdbw-logo ( x y -- )
  88. 2dup at-xy ." ______" 1+
  89. 2dup at-xy ." | ____| __ ___ ___ " 1+
  90. 2dup at-xy ." | |__ | '__/ _ \/ _ \" 1+
  91. 2dup at-xy ." | __|| | | __/ __/" 1+
  92. 2dup at-xy ." | | | | | | |" 1+
  93. 2dup at-xy ." |_| |_| \___|\___|" 1+
  94. 2dup at-xy ." ____ _____ _____" 1+
  95. 2dup at-xy ." | _ \ / ____| __ \" 1+
  96. 2dup at-xy ." | |_) | (___ | | | |" 1+
  97. 2dup at-xy ." | _ < \___ \| | | |" 1+
  98. 2dup at-xy ." | |_) |____) | |__| |" 1+
  99. 2dup at-xy ." | | | |" 1+
  100. at-xy ." |____/|_____/|_____/"
  101. ;
  102. : print-logo ( x y -- )
  103. s" loader_logo" getenv
  104. dup -1 = if
  105. drop
  106. fbsdbw-logo
  107. exit
  108. then
  109. 2dup s" fbsdbw" compare-insensitive 0= if
  110. 2drop
  111. fbsdbw-logo
  112. exit
  113. then
  114. 2dup s" beastiebw" compare-insensitive 0= if
  115. 2drop
  116. beastiebw-logo
  117. exit
  118. then
  119. 2dup s" beastie" compare-insensitive 0= if
  120. 2drop
  121. beastie-logo
  122. exit
  123. then
  124. 2dup s" none" compare-insensitive 0= if
  125. 2drop
  126. \ no logo
  127. exit
  128. then
  129. 2drop
  130. fbsdbw-logo
  131. ;
  132. : acpienabled? ( -- flag )
  133. s" acpi_load" getenv
  134. dup -1 = if
  135. drop false exit
  136. then
  137. s" YES" compare-insensitive 0<> if
  138. false exit
  139. then
  140. s" hint.acpi.0.disabled" getenv
  141. dup -1 <> if
  142. s" 0" compare 0<> if
  143. false exit
  144. then
  145. else
  146. drop
  147. then
  148. true
  149. ;
  150. : printmenuitem ( -- n )
  151. menuidx @
  152. 1+ dup
  153. menuidx !
  154. menuY @ + dup menuX @ swap at-xy
  155. menuidx @ .
  156. menuX @ 1+ swap at-xy
  157. menubllt @ emit
  158. menuidx @ 48 +
  159. ;
  160. : beastie-menu ( -- )
  161. 0 menuidx !
  162. dot menubllt !
  163. 8 menuY !
  164. 5 menuX !
  165. clear
  166. 46 4 print-logo
  167. 42 20 2 2 box
  168. 13 6 at-xy ." Welcome to FreeBSD!"
  169. printmenuitem ." Boot FreeBSD [default]" bootkey !
  170. s" arch-i386" environment? if
  171. drop
  172. printmenuitem ." Boot FreeBSD with ACPI " bootacpikey !
  173. acpienabled? if
  174. ." disabled"
  175. else
  176. ." enabled"
  177. then
  178. else
  179. -2 bootacpikey !
  180. then
  181. printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey !
  182. printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey !
  183. printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey !
  184. printmenuitem ." Escape to loader prompt" escapekey !
  185. printmenuitem ." Reboot" rebootkey !
  186. menuX @ 20 at-xy
  187. ." Select option, [Enter] for default"
  188. menuX @ 21 at-xy
  189. s" or [Space] to pause timer " dup 2 - promptwidth !
  190. type
  191. ;
  192. : tkey
  193. seconds +
  194. begin 1 while
  195. over 0<> if
  196. dup seconds u< if
  197. drop
  198. -1
  199. exit
  200. then
  201. menuX @ promptwidth @ + 21 at-xy dup seconds - .
  202. then
  203. key? if
  204. drop
  205. key
  206. exit
  207. then
  208. 50 ms
  209. repeat
  210. ;
  211. set-current
  212. : beastie-start
  213. s" beastie_disable" getenv
  214. dup -1 <> if
  215. s" YES" compare-insensitive 0= if
  216. exit
  217. then
  218. else
  219. drop
  220. then
  221. beastie-menu
  222. s" autoboot_delay" getenv
  223. dup -1 = if
  224. drop
  225. 10
  226. else
  227. 0 0 2swap >number drop drop drop
  228. then
  229. begin
  230. dup tkey
  231. 0 25 at-xy
  232. dup 32 = if nip 0 swap then
  233. dup -1 = if 0 boot then
  234. dup 13 = if 0 boot then
  235. dup bootkey @ = if 0 boot then
  236. dup bootacpikey @ = if
  237. acpienabled? if
  238. s" acpi_load" unsetenv
  239. s" 1" s" hint.acpi.0.disabled" setenv
  240. s" 1" s" loader.acpi_disabled_by_user" setenv
  241. else
  242. s" YES" s" acpi_load" setenv
  243. s" 0" s" hint.acpi.0.disabled" setenv
  244. then
  245. 0 boot
  246. then
  247. dup bootsafekey @ = if
  248. s" arch-i386" environment? if
  249. drop
  250. s" acpi_load" unsetenv
  251. s" 1" s" hint.acpi.0.disabled" setenv
  252. s" 1" s" loader.acpi_disabled_by_user" setenv
  253. s" 1" s" hint.apic.0.disabled" setenv
  254. then
  255. s" 0" s" hw.ata.ata_dma" setenv
  256. s" 0" s" hw.ata.atapi_dma" setenv
  257. s" 0" s" hw.ata.wc" setenv
  258. s" 0" s" hw.eisa_slots" setenv
  259. s" 1" s" hint.kbdmux.0.disabled" setenv
  260. 0 boot
  261. then
  262. dup bootverbosekey @ = if
  263. s" YES" s" boot_verbose" setenv
  264. 0 boot
  265. then
  266. dup bootsinglekey @ = if
  267. s" YES" s" boot_single" setenv
  268. 0 boot
  269. then
  270. dup escapekey @ = if
  271. 2drop
  272. s" NO" s" autoboot_delay" setenv
  273. exit
  274. then
  275. rebootkey @ = if 0 reboot then
  276. again
  277. ;
  278. previous