Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: tso_n1_self_mod101.s | |
5 | * Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
6 | * 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
7 | * | |
8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; version 2 of the License. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | * | |
23 | * For the avoidance of doubt, and except that if any non-GPL license | |
24 | * choice is available it will apply instead, Sun elects to use only | |
25 | * the General Public License version 2 (GPLv2) at this time for any | |
26 | * software where a choice of GPL license versions is made | |
27 | * available with the language indicating that GPLv2 or any later version | |
28 | * may be used, or where a choice of which version of the GPL is applied is | |
29 | * otherwise unspecified. | |
30 | * | |
31 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
32 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
33 | * have any questions. | |
34 | * | |
35 | * | |
36 | * ========== Copyright Header End ============================================ | |
37 | */ | |
38 | #define MAIN_BASE_DATA_ADDR 0x160000 | |
39 | #define MAIN_BASE_TEXT_ADDR 0x150000 | |
40 | #define MAIN_BASE_DATA_ADDR_RA 0x100160000 | |
41 | #define MAIN_BASE_TEXT_ADDR_RA 0x100150000 | |
42 | ||
43 | #define USER_PAGE_CUSTOM_MAP | |
44 | #include "hboot.s" | |
45 | ||
46 | SECTION .MAIN TEXT_VA=0x150000, DATA_VA=0x160000 | |
47 | ||
48 | attr_text { | |
49 | Name = .MAIN, | |
50 | VA=MAIN_BASE_TEXT_ADDR, | |
51 | RA=MAIN_BASE_TEXT_ADDR_RA, | |
52 | PA=ra2pa(MAIN_BASE_TEXT_ADDR_RA,0), | |
53 | part_0_ctx_nonzero_tsb_config_0, | |
54 | TTE_G=0, TTE_Context=PCONTEXT, TTE_V=1, TTE_Size=0, TTE_NFO=0, | |
55 | TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, | |
56 | TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_EP=1, TTE_W=1 | |
57 | } | |
58 | attr_data { | |
59 | Name = .MAIN, | |
60 | VA=MAIN_BASE_DATA_ADDR, | |
61 | RA=MAIN_BASE_DATA_ADDR_RA, | |
62 | PA=ra2pa(MAIN_BASE_DATA_ADDR_RA,0), | |
63 | part_0_ctx_nonzero_tsb_config_0, | |
64 | TTE_G=0, TTE_Context=PCONTEXT, TTE_V=1, TTE_Size=0, TTE_NFO=0, | |
65 | TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, | |
66 | TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1 | |
67 | } | |
68 | ||
69 | .text | |
70 | .global main | |
71 | main: clr %l0 | |
72 | ||
73 | ! Case 1: Start from the line state being Invalid, goes to Shared | |
74 | !=============================================================== | |
75 | ||
76 | firstExecuteMain1: | |
77 | set main1,%i0 | |
78 | jmpl %i0,%o7 ! the jump causes a new cache line to be | |
79 | nop ! loaded into the l2 and the icache. | |
80 | nop | |
81 | nop | |
82 | ||
83 | ||
84 | modifyCodeAtMain1: | |
85 | set copied_code, %i0 ! Get known data into the store reg. | |
86 | set main1,%i1 ! Change data at main1 | |
87 | ld [%i1],%l0 ! Bring main1 to D$ for testing | |
88 | ! THIS IS THE NEW FEATURE compared | |
89 | ! to self_mod1 | |
90 | ld [%i0],%l0 | |
91 | st %l0,[%i1] | |
92 | flush %i0 ! flush is mandatory here | |
93 | ||
94 | execute_main1_again: | |
95 | set main1,%i0 | |
96 | jmpl %i0,%o7 | |
97 | nop | |
98 | ||
99 | mov 7, %l1 ! check that the modified instruction | |
100 | sub %l1, %l0, %l1 ! is used and not the original | |
101 | brnz,pn %l1, bad_end | |
102 | nop | |
103 | ||
104 | get_new_cache_line: ! Same thing but with another address | |
105 | set main2, %i0 | |
106 | set new_cache_line, %i1 | |
107 | ld [%i1],%l0 | |
108 | ld [%i0], %l0 | |
109 | st %l0,[%i1] | |
110 | flush %i0 | |
111 | ||
112 | execute_new_cache_line: | |
113 | set new_cache_line,%i0 | |
114 | jmpl %i0,%o7 | |
115 | nop | |
116 | nop | |
117 | set 0xbe, %l1 | |
118 | sub %l1, %l0, %l1 | |
119 | brnz,pn %l1, bad_end | |
120 | nop | |
121 | ||
122 | normal_end: | |
123 | ta T_GOOD_TRAP | |
124 | bad_end: | |
125 | ta T_BAD_TRAP | |
126 | ||
127 | ||
128 | !========================================================================== | |
129 | ! the point of these next two pages is to have text pages that | |
130 | ! can be written and read | |
131 | ! The first page holds 2 cache lines worth, the second page has 1 cache line. | |
132 | !========================================================================== | |
133 | ||
134 | main1: | |
135 | mov 1,%l0 ! Replaced with copied_code second pass | |
136 | jmpl %o7+8, %g0 | |
137 | nop | |
138 | copied_code: | |
139 | mov 7,%l0 | |
140 | nop | |
141 | nop | |
142 | nop | |
143 | nop | |
144 | nop | |
145 | nop | |
146 | nop | |
147 | nop | |
148 | nop | |
149 | nop | |
150 | nop | |
151 | nop | |
152 | new_cache_line: | |
153 | mov 0xbad,%l0 | |
154 | jmpl %o7+8, %g0 | |
155 | nop | |
156 | nop | |
157 | user_text2_end: | |
158 | ||
159 | main2: | |
160 | mov 0xbe,%l0 ! Replaced with copied_code second pass | |
161 | jmpl %o7+8, %g0 | |
162 | nop | |
163 | ||
164 | !====================================== | |
165 | .data | |
166 | user_data_start: | |
167 | .word 0x0 | |
168 | user_data_end: |