Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: scrubmem.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: @(#)scrubmem.fth 2.39 06/02/16 | |
43 | purpose: | |
44 | copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | \ Clear memory to establish valid check bits. | |
48 | \ This depends on the availmemory list organization defined in memlist.fth | |
49 | ||
50 | defer scrub-bank ( padr-lo padr-hi size -- ) | |
51 | ||
52 | headerless | |
53 | stand-init: Init scrub-bank | |
54 | fpu-enabled? if ['] bclear-memory-4MB else ['] clear-memory then | |
55 | is scrub-bank | |
56 | ; | |
57 | ||
58 | " /memory" find-device | |
59 | ||
60 | : scrub-4meg ( pa.lo pa.hi len -- ) lock[ 4meg min scrub-bank ]unlock ; | |
61 | ||
62 | : .megs ( n -- ) | |
63 | push-decimal ( n ) ( r: base ) | |
64 | 1meg round-up 1meg / \ Modulo 1MB | |
65 | dup h# fff and if \ Even GB count? | |
66 | 5 u.r ." MB" \ No, list in MegaBytes | |
67 | else ( n ) ( r: base ) | |
68 | d# 10 rshift 5 u.r ." GB" \ Yes, list in GigaBytes | |
69 | then ( ) ( r: base ) | |
70 | pop-base ( ) | |
71 | ; | |
72 | ||
73 | : next-chunk ( adr,len chunk -- adr+chunk len+chunk ) | |
74 | 2dup > if /string exit then | |
75 | drop + 0 | |
76 | ; | |
77 | ||
78 | : .mem-progress ( megabytes -- megabytes ) | |
79 | \ d# 29 to match ".5GB" check in 'scrub-node' below | |
80 | dup d# 29 rshift 4 mod " -/|\" drop + c@ emit 1 backspaces | |
81 | ; | |
82 | ||
83 | : .initializing ( pa.lo pa.hi len -- pa.lo pa.hi len ) | |
84 | min+mode? if | |
85 | 3dup nip ( pa.lo pa.hi len pa.lo len ) | |
86 | ." Initializing " .megs ." of memory at addr " .nx | |
87 | 1 spaces ( pa.lo pa.hi len ) | |
88 | then | |
89 | ; | |
90 | ||
91 | \ Routine for use with find-node. Scrubs the nodes memory, returning | |
92 | \ false so that every node will be processed. | |
93 | : scrub-node ( node-adr -- false ) | |
94 | node-range pages>phys-adr,len ( pa.lo pa.hi len ) | |
95 | .initializing ( pa.lo pa.hi len ) | |
96 | swap >r ( pa.lo len ) ( r: pa.hi ) | |
97 | min+mode? -rot ( flag pa.lo len ) ( r: pa.hi ) | |
98 | ||
99 | begin ( flag pa.lo len ) ( r: pa.hi ) | |
100 | 2dup r@ swap scrub-4meg ( flag pa.lo len ) ( r: pa.hi ) | |
101 | 4meg next-chunk ( flag pa.lo+ len- ) ( r: pa.hi ) | |
102 | 2 pick if ( flag pa.lo+ len- ) ( r: pa.hi ) | |
103 | \ Slow down idle chatter...only every .5GB or so...often | |
104 | \ enough to indicate "still alive" yet not slow us down | |
105 | dup h# 1ff00000 and 0= if ( flag pa.lo+ len- ) ( r: pa.hi ) | |
106 | .mem-progress ( flag pa.lo+ len- ) ( r: pa.hi ) | |
107 | then ( flag pa.lo+ len- ) ( r: pa.hi ) | |
108 | then ( flag pa.lo+ len- ) ( r: pa.hi ) | |
109 | dup 0<= ( flag pa.lo+ len- ) ( r: pa.hi ) | |
110 | until ( flag pa.lo+ len- ) ( r: pa.hi ) | |
111 | r> 3drop false ( flag false ) | |
112 | swap if (cr d# 70 spaces (cr then ( flag false ) | |
113 | ; | |
114 | ||
115 | headers | |
116 | ||
117 | : scrub-memory ( -- ) | |
118 | memory-clean? @ 0= if | |
119 | physavail ['] scrub-node find-node 2drop | |
120 | first-phys-avail drop 0 4meg map-pages | |
121 | memory-clean? on | |
122 | ['] clear-memory is clear-mem | |
123 | then | |
124 | ; | |
125 | ||
126 | device-end |