Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: forthinit.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: @(#)forthinit.fth 1.5 07/06/05 10:54:36 | |
43 | purpose: | |
44 | copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headerless | |
48 | 0 value heap-base | |
49 | ||
50 | : initial-mem ( -- adr,len ) | |
51 | heap-base prom-main-task over - | |
52 | ; | |
53 | ' initial-mem is initial-heap | |
54 | ||
55 | \ In: | |
56 | \ up, base | |
57 | \ %o0 = memory base | |
58 | \ %o1 = memory size or free-memory size if %o2 is non-zero. | |
59 | \ %o2 = Non-standard layout flag. | |
60 | \ | |
61 | \ non Zero %o2 means dont compute anything just use %o0,%o1 as base,len | |
62 | \ | |
63 | \ Out: | |
64 | \ up, base, %o0 = rp, %o1 = sp | |
65 | \ | |
66 | \ This routine returns initial values for up, base, sp, an rp. | |
67 | \ The initialization ip is left to the caller. Since we want | |
68 | \ to provide a degree of flexibility in the assignment of | |
69 | \ processor registers to the forth engine, we really should | |
70 | \ be returning all those registers in out registers to allow | |
71 | \ the caller to assign them to arbitrary registers. However, | |
72 | \ since this routine is dependent on the use of base and up | |
73 | \ registers, and they are still assigned to global registers, | |
74 | \ it's easier to leave them in place rather than copy them to | |
75 | \ out registers and have the caller copy them back. But | |
76 | \ because sp and rp are %in registers and they are not visible | |
77 | \ within this register window, we must return those registers | |
78 | \ in %o0 and %o1. | |
79 | ||
80 | label init-forth-environment | |
81 | \ Set the base register | |
82 | %g0 %g0 %g0 save | |
83 | ||
84 | %i2 %g0 %g0 subcc \ Use non standard layout? | |
85 | 0= if | |
86 | nop \ (delay) | |
87 | ||
88 | %i0 %i1 %o1 add \ Top of memory | |
89 | ||
90 | pagesize %l1 set | |
91 | RAMsize-start %l4 set | |
92 | ROMsize %o2 set | |
93 | ||
94 | %o1 %o2 %o1 sub \ remove OBPs dictionary | |
95 | %o1 %l4 %o1 sub \ %o1 = Addr of User Area | |
96 | %o1 %l1 %o0 sub \ %o0 = Addr of locked VPT | |
97 | %o0 %i0 %i1 sub \ Size of unused memory in %i1 | |
98 | then | |
99 | ||
100 | scr sc1 sc2 mutex-try-enter prom-lock | |
101 | ||
102 | \ Clear the initial user segment | |
103 | [ifdef] PreCleanedMemory | |
104 | ||
105 | \ Platforms (currently, only StarCat) that come up with | |
106 | \ memory pre-cleaned (e.g., by POST), still dirty-up the | |
107 | \ area used for scratch during decompression. | |
108 | \ | |
109 | \ The following only works for platforms that have the | |
110 | \ decompression scratch area hard-coded at VA=0 and for | |
111 | \ which a range of physical memory -- hard-coded to a size | |
112 | \ of 1/2 meg -- extends through the initial user segment | |
113 | \ and the initial VPT. | |
114 | \ | |
115 | \ See the platform-specific reset.fth file. | |
116 | ||
117 | 0 %l3 set | |
118 | h# 8.0000 %l2 set | |
119 | [else] | |
120 | RAMbase %l3 set | |
121 | RAMsize-start %l2 set | |
122 | [then] | |
123 | ||
124 | \ %l3 = base VA %l2 = size | |
125 | begin | |
126 | %l2 /n %l2 subcc | |
127 | 0= until | |
128 | %g0 %l3 %l2 stx \ Delay slot | |
129 | ||
130 | \ Copy the PROM copy of the data segment into RAM, | |
131 | \ Including the user area | |
132 | ||
133 | base h# 18 %l3 ldx \ get the dictionary length | |
134 | base %l3 %l3 add \ compute the VA | |
135 | base h# 10 %l2 ldx \ sizeof user segment | |
136 | begin | |
137 | %l2 /n %l2 subcc | |
138 | %l3 %l2 %l5 ldx | |
139 | 0= until | |
140 | %l5 up %l2 stx \ (Delay) | |
141 | ||
142 | \itc up %g0 iflush \ For t16 this is required. | |
143 | ||
144 | \ The User Area is now initialized | |
145 | ||
146 | %i0 pageshift %i0 srlx \ convert to page# | |
147 | 'user# hi-memory-base scr set | |
148 | %i0 up scr nput \ Set the memory configuration variable | |
149 | ||
150 | %i1 pageshift %i1 srlx \ convert to #pages | |
151 | 'user# hi-memory-size scr set | |
152 | %i1 up scr nput \ Set the memory configuration variable | |
153 | ||
154 | up 'user up0 nput \ Set the up0 user variable | |
155 | ||
156 | RAMbase rs-size + %i0 set \ Initialize the Return Stack Pointer | |
157 | %i0 'user .rp0 nput \ Set the rp0 user variable | |
158 | ||
159 | %i0 h# 20 scr add | |
160 | scr ps-size scr add | |
161 | scr 'user .sp0 nput \ Set the sp0 user variable | |
162 | scr /n %i1 add \ Account for the top of stack register | |
163 | ||
164 | %i1 /n scr add | |
165 | 'user# heap-base sc1 set | |
166 | scr up sc1 nput | |
167 | ||
168 | %i7 8 return | |
169 | nop \ (delay) | |
170 | end-code | |
171 | ||
172 |