Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: mdnode.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: @(#)mdnode.fth 1.2 07/02/12 | |
43 | purpose: | |
44 | copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headers | |
48 | ||
49 | 0 value guest-md \ always points to the guest MD | |
50 | 0 value md-data \ MD data (aligned) | |
51 | 0 value /md-data \ MD data length | |
52 | ||
53 | headerless | |
54 | ||
55 | : unaligned-x@ ( addr -- value ) | |
56 | dup unaligned-l@ swap 4 + unaligned-l@ swap lxjoin | |
57 | ; | |
58 | ||
59 | \ Machine description header | |
60 | struct | |
61 | /l field >mdhdr-version \ Transport version | |
62 | /l field >mdhdr-nodeblk-sz \ Size of node block (in bytes) | |
63 | /l field >mdhdr-nameblk-sz \ Size of name block (in bytes) | |
64 | /l field >mdhdr-datablk-sz \ Size of data block (in bytes) | |
65 | constant /md-header | |
66 | ||
67 | : md-nodeblk ( -- adr ) md-data /md-header + ; | |
68 | : md-nodeblksz ( -- n ) md-data >mdhdr-nodeblk-sz unaligned-l@ ; | |
69 | : md-nameblk ( -- adr ) md-nodeblk md-nodeblksz + ; | |
70 | : md-nameblksz ( -- n ) md-data >mdhdr-nameblk-sz unaligned-l@ ; | |
71 | : md-datablk ( -- adr ) md-nameblk md-nameblksz + ; | |
72 | : md-datablksz ( -- n ) md-data >mdhdr-datablk-sz unaligned-l@ ; | |
73 | ||
74 | \ Machine description element format | |
75 | struct | |
76 | /c field >mde-tag \ Element type | |
77 | /c field >mde-namelen \ Name length | |
78 | /w + \ Reserved | |
79 | /l field >mde-nameoffset \ Name (offset in name block) | |
80 | 0 field >mde-value \ Data value for PROP_VAL | |
81 | 0 field >mde-index \ Node Index and PROP_ARC | |
82 | 0 field >mde-next \ Next Node for NODE | |
83 | /l field >mde-datalen \ Data length (for STR and DATA) | |
84 | /l field >mde-dataoffset \ Data (offset in data block) | |
85 | constant /md-entry | |
86 | ||
87 | \ Tag definitions | |
88 | 0 constant MD_LIST_END \ End of element list | |
89 | ascii N constant MD_NODE \ Start of node definition | |
90 | ascii E constant MD_NODE_END \ End of node definition | |
91 | h# 20 constant MD_NOOP \ NOOP list element | |
92 | ascii a constant MD_PROP_ARC \ ARC to another node | |
93 | ascii v constant MD_PROP_VAL \ Data value | |
94 | ascii s constant MD_PROP_STR \ String value | |
95 | ascii d constant MD_PROP_DATA \ Data block | |
96 | ||
97 | : mde-index>adr ( index -- adr ) md-nodeblk swap /md-entry * ca+ ; | |
98 | : mde-adr>index ( adr -- index ) md-nodeblk - /md-entry / ; | |
99 | ||
100 | \ Return element type | |
101 | : mde-type ( mdentry -- n ) >mde-tag c@ ; | |
102 | ||
103 | \ Return element name | |
104 | : mde-name ( mdentry -- $name ) | |
105 | md-nameblk over >mde-nameoffset unaligned-l@ + swap >mde-namelen c@ | |
106 | ; | |
107 | ||
108 | \ Return element data (for use by PROP_STR and PROP_DATA) | |
109 | : mde-data ( mdentry -- data len ) | |
110 | md-datablk over >mde-dataoffset unaligned-l@ + | |
111 | swap >mde-datalen unaligned-l@ | |
112 | ; | |
113 | ||
114 | \ Return element value | |
115 | : mde-value ( mdentry -- n ) >mde-value unaligned-x@ ; | |
116 | ||
117 | : md-noops-skip ( mdentry -- mdentry' ) | |
118 | begin dup mde-type MD_NOOP = while /md-entry + repeat | |
119 | ; | |
120 | ||
121 | : mde-nametag@ ( mdentry -- nametag ) unaligned-x@ ; | |
122 | ||
123 | headerless | |
124 |