Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: tte.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: @(#)tte.fth 1.1 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 | headerless | |
48 | 1 #pabits lshift 1- constant pa-mask | |
49 | h# 3 constant tteshift | |
50 | h# 8 constant /tte | |
51 | ||
52 | : >tte-writable ( tte -- tte' ) 1 d# 6 lshift or ; | |
53 | : >tte-readonly ( tte -- tte' ) 1 d# 6 lshift invert and ; | |
54 | : >tte-priv ( tte -- tte' ) 1 d# 8 lshift or ; | |
55 | : >tte-cv ( tte -- tte' ) 1 d# 9 lshift or ; | |
56 | : >tte-cp ( tte -- tte' ) 1 d# 10 lshift or ; | |
57 | : >tte-effect ( tte -- tte' ) 1 d# 11 lshift or ; | |
58 | : >tte-invert ( tte -- tte' ) 1 d# 12 lshift or ; | |
59 | : >tte-locked ( tte -- tte' ) 1 d# 61 lshift or ; | |
60 | : >tte-valid ( tte -- tte' ) 1 d# 63 lshift or ; | |
61 | : >tte-global ( tte -- tte' ) 0 or ; | |
62 | : >tte-8k ( tte -- tte' ) 7 invert and 0 or ; | |
63 | : >tte-64k ( tte -- tte' ) 7 invert and 1 or ; | |
64 | : >tte-4m ( tte -- tte' ) 7 invert and 3 or ; | |
65 | : >tte-256m ( tte -- tte' ) 7 invert and 5 or ; | |
66 | ||
67 | : >tte-soft ( tte -- tte' ) h# 30 invert and h# 10 or ; | |
68 | 0 | |
69 | >tte-writable | |
70 | >tte-cv | |
71 | >tte-effect | |
72 | >tte-global | |
73 | >tte-invert | |
74 | constant tte-mode-mask | |
75 | ||
76 | : mode>tte ( mode tte -- tte' ) | |
77 | ||
78 | \ MODE == -1 is the default | |
79 | over true = if nip exit then ( mode tte ) | |
80 | ||
81 | tte-mode-mask invert and ( mode tte" ) | |
82 | over h# 001 and if >tte-writable then ( mode tte" ) | |
83 | over h# 020 and if >tte-cv then ( mode tte" ) | |
84 | over h# 040 and if >tte-effect then ( mode tte" ) | |
85 | over h# 080 and if >tte-global then ( mode tte" ) | |
86 | over h# 100 and if >tte-invert then ( mode tte" ) | |
87 | nip | |
88 | ; | |
89 | : tte>mode ( tte -- mode ) | |
90 | 0 ( tte mode" ) | |
91 | over 0 >tte-writable and if h# 001 or then ( tte mode' ) | |
92 | 2 or \ Always readable ( tte mode' ) | |
93 | 4 or \ Always executable ( tte mode' ) | |
94 | over 0 >tte-cv and if h# 020 or then ( tte mode' ) | |
95 | over 0 >tte-effect and if h# 040 or then ( tte mode' ) | |
96 | over 0 >tte-global and if h# 080 or then ( tte mode' ) | |
97 | over 0 >tte-invert and if h# 100 or then ( tte mode ) | |
98 | nip | |
99 | ; | |
100 | ||
101 | : valid-tte? ( tte -- flag ) 0< ; | |
102 | ||
103 | : tte>size ( tte -- size ) 1 swap 7 and 3 * d# 13 + lshift ; | |
104 | ||
105 | \ Set this as the memory high water mark. | |
106 | variable physmax physmax off | |
107 | ||
108 | headers | |
109 | : memory? ( pa.lo pa.hi -- flag ) drop physmax @ < ; | |
110 | ||
111 | : tte> ( tte -- pa.lo pa.hi ) | |
112 | pa-mask and page#mask and 0 ( pa.lo pa.hi ) | |
113 | ; | |
114 | : >tte ( pa.lo pa.hi -- tte ) | |
115 | 2dup memory? if ( pa.lo pa.hi ) | |
116 | drop 0 >tte-cp >tte-cv ( pa tte ) | |
117 | else ( pa.lo pa.hi ) | |
118 | drop 0 >tte-effect ( pa tte ) | |
119 | then ( pa tte ) | |
120 | swap pa-mask and page#mask and or ( tte ) | |
121 | >tte-valid >tte-writable >tte-priv ( tte ) | |
122 | ; | |
123 | headerless |