/* This file is subject to the terms and conditions of the GNU General Public1* License. See the file "COPYING" in the main directory of this archive2* for more details.3*4* Copyright (C) 1999-2007 by Helge Deller <[email protected]>5* Copyright 1999 SuSE GmbH (Philipp Rumpf)6* Copyright 1999 Philipp Rumpf ([email protected])7* Copyright 2000 Hewlett Packard (Paul Bame, [email protected])8* Copyright (C) 2001 Grant Grundler (Hewlett Packard)9* Copyright (C) 2004 Kyle McMartin <[email protected]>10*11* Initial Version 04-23-1999 by Helge Deller <[email protected]>12*/1314#include <asm/asm-offsets.h>15#include <asm/psw.h>16#include <asm/pdc.h>1718#include <asm/assembly.h>1920#include <linux/linkage.h>21#include <linux/init.h>22#include <linux/pgtable.h>2324.level 1.12526__INITDATA27ENTRY(boot_args)28.word 0 /* arg0 */29.word 0 /* arg1 */30.word 0 /* arg2 */31.word 0 /* arg3 */32END(boot_args)3334__HEAD3536.align 437.import init_task,data38.import init_stack,data39.import fault_vector_20,code /* IVA parisc 2.0 32 bit */40#ifndef CONFIG_64BIT41.import fault_vector_11,code /* IVA parisc 1.1 32 bit */42.import $global$ /* forward declaration */43#endif /*!CONFIG_64BIT*/44ENTRY(parisc_kernel_start)45.proc46.callinfo4748/* Make sure sr4-sr7 are set to zero for the kernel address space */49mtsp %r0,%sr450mtsp %r0,%sr551mtsp %r0,%sr652mtsp %r0,%sr75354/* Clear BSS (shouldn't the boot loader do this?) */5556.import __bss_start,data57.import __bss_stop,data5859load32 PA(__bss_start),%r360load32 PA(__bss_stop),%r461$bss_loop:62cmpb,<<,n %r3,%r4,$bss_loop63stw,ma %r0,4(%r3)6465/* Save away the arguments the boot loader passed in (32 bit args) */66load32 PA(boot_args),%r167stw,ma %arg0,4(%r1)68stw,ma %arg1,4(%r1)69stw,ma %arg2,4(%r1)70stw,ma %arg3,4(%r1)7172#if defined(CONFIG_PA20)73/* check for 64-bit capable CPU as required by current kernel */74ldi 32,%r1075mtctl %r10,%cr1176.level 2.077mfctl,w %cr11,%r1078.level 1.179comib,<>,n 0,%r10,$cpu_ok8081load32 PA(msg1),%arg082ldi msg1_end-msg1,%arg183$iodc_panic:84copy %arg0, %r1085copy %arg1, %r1186load32 PA(init_stack),%sp87#define MEM_CONS 0x3A088ldw MEM_CONS+32(%r0),%arg0 // HPA89ldi ENTRY_IO_COUT,%arg190ldw MEM_CONS+36(%r0),%arg2 // SPA91ldw MEM_CONS+8(%r0),%arg3 // layers92load32 PA(__bss_start),%r193stw %r1,-52(%sp) // arg494stw %r0,-56(%sp) // arg595stw %r10,-60(%sp) // arg6 = ptr to text96stw %r11,-64(%sp) // arg7 = len97stw %r0,-68(%sp) // arg898load32 PA(.iodc_panic_ret), %rp99ldw MEM_CONS+40(%r0),%r1 // ENTRY_IODC100bv,n (%r1)101.iodc_panic_ret:102b . /* wait endless with ... */103or %r10,%r10,%r10 /* qemu idle sleep */104msg1: .ascii "Can't boot kernel which was built for PA8x00 CPUs on this machine.\r\n"105msg1_end:106107$cpu_ok:108#endif109110.level PA_ASM_LEVEL111112/* Initialize startup VM. Just map first 16/32 MB of memory */113load32 PA(swapper_pg_dir),%r4114mtctl %r4,%cr24 /* Initialize kernel root pointer */115mtctl %r4,%cr25 /* Initialize user root pointer */116117#if CONFIG_PGTABLE_LEVELS == 3118/* Set pmd in pgd */119load32 PA(pmd0),%r5120shrd %r5,PxD_VALUE_SHIFT,%r3121ldo (PxD_FLAG_PRESENT+PxD_FLAG_VALID)(%r3),%r3122stw %r3,ASM_PGD_ENTRY*ASM_PGD_ENTRY_SIZE(%r4)123ldo ASM_PMD_ENTRY*ASM_PMD_ENTRY_SIZE(%r5),%r4124#else125/* 2-level page table, so pmd == pgd */126ldo ASM_PGD_ENTRY*ASM_PGD_ENTRY_SIZE(%r4),%r4127#endif128129/* Fill in pmd with enough pte directories */130load32 PA(pg0),%r1131SHRREG %r1,PxD_VALUE_SHIFT,%r3132ldo (PxD_FLAG_PRESENT+PxD_FLAG_VALID)(%r3),%r3133134ldi ASM_PT_INITIAL,%r11351361:137stw %r3,0(%r4)138ldo (PAGE_SIZE >> PxD_VALUE_SHIFT)(%r3),%r3139addib,> -1,%r1,1b140#if CONFIG_PGTABLE_LEVELS == 3141ldo ASM_PMD_ENTRY_SIZE(%r4),%r4142#else143ldo ASM_PGD_ENTRY_SIZE(%r4),%r4144#endif145146147/* Now initialize the PTEs themselves. We use RWX for148* everything ... it will get remapped correctly later */149ldo 0+_PAGE_KERNEL_RWX(%r0),%r3 /* Hardwired 0 phys addr start */150load32 (1<<(KERNEL_INITIAL_ORDER-PAGE_SHIFT)),%r11 /* PFN count */151load32 PA(pg0),%r1152153$pgt_fill_loop:154STREGM %r3,ASM_PTE_ENTRY_SIZE(%r1)155ldo (1<<PFN_PTE_SHIFT)(%r3),%r3 /* add one PFN */156addib,> -1,%r11,$pgt_fill_loop157nop158159/* Load the return address...er...crash 'n burn */160copy %r0,%r2161162/* And the RFI Target address too */163load32 start_parisc,%r11164165/* And the initial task pointer */166load32 init_task,%r6167mtctl %r6,%cr30168169/* And the stack pointer too */170load32 init_stack,%sp171tophys_r1 %sp172#if defined(CONFIG_64BIT) && defined(CONFIG_FUNCTION_TRACER)173.import _mcount,data174/* initialize mcount FPTR */175/* Get the global data pointer */176loadgp177load32 PA(_mcount), %r10178std %dp,0x18(%r10)179#endif180181#define MEM_PDC_LO 0x388182#define MEM_PDC_HI 0x35C183#ifdef CONFIG_64BIT184/* Get PDCE_PROC for monarch CPU. */185ldw MEM_PDC_LO(%r0),%r3186ldw MEM_PDC_HI(%r0),%r10187depd %r10, 31, 32, %r3 /* move to upper word */188#endif189190191#ifdef CONFIG_SMP192/* Set the smp rendezvous address into page zero.193** It would be safer to do this in init_smp_config() but194** it's just way easier to deal with here because195** of 64-bit function ptrs and the address is local to this file.196*/197load32 PA(smp_slave_stext),%r10198stw %r10,0x10(%r0) /* MEM_RENDEZ */199stw %r0,0x28(%r0) /* MEM_RENDEZ_HI - assume addr < 4GB */200201/* FALLTHROUGH */202.procend203204#ifdef CONFIG_HOTPLUG_CPU205/* common_stext is far away in another section... jump there */206load32 PA(common_stext), %rp207bv,n (%rp)208209/* common_stext and smp_slave_stext needs to be in text section */210.text211#endif212213/*214** Code Common to both Monarch and Slave processors.215** Entry:216**217** 1.1:218** %r11 must contain RFI target address.219** %r25/%r26 args to pass to target function220** %r2 in case rfi target decides it didn't like something221**222** 2.0w:223** %r3 PDCE_PROC address224** %r11 RFI target address225**226** Caller must init: SR4-7, %sp, %r10, %cr24/25,227*/228common_stext:229.proc230.callinfo231#else232/* Clear PDC entry point - we won't use it */233stw %r0,0x10(%r0) /* MEM_RENDEZ */234stw %r0,0x28(%r0) /* MEM_RENDEZ_HI */235#endif /*CONFIG_SMP*/236237#ifdef CONFIG_64BIT238mfctl %cr30,%r6 /* PCX-W2 firmware bug */239tophys_r1 %r6240241/* Save the rfi target address */242STREG %r11, TASK_PT_GR11(%r6)243/* Switch to wide mode Superdome doesn't support narrow PDC244** calls.245*/2461: mfia %rp /* clear upper part of pcoq */247ldo 2f-1b(%rp),%rp248depdi 0,31,32,%rp249bv (%rp)250ssm PSW_SM_W,%r0251252/* Set Wide mode as the "Default" (eg for traps)253** First trap occurs *right* after (or part of) rfi for slave CPUs.254** Someday, palo might not do this for the Monarch either.255*/2562:257258ldo PDC_PSW(%r0),%arg0 /* 21 */259ldo PDC_PSW_SET_DEFAULTS(%r0),%arg1 /* 2 */260ldo PDC_PSW_WIDE_BIT(%r0),%arg2 /* 2 */261load32 PA(stext_pdc_ret), %rp262bv (%r3)263copy %r0,%arg3264265stext_pdc_ret:266LDREG TASK_PT_GR11(%r6), %r11267tovirt_r1 %r6268mtctl %r6,%cr30 /* restore task thread info */269#endif270271#ifndef CONFIG_64BIT272/* clear all BTLBs */273ldi PDC_BLOCK_TLB,%arg0274load32 PA(stext_pdc_btlb_ret), %rp275ldw MEM_PDC_LO(%r0),%r3276bv (%r3)277ldi PDC_BTLB_PURGE_ALL,%arg1278stext_pdc_btlb_ret:279#endif280281/* PARANOID: clear user scratch/user space SR's */282mtsp %r0,%sr0283mtsp %r0,%sr1284mtsp %r0,%sr2285mtsp %r0,%sr3286287/* Initialize Protection Registers */288mtctl %r0,%cr8289mtctl %r0,%cr9290mtctl %r0,%cr12291mtctl %r0,%cr13292293/* Initialize the global data pointer */294loadgp295296/* Set up our interrupt table. HPMCs might not work after this!297*298* We need to install the correct iva for PA1.1 or PA2.0. The299* following short sequence of instructions can determine this300* (without being illegal on a PA1.1 machine).301*/302#ifndef CONFIG_64BIT303ldi 32,%r10304mtctl %r10,%cr11305.level 2.0306mfctl,w %cr11,%r10307.level 1.1308comib,<>,n 0,%r10,$is_pa20309ldil L%PA(fault_vector_11),%r10310b $install_iva311ldo R%PA(fault_vector_11)(%r10),%r10312313$is_pa20:314.level PA_ASM_LEVEL /* restore 1.1 || 2.0w */315#endif /*!CONFIG_64BIT*/316load32 PA(fault_vector_20),%r10317318$install_iva:319mtctl %r10,%cr14320321b aligned_rfi /* Prepare to RFI! Man all the cannons! */322nop323324.align 128325aligned_rfi:326pcxt_ssm_bug327328copy %r3, %arg0 /* PDCE_PROC for smp_callin() */329330rsm PSW_SM_QUIET,%r0 /* off troublesome PSW bits */331/* Don't need NOPs, have 8 compliant insn before rfi */332333mtctl %r0,%cr17 /* Clear IIASQ tail */334mtctl %r0,%cr17 /* Clear IIASQ head */335336/* Load RFI target into PC queue */337mtctl %r11,%cr18 /* IIAOQ head */338ldo 4(%r11),%r11339mtctl %r11,%cr18 /* IIAOQ tail */340341load32 KERNEL_PSW,%r10342mtctl %r10,%ipsw343344tovirt_r1 %sp345346/* Jump through hyperspace to Virt Mode */347rfi348nop349350.procend351352#ifdef CONFIG_SMP353354.import smp_init_current_idle_task,data355.import smp_callin,code356357#ifndef CONFIG_64BIT358smp_callin_rtn:359.proc360.callinfo361break 1,1 /* Break if returned from start_secondary */362nop363nop364.procend365#endif /*!CONFIG_64BIT*/366367/***************************************************************************368* smp_slave_stext is executed by all non-monarch Processors when the Monarch369* pokes the slave CPUs in smp.c:smp_boot_cpus().370*371* Once here, registers values are initialized in order to branch to virtual372* mode. Once all available/eligible CPUs are in virtual mode, all are373* released and start out by executing their own idle task.374*****************************************************************************/375smp_slave_stext:376.proc377.callinfo378379/*380** Initialize Space registers381*/382mtsp %r0,%sr4383mtsp %r0,%sr5384mtsp %r0,%sr6385mtsp %r0,%sr7386387#ifdef CONFIG_64BIT388/*389* Enable Wide mode early, in case the task_struct for the idle390* task in smp_init_current_idle_task was allocated above 4GB.391*/3921: mfia %rp /* clear upper part of pcoq */393ldo 2f-1b(%rp),%rp394depdi 0,31,32,%rp395bv (%rp)396ssm PSW_SM_W,%r03972:398#endif399400/* Initialize the SP - monarch sets up smp_init_current_idle_task */401load32 PA(smp_init_current_idle_task),%r6402LDREG 0(%r6),%r6403mtctl %r6,%cr30404tophys_r1 %r6405LDREG TASK_STACK(%r6),%sp406tophys_r1 %sp407ldo FRAME_SIZE(%sp),%sp408409/* point CPU to kernel page tables */410load32 PA(swapper_pg_dir),%r4411mtctl %r4,%cr24 /* Initialize kernel root pointer */412mtctl %r4,%cr25 /* Initialize user root pointer */413414#ifdef CONFIG_64BIT415/* Setup PDCE_PROC entry */416copy %arg0,%r3417#else418/* Load RFI *return* address in case smp_callin bails */419load32 smp_callin_rtn,%r2420#endif421422/* Load RFI target address. */423load32 smp_callin,%r11424425/* ok...common code can handle the rest */426b common_stext427nop428429.procend430#endif /* CONFIG_SMP */431432#ifndef CONFIG_64BIT433.section .data..ro_after_init434435.align 4436.export $global$,data437438.type $global$,@object439.size $global$,4440$global$:441.word 0442#endif /*!CONFIG_64BIT*/443444445