Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: initdict.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: @(#)initdict.fth 2.18 03/12/08 13:22:40 | |
43 | purpose: | |
44 | copyright: Copyright 1990-2003 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | \ For use in virtual-memory systems in which the Forth dictionary does | |
48 | \ not have memory preallocated to it, this file establishes a mechanism | |
49 | \ for allocating physical memory to the dictionary "on demand". | |
50 | ||
51 | headerless | |
52 | \ Called when ALLOT can't satisfy the request. Allocates some more | |
53 | \ physical memory for the dictionary, maps it in, and updates limit | |
54 | \ to include the new memory. | |
55 | h# 1.0000 constant /dictionary-growth \ 64K chosen to reduce map calls | |
56 | ||
57 | \ Return a "success" indication if called when the dictionary already | |
58 | \ satisfies the request. | |
59 | ||
60 | \ Implementation factor. | |
61 | \ Restriction: both parameters must be mmu-aligned | |
62 | : extend-dict-phys ( old-top-adr size' -- ) | |
63 | dup /dictionary-growth ( old-top size' size' alignment ) | |
64 | mem-claim ( old-top size' p.lo p.hi ) | |
65 | 2swap ( p.lo p.hi old-top=start-addr size' ) | |
66 | mem-mode mmu-map | |
67 | ; | |
68 | ||
69 | : extend-dictionary ( size -- size ) | |
70 | dup pad + d# 100 + ( size top-adr ) | |
71 | /dictionary-growth round-up ( size new-top-adr ) | |
72 | dup dictionary-top > if allot-abort then ( size new-top-adr ) | |
73 | limit ( size new-top-adr old-top-adr ) | |
74 | ||
75 | \ We didn't expect to call this routine unless we're about | |
76 | \ to run out of space, but it's more robust this way... | |
77 | 2dup u<= if | |
78 | 2drop exit \ Retreat and claim victory. | |
79 | then | |
80 | ( size new-top-adr old-top-adr ) | |
81 | 2dup - ( size new-top-adr old-top-adr size' ) | |
82 | extend-dict-phys ( size new-top-adr ) | |
83 | is limit | |
84 | ; | |
85 | ||
86 | \ The in-dictionary? function is used to validate an | |
87 | \ instruction-pointer or the occurrence of a token in a | |
88 | \ colon-definition. But if set to point to origin it | |
89 | \ can get tripped up, for instance, when the trap-table | |
90 | \ address was put on the return-stack and ftrace is run. | |
91 | \ | |
92 | \ Instead, point it to the first code-definition in the | |
93 | \ dictionary, which, after all, is the *real* start of | |
94 | \ the area where valid IPs or tokens can begin. | |
95 | ||
96 | : init-dictionary ( -- ) | |
97 | ||
98 | RAM-dictionary-base dp ! | |
99 | initial-limit is limit | |
100 | ['] extend-dictionary is allot-error | |
101 | ||
102 | ['] origin is lo-segment-base | |
103 | ['] origin is lo-segment-limit | |
104 | ['] first-code-word is hi-segment-base | |
105 | \ XXX Later, we may change first-code-word to low-dictionary-adr | |
106 | ['] here is hi-segment-limit | |
107 | ; | |
108 | ||
109 | stand-init: Init Dictionary | |
110 | init-dictionary | |
111 | ; | |
112 | ||
113 | headers |