Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: make-path.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: %Z%%M% %I% %E% %U% | |
43 | purpose: %Y% | |
44 | copyright: Copyright 2000-2002 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | h# 80 buffer: pci-path | |
48 | ||
49 | \ I'm not sure if the userland interpreter can cope with the | |
50 | \ package-to-path client-service; so just in case it cannot | |
51 | \ I have implemented a recursive FCODE implementation. | |
52 | \ | |
53 | \ Unless memory is an issue; use-cif? need not be defined. | |
54 | \ | |
55 | ||
56 | [ifdef] use-cif? | |
57 | defer package-to-path 0 " package-to-path" do-cif is package-to-path | |
58 | ||
59 | : make-path$ ( -- ok? ) | |
60 | pci-path 0 over c! ( buf ) | |
61 | h# 7f over 1+ ( buf len buf' ) | |
62 | my-self ihandle>phandle ( buf len phandle ) | |
63 | package-to-path ( buf len' ) | |
64 | swap c! ( ) | |
65 | true ( true ) | |
66 | ; | |
67 | ||
68 | [else] | |
69 | ||
70 | : >path$ ( $adr,len -- ) | |
71 | tuck pci-path count + ( len adr len buf-end-adr ) | |
72 | swap move ( len ) | |
73 | pci-path dup c@ ( len buf-adr buf-old-len ) | |
74 | rot + swap c! | |
75 | ; | |
76 | ||
77 | : (assemble-path) ( -- ) | |
78 | " name" get-my-property if exit then ( namep,len ) | |
79 | " reg" get-my-property if 2drop exit then | |
80 | " #address-cells" my-parent ihandle>phandle get-package-property | |
81 | if 2 else decode-int nip nip then | |
82 | dup >r 0 ?do ( namep,len regp,len ) | |
83 | decode-int -rot ( namep,len ?? regp,len' ) | |
84 | loop 2drop ( namep,len ?? ) | |
85 | r> case | |
86 | 2 of swap endof | |
87 | 3 of -rot swap endof | |
88 | endcase ( namep,len pa.lo..pa.hi ) | |
89 | " encode-unit" $call-parent ( namep,len unit$ ) | |
90 | " /" >path$ 2swap decode-string >path$ ( unit$ xdr,len ) | |
91 | 2drop " @" >path$ >path$ ( ) | |
92 | ; | |
93 | ||
94 | : (fallback-make-path$) ( -- ) | |
95 | recursive | |
96 | my-parent if | |
97 | my-self >r my-parent is my-self | |
98 | (fallback-make-path$) r> is my-self | |
99 | (assemble-path) | |
100 | then | |
101 | ; | |
102 | ||
103 | : make-path$ ( -- ok? ) | |
104 | 0 pci-path c! (fallback-make-path$) true | |
105 | ; | |
106 | [then] | |
107 | ||
108 | : .path$ ( -- ) pci-path count type ; | |
109 | ||
110 | headerless |