PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/sys/boot/forth/beastie.4th

https://repo.or.cz/dfdiff.git
Forth | 257 lines | 241 code | 16 blank | 0 comment | 6 complexity | 6bc6de368dba7091d8df9545eec9a1d1 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-3.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, GPL-2.0
  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.7 2003/10/28 17:18:42 scottl Exp $
  27. \ $DragonFly: src/sys/boot/forth/beastie.4th,v 1.8 2007/08/09 00:28:09 swildner Exp $
  28. marker task-beastie.4th
  29. include /boot/screen.4th
  30. include /boot/frames.4th
  31. hide
  32. variable menuidx
  33. variable menubllt
  34. variable menuX
  35. variable menuY
  36. variable promptwidth
  37. variable bootkey
  38. variable bootacpikey
  39. variable bootsafekey
  40. variable bootverbosekey
  41. variable bootsinglekey
  42. variable escapekey
  43. variable rebootkey
  44. 46 constant dot
  45. \ Fred, the official DragonFly BSD mascot.
  46. \ He is 19 rows high and 34 columns wide
  47. : technicolor-fred ( x y -- )
  48. 2dup at-xy ." " 1+
  49. 2dup at-xy ." " 1+
  50. 2dup at-xy ." ,--, | ,--," 1+
  51. 2dup at-xy ." | `-, ,^, ,-' |" 1+
  52. 2dup at-xy ." `, `-, (/ \) ,-' ,'" 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 ." | |" 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. 2dup at-xy ." `|'" 1+
  65. 2dup at-xy ." " 1+
  66. at-xy ."
  67. ;
  68. : boring-fred ( x y -- )
  69. 2dup at-xy ." " 1+
  70. 2dup at-xy ." " 1+
  71. 2dup at-xy ." ,--, | ,--," 1+
  72. 2dup at-xy ." | `-, ,^, ,-' |" 1+
  73. 2dup at-xy ." `, `-, (/ \) ,-' ,'" 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 ." | |" 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. 2dup at-xy ." `|'" 1+
  86. 2dup at-xy ." " 1+
  87. at-xy ."
  88. ;
  89. : print-fred ( x y -- )
  90. s" loader_color" getenv
  91. dup -1 = if
  92. drop
  93. boring-fred
  94. exit
  95. then
  96. s" YES" compare-insensitive 0<> if
  97. boring-fred
  98. exit
  99. then
  100. technicolor-fred
  101. ;
  102. : acpienabled? ( -- flag )
  103. s" acpi_load" getenv
  104. dup -1 = if
  105. drop false exit
  106. then
  107. s" YES" compare-insensitive 0<> if
  108. false exit
  109. then
  110. s" hint.acpi.0.disabled" getenv
  111. dup -1 <> if
  112. s" 0" compare 0<> if
  113. false exit
  114. then
  115. then
  116. true
  117. ;
  118. : printmenuitem ( -- n )
  119. menuidx @
  120. 1+ dup
  121. menuidx !
  122. menuY @ + dup menuX @ swap at-xy
  123. menuidx @ .
  124. menuX @ 1+ swap at-xy
  125. menubllt @ emit
  126. menuidx @ 48 +
  127. ;
  128. : fred-menu ( -- )
  129. 0 menuidx !
  130. dot menubllt !
  131. 8 menuY !
  132. 5 menuX !
  133. clear
  134. 46 4 print-fred
  135. 42 20 2 2 box
  136. 13 6 at-xy ." Welcome to DragonFly!"
  137. printmenuitem ." Boot DragonFly [default]" bootkey !
  138. s" arch-i386" environment? if
  139. printmenuitem ." Boot DragonFly with ACPI " bootacpikey !
  140. acpienabled? if
  141. ." disabled"
  142. else
  143. ." enabled"
  144. then
  145. else
  146. -2 bootacpikey !
  147. then
  148. printmenuitem ." Boot DragonFly in Safe Mode" bootsafekey !
  149. printmenuitem ." Boot DragonFly in single user mode" bootsinglekey !
  150. printmenuitem ." Boot DragonFly with verbose logging" bootverbosekey !
  151. printmenuitem ." Escape to loader prompt" escapekey !
  152. printmenuitem ." Reboot" rebootkey !
  153. menuX @ 20 at-xy
  154. ." Select option, [Enter] for default"
  155. menuX @ 21 at-xy
  156. s" or [Space] to pause timer " dup 2 - promptwidth !
  157. type
  158. ;
  159. : tkey
  160. dup
  161. seconds +
  162. begin 1 while
  163. over 0<> if
  164. dup seconds u< if
  165. drop
  166. -1
  167. exit
  168. then
  169. menuX @ promptwidth @ + 21 at-xy dup seconds - .
  170. then
  171. key? if
  172. drop
  173. key
  174. exit
  175. then
  176. 50 ms
  177. repeat
  178. ;
  179. set-current
  180. : beastie-start
  181. s" fred_disable" getenv
  182. dup -1 <> if
  183. s" YES" compare-insensitive 0= if
  184. exit
  185. then
  186. then
  187. fred-menu
  188. s" autoboot_delay" getenv
  189. dup -1 = if
  190. drop
  191. 10
  192. else
  193. 0 0 2swap >number drop drop drop
  194. then
  195. begin true while
  196. dup tkey
  197. 0 25 at-xy
  198. dup 32 = if nip 0 swap then
  199. dup -1 = if 0 boot then
  200. dup 13 = if 0 boot then
  201. dup bootkey @ = if 0 boot then
  202. dup bootacpikey @ = if
  203. acpienabled? if
  204. s" acpi_load" unsetenv
  205. s" 1" s" hint.acpi.0.disabled" setenv
  206. s" 1" s" loader.acpi_disabled_by_user" setenv
  207. else
  208. s" YES" s" acpi_load" setenv
  209. s" 0" s" hint.acpi.0.disabled" setenv
  210. then
  211. 0 boot
  212. then
  213. dup bootsafekey @ = if
  214. s" arch-i386" environment? if
  215. s" acpi_load" unsetenv
  216. s" 1" s" hint.acpi.0.disabled" setenv
  217. s" 1" s" loader.acpi_disabled_by_user" setenv
  218. then
  219. s" 0" s" hw.ata.ata_dma" setenv
  220. s" 0" s" hw.ata.atapi_dma" setenv
  221. s" 0" s" hw.ata.wc" setenv
  222. s" 0" s" hw.eisa_slots" setenv
  223. 0 boot
  224. then
  225. dup bootverbosekey @ = if
  226. s" YES" s" boot_verbose" setenv
  227. 0 boot
  228. then
  229. dup bootsinglekey @ = if
  230. s" YES" s" boot_single" setenv
  231. 0 boot
  232. then
  233. dup escapekey @ = if
  234. 2drop
  235. s" NO" s" autoboot_delay" setenv
  236. exit
  237. then
  238. rebootkey @ = if 0 reboot then
  239. repeat
  240. ;
  241. previous