Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: asr-state.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 ============================================ | |
42 | id: @(#)asr-state.fth 1.1 07/02/07 | |
43 | purpose: | |
44 | copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | ||
48 | \ FWARC/2006/080 | |
49 | ||
50 | headerless | |
51 | ||
52 | \ ASR State message types | |
53 | h# a constant ASR-STATE-REQ | |
54 | h# 1a constant ASR-STATE-RES | |
55 | ||
56 | \ ASR State Response | |
57 | struct | |
58 | /l field >state-result | |
59 | /l field >state-length | |
60 | d# 1000 field >key-strings \ This field is a variable field, | |
61 | \ max size is determined by DS layer | |
62 | \ for now use 1000 byte | |
63 | constant /state-response | |
64 | ||
65 | \ Wrap state data to be sent to the domain services layer | |
66 | \ We only need to send command, there is no payload to go with | |
67 | ||
68 | \ ASR state request command | |
69 | : assemble-state-pkt ( -- pkt len ) | |
70 | asr-buf ( pkt ) | |
71 | ASR-STATE-REQ over asr-cmd! ( pkt ) | |
72 | /asr-hdr ( pkt len ) | |
73 | ; | |
74 | ||
75 | : (asr-state) ( -- $response | -1 ) | |
76 | asr-buf /max-asr-response erase | |
77 | check-asr-channel-state if | |
78 | \ Assume nothing disabled | |
79 | true exit ( -1 ) | |
80 | then | |
81 | assemble-state-pkt ( buf len ) | |
82 | asr-svc-handle send-ds-data if | |
83 | cmn-warn[ " Error sending ASR data - transaction failed" ]cmn-end | |
84 | \ Assume nothing disabled | |
85 | -1 exit ( -1 ) | |
86 | then | |
87 | receive-asr-response ?dup 0= if ( buf' len' ) | |
88 | \ subtract asr-hdr, state-result and state-length bytes | |
89 | /asr-hdr - 0 >key-strings - ( buf' len" ) | |
90 | swap dup asr-cmd@ ASR-STATE-RES = if ( len" buf ) | |
91 | >asr-payload ( len" payload-buf ) | |
92 | dup >state-result l@ ( len" payload-buf result ) | |
93 | ASR-CMD-FAILED = if ( len" payload-buf ) | |
94 | cmn-warn[ " ASR State request Failed - Command Failed" ]cmn-end | |
95 | \ Assume nothing disabled | |
96 | 2drop -1 exit ( -1 ) | |
97 | then ( len" payload-buf ) | |
98 | dup >key-strings swap >state-length l@ rot min ( $response ) | |
99 | else ( buf' len' ) | |
100 | \ Assume nothing disabled | |
101 | 2drop -1 ( -1 ) | |
102 | then ( $response | -1 ) | |
103 | then ( $response | -1 ) | |
104 | ; | |
105 | ||
106 | \ len = 0 means nothing is disabled | |
107 | : asr-state ( -- $response ) | |
108 | (asr-state) dup -1 = if ( $response | ) | |
109 | \ Assume nothing disabled | |
110 | drop 0 0 ( 0 0 ) | |
111 | then ( $response' ) | |
112 | ; | |
113 | ||
114 | ||
115 | : cstrlen ( cstr -- length ) | |
116 | dup begin dup c@ while ca1+ repeat swap - | |
117 | ; | |
118 | ||
119 | : cscount ( cstr -- adr len ) dup cstrlen ; | |
120 | ||
121 | \ returns ptr to the next byte after the cstring | |
122 | : cmn-cstr ( ptr -- ptr' ) cscount 2dup cmn-append + 1+ ; | |
123 | ||
124 | ||
125 | \ state [key1][0][key2][0][keyn][0] | |
126 | \ len = 0 means nothing is disabled | |
127 | : check-asr-state ( -- ) | |
128 | \ Get ASR State information, length of 0 means nothing disabled | |
129 | asr-state ?dup 0= if drop exit then ( ) | |
130 | cmn-error[ " The following devices are disabled:"r"n" cmn-append | |
131 | over + swap ( end buf ) | |
132 | begin ( end buf ) | |
133 | 2dup > while ( end buf ) | |
134 | " " cmn-append ( end buf' ) | |
135 | cmn-cstr ( end buf' ) | |
136 | " "r"n" cmn-append ( end buf' ) | |
137 | repeat 2drop ( ) | |
138 | " " ]cmn-end ( ) | |
139 | ; | |
140 | ||
141 | chain: check-machine-state ( -- ) check-asr-state ; | |
142 |