Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: md-parse.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: @(#)md-parse.fth 1.1 07/06/22 | |
43 | purpose: | |
44 | copyright: Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headerless | |
48 | ||
49 | : $= ( adr,len adr2,len -- same? ) | |
50 | rot tuck <> if 3drop false exit then comp 0= | |
51 | ; | |
52 | ||
53 | \ Search for ldc id that can be used for net boot | |
54 | ||
55 | : md-next-fwd ( node fwd|0 -- entry|0 ) | |
56 | begin | |
57 | over swap md-next-prop dup ( node next next ) | |
58 | while ( node next ) | |
59 | dup md-prop-type ascii a = if ( node next ) | |
60 | dup md-prop-name " fwd" $= if ( node next ) | |
61 | nip exit ( entry ) | |
62 | then ( node next ) | |
63 | then ( node next ) | |
64 | repeat ( node next ) | |
65 | nip ( 0 ) | |
66 | ; | |
67 | ||
68 | : md-applyto-fwds ( ??? acf node -- ??? ) | |
69 | 0 ( ?? acf node 0 ) | |
70 | begin | |
71 | 2dup md-next-fwd nip dup ( ?? acf node next-fwd|0 next-fwd|0 ) | |
72 | while | |
73 | dup md-decode-prop drop ( ?? acf node next-fwd fwd-node ) | |
74 | -rot >r >r swap >r r@ ( ?? fwd-node acf ) | |
75 | catch ?dup if | |
76 | r> r> r> 3drop throw ( ) | |
77 | then | |
78 | r> r> r> ( acf node next-fwd ) | |
79 | repeat | |
80 | 3drop ( ) | |
81 | ; | |
82 | ||
83 | : md-get-required-prop ( node $name -- [val type] | [buf len type] ) | |
84 | 3dup -1 md-find-prop ?dup if | |
85 | nip nip nip md-decode-prop ( [val type] | [buf len type] ) | |
86 | else | |
87 | rot md-node-name 2swap ( $name $prop ) | |
88 | cmn-fatal[ " Missing required property: %s " cmn-append | |
89 | " in node %s" ]cmn-end | |
90 | then | |
91 | ; | |
92 | ||
93 | \ Integers in MD are stored in arrays of 64 bits, encode-int wants 32 bits. | |
94 | : encode-md-prop-data ( data,len -- prop,len ) | |
95 | 0 0 encode-bytes rot 0 ?do ( data prop,len ) | |
96 | 2 pick i + x@ encode-int encode+ ( data prop,len' ) | |
97 | /x +loop ( data prop,len' ) | |
98 | rot drop ( prop,len' ) | |
99 | ; |