aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/head.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc64/kernel/head.S')
-rw-r--r--arch/sparc64/kernel/head.S152
1 files changed, 92 insertions, 60 deletions
diff --git a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S
index 89406f9649a9..f1dcdf8f7433 100644
--- a/arch/sparc64/kernel/head.S
+++ b/arch/sparc64/kernel/head.S
@@ -325,23 +325,7 @@ cheetah_tlb_fixup:
3251: sethi %hi(tlb_type), %g1 3251: sethi %hi(tlb_type), %g1
326 stw %g2, [%g1 + %lo(tlb_type)] 326 stw %g2, [%g1 + %lo(tlb_type)]
327 327
328 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g7,1f) 328 /* Patch copy/page operations to cheetah optimized versions. */
329 ba,pt %xcc, 2f
330 nop
331
3321: /* Patch context register writes to support nucleus page
333 * size correctly.
334 */
335 call cheetah_plus_patch_etrap
336 nop
337 call cheetah_plus_patch_rtrap
338 nop
339 call cheetah_plus_patch_fpdis
340 nop
341 call cheetah_plus_patch_winfixup
342 nop
343
3442: /* Patch copy/page operations to cheetah optimized versions. */
345 call cheetah_patch_copyops 329 call cheetah_patch_copyops
346 nop 330 nop
347 call cheetah_patch_copy_page 331 call cheetah_patch_copy_page
@@ -398,32 +382,79 @@ tlb_fixup_done:
398 nop 382 nop
399 /* Not reached... */ 383 /* Not reached... */
400 384
401/* IMPORTANT NOTE: Whenever making changes here, check 385 /* This is meant to allow the sharing of this code between
402 * trampoline.S as well. -jj */ 386 * boot processor invocation (via setup_tba() below) and
403 .globl setup_tba 387 * secondary processor startup (via trampoline.S). The
404setup_tba: /* i0 = is_starfire */ 388 * former does use this code, the latter does not yet due
405 save %sp, -160, %sp 389 * to some complexities. That should be fixed up at some
390 * point.
391 */
392 .globl setup_trap_table
393setup_trap_table:
394 save %sp, -192, %sp
395
396 /* Force interrupts to be disabled. Transferring over to
397 * the Linux trap table is a very delicate operation.
398 * Until we are actually on the Linux trap table, we cannot
399 * get the PAGE_OFFSET linear mappings translated. We need
400 * that mapping to be setup in order to initialize the firmware
401 * page tables.
402 *
403 * So there is this window of time, from the return from
404 * prom_set_trap_table() until inherit_prom_mappings_post()
405 * (in arch/sparc64/mm/init.c) completes, during which no
406 * firmware address space accesses can be made.
407 */
408 rdpr %pstate, %o1
409 andn %o1, PSTATE_IE, %o1
410 wrpr %o1, 0x0, %pstate
411 wrpr %g0, 15, %pil
406 412
407 rdpr %tba, %g7 413 /* Ok, now make the final valid firmware call to jump over
408 sethi %hi(prom_tba), %o1 414 * to the Linux trap table.
409 or %o1, %lo(prom_tba), %o1 415 */
410 stx %g7, [%o1] 416 call prom_set_trap_table
417 sethi %hi(sparc64_ttable_tl0), %o0
418
419 /* Start using proper page size encodings in ctx register. */
420 sethi %hi(sparc64_kern_pri_context), %g3
421 ldx [%g3 + %lo(sparc64_kern_pri_context)], %g2
422 mov PRIMARY_CONTEXT, %g1
423 stxa %g2, [%g1] ASI_DMMU
424 membar #Sync
425
426 /* The Linux trap handlers expect various trap global registers
427 * to be setup with some fixed values. So here we set these
428 * up very carefully. These globals are:
429 *
430 * Alternate Globals (PSTATE_AG):
431 *
432 * %g6 --> current_thread_info()
433 *
434 * MMU Globals (PSTATE_MG):
435 *
436 * %g1 --> TLB_SFSR
437 * %g2 --> ((_PAGE_VALID | _PAGE_SZ4MB |
438 * _PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
439 * ^ 0xfffff80000000000)
440 * (this %g2 value is used for computing the PAGE_OFFSET kernel
441 * TLB entries quickly, the virtual address of the fault XOR'd
442 * with this %g2 value is the PTE to load into the TLB)
443 * %g3 --> VPTE_BASE_CHEETAH or VPTE_BASE_SPITFIRE
444 *
445 * Interrupt Globals (PSTATE_IG, setup by init_irqwork_curcpu()):
446 *
447 * %g6 --> __irq_work[smp_processor_id()]
448 */
411 449
412 /* Setup "Linux" globals 8-) */
413 rdpr %pstate, %o1 450 rdpr %pstate, %o1
414 mov %g6, %o2 451 mov %g6, %o2
415 wrpr %o1, (PSTATE_AG|PSTATE_IE), %pstate 452 wrpr %o1, PSTATE_AG, %pstate
416 sethi %hi(sparc64_ttable_tl0), %g1
417 wrpr %g1, %tba
418 mov %o2, %g6 453 mov %o2, %g6
419 454
420 /* Set up MMU globals */
421 wrpr %o1, (PSTATE_MG|PSTATE_IE), %pstate
422
423 /* Set fixed globals used by dTLB miss handler. */
424#define KERN_HIGHBITS ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000) 455#define KERN_HIGHBITS ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000)
425#define KERN_LOWBITS (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W) 456#define KERN_LOWBITS (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
426 457 wrpr %o1, PSTATE_MG, %pstate
427 mov TSB_REG, %g1 458 mov TSB_REG, %g1
428 stxa %g0, [%g1] ASI_DMMU 459 stxa %g0, [%g1] ASI_DMMU
429 membar #Sync 460 membar #Sync
@@ -435,17 +466,17 @@ setup_tba: /* i0 = is_starfire */
435 sllx %g2, 32, %g2 466 sllx %g2, 32, %g2
436 or %g2, KERN_LOWBITS, %g2 467 or %g2, KERN_LOWBITS, %g2
437 468
438 BRANCH_IF_ANY_CHEETAH(g3,g7,cheetah_vpte_base) 469 BRANCH_IF_ANY_CHEETAH(g3,g7,8f)
439 ba,pt %xcc, spitfire_vpte_base 470 ba,pt %xcc, 9f
440 nop 471 nop
441 472
442cheetah_vpte_base: 4738:
443 sethi %uhi(VPTE_BASE_CHEETAH), %g3 474 sethi %uhi(VPTE_BASE_CHEETAH), %g3
444 or %g3, %ulo(VPTE_BASE_CHEETAH), %g3 475 or %g3, %ulo(VPTE_BASE_CHEETAH), %g3
445 ba,pt %xcc, 2f 476 ba,pt %xcc, 2f
446 sllx %g3, 32, %g3 477 sllx %g3, 32, %g3
447 478
448spitfire_vpte_base: 4799:
449 sethi %uhi(VPTE_BASE_SPITFIRE), %g3 480 sethi %uhi(VPTE_BASE_SPITFIRE), %g3
450 or %g3, %ulo(VPTE_BASE_SPITFIRE), %g3 481 or %g3, %ulo(VPTE_BASE_SPITFIRE), %g3
451 sllx %g3, 32, %g3 482 sllx %g3, 32, %g3
@@ -471,36 +502,37 @@ spitfire_vpte_base:
471 sllx %o2, 32, %o2 502 sllx %o2, 32, %o2
472 wr %o2, %asr25 503 wr %o2, %asr25
473 504
474 /* Ok, we're done setting up all the state our trap mechanims needs,
475 * now get back into normal globals and let the PROM know what is up.
476 */
4772: 5052:
478 wrpr %g0, %g0, %wstate 506 wrpr %g0, %g0, %wstate
479 wrpr %o1, PSTATE_IE, %pstate 507 wrpr %o1, 0x0, %pstate
480 508
481 call init_irqwork_curcpu 509 call init_irqwork_curcpu
482 nop 510 nop
483 511
484 call prom_set_trap_table 512 /* Now we can turn interrupts back on. */
485 sethi %hi(sparc64_ttable_tl0), %o0
486
487 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g2,g3,1f)
488 ba,pt %xcc, 2f
489 nop
490
4911: /* Start using proper page size encodings in ctx register. */
492 sethi %uhi(CTX_CHEETAH_PLUS_NUC), %g3
493 mov PRIMARY_CONTEXT, %g1
494 sllx %g3, 32, %g3
495 sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
496 or %g3, %g2, %g3
497 stxa %g3, [%g1] ASI_DMMU
498 membar #Sync
499
5002:
501 rdpr %pstate, %o1 513 rdpr %pstate, %o1
502 or %o1, PSTATE_IE, %o1 514 or %o1, PSTATE_IE, %o1
503 wrpr %o1, 0, %pstate 515 wrpr %o1, 0, %pstate
516 wrpr %g0, 0x0, %pil
517
518 ret
519 restore
520
521 .globl setup_tba
522setup_tba: /* i0 = is_starfire */
523 save %sp, -192, %sp
524
525 /* The boot processor is the only cpu which invokes this
526 * routine, the other cpus set things up via trampoline.S.
527 * So save the OBP trap table address here.
528 */
529 rdpr %tba, %g7
530 sethi %hi(prom_tba), %o1
531 or %o1, %lo(prom_tba), %o1
532 stx %g7, [%o1]
533
534 call setup_trap_table
535 nop
504 536
505 ret 537 ret
506 restore 538 restore