Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: root-prober.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: @(#)root-prober.fth 1.4 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 | : make-root$ ( n type$ -- root$ ) | |
50 | push-hex | |
51 | rot <# u#s -rot ascii - hold 1- bounds swap do i c@ hold -1 +loop u#> | |
52 | pop-base | |
53 | ; | |
54 | ||
55 | : get-root-driver? ( name$ -- acf,-1|0 ) | |
56 | ['] builtin-drivers-package find-method | |
57 | ; | |
58 | ||
59 | 0 value pdnode-handle | |
60 | ||
61 | : make-io-node ( acf node unit -- ) | |
62 | push-hex (.) pop-base ( acf node $reg ) | |
63 | rot encode-int 2swap ( acf $args $reg ) | |
64 | cmn-type[ " Device: " cmn-append ( acf $args $reg ) | |
65 | " /" begin-package ( acf ) | |
66 | catch drop ( ) | |
67 | end-package ( ) | |
68 | " " ]cmn-end ( ) | |
69 | ; | |
70 | ||
71 | \ When attaching FCode drivers, look for drivers that match the | |
72 | \ "compatible" property first, then "device-type" | |
73 | \ | |
74 | : load-root-driver ( node -- ) | |
75 | dup " disabled" ascii v md-find-prop dup if ( node prop ) | |
76 | md-decode-prop drop ( node status ) | |
77 | then ( node status ) | |
78 | 0= if ( node ) | |
79 | dup " cfg-handle" ascii v md-find-prop ( node prop ) | |
80 | dup if md-decode-prop drop then ( node unit ) | |
81 | over " compatible" -1 md-find-prop ?dup if ( node unit node'| ) | |
82 | md-decode-prop drop ( node unit prop,len ) | |
83 | \ Currently, we only support attaching the driver to the | |
84 | \ first compatible property. This can be extended to a loop | |
85 | \ if necessary. | |
86 | decode-string 2swap 2drop ( node unit str,len ) | |
87 | get-root-driver? ?dup 0= if ( node unit [acf -1]| ) | |
88 | over " device-type" -1 md-find-prop ( node unit node' ) | |
89 | dup if ( node unit node'|0 ) | |
90 | md-decode-prop drop ( node unit str,len ) | |
91 | get-root-driver? ( node unit [acf -1]|0 ) | |
92 | then ( node unit [acf -1]|0 ) | |
93 | then ( node unit [acf -1]|0 ) | |
94 | if ( node unit acf| ) | |
95 | -rot over >r make-io-node r> ( node ) | |
96 | else ( node unit ) | |
97 | drop ( node ) | |
98 | then ( node ) | |
99 | else ( node unit ) | |
100 | drop ( node ) | |
101 | then ( node ) | |
102 | then ( node ) | |
103 | drop ( ) | |
104 | ; | |
105 | ||
106 | : probe-wart ( node -- ) | |
107 | dup md-node-name " wart" $= if | |
108 | load-root-driver | |
109 | else | |
110 | drop | |
111 | then | |
112 | ; | |
113 | ||
114 | : load-wart-drivers ( node -- ) | |
115 | ['] probe-wart swap md-applyto-fwds | |
116 | ; | |
117 | ||
118 | : make-io-nodes ( -- ) | |
119 | 0 | |
120 | begin | |
121 | " iodevice" md-find-node ?dup ( 0 | node node ) | |
122 | while | |
123 | dup load-root-driver ( node ) | |
124 | dup load-wart-drivers ( node ) | |
125 | repeat | |
126 | ; | |
127 | ||
128 | stand-init: Probe root devices | |
129 | make-io-nodes | |
130 | ; | |
131 |