Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / pkg / dropins / sparc / find-dropin.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: find-dropin.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: @(#)find-dropin.fth 1.1 02/08/22
43purpose:
44copyright: Copyright 1999-2002 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47inline-struct? on
48struct
49 /l field >di-magic
50 /l field >di-size
51 /l field >di-sum
52 /l field >di-exp \ Reserved
53d# 16 field >di-name
54 0 field >di-image
55constant /lvl1-hdr
56inline-struct? off
57
58[ifdef] dropin-debug?
59label di-print-addr
60 %l5 %o0 move
61 %g0 %g0 %g0 save
62 print" "r"nScan addr: "
63 %i0 print-reg
64 %i7 8 return
65 nop
66end-code
67
68label di-print-name
69 %g0 %g0 %g0 save
70 ttya-pa %o2 %l7 setx
71
72 %l7 %o1 move
73 bpemit call
74 ascii [ %o0 move \ (delay)
75
76 %l7 %o1 move
77 bpemit call
78 %i2 %o0 move \ (delay)
79
80 %l7 %o1 move
81 bpemit call
82 ascii ! %o0 move \ (delay)
83
84 %l7 %o1 move
85 bpemit call
86 %i3 %o0 move \ (delay)
87
88 %l7 %o1 move
89 bpemit call
90 ascii ] %o0 move \ (delay)
91
92 %i7 8 return
93 nop
94end-code
95[then]
96
97\ In
98\ %o0 = di-name
99\ %o1 = start-addr
100\ Out
101\ %o0 = addr of dropin-header or 0 if not found.
102label find-drop-in
103 %g0 %g0 %g0 save
104
105 %i1 %l5 move \ start address
106 h# 4f424d44 %l6 set \ dropin magic
107 %g0 %g0 %l7 add \ found address
108 begin
109 \ Skip trailing 01 bytes.
110 begin
111 %l5 0 %o0 ldub
112 %o0 h# 01 %g0 subcc
113 0<> until
114 %l5 1 %l5 add
115 %l5 3 %l5 andn \ Force alignment
116[ifdef] dropin-debug?
117 di-print-addr call nop
118[then]
119 %l5 0 >di-magic %l4 ld \ get magic
120 %l5 0 >di-size %l1 ld \ get size
121 %l4 %l6 %g0 subcc
122 0= if
123 %g0 %g0 %g0 subcc \ (delay) mark exit
124
125 \ Check the name
126 %l5 0 >di-name %o0 add \ Dropin name
127 %i0 %g0 %o1 add \ SRC name
128 %g0 d# 16 %o4 add \ max len.
129 begin
130 %o0 0 %o2 ldub
131 %o1 0 %o3 ldub
132[ifdef] dropin-debug?
133 di-print-name call nop
134[then]
135 %o2 %o3 %g0 subcc
136 0= if
137 %g0 %g0 %g0 subcc \ (delay) no match exit
138 %o2 %g0 %g0 subcc
139 0= if
140 %o4 1 %o4 subcc \ decr and continue (delay)
141 %l5 %l7 move \ name matched.
142 %g0 %g0 %g0 subcc \ force exit.
143 then
144 then
145 %o0 1 %o0 add
146 0= until
147 %o1 1 %o1 add
148
149 %l7 %g0 %g0 subcc \ name matched?
150 0<> if
151 %g0 1 %g0 subcc \ continue
152 %g0 %g0 %g0 subcc \ End
153 then
154 then
155 %l5 /lvl1-hdr %l5 add \ Skip the header.
156 0= until
157 %l5 %l1 %l5 add \ Skip the data to next dropin.
158
159 %l7 %g0 %i0 add
160 %i7 8 return
161 nop
162end-code