~ubuntu-branches/ubuntu/wily/slof/wily

« back to all changes in this revision

Viewing changes to slof/fs/start-up.fs

  • Committer: Package Import Robot
  • Author(s): Aurelien Jarno
  • Date: 2012-09-16 23:05:23 UTC
  • Revision ID: package-import@ubuntu.com-20120916230523-r2ynulqmp2tyu2e5
Tags: upstream-20120217+dfsg
ImportĀ upstreamĀ versionĀ 20120217+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\ *****************************************************************************
 
2
\ * Copyright (c) 2004, 2008 IBM Corporation
 
3
\ * All rights reserved.
 
4
\ * This program and the accompanying materials
 
5
\ * are made available under the terms of the BSD License
 
6
\ * which accompanies this distribution, and is available at
 
7
\ * http://www.opensource.org/licenses/bsd-license.php
 
8
\ *
 
9
\ * Contributors:
 
10
\ *     IBM Corporation - initial implementation
 
11
\ ****************************************************************************/
 
12
 
 
13
: (boot) ( -- )
 
14
   s" Executing following boot-command: "
 
15
   boot-command $cat nvramlog-write-string-cr
 
16
   s" boot-command" evaluate      \ get boot command
 
17
   ['] evaluate catch ?dup IF     \ and execute it
 
18
      ." boot attempt returned: "
 
19
      abort"-str @ count type cr
 
20
      nip nip                     \ drop string from 1st evaluate
 
21
      throw
 
22
   THEN
 
23
;
 
24
 
 
25
\ Note: The following ESC sequences has to be handled:
 
26
\     1B 4F 50
 
27
\     1B 5B 31 31 7E
 
28
 
 
29
\ Reads and converts the function key.
 
30
\ key = F1 -- n = 1
 
31
: (function-key) ( -- n )
 
32
   key? IF
 
33
      key CASE
 
34
         50  OF 1 ENDOF
 
35
         7e  OF 1 ENDOF
 
36
         dup OF 0 ENDOF
 
37
      ENDCASE
 
38
   THEN
 
39
;
 
40
 
 
41
\ Checks if an ESC sequence occurs.
 
42
: (esc-sequence) ( -- n )
 
43
   key? IF
 
44
      key CASE
 
45
          4f  OF (function-key) ENDOF
 
46
          5b  OF
 
47
             key key drop (function-key) ENDOF
 
48
          dup OF 0 ENDOF
 
49
       ENDCASE
 
50
   THEN
 
51
;
 
52
 
 
53
: (s-pressed) ( -- )
 
54
   s" An 's' has been pressed. Entering Open Firmware Prompt"
 
55
   nvramlog-write-string-cr
 
56
;
 
57
 
 
58
: (boot?) ( -- )
 
59
   of-prompt? not auto-boot? and IF
 
60
      (boot)
 
61
   THEN
 
62
;
 
63
 
 
64
 
 
65
#include "sms/sms-load.fs"
 
66
 
 
67
 
 
68
\ Watchdog will be rearmed during load if use-load-watchdog variable is TRUE
 
69
TRUE VALUE use-load-watchdog?
 
70
 
 
71
 
 
72
: start-it ( -- )
 
73
   key? IF
 
74
      key CASE
 
75
         [char] s  OF (s-pressed) ENDOF
 
76
         1b        OF
 
77
 
 
78
            (esc-sequence) CASE
 
79
               1   OF console-clean-fifo sms-start (boot) ENDOF
 
80
               dup OF (boot?) ENDOF
 
81
            ENDCASE
 
82
 
 
83
         ENDOF
 
84
         dup OF (boot?) ENDOF
 
85
      ENDCASE
 
86
   ELSE
 
87
      (boot?)
 
88
   THEN
 
89
 
 
90
   disable-watchdog  FALSE to use-load-watchdog?
 
91
   .banner
 
92
;