1
2
3
4
5
6
7
8
9
10 #undef DEBUGPICA
11
12 #include <linux/tasks.h>
13
14 #include <asm/segment.h>
15 #include <asm/cachectl.h>
16 #include <asm/mipsregs.h>
17 #include <asm/mipsconfig.h>
18 #include <asm/stackframe.h>
19 #include <asm/regdef.h>
20 #include <asm/bootinfo.h>
21 #include <asm/segment.h>
22
23 #define PAGE_SIZE 0x1000
24
25
26
27
28
29
30
31 #define PAGE_TABLE 0x0580
32 #define PAGE_SHARED 0x0580
33 #define MODE_ALIAS 0x0016
34
35 .globl _empty_bad_page
36 .globl _empty_bad_page_table
37 .globl _pg0
38 .globl _empty_zero_page
39 .globl _swapper_pg_dir
40
41 .text
42 .globl _kernelbase
43 _kernelbase:
44
45
46
47
48
49
50
51
52 .set noreorder
53 .set noat
54 except_vec0:
55 #if KERNELBASE == KSEG1
56 la k0,1f
57 jr k0
58 nop
59 1:
60 #endif
61 dmfc0 k1,CP0_CONTEXT
62 dsra k1,k1,1
63 lwu k0,(k1) # May cause another exception
64 lwu k1,4(k1)
65 dsrl k0,k0,6 # Convert to EntryLo format
66 dsrl k1,k1,6 # Convert to EntryLo format
67 dmtc0 k0,CP0_ENTRYLO0
68 dmtc0 k1,CP0_ENTRYLO1
69 tlbwr
70 eret
71
72
73
74
75
76 .org except_vec0+0x80
77 except_vec1:
78 #if KERNELBASE == KSEG1
79 la k0,1f
80 jr k0
81 nop
82 1:
83 #endif
84 la a0,xtlb_text
85 jal _panic
86 nop
87 1: j 1b
88 nop
89 xtlb_text: .asciz "XTLB Refill exception.\n"
90
91
92
93
94 .org except_vec1+0x80
95 except_vec2:
96 #if KERNELBASE == KSEG1
97 la k0,1f
98 jr k0
99 nop
100 1:
101 #endif
102
103
104
105 la a0,xtlb_text
106 jal _panic
107 nop
108 1: j 1b
109 nop
110 cache_text: .asciz "Cache error exception\n"
111
112
113
114
115 .org except_vec2+0x80
116 except_vec3:
117
118
119
120 #if KERNELBASE == KSEG1
121 la k0,1f
122 jr k0
123 nop
124 1:
125 #endif
126 .set noat
127 mfc0 k1,CP0_CAUSE
128 la k0,_exception_handlers
129
130
131
132
133
134 andi k1,k1,0x7c
135 addu k0,k0,k1
136 lw k0,(k0)
137 FILL_LDS
138 jr k0
139 nop
140
141
142
143
144
145
146 .set noreorder
147 .set at
148 kernel_entry:
149 jal refill
150 nop
151
152
153
154
155 la t0,__edata
156 la t1,__end
157 sw zero,(t0)
158 1: addiu t0,t0,4
159 bnel t0,t1,1b
160 sw zero,(t0)
161
162 #ifdef DEBUGPICA
163 la t0,_boot_info
164 lw t0,OFFSET_BOOTINFO_VRAM_BASE(t0)
165 li t1,0x0f00 + '3'
166 sh t1,4(t0)
167 #endif
168
169 .set noreorder
170 jal _tlbflush
171 mtc0 zero,CP0_WIRED
172
173
174
175 la t0,_end
176 la t1,0x003ffffc
177 la t2,KERNELBASE
178 or t1,t2
179 li t2,0xdeadbeef
180 1: sw t2,(t0)
181 bne t0,t1,1b
182 addiu t0,t0,4
183
184
185
186 .set reorder
187 jal setup_paging
188 #if KERNELBASE == KSEG0
189 jal _sys_cacheflush
190 #endif
191
192 #ifdef DEBUGPICA
193 la t0,_boot_info
194 lw t0,OFFSET_BOOTINFO_VRAM_BASE(t0)
195 li t1,0x0f00 + '4'
196 sh t1,6(t0)
197 #endif
198
199
200
201 la sp,_init_user_stack+PAGE_SIZE-24
202 sw sp,_kernelsp
203
204 1: jal _start_kernel
205
206
207
208
209 j 1b
210
211
212
213
214
215
216
217
218 .set noreorder
219 setup_paging:
220
221
222
223
224 la t0,_boot_info
225 lw t1,OFFSET_BOOTINFO_MACHTYPE(t0)
226 sll t1,t1,2 # machtype used as index
227 la t0,map0table
228 addu t0,t0,t1
229 lw t0,(t0) # get base address
230
231
232
233
234
235 lw t1,(t0) # number of wired TLB entries
236 move t2,zero # TLB entry counter
237 addiu t3,t1,1 # wire one additional entry
238 beqz t1,2f # null, exit
239 mtc0 t3,CP0_WIRED # delay slot
240 addiu t0,t0,8
241 1: lw t4,24(t0) # PageMask
242 ld t5,0(t0) # entryHi
243 ld t6,8(t0) # entryLo0
244 ld t7,16(t0) # entryLo1
245 addiu t2,t2,1 # increment ctr
246 mtc0 t2,CP0_INDEX # set TLB entry
247 mtc0 t4,CP0_PAGEMASK
248 dmtc0 t5,CP0_ENTRYHI
249 dmtc0 t6,CP0_ENTRYLO0
250 dmtc0 t7,CP0_ENTRYLO1
251 tlbwi
252 bne t1,t2,1b # next TLB entry
253 addiu t0,t0,32 # delay slot
254
255
256
257
258
259 2: li t0,PM_4K
260 mtc0 t0,CP0_PAGEMASK
261
262 la t1,_swapper_pg_dir # swapper_pg_dir is at 0x1000
263 la t2,_swapper_pg_dir+(PAGE_SIZE-4)
264 1: sw zero,(t1)
265 bne t1,t2,1b
266 addiu t1,t1,4 # delay slot
267
268
269
270
271
272 la t0,_pg0 # swapper_pg_dir is at 0x1000
273 la t1,_pg0+PAGE_SIZE
274 li t2,KERNELBASE
275 addu t0,t2
276 addu t1,t2
277 1: sw zero,(t0)
278 addiu t0,t0,4
279 bne t0,t1,1b
280 addiu t2,t2,4 # delay slot
281
282
283
284
285
286
287 la t0,_pg0+PAGE_TABLE # set valid bit/user r/w
288 sw t0,_swapper_pg_dir
289
290 li t0,PAGE_SHARED # set valid bit/user r/w
291 la t1,_pg0
292 la t2,_pg0+PAGE_SIZE
293 li t3,KERNELBASE
294 addu t1,t3
295 addu t2,t3
296 1: sw t0,(t1)
297 addiu t1,t1,4
298 bne t1,t2,1b
299 addiu t0,t0,PAGE_SIZE # delay slot
300
301
302
303
304 mtc0 zero,CP0_INDEX
305 la t0,TLB_ROOT
306 dmtc0 t0,CP0_ENTRYHI
307 la t0,_swapper_pg_dir
308 srl t0,t0,6
309 ori t0,t0,MODE_ALIAS # uncachable, dirty, valid
310 dmtc0 t0,CP0_ENTRYLO0
311 dmtc0 zero,CP0_ENTRYLO1
312 tlbwi
313
314
315
316 la t0,_pg0
317 li t0,KERNELBASE
318 addu t0,t1
319 sw zero,(t0)
320
321
322
323
324
325
326 li t0,TLBMAP
327 dsll t0,t0,1
328 jr ra
329 dmtc0 t0,CP0_CONTEXT # delay slot
330
331
332
333
334
335
336
337
338 .globl _tlbflush
339 _tlbflush: li t0,PM_4K
340 mtc0 t0,CP0_PAGEMASK
341 lw t0,_boot_info+OFFSET_BOOTINFO_TLB_ENTRIES(t0)
342 dmtc0 zero,CP0_ENTRYLO0
343 dmtc0 zero,CP0_ENTRYLO1
344 mfc0 t2,CP0_WIRED
345 1: subu t0,t0,1
346 mtc0 t0,CP0_INDEX
347 lui t1,0x0008
348 or t1,t0,t1
349 dsll t1,t1,13
350 dmtc0 t1,CP0_ENTRYHI
351 bne t2,t0,1b
352 tlbwi # delay slot
353 jr ra
354 nop
355
356
357
358
359 #include <asm/mipsconfig.h>
360 #include <asm/regdef.h>
361 #include <asm/segment.h>
362
363 #define PAGE_SIZE 0x1000
364
365 #define CACHELINES 512
366
367 .set noreorder
368 .text
369 refill:
370
371
372
373 li t0,KSEG0
374 li t1,CACHELINES
375 1: cache 21,0(t0)
376 cache 21,32(t0)
377 cache 21,64(t0)
378 cache 21,96(t0)
379 cache 21,128(t0)
380 cache 21,160(t0)
381 cache 21,192(t0)
382 cache 21,224(t0)
383 cache 21,256(t0)
384 cache 21,288(t0)
385 cache 21,320(t0)
386 cache 21,352(t0)
387 cache 21,384(t0)
388 cache 21,416(t0)
389 cache 21,448(t0)
390 cache 21,480(t0)
391 subu t1,t1,1
392 bnez t1,1b
393 addiu t0,t0,512 # delay slot
394
395 jr ra
396 nop
397
398
399
400
401 .globl _beep
402 _beep: lw t0,beepflag
403 nop
404 bnez t0,1f
405 lbu t0,0xe0000061
406 xori t0,t0,3
407 sb t0,0xe0000061
408 li t0,1
409 sw t0,beepflag
410 1: jr ra
411 nop
412
413
414
415
416 .globl _csum
417 #if 0
418 _csum: jal _sys_cacheflush
419 move t8,ra # delay slot
420 #else
421 _csum: move t8,ra
422 #endif
423 li t0,KSEG1
424 la t1,final
425 li t2,KSEG1
426 or t0,t2
427 or t1,t2
428 move v0,zero
429 1: lw t2,(t0)
430 addiu t0,t0,4
431 bne t0,t1,1b
432 xor v0,v0,t2
433 jr t8
434 nop
435 final:
436
437 .data
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452 map0table: .word map0_dummy # machtype = unknown
453 .word map0_tyne # Deskstation Tyne
454 .word map0_pica61 # Acer Pica-61
455
456 map0_dummy: .word 0 # 0 entries
457
458
459
460
461 .align 8
462
463 map0_tyne: .word 3 # no. of wired TLB entries
464 .word 0 # pad for alignment
465
466
467
468 .quad 0xffffffffe0000000 # TLB #0 EntryHi
469 .quad 0x24000017 # TLB #0 EntryLo0
470 .quad 0 # TLB #0 EntryLo1
471 .word PM_64K # page mask
472 .word 0 # pad for alignment
473
474
475
476 .quad 0xffffffffe1000000 # TLB #1 EntryHi
477 .quad 0x04000017 # TLB #1 EntryLo0
478 .quad 0 # TLB #1 EntryLo1
479 .word PM_1M
480 .word 0 # pad for alignment
481
482
483
484 .quad 0xffffffffe2000000 # TLB #2 EntryHi
485 .quad 0x04020017 # TLB #2 EntryLo0
486 .quad 0 # TLB #2 EntryLo1
487 .word PM_1M
488 .word 0 # pad for alignment
489
490
491
492
493
494
495
496
497
498
499
500
501 map0_pica61: .word 9 # no. wired TLB entries
502 .word 0 # dummy
503
504
505
506 # .quad 0xffffffffe1000000 # BIOS mapping
507 .quad 0xffffffffe4000000 # new mapping
508 .quad 0x03ffc013
509 .quad 0x00000001 # global, not valid
510 .word PM_256K
511 .word 0
512
513
514
515 .quad 0xffffffffe0000000
516 .quad 0x02000017
517 .quad 0x00000001 # global, not valid
518 .word PM_64K
519 .word 0
520
521
522
523 .quad 0xffffffffe00e0000
524 .quad 0x02003817
525 .quad 0x02003c17
526 .word PM_64K
527 .word 0
528
529
530
531 .quad 0xffffffffe0100000
532 .quad 0x03c00017
533 .quad 0x00000001 # global, not valid
534 .word PM_4K
535 .word 0
536
537
538
539 .quad 0xffffffffe0200000
540 .quad 0x01800017
541 .quad 0x01804017
542 .word PM_1M
543 .word 0
544
545
546
547 .quad 0xffffffffe0400000
548 .quad 0x01808017
549 .quad 0x0180c017
550 .word PM_1M
551 .word 0
552
553
554
555 .quad 0xffffffffe0800000
556 .quad 0x01000017
557 .quad 0x01010017
558 .word PM_4M
559 .word 0
560
561
562
563 # .quad 0xffffffffe1000000
564 # .quad 0x01000017
565 # .quad 0x01010017
566 # .word PM_4M
567 # .word 0
568
569
570
571 .quad 0xffffffffe2000000
572 .quad 0x02400017
573 .quad 0x02440017
574 .word PM_16M
575 .word 0
576
577
578
579 .quad 0xffffffffffffe000
580 .quad 0x00000001 # nonsense...
581 .quad 0x0001ffd7
582 .word PM_4K
583 .word 0
584
585
586
587
588
589
590 #if 0
591 map0_pica61: .word 11 # no. wired TLB entries
592 .word 0 # dummy
593
594
595
596 .quad 0xfffffffffffe2000
597 .quad 0x0000029e
598 .quad 0x00000000
599 .word PM_4K
600 .word 0
601
602
603
604 .quad 0xffffffffe1000000
605 .quad 0x03ffc013
606 .quad 0x00000001 # nonsense ...
607 .word PM_256K
608 .word 0
609
610
611
612 .quad 0xffffffffe0000000
613 .quad 0x02000017
614 .quad 0x00000001 # nonsense ...
615 .word PM_64K
616 .word 0
617
618
619
620 .quad 0xffffffffe00e0000
621 .quad 0x02003817
622 .quad 0x02003c17
623 .word PM_64K
624 .word 0
625
626
627
628 .quad 0xffffffffe0100000
629 .quad 0x03c00017
630 .quad 0x00000001 # nonsense ...
631 .word PM_4K
632 .word 0
633
634
635
636 .quad 0xffffffffe0200000
637 .quad 0x01800017
638 .quad 0x01804017
639 .word PM_1M
640 .word 0
641
642
643
644 .quad 0xffffffffe0400000
645 .quad 0x01808017
646 .quad 0x0180c017
647 .word PM_1M
648 .word 0
649
650
651
652 .quad 0xffffffffe0800000
653 .quad 0x01000017
654 .quad 0x01010017
655 .word PM_4M
656 .word 0
657
658
659
660 .quad 0xffffffffe2000000
661 .quad 0x02400017
662 .quad 0x02440017
663 .word PM_16M
664 .word 0
665
666
667
668 .quad 0xffffffffffffe000
669 .quad 0x00000001 # nonsense...
670 .quad 0x0001ffd7
671 .word PM_4K
672 .word 0
673
674
675
676 .quad 0xffffffff10000000
677 .quad 0x0000141f
678 .quad 0x00000001 # nonsense
679 .word PM_64K
680 .word 0
681 #endif
682
683
684
685
686
687
688
689
690
691
692
693 .text
694
695 .org 0x1000
696 _swapper_pg_dir = 0x1000
697
698
699
700
701 .org 0x2000
702 _pg0 = 0x2000
703
704 .org 0x3000
705 _empty_bad_page = 0x3000
706
707 .org 0x4000
708 _empty_bad_page_table = 0x4000
709
710 .org 0x5000
711 _empty_zero_page = 0x5000
712
713 .org 0x6000
714
715 #if defined (CONFIG_DESKSTATION_TYNE) && !defined (CONFIG_ACER_PICA_61)
716 #if 0
717
718
719
720
721
722 .globl _tmp_floppy_area
723 _tmp_floppy_area: .fill 1024,1,0
724 #endif
725
726
727
728
729
730
731 .globl _floppy_track_buffer
732 _floppy_track_buffer: .fill 512*2*36,1,0
733 #endif
734 .globl _kernelsp
735 _kernelsp: .word 0
736 beepflag: .word 0