···382382 nop383383 /* Not reached... */384384385385-/* IMPORTANT NOTE: Whenever making changes here, check386386- * trampoline.S as well. -jj */387387- .globl setup_tba388388-setup_tba: /* i0 = is_starfire */389389- save %sp, -160, %sp385385+ /* This is meant to allow the sharing of this code between386386+ * boot processor invocation (via setup_tba() below) and387387+ * secondary processor startup (via trampoline.S). The388388+ * former does use this code, the latter does not yet due389389+ * to some complexities. That should be fixed up at some390390+ * point.391391+ */392392+ .globl setup_trap_table393393+setup_trap_table:394394+ save %sp, -192, %sp390395391391- rdpr %tba, %g7392392- sethi %hi(prom_tba), %o1393393- or %o1, %lo(prom_tba), %o1394394- stx %g7, [%o1]396396+ /* Force interrupts to be disabled. Transferring over to397397+ * the Linux trap table is a very delicate operation.398398+ * Until we are actually on the Linux trap table, we cannot399399+ * get the PAGE_OFFSET linear mappings translated. We need400400+ * that mapping to be setup in order to initialize the firmware401401+ * page tables.402402+ *403403+ * So there is this window of time, from the return from404404+ * prom_set_trap_table() until inherit_prom_mappings_post()405405+ * (in arch/sparc64/mm/init.c) completes, during which no406406+ * firmware address space accesses can be made.407407+ */408408+ rdpr %pstate, %o1409409+ andn %o1, PSTATE_IE, %o1410410+ wrpr %o1, 0x0, %pstate411411+ wrpr %g0, 15, %pil395412396396- /* Setup "Linux" globals 8-) */413413+ /* Ok, now make the final valid firmware call to jump over414414+ * to the Linux trap table.415415+ */416416+ call prom_set_trap_table417417+ sethi %hi(sparc64_ttable_tl0), %o0418418+419419+ /* Start using proper page size encodings in ctx register. */420420+ sethi %hi(sparc64_kern_pri_context), %g3421421+ ldx [%g3 + %lo(sparc64_kern_pri_context)], %g2422422+ mov PRIMARY_CONTEXT, %g1423423+ stxa %g2, [%g1] ASI_DMMU424424+ membar #Sync425425+426426+ /* The Linux trap handlers expect various trap global registers427427+ * to be setup with some fixed values. So here we set these428428+ * up very carefully. These globals are:429429+ *430430+ * Alternate Globals (PSTATE_AG):431431+ *432432+ * %g6 --> current_thread_info()433433+ *434434+ * MMU Globals (PSTATE_MG):435435+ *436436+ * %g1 --> TLB_SFSR437437+ * %g2 --> ((_PAGE_VALID | _PAGE_SZ4MB |438438+ * _PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)439439+ * ^ 0xfffff80000000000)440440+ * (this %g2 value is used for computing the PAGE_OFFSET kernel441441+ * TLB entries quickly, the virtual address of the fault XOR'd442442+ * with this %g2 value is the PTE to load into the TLB)443443+ * %g3 --> VPTE_BASE_CHEETAH or VPTE_BASE_SPITFIRE444444+ *445445+ * Interrupt Globals (PSTATE_IG, setup by init_irqwork_curcpu()):446446+ *447447+ * %g6 --> __irq_work[smp_processor_id()]448448+ */449449+397450 rdpr %pstate, %o1398451 mov %g6, %o2399399- wrpr %o1, (PSTATE_AG|PSTATE_IE), %pstate400400- sethi %hi(sparc64_ttable_tl0), %g1401401- wrpr %g1, %tba452452+ wrpr %o1, PSTATE_AG, %pstate402453 mov %o2, %g6403454404404- /* Set up MMU globals */405405- wrpr %o1, (PSTATE_MG|PSTATE_IE), %pstate406406-407407- /* Set fixed globals used by dTLB miss handler. */408455#define KERN_HIGHBITS ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000)409456#define KERN_LOWBITS (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)410410-457457+ wrpr %o1, PSTATE_MG, %pstate411458 mov TSB_REG, %g1412459 stxa %g0, [%g1] ASI_DMMU413460 membar #Sync···466419 sllx %g2, 32, %g2467420 or %g2, KERN_LOWBITS, %g2468421469469- BRANCH_IF_ANY_CHEETAH(g3,g7,cheetah_vpte_base)470470- ba,pt %xcc, spitfire_vpte_base422422+ BRANCH_IF_ANY_CHEETAH(g3,g7,8f)423423+ ba,pt %xcc, 9f471424 nop472425473473-cheetah_vpte_base:426426+8:474427 sethi %uhi(VPTE_BASE_CHEETAH), %g3475428 or %g3, %ulo(VPTE_BASE_CHEETAH), %g3476429 ba,pt %xcc, 2f477430 sllx %g3, 32, %g3478431479479-spitfire_vpte_base:432432+9:480433 sethi %uhi(VPTE_BASE_SPITFIRE), %g3481434 or %g3, %ulo(VPTE_BASE_SPITFIRE), %g3482435 sllx %g3, 32, %g3···502455 sllx %o2, 32, %o2503456 wr %o2, %asr25504457505505- /* Ok, we're done setting up all the state our trap mechanims needs,506506- * now get back into normal globals and let the PROM know what is up.507507- */5084582:509459 wrpr %g0, %g0, %wstate510510- wrpr %o1, PSTATE_IE, %pstate460460+ wrpr %o1, 0x0, %pstate511461512462 call init_irqwork_curcpu513463 nop514464515515- call prom_set_trap_table516516- sethi %hi(sparc64_ttable_tl0), %o0517517-518518- /* Start using proper page size encodings in ctx register. */519519- sethi %hi(sparc64_kern_pri_context), %g3520520- ldx [%g3 + %lo(sparc64_kern_pri_context)], %g2521521- mov PRIMARY_CONTEXT, %g1522522- stxa %g2, [%g1] ASI_DMMU523523- membar #Sync524524-465465+ /* Now we can turn interrupts back on. */525466 rdpr %pstate, %o1526467 or %o1, PSTATE_IE, %o1527468 wrpr %o1, 0, %pstate469469+ wrpr %g0, 0x0, %pil470470+471471+ ret472472+ restore473473+474474+ .globl setup_tba475475+setup_tba: /* i0 = is_starfire */476476+ save %sp, -192, %sp477477+478478+ /* The boot processor is the only cpu which invokes this479479+ * routine, the other cpus set things up via trampoline.S.480480+ * So save the OBP trap table address here.481481+ */482482+ rdpr %tba, %g7483483+ sethi %hi(prom_tba), %o1484484+ or %o1, %lo(prom_tba), %o1485485+ stx %g7, [%o1]486486+487487+ call setup_trap_table488488+ nop528489529490 ret530491 restore