Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: go.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: @(#)go.fth 1.22 06/03/14 | |
43 | purpose: | |
44 | copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headerless | |
48 | \ A wrapper for the cif calls. | |
49 | overload: do-cif ( ( adr -- result ) | |
50 | mid@ cif-owner l! do-cif -1 cif-owner l! | |
51 | ; | |
52 | ||
53 | 1 1 ' do-cif make-c-entry create &cif-func() token, | |
54 | headers | |
55 | : cif-func() ( -- adr ) &cif-func() token@ ; | |
56 | ||
57 | headers | |
58 | : (init-program) ( -- ) | |
59 | ||
60 | cif-64 \ 64-Bit IEEE 1275 Client Interface | |
61 | ||
62 | init-c-stack \ Erase any previous C stack state | |
63 | ||
64 | \ Zero all the general registers. | |
65 | 0w | |
66 | 0 to %g0 0 to %o0 0 to %l0 0 to %i0 | |
67 | 0 to %g1 0 to %o1 0 to %l1 0 to %i1 | |
68 | 0 to %g2 0 to %o2 0 to %l2 0 to %i2 | |
69 | 0 to %g3 0 to %o3 0 to %l3 0 to %i3 | |
70 | 0 to %g4 0 to %o4 0 to %l4 0 to %i4 | |
71 | 0 to %g5 0 to %o5 0 to %l5 0 to %i5 | |
72 | 0 to %g6 0 to %o6 0 to %l6 0 to %i6 | |
73 | 0 to %g7 0 to %o7 0 to %l7 0 to %i7 | |
74 | ||
75 | cif-func() to %o4 \ IEEE 1275 Client Services Handler | |
76 | %o6@ to %o6 \ C stack pointer | |
77 | ||
78 | trap-table to %tba \ Set trap table | |
79 | ||
80 | h# 0 to %y h# 4 to %fprs | |
81 | h# 16 to %pstate h# 0d to %pil | |
82 | ||
83 | 7 to %cleanwin 0 to %otherwin | |
84 | 0 to %wstate 0 to %canrestore | |
85 | 6 to %cansave 0 to %cwp | |
86 | ||
87 | h# 16 8 lshift to %tstate-c | |
88 | ||
89 | load-base set-pc | |
90 | ||
91 | [ifdef] SUN4V | |
92 | \ Since we are initializing a stack, make sure we clear out previous saved | |
93 | \ state indications. This affects ultra4v/savecpu.fth:restore-cpu-state, | |
94 | \ which is invoked shortly after this. | |
95 | ||
96 | 0 to full-save? | |
97 | [then] | |
98 | ||
99 | sp@ saved-sp ! rp@ saved-rp ! \ Needed for later callbacks into Forth | |
100 | ||
101 | state-valid on restartable? on | |
102 | true to already-go? | |
103 | [ifdef] Starcat? | |
104 | RELEASE-SLAVE-INVALID release-slaves? l! | |
105 | [then] | |
106 | ; | |
107 | ||
108 | \ Allow dropin drivers to be standalone programs. | |
109 | ||
110 | headers | |
111 | tail-chain: execute-buffer ( adr len -- ) | |
112 | over adjust-elf32-header if ( adr,len entry ) | |
113 | (init-program) set-pc 2drop ( entry ) | |
114 | go | |
115 | exit | |
116 | then ( adr,len ) | |
117 | tail; | |
118 | ||
119 | tail-chain: execute-buffer ( adr len -- ) | |
120 | over adjust-elf64-header if ( adr,len entry ) | |
121 | (init-program) set-pc 2drop ( entry ) | |
122 | go | |
123 | exit | |
124 | then ( adr,len ) | |
125 | tail; | |
126 | ||
127 | tail-chain: execute-buffer ( adr len -- ) | |
128 | over 2 + unaligned-w@ h# 107 = if ( adr len ) | |
129 | over a.out-header /a.out-header move ( adr len ) | |
130 | 2dup initsyms ( adr len ) | |
131 | drop /a.out-header + entry-adr ( src dest ) | |
132 | /text /data + move ( ) | |
133 | entry-adr /text /data + + /bss erase ( ) | |
134 | (init-program) entry-adr set-pc ( ) | |
135 | go \ XXX we need some way to get back! | |
136 | exit | |
137 | then | |
138 | tail; | |
139 | ||
140 | tail-chain: execute-buffer ( adr len -- ) | |
141 | over 2 + unaligned-w@ h# 107 = if ( adr len ) | |
142 | over >r ( adr len ) ( r: adr ) | |
143 | r@ a_entry l@ r@ a_text l@ r> a_data l@ or or | |
144 | h# 9000.0000 tuck and = if ( adr len ) | |
145 | >r dup dup /a.out-header - r> move ( adr len ) | |
146 | (init-program) set-pc ( adr len ) | |
147 | go \ XXX we need some way to get back! | |
148 | exit | |
149 | then ( adr len ) | |
150 | then ( adr len ) | |
151 | tail; | |
152 | ||
153 | cif: enter ( -- ) reenter call ; | |
154 | cif: exit ( -- ) exittomon call ; | |
155 | \ cif: chain ( len args entry size virt -- ) op-chain ; | |
156 | ||
157 | headers | |
158 | : init-program ( -- ) | |
159 | load-base file-size @ 'execute-buffer execute (init-program) | |
160 | ; |