Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / pkg / dropins / finder.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: finder.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 ============================================
42id: @(#)finder.fth 1.3 06/04/18
43purpose: Package for FLASH ROM device
44copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47hex
48headerless
49
500 value di-limit
51
52struct
53 /l field >di-magic
54 /l field >di-size
55 /l field >di-sum
56 /l field >di-exp \ Reserved
57d# 16 field >di-name
58 0 field >di-image
59constant /lvl1-hdr
60
61struct
62 /l field >di2-magic
63 0 field >di2-image
64constant lvl2-hdr
65
66: check-di-magic ( addr -- header flag? )
67 4 round-up ( addr' )
68 dup >di-magic rl@ h# 4f424d44 = ( addr' flag )
69;
70
71: check-directory-magic ( addr -- addr flag )
72 dup rl@ h# 4f424d45 = ( addr' flag )
73;
74
75: (find-drop-in?) ( name$ base -- false | header,true )
76 recursive
77 swap d# 15 min swap ( name$' base )
78 over 0= if 3drop false exit then ( false )
79 check-di-magic if ( name$ addr )
80 >r 2dup r@ >di-name cscount $= if ( name$ )
81 2drop r> true ( header,true )
82 else ( name$ )
83 r> dup >di-size rl@ ( name$ addr len )
84 swap >di-image + ( name$ addr )
85 dup di-limit < if ( name$ addr )
86 (find-drop-in?) ( header,true | false )
87 else ( header,true | false )
88 cmn-warn[ " Dropin search goes past prom boundary" ]cmn-end
89 3drop false exit ( false )
90 then ( false )
91 then ( header,true | false )
92 else ( name$ header )
93 3drop false ( false )
94 then ( header,true | false )
95;
96
97\
98\ The device tree requires that / be replaced with |
99\ so that arguments and device nodes are correctly delimited.
100\ So the left-parse-string below uses |
101\
102: find-drop-in? ( name-adr,len addr -- addr,true | false )
103 recursive
104 >r ( name$ )
105 ascii | left-parse-string ( r,len l,len )
106 r> (find-drop-in?) if ( r,len addr )
107 over if ( r,len )
108 >di-image ( r,len addr' )
109 check-directory-magic if ( r,len addr )
110 >di2-image find-drop-in? ( addr,true | false )
111 else ( r,len addr )
112 3drop false ( false )
113 then ( addr,true | false )
114 else ( r,0 addr )
115 nip nip true ( addr,true )
116 then ( addr,true | false )
117 else ( r,len )
118 2drop false ( false )
119 then ( addr,true | false )
120;
121