Subversion Repositories HelenOS

Rev

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

Rev 2071 Rev 3824
Line 26... Line 26...
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 "asm.h"
30
#include "regname.h"
30
#include "regname.h"
31
#include "debug.inc"
-
 
32
 
31
 
33
.text
32
.text
34
 
33
 
35
.global halt
34
.global halt
36
.global memcpy
35
.global memcpy
Line 138... Line 137...
138
.align PAGE_WIDTH
137
.align PAGE_WIDTH
139
.global real_mode
138
.global real_mode
140
 
139
 
141
real_mode:
140
real_mode:
142
	
141
	
143
	DEBUG_INIT
-
 
144
	DEBUG_real_mode
-
 
145
	
-
 
146
	# copy kernel to proper location
142
	# copy kernel to proper location
147
	#
143
	#
148
	# r5 = trans (pa)
144
	# r5 = trans (pa)
149
	# r6 = bytes to copy
145
	# r6 = bytes to copy
150
	# r8 = framebuffer (pa)
146
	# r8 = framebuffer (pa)
Line 161... Line 157...
161
		# copy page
157
		# copy page
162
		
158
		
163
		mtctr r31
159
		mtctr r31
164
		lwz r29, 0(r5)
160
		lwz r29, 0(r5)
165
		
161
		
166
		DEBUG_INIT
-
 
167
		DEBUG_copy_loop
-
 
168
		
-
 
169
		copy_loop:
162
		copy_loop:
170
			
163
			
171
			lwz r28, 0(r29)
164
			lwz r28, 0(r29)
172
			stw r28, 0(r30)
165
			stw r28, 0(r30)
173
			
166
			
Line 178... Line 171...
178
			cmpwi r6, 0
171
			cmpwi r6, 0
179
			beq copy_end
172
			beq copy_end
180
			
173
			
181
			bdnz copy_loop
174
			bdnz copy_loop
182
			
175
			
183
			DEBUG_end_copy_loop
-
 
184
		
-
 
185
		addi r5, r5, 4
176
		addi r5, r5, 4
186
		b page_copy
177
		b page_copy
187
	
178
	
188
	copy_end:
179
	copy_end:
189
	
180
	
190
	DEBUG_segments
-
 
191
	
-
 
192
	# initially fill segment registers
181
	# initially fill segment registers
193
	
182
	
194
	li r31, 0
183
	li r31, 0
195
	
184
	
196
	li r29, 8
185
	li r29, 8
Line 218... Line 207...
218
		
207
		
219
		bdnz seg_fill_kernel
208
		bdnz seg_fill_kernel
220
	
209
	
221
	# invalidate block address translation registers
210
	# invalidate block address translation registers
222
	
211
	
223
	DEBUG_bat
-
 
224
	
-
 
225
	li r30, 0
212
	li r30, 0
226
	
213
	
227
	mtspr ibat0u, r30
214
	mtspr ibat0u, r30
228
	mtspr ibat0l, r30
215
	mtspr ibat0l, r30
229
	
216
	
Line 249... Line 236...
249
	mtspr dbat3l, r30
236
	mtspr dbat3l, r30
250
	
237
	
251
	# create empty Page Hash Table
238
	# create empty Page Hash Table
252
	# on top of memory, size 64 KB
239
	# on top of memory, size 64 KB
253
	
240
	
254
	DEBUG_pht
-
 
255
	
-
 
256
	lwz r31, 0(r3)                # r31 = memory size
241
	lwz r31, 0(r3)                # r31 = memory size
257
	
242
	
258
	lis r30, 65536@h
243
	lis r30, 65536@h
259
	ori r30, r30, 65536@l         # r30 = 65536
244
	ori r30, r30, 65536@l         # r30 = 65536
260
	
245
	
Line 280... Line 265...
280
		
265
		
281
		cmpwi r30, 0
266
		cmpwi r30, 0
282
		beq clear_end
267
		beq clear_end
283
		
268
		
284
		bdnz pht_clear
269
		bdnz pht_clear
285
 
-
 
286
		DEBUG_end_pht_clear
-
 
287
		
270
		
288
	clear_end:
271
	clear_end:
289
	
272
	
290
#ifdef CONFIG_BAT
273
#ifdef CONFIG_BAT
291
	
274
	
292
	# create BAT identity mapping
275
	# create BAT identity mapping
293
	
276
	
294
	DEBUG_mapping
-
 
295
	
-
 
296
	lwz r31, 0(r3)                # r31 = memory size
277
	lwz r31, 0(r3)                # r31 = memory size
297
	
278
	
298
	lis r29, 0x0002
279
	lis r29, 0x0002
299
	cmpw r31, r29
280
	cmpw r31, r29
300
	blt no_bat                    # less than 128 KB -> no BAT
281
	blt no_bat                    # less than 128 KB -> no BAT
Line 313... Line 294...
313
		srw r30, r31, r29         # r30 = mask >> 1
294
		srw r30, r31, r29         # r30 = mask >> 1
314
		or r31, r31, r30          # mask = mask | r30
295
		or r31, r31, r30          # mask = mask | r30
315
		
296
		
316
		bdnz bat_mask
297
		bdnz bat_mask
317
	
298
	
318
	DEBUG_bat_mask
-
 
319
	
-
 
320
	andi. r31, r31, 0x07ff        # mask = mask & 0x07ff (BAT can map up to 256 MB)
299
	andi. r31, r31, 0x07ff        # mask = mask & 0x07ff (BAT can map up to 256 MB)
321
	
300
	
322
	li r29, 2
301
	li r29, 2
323
	slw r31, r31, r29             # mask = mask << 2
302
	slw r31, r31, r29             # mask = mask << 2
324
	ori r31, r31, 0x0002          # mask = mask | 0x0002 (priviledged access only)
303
	ori r31, r31, 0x0002          # mask = mask | 0x0002 (priviledged access only)
Line 334... Line 313...
334
	
313
	
335
	mtspr dbat0u, r29
314
	mtspr dbat0u, r29
336
	mtspr dbat0l, r30
315
	mtspr dbat0l, r30
337
	
316
	
338
	no_bat:
317
	no_bat:
339
 
-
 
340
#endif
-
 
341
	
318
	
342
	DEBUG_tlb
319
#endif
343
	
320
	
344
	tlbia
321
	tlbia
345
	tlbsync
322
	tlbsync
346
	
323
	
347
	DEBUG_prepare
-
 
348
	
-
 
349
	# start the kernel
324
	# start the kernel
350
	#
325
	#
351
	# pc = KERNEL_START_ADDR
326
	# pc = KERNEL_START_ADDR
352
	# r3 = bootinfo (pa)
327
	# r3 = bootinfo (pa)
353
	# sprg0 = KA2PA(KERNEL_START_ADDR)
328
	# sprg0 = KA2PA(KERNEL_START_ADDR)
Line 371... Line 346...
371
	ori r31, r31, (msr_ir | msr_dr)@l
346
	ori r31, r31, (msr_ir | msr_dr)@l
372
	mtspr srr1, r31
347
	mtspr srr1, r31
373
	
348
	
374
	sync
349
	sync
375
	isync
350
	isync
376
	
-
 
377
	DEBUG_rfi
-
 
378
	rfi
351
	rfi
379
 
352
 
380
.align PAGE_WIDTH
353
.align PAGE_WIDTH
381
.global trans
354
.global trans
382
trans:
355
trans: