PageRenderTime 24ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/builder_scripts/builder_profiles/pfPBX/copy_overlay/boot/beastie.4th

https://github.com/vongrippen/pfsense-tools
Forth | 296 lines | 277 code | 17 blank | 2 comment | 6 complexity | 4837bfdeac15bcdae8ffa8df11e26f54 MD5 | raw file
  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 2006/03/31 21:36:17 scottl 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 ." _____/ f \ " 1+
  94. 2dup at-xy ." / \ / " 1+
  95. 2dup at-xy ." / p \______/ DNS " 1+
  96. 2dup at-xy ." \ / \ by " 1+
  97. 2dup at-xy ." \_____/ \ pfSense " 1+
  98. 2dup at-xy ." \ / " 1+
  99. 2dup at-xy ." \______/ " 1+
  100. 2dup at-xy ." " 1+
  101. at-xy ." "
  102. ;
  103. : print-logo ( x y -- )
  104. s" loader_logo" getenv
  105. dup -1 = if
  106. drop
  107. fbsdbw-logo
  108. exit
  109. then
  110. 2dup s" fbsdbw" compare-insensitive 0= if
  111. 2drop
  112. fbsdbw-logo
  113. exit
  114. then
  115. 2dup s" beastiebw" compare-insensitive 0= if
  116. 2drop
  117. beastiebw-logo
  118. exit
  119. then
  120. 2dup s" beastie" compare-insensitive 0= if
  121. 2drop
  122. beastie-logo
  123. exit
  124. then
  125. 2dup s" none" compare-insensitive 0= if
  126. 2drop
  127. \ no logo
  128. exit
  129. then
  130. 2drop
  131. fbsdbw-logo
  132. ;
  133. : acpienabled? ( -- flag )
  134. s" acpi_load" getenv
  135. dup -1 = if
  136. drop false exit
  137. then
  138. s" YES" compare-insensitive 0<> if
  139. false exit
  140. then
  141. s" hint.acpi.0.disabled" getenv
  142. dup -1 <> if
  143. s" 0" compare 0<> if
  144. false exit
  145. then
  146. else
  147. drop
  148. then
  149. true
  150. ;
  151. : printmenuitem ( -- n )
  152. menuidx @
  153. 1+ dup
  154. menuidx !
  155. menuY @ + dup menuX @ swap at-xy
  156. menuidx @ .
  157. menuX @ 1+ swap at-xy
  158. menubllt @ emit
  159. menuidx @ 48 +
  160. ;
  161. : beastie-menu ( -- )
  162. 0 menuidx !
  163. dot menubllt !
  164. 8 menuY !
  165. 5 menuX !
  166. clear
  167. 46 4 print-logo
  168. 42 20 2 2 box
  169. 13 6 at-xy ." Welcome to pfPBX!"
  170. printmenuitem ." Boot pfPBX [default]" bootkey !
  171. s" arch-i386" environment? if
  172. drop
  173. printmenuitem ." Boot pfPBX with ACPI " bootacpikey !
  174. acpienabled? if
  175. ." disabled"
  176. else
  177. ." enabled"
  178. then
  179. else
  180. -2 bootacpikey !
  181. then
  182. printmenuitem ." Boot pfPBX in Safe Mode" bootsafekey !
  183. printmenuitem ." Boot pfPBX in single user mode" bootsinglekey !
  184. printmenuitem ." Boot pfPBX with verbose logging" bootverbosekey !
  185. printmenuitem ." Escape to loader prompt" escapekey !
  186. printmenuitem ." Reboot" rebootkey !
  187. menuX @ 20 at-xy
  188. ." Select option, [Enter] for default"
  189. menuX @ 21 at-xy
  190. s" or [Space] to pause timer " dup 2 - promptwidth !
  191. type
  192. ;
  193. : tkey
  194. seconds +
  195. begin 1 while
  196. over 0<> if
  197. dup seconds u< if
  198. drop
  199. -1
  200. exit
  201. then
  202. menuX @ promptwidth @ + 21 at-xy dup seconds - .
  203. then
  204. key? if
  205. drop
  206. key
  207. exit
  208. then
  209. 50 ms
  210. repeat
  211. ;
  212. set-current
  213. : beastie-start
  214. s" beastie_disable" getenv
  215. dup -1 <> if
  216. s" YES" compare-insensitive 0= if
  217. exit
  218. then
  219. else
  220. drop
  221. then
  222. beastie-menu
  223. s" autoboot_delay" getenv
  224. dup -1 = if
  225. drop
  226. 10
  227. else
  228. 0 0 2swap >number drop drop drop
  229. then
  230. begin
  231. dup tkey
  232. 0 25 at-xy
  233. dup 32 = if nip 0 swap then
  234. dup -1 = if 0 boot then
  235. dup 13 = if 0 boot then
  236. dup bootkey @ = if 0 boot then
  237. dup bootacpikey @ = if
  238. acpienabled? if
  239. s" acpi_load" unsetenv
  240. s" 1" s" hint.acpi.0.disabled" setenv
  241. s" 1" s" loader.acpi_disabled_by_user" setenv
  242. else
  243. s" YES" s" acpi_load" setenv
  244. s" 0" s" hint.acpi.0.disabled" setenv
  245. then
  246. 0 boot
  247. then
  248. dup bootsafekey @ = if
  249. s" arch-i386" environment? if
  250. drop
  251. s" acpi_load" unsetenv
  252. s" 1" s" hint.acpi.0.disabled" setenv
  253. s" 1" s" loader.acpi_disabled_by_user" setenv
  254. s" 1" s" hint.apic.0.disabled" setenv
  255. then
  256. s" 0" s" hw.ata.ata_dma" setenv
  257. s" 0" s" hw.ata.atapi_dma" setenv
  258. s" 0" s" hw.ata.wc" setenv
  259. s" 0" s" hw.eisa_slots" setenv
  260. s" 1" s" hint.kbdmux.0.disabled" setenv
  261. 0 boot
  262. then
  263. dup bootverbosekey @ = if
  264. s" YES" s" boot_verbose" setenv
  265. 0 boot
  266. then
  267. dup bootsinglekey @ = if
  268. s" YES" s" boot_single" setenv
  269. 0 boot
  270. then
  271. dup escapekey @ = if
  272. 2drop
  273. s" NO" s" autoboot_delay" setenv
  274. exit
  275. then
  276. rebootkey @ = if 0 reboot then
  277. again
  278. ;
  279. previous