Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / os / bootprom / execall.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: execall.fth
4\
5\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6\
7\ - Do no alter or remove copyright notices
8\
9\ - Redistribution and use of this software in source and binary forms, with
10\ or without modification, are permitted provided that the following
11\ conditions are met:
12\
13\ - Redistribution of source code must retain the above copyright notice,
14\ this list of conditions and the following disclaimer.
15\
16\ - Redistribution in binary form must reproduce the above copyright notice,
17\ this list of conditions and the following disclaimer in the
18\ documentation and/or other materials provided with the distribution.
19\
20\ Neither the name of Sun Microsystems, Inc. or the names of contributors
21\ may be used to endorse or promote products derived from this software
22\ without specific prior written permission.
23\
24\ This software is provided "AS IS," without a warranty of any kind.
25\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
26\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
27\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
28\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
29\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
31\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
32\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
33\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
34\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
35\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
36\
37\ You acknowledge that this software is not designed, licensed or
38\ intended for use in the design, construction, operation or maintenance of
39\ any nuclear facility.
40\
41\ ========== Copyright Header End ============================================
42id: @(#)execall.fth 1.10 07/01/22
43purpose:
44copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved
45
46headerless
47
48defer the-action ( phandle -- )
49: execute-action ( -- false )
50 current-device >r the-action false r> push-device
51;
52
53: (scan-level) ( -- )
54 current-device >r
55 ['] execute-action ['] (search-level) catch 2drop
56 r> push-device
57;
58
59: scan-level ( action-acf -- ) is the-action (scan-level) ;
60
61headers
62
63\ "action-acf" is executed for each device node in the subtree
64\ rooted at dev-addr,len , with current-device set to the
65\ node in question. "action-acf" can perform arbitrary tests
66\ on the node to determine if that node is appropriate for
67\ the action that it wished to undertake.
68
69: scan-subtree ( dev-addr,len action-acf -- )
70 current-device >r ( dev-addr,len action-acf )
71 is the-action ( dev-addr,len )
72 find-device ( )
73 ['] execute-action ['] (search-preorder) catch 2drop
74 r> push-device ( )
75;
76
77headerless
78
792variable method-name
80
81\ : output-device? ( -- flag ) current-device stdout @ pihandle= ;
82
83\ do-method? is an action routine for "scan-subtree" that is used
84\ by execute-all-methods. For each device node, excluding the current
85\ output device, that has a method whose name is given by method-name ,
86\ that method is executed.
87
88: do-method? ( -- )
89 \ Don't test the output device
90\ output-device? if exit then
91
92 method-name 2@ current-device (search-wordlist) if ( xt )
93 drop pwd$ ( path-adr,len )
94 2dup type cr ( path-adr,len )
95 method-name 2@ execute-device-method drop cr ( )
96 then ( )
97;
98
99\ call-method? is a variation on do-method? - distinctions being that
100\ this won't type out the nodename, and will call open/close on the node
101\ before calling the method.
102
103: call-method? ( -- )
104 method-name 2@ current-device (search-wordlist) if ( xt )
105 drop pwd$ ( path-adr,len )
106 method-name 2@ execute-method-opened drop ( )
107 then ( )
108;
109
110headers
111
112: execute-all-methods ( dev-addr,len method-adr,len -- )
113 method-name 2!
114 ['] do-method? scan-subtree
115;
116
117: most-tests ( -- )
118 \ Don't test the output device
119 \ output-device? if exit then
120
121 method-name 2@ current-device (search-wordlist) if ( xt )
122
123 drop ( )
124
125 \ We only want to execute the selftest routine if the device has
126 \ a "reg" property. This eliminates the execution of selftest
127 \ routines for "wildcard" devices like st and sd.
128
129 " reg" get-property if exit then 2drop ( )
130
131 ??cr ." Testing " pwd
132 method-name 2@ current-device ( method-adr,len phandle )
133 execute-phandle-method drop ( result )
134
135 ?dup if ??cr ." Selftest failed. Return code = " .d cr then
136
137 then ( )
138;
139