PageRenderTime 51ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/freebsd5/sys/boot/forth/beastie.4th

https://github.com/kame/kame
Forth | 208 lines | 193 code | 14 blank | 1 comment | 7 complexity | 1da613d27fe7c495f4e375ccc15a8aba MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. \ Copyright (c) 2003 Scott Long <scottl@freebsd.org>
  2. \ All rights reserved.
  3. \
  4. \ Redistribution and use in source and binary forms, with or without
  5. \ modification, are permitted provided that the following conditions
  6. \ are met:
  7. \ 1. Redistributions of source code must retain the above copyright
  8. \ notice, this list of conditions and the following disclaimer.
  9. \ 2. Redistributions in binary form must reproduce the above copyright
  10. \ notice, this list of conditions and the following disclaimer in the
  11. \ documentation and/or other materials provided with the distribution.
  12. \
  13. \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  14. \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. \ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  17. \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19. \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20. \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. \ SUCH DAMAGE.
  24. \
  25. \ $FreeBSD: src/sys/boot/forth/beastie.4th,v 1.2 2003/05/31 11:19:11 scottl Exp $
  26. marker task-beastie.4th
  27. include /boot/screen.4th
  28. include /boot/frames.4th
  29. hide
  30. variable menuidx
  31. variable menubllt
  32. variable menuX
  33. variable menuY
  34. variable promptwidth
  35. variable bootkey
  36. variable bootacpikey
  37. variable bootsafekey
  38. variable bootverbosekey
  39. variable bootsinglekey
  40. variable escapekey
  41. variable rebootkey
  42. 46 constant dot
  43. \ The BSD Daemon. He is 19 rows high and 34 columns wide
  44. : print-beastie ( x y -- )
  45. 2dup at-xy ." , ," 1+
  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 ." O O ) / |" 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 ." <----|====O)))==) \\) /====" 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. at-xy ." `--{__________)"
  64. ;
  65. : acpienabled? ( -- flag )
  66. s" acpi_load" getenv
  67. dup -1 = if
  68. drop false exit
  69. then
  70. s" YES" compare-insensitive 0<> if
  71. false exit
  72. then
  73. s" hint.acpi.0.disabled" getenv
  74. dup -1 <> if
  75. s" 0" compare 0<> if
  76. false exit
  77. then
  78. then
  79. true
  80. ;
  81. : printmenuitem ( -- n )
  82. menuidx @
  83. 1+ dup
  84. menuidx !
  85. menuY @ + dup menuX @ swap at-xy
  86. menuidx @ .
  87. menuX @ 1+ swap at-xy
  88. menubllt @ emit
  89. menuidx @ 48 +
  90. ;
  91. : beastie-menu ( -- )
  92. 0 menuidx !
  93. dot menubllt !
  94. 8 menuY !
  95. 5 menuX !
  96. clear
  97. 46 4 print-beastie
  98. 42 20 2 2 box
  99. 13 6 at-xy ." Welcome to FreeBSD!"
  100. printmenuitem ." Boot FreeBSD [default]" bootkey !
  101. s" arch-i386" environment? if
  102. printmenuitem ." Boot FreeBSD with ACPI " bootacpikey !
  103. acpienabled? if
  104. ." disabled"
  105. else
  106. ." enabled"
  107. then
  108. else
  109. -2 bootacpikey !
  110. then
  111. printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey !
  112. printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey !
  113. printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey !
  114. printmenuitem ." Escape to loader prompt" escapekey !
  115. printmenuitem ." Reboot" rebootkey !
  116. menuX @ 20 at-xy
  117. ." Select option, [Enter] for default"
  118. menuX @ 21 at-xy
  119. s" or [Space] to pause timer " dup 2 - promptwidth !
  120. type
  121. ;
  122. : tkey
  123. dup
  124. seconds +
  125. begin 1 while
  126. over 0<> if
  127. dup seconds u< if
  128. drop
  129. -1
  130. exit
  131. then
  132. menuX @ promptwidth @ + 21 at-xy dup seconds - .
  133. then
  134. key? if
  135. drop
  136. key
  137. exit
  138. then
  139. 50 ms
  140. repeat
  141. ;
  142. set-current
  143. : beastie-start
  144. beastie-menu
  145. s" autoboot_delay" getenv
  146. dup -1 = if
  147. drop
  148. 10
  149. else
  150. 0 0 2swap >number drop drop drop
  151. then
  152. begin true while
  153. dup tkey
  154. 0 25 at-xy
  155. dup 32 = if nip 0 swap then
  156. dup -1 = if s" boot" evaluate then
  157. dup 13 = if s" boot" evaluate then
  158. dup bootkey @ = if s" boot" evaluate then
  159. dup bootacpikey @ = if
  160. acpienabled? if
  161. s" acpi_load" unsetenv
  162. s" 1" s" hint.acpi.0.disabled" setenv
  163. s" 1" s" loader.acpi_disabled_by_user" setenv
  164. else
  165. s" YES" s" acpi_load" setenv
  166. s" 0" s" hint.acpi.0.disabled" setenv
  167. then
  168. s" boot" evaluate
  169. then
  170. dup bootsafekey @ = if
  171. s" arch-i386" environment? if
  172. s" acpi_load" unsetenv
  173. s" 1" s" hint.acpi.0.disabled" setenv
  174. s" 1" s" loader.acpi_disabled_by_user" setenv
  175. then
  176. s" 0" s" hw.ata.ata_dma" setenv
  177. s" 0" s" hw.ata.atapi_dma" setenv
  178. s" 0" s" hw.ata.wc" setenv
  179. s" 0" s" hw.eisa_slots" setenv
  180. s" boot" evaluate
  181. then
  182. dup bootverbosekey @ = if
  183. s" YES" s" boot_verbose" setenv
  184. s" boot" evaluate
  185. then
  186. dup bootsinglekey @ = if
  187. s" YES" s" boot_single" setenv
  188. s" boot" evaluate
  189. then
  190. dup escapekey @ = if 2drop exit then
  191. rebootkey @ = if s" reboot" evaluate then
  192. repeat
  193. ;
  194. previous