Subversion Repositories HelenOS-historic

Rev

Rev 1022 | Rev 1068 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1022 Rev 1058
Line 24... Line 24...
24
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
#
27
#
28
 
28
 
-
 
29
#include "asm.h"
29
#include "regname.h"
30
#include "regname.h"
30
 
31
 
31
.data
32
.data
32
 
33
 
33
flush_buffer:
34
flush_buffer:
34
	.space (L1_CACHE_LINES * L1_CACHE_BYTES)
35
	.space (L1_CACHE_LINES * L1_CACHE_BYTES)
35
 
36
 
36
.text
37
.text
37
 
38
 
38
.global memsetb
39
.global halt
39
.global memcpy
-
 
40
.global flush_instruction_cache
-
 
41
.global jump_to_kernel
40
.global jump_to_kernel
42
 
41
 
43
memsetb:
-
 
44
	rlwimi r5, r5, 8, 16, 23
-
 
45
	rlwimi r5, r5, 16, 0, 15
-
 
46
	
-
 
47
	addi r14, r3, -4
-
 
48
	
-
 
49
	cmplwi 0, r4, 4
-
 
50
	blt 7f
-
 
51
	
-
 
52
	stwu r5, 4(r14)
-
 
53
	beqlr
-
 
54
	
-
 
55
	andi. r15, r14, 3
-
 
56
	add r4, r15, r4
-
 
57
	subf r14, r15, r14
-
 
58
	srwi r15, r4, 2
-
 
59
	mtctr r15
-
 
60
	
-
 
61
	bdz 6f
-
 
62
	
-
 
63
	1:
-
 
64
		stwu r5, 4(r14)
-
 
65
		bdnz 1b
-
 
66
	
-
 
67
	6:
-
 
68
	
-
 
69
	andi. r4, r4, 3
-
 
70
	
-
 
71
	7:
-
 
72
	
-
 
73
	cmpwi 0, r4, 0
-
 
74
	beqlr
-
 
75
	
-
 
76
	mtctr r4
-
 
77
	addi r6, r6, 3
-
 
78
	
-
 
79
	8:
-
 
80
	
-
 
81
	stbu r5, 1(r14)
-
 
82
	bdnz 8b
-
 
83
	
-
 
84
	blr
42
halt:
85
 
-
 
86
memcpy:
-
 
87
	srwi. r7, r5, 3
-
 
88
	addi r6, r3, -4
-
 
89
	addi r4, r4, -4
-
 
90
	beq	2f
-
 
91
	
-
 
92
	andi. r0, r6, 3
-
 
93
	mtctr r7
-
 
94
	bne 5f
-
 
95
	
-
 
96
	1:
-
 
97
	
-
 
98
	lwz r7, 4(r4)
-
 
99
	lwzu r8, 8(r4)
-
 
100
	stw r7, 4(r6)
-
 
101
	stwu r8, 8(r6)
-
 
102
	bdnz 1b
-
 
103
	
-
 
104
	andi. r5, r5, 7
-
 
105
	
-
 
106
	2:
-
 
107
	
-
 
108
	cmplwi 0, r5, 4
-
 
109
	blt 3f
-
 
110
	
-
 
111
	lwzu r0, 4(r4)
-
 
112
	addi r5, r5, -4
-
 
113
	stwu r0, 4(r6)
-
 
114
	
-
 
115
	3:
-
 
116
	
-
 
117
	cmpwi 0, r5, 0
-
 
118
	beqlr
43
	b halt
119
	mtctr r5
-
 
120
	addi r4, r4, 3
-
 
121
	addi r6, r6, 3
-
 
122
	
-
 
123
	4:
-
 
124
	
-
 
125
	lbzu r0, 1(r4)
-
 
126
	stbu r0, 1(r6)
-
 
127
	bdnz 4b
-
 
128
	blr
-
 
129
	
-
 
130
	5:
-
 
131
	
-
 
132
	subfic r0, r0, 4
-
 
133
	mtctr r0
-
 
134
	
-
 
135
	6:
-
 
136
	
-
 
137
	lbz r7, 4(r4)
-
 
138
	addi r4, r4, 1
-
 
139
	stb r7, 4(r6)
-
 
140
	addi r6, r6, 1
-
 
141
	bdnz 6b
-
 
142
	subf r5, r0, r5
-
 
143
	rlwinm. r7, r5, 32-3, 3, 31
-
 
144
	beq 2b
-
 
145
	mtctr r7
-
 
146
	b 1b
-
 
147
	
-
 
148
flush_instruction_cache:
-
 
149
 
-
 
150
	# Flush data cache
-
 
151
	
-
 
152
	lis r3, flush_buffer@h
-
 
153
	ori r3, r3, flush_buffer@l
-
 
154
	li r4, L1_CACHE_LINES
-
 
155
	mtctr r4
-
 
156
	
-
 
157
	0:
-
 
158
	
-
 
159
	lwz r4, 0(r3)
-
 
160
	addi r3, r3, L1_CACHE_BYTES
-
 
161
	bdnz 0b
-
 
162
	
-
 
163
	# Invalidate instruction cache
-
 
164
	
-
 
165
	li r3, 0
-
 
166
	ori	r3, r3, (hid0_ice | hid0_dce | hid0_icfi | hid0_dci)
-
 
167
	mfspr r4, hid0
-
 
168
	or r5, r4, r3
-
 
169
	isync
-
 
170
	mtspr hid0, r5
-
 
171
	sync
-
 
172
	isync
-
 
173
	
-
 
174
	# Enable instruction cache
-
 
175
	
-
 
176
	ori	r5, r4, hid0_ice
-
 
177
	mtspr hid0, r5
-
 
178
	sync
-
 
179
	isync
-
 
180
	blr
-
 
181
 
44
 
182
jump_to_kernel:
45
jump_to_kernel:
183
	
46
	
184
	# r3 = kernel_start (va)
47
	# r3 = memmap (pa)
185
	# r4 = memmap (pa)
48
	# r4 = trans (pa)
-
 
49
	# r5 = number of kernel pages
186
	# r5 = real_mode (pa)
50
	# r6 = real_mode (pa)
187
	
51
	
188
	mtspr srr0, r5
52
	mtspr srr0, r6
189
	
53
	
190
	# jumps to real_mode
54
	# jumps to real_mode
191
	
55
	
192
	mfmsr r5
56
	mfmsr r31
193
	lis r6, ~0@h
57
	lis r30, ~0@h
194
	ori r6, r6, ~(msr_ir | msr_dr)@l
58
	ori r30, r30, ~(msr_ir | msr_dr)@l
195
	and r5, r5, r6
59
	and r31, r31, r30
196
	mtspr srr1, r5
60
	mtspr srr1, r31
197
	rfi
61
	rfi
198
 
62
 
199
.section REALMODE
63
.section REALMODE
200
.align 12
64
.align PAGE_WIDTH
201
.global real_mode
65
.global real_mode
202
 
66
 
203
real_mode:
67
real_mode:
204
 
68
	
-
 
69
	# copy kernel to proper location
-
 
70
	#
-
 
71
	# r4 = trans (pa)
-
 
72
	# r5 = number of kernel pages
-
 
73
	
-
 
74
	li r31, PAGE_SIZE >> 3
-
 
75
	li r30, 0
-
 
76
	
-
 
77
	page_copy:
-
 
78
		
-
 
79
		cmpwi r5, 0
-
 
80
		beq copy_end
-
 
81
		
-
 
82
		# copy single page
-
 
83
		
-
 
84
		mtctr r31
-
 
85
		lwz r29, 0(r4)
-
 
86
		
-
 
87
		copy_loop:
-
 
88
			
-
 
89
			lwz r28, 0(r29)
-
 
90
			stw r28, 0(r30)
-
 
91
			
-
 
92
			addi r29, r29, 4
-
 
93
			addi r30, r30, 4
-
 
94
			
-
 
95
			bdnz copy_loop
-
 
96
		
-
 
97
		subi r5, r5, 1
-
 
98
		addi r4, r4, 4
-
 
99
		b page_copy
-
 
100
	
-
 
101
	copy_end:
-
 
102
		
205
	# fill segment registers
103
	# fill segment registers
206
 
104
 
207
	li r5, 16
105
	li r31, 16
208
	mtctr r5
106
	mtctr r31
209
	li r5, 0
107
	li r31, 0
210
	li r6, 0
108
	li r30, 0x2000
211
	
109
	
212
	seg_fill:
110
	seg_fill:
213
	
111
	
214
		mtsrin r6, r5
112
		mtsrin r30, r31
-
 
113
		
215
		addis r5, r5, 0x1000    # move to next SR
114
		addis r31, r31, 0x1000    # add 256 MB
216
		addis r6, r6, 0x10      # add 256 MB, move to next SR
115
		addi  r30, r30, 0x111     # move to next SR
217
		
116
		
218
		bdnz seg_fill
117
		bdnz seg_fill
219
	
118
	
-
 
119
	# create identity mapping
-
 
120
	
-
 
121
	tlbia
-
 
122
	
220
	# bootstrap kernel
123
	# start the kernel
221
	#
124
	#
222
	# r3 = kernel_start (va)
125
	# r3 = memmap (pa)
-
 
126
	
-
 
127
	lis r31, KERNEL_START_ADDR@ha
223
	# r4 = memmap (pa)       -> r10
128
	addi r31, r31, KERNEL_START_ADDR@l
224
	
129
	
225
	mtspr srr0, r3
130
	mtspr srr0, r31
226
	
131
	
227
	mfmsr r5
132
	mfmsr r31
228
	ori r5, r5, (msr_ir | msr_dr)@l
133
	ori r31, r31, (msr_ir | msr_dr)@l
229
	mtspr srr1, r5
134
	mtspr srr1, r31
230
	
135
	
231
	mr r10, r4
-
 
232
	rfi
136
	rfi
-
 
137
 
-
 
138
.align PAGE_WIDTH
-
 
139
.global trans
-
 
140
trans:
-
 
141
	.space (TRANS_SIZE * TRANS_ITEM_SIZE)