114cf11afSPaul Mackerras/* 214cf11afSPaul Mackerras * PowerPC version 314cf11afSPaul Mackerras * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 414cf11afSPaul Mackerras * 514cf11afSPaul Mackerras * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP 614cf11afSPaul Mackerras * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu> 714cf11afSPaul Mackerras * Adapted for Power Macintosh by Paul Mackerras. 814cf11afSPaul Mackerras * Low-level exception handlers and MMU support 914cf11afSPaul Mackerras * rewritten by Paul Mackerras. 1014cf11afSPaul Mackerras * Copyright (C) 1996 Paul Mackerras. 1114cf11afSPaul Mackerras * 1214cf11afSPaul Mackerras * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and 1314cf11afSPaul Mackerras * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com 1414cf11afSPaul Mackerras * 150ebc4cdaSBenjamin Herrenschmidt * This file contains the entry point for the 64-bit kernel along 160ebc4cdaSBenjamin Herrenschmidt * with some early initialization code common to all 64-bit powerpc 170ebc4cdaSBenjamin Herrenschmidt * variants. 1814cf11afSPaul Mackerras * 1914cf11afSPaul Mackerras * This program is free software; you can redistribute it and/or 2014cf11afSPaul Mackerras * modify it under the terms of the GNU General Public License 2114cf11afSPaul Mackerras * as published by the Free Software Foundation; either version 2214cf11afSPaul Mackerras * 2 of the License, or (at your option) any later version. 2314cf11afSPaul Mackerras */ 2414cf11afSPaul Mackerras 2514cf11afSPaul Mackerras#include <linux/threads.h> 26b5bbeb23SPaul Mackerras#include <asm/reg.h> 2714cf11afSPaul Mackerras#include <asm/page.h> 2814cf11afSPaul Mackerras#include <asm/mmu.h> 2914cf11afSPaul Mackerras#include <asm/ppc_asm.h> 3014cf11afSPaul Mackerras#include <asm/asm-offsets.h> 3114cf11afSPaul Mackerras#include <asm/bug.h> 3214cf11afSPaul Mackerras#include <asm/cputable.h> 3314cf11afSPaul Mackerras#include <asm/setup.h> 3414cf11afSPaul Mackerras#include <asm/hvcall.h> 35c43a55ffSKelly Daly#include <asm/iseries/lpar_map.h> 366cb7bfebSDavid Gibson#include <asm/thread_info.h> 373f639ee8SStephen Rothwell#include <asm/firmware.h> 3816a15a30SStephen Rothwell#include <asm/page_64.h> 39945feb17SBenjamin Herrenschmidt#include <asm/irqflags.h> 4014cf11afSPaul Mackerras 410ebc4cdaSBenjamin Herrenschmidt/* The physical memory is layed out such that the secondary processor 420ebc4cdaSBenjamin Herrenschmidt * spin code sits at 0x0000...0x00ff. On server, the vectors follow 430ebc4cdaSBenjamin Herrenschmidt * using the layout described in exceptions-64s.S 4414cf11afSPaul Mackerras */ 4514cf11afSPaul Mackerras 4614cf11afSPaul Mackerras/* 4714cf11afSPaul Mackerras * Entering into this code we make the following assumptions: 480ebc4cdaSBenjamin Herrenschmidt * 490ebc4cdaSBenjamin Herrenschmidt * For pSeries or server processors: 5014cf11afSPaul Mackerras * 1. The MMU is off & open firmware is running in real mode. 5114cf11afSPaul Mackerras * 2. The kernel is entered at __start 5214cf11afSPaul Mackerras * 5314cf11afSPaul Mackerras * For iSeries: 5414cf11afSPaul Mackerras * 1. The MMU is on (as it always is for iSeries) 5514cf11afSPaul Mackerras * 2. The kernel is entered at system_reset_iSeries 560ebc4cdaSBenjamin Herrenschmidt * 570ebc4cdaSBenjamin Herrenschmidt * For Book3E processors: 580ebc4cdaSBenjamin Herrenschmidt * 1. The MMU is on running in AS0 in a state defined in ePAPR 590ebc4cdaSBenjamin Herrenschmidt * 2. The kernel is entered at __start 6014cf11afSPaul Mackerras */ 6114cf11afSPaul Mackerras 6214cf11afSPaul Mackerras .text 6314cf11afSPaul Mackerras .globl _stext 6414cf11afSPaul Mackerras_stext: 6514cf11afSPaul Mackerras_GLOBAL(__start) 6614cf11afSPaul Mackerras /* NOP this out unconditionally */ 6714cf11afSPaul MackerrasBEGIN_FTR_SECTION 6814cf11afSPaul Mackerras b .__start_initialization_multiplatform 6914cf11afSPaul MackerrasEND_FTR_SECTION(0, 1) 7014cf11afSPaul Mackerras 7114cf11afSPaul Mackerras /* Catch branch to 0 in real mode */ 7214cf11afSPaul Mackerras trap 7314cf11afSPaul Mackerras 741f6a93e4SPaul Mackerras /* Secondary processors spin on this value until it becomes nonzero. 751f6a93e4SPaul Mackerras * When it does it contains the real address of the descriptor 761f6a93e4SPaul Mackerras * of the function that the cpu should jump to to continue 771f6a93e4SPaul Mackerras * initialization. 781f6a93e4SPaul Mackerras */ 7914cf11afSPaul Mackerras .globl __secondary_hold_spinloop 8014cf11afSPaul Mackerras__secondary_hold_spinloop: 8114cf11afSPaul Mackerras .llong 0x0 8214cf11afSPaul Mackerras 8314cf11afSPaul Mackerras /* Secondary processors write this value with their cpu # */ 8414cf11afSPaul Mackerras /* after they enter the spin loop immediately below. */ 8514cf11afSPaul Mackerras .globl __secondary_hold_acknowledge 8614cf11afSPaul Mackerras__secondary_hold_acknowledge: 8714cf11afSPaul Mackerras .llong 0x0 8814cf11afSPaul Mackerras 891dce0e30SMichael Ellerman#ifdef CONFIG_PPC_ISERIES 901dce0e30SMichael Ellerman /* 911dce0e30SMichael Ellerman * At offset 0x20, there is a pointer to iSeries LPAR data. 921dce0e30SMichael Ellerman * This is required by the hypervisor 931dce0e30SMichael Ellerman */ 941dce0e30SMichael Ellerman . = 0x20 951dce0e30SMichael Ellerman .llong hvReleaseData-KERNELBASE 961dce0e30SMichael Ellerman#endif /* CONFIG_PPC_ISERIES */ 971dce0e30SMichael Ellerman 988b8b0cc1SMilton Miller#ifdef CONFIG_CRASH_DUMP 998b8b0cc1SMilton Miller /* This flag is set to 1 by a loader if the kernel should run 1008b8b0cc1SMilton Miller * at the loaded address instead of the linked address. This 1018b8b0cc1SMilton Miller * is used by kexec-tools to keep the the kdump kernel in the 1028b8b0cc1SMilton Miller * crash_kernel region. The loader is responsible for 1038b8b0cc1SMilton Miller * observing the alignment requirement. 1048b8b0cc1SMilton Miller */ 1058b8b0cc1SMilton Miller /* Do not move this variable as kexec-tools knows about it. */ 1068b8b0cc1SMilton Miller . = 0x5c 1078b8b0cc1SMilton Miller .globl __run_at_load 1088b8b0cc1SMilton Miller__run_at_load: 1098b8b0cc1SMilton Miller .long 0x72756e30 /* "run0" -- relocate to 0 by default */ 1108b8b0cc1SMilton Miller#endif 1118b8b0cc1SMilton Miller 11214cf11afSPaul Mackerras . = 0x60 11314cf11afSPaul Mackerras/* 11475423b7bSGeoff Levand * The following code is used to hold secondary processors 11575423b7bSGeoff Levand * in a spin loop after they have entered the kernel, but 11614cf11afSPaul Mackerras * before the bulk of the kernel has been relocated. This code 11714cf11afSPaul Mackerras * is relocated to physical address 0x60 before prom_init is run. 11814cf11afSPaul Mackerras * All of it must fit below the first exception vector at 0x100. 1191f6a93e4SPaul Mackerras * Use .globl here not _GLOBAL because we want __secondary_hold 1201f6a93e4SPaul Mackerras * to be the actual text address, not a descriptor. 12114cf11afSPaul Mackerras */ 1221f6a93e4SPaul Mackerras .globl __secondary_hold 1231f6a93e4SPaul Mackerras__secondary_hold: 124*2d27cfd3SBenjamin Herrenschmidt#ifndef CONFIG_PPC_BOOK3E 12514cf11afSPaul Mackerras mfmsr r24 12614cf11afSPaul Mackerras ori r24,r24,MSR_RI 12714cf11afSPaul Mackerras mtmsrd r24 /* RI on */ 128*2d27cfd3SBenjamin Herrenschmidt#endif 129f1870f77SAnton Blanchard /* Grab our physical cpu number */ 13014cf11afSPaul Mackerras mr r24,r3 13114cf11afSPaul Mackerras 13214cf11afSPaul Mackerras /* Tell the master cpu we're here */ 13314cf11afSPaul Mackerras /* Relocation is off & we are located at an address less */ 13414cf11afSPaul Mackerras /* than 0x100, so only need to grab low order offset. */ 135e31aa453SPaul Mackerras std r24,__secondary_hold_acknowledge-_stext(0) 13614cf11afSPaul Mackerras sync 13714cf11afSPaul Mackerras 13814cf11afSPaul Mackerras /* All secondary cpus wait here until told to start. */ 139e31aa453SPaul Mackerras100: ld r4,__secondary_hold_spinloop-_stext(0) 1401f6a93e4SPaul Mackerras cmpdi 0,r4,0 1411f6a93e4SPaul Mackerras beq 100b 14214cf11afSPaul Mackerras 143f1870f77SAnton Blanchard#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC) 1441f6a93e4SPaul Mackerras ld r4,0(r4) /* deref function descriptor */ 145758438a7SMichael Ellerman mtctr r4 14614cf11afSPaul Mackerras mr r3,r24 147*2d27cfd3SBenjamin Herrenschmidt li r4,0 148758438a7SMichael Ellerman bctr 14914cf11afSPaul Mackerras#else 15014cf11afSPaul Mackerras BUG_OPCODE 15114cf11afSPaul Mackerras#endif 15214cf11afSPaul Mackerras 15314cf11afSPaul Mackerras/* This value is used to mark exception frames on the stack. */ 15414cf11afSPaul Mackerras .section ".toc","aw" 15514cf11afSPaul Mackerrasexception_marker: 15614cf11afSPaul Mackerras .tc ID_72656773_68657265[TC],0x7265677368657265 15714cf11afSPaul Mackerras .text 15814cf11afSPaul Mackerras 15914cf11afSPaul Mackerras/* 1600ebc4cdaSBenjamin Herrenschmidt * On server, we include the exception vectors code here as it 1610ebc4cdaSBenjamin Herrenschmidt * relies on absolute addressing which is only possible within 1620ebc4cdaSBenjamin Herrenschmidt * this compilation unit 16314cf11afSPaul Mackerras */ 1640ebc4cdaSBenjamin Herrenschmidt#ifdef CONFIG_PPC_BOOK3S 1650ebc4cdaSBenjamin Herrenschmidt#include "exceptions-64s.S" 1661f6a93e4SPaul Mackerras#endif 16714cf11afSPaul Mackerras 168*2d27cfd3SBenjamin Herrenschmidt_GLOBAL(generic_secondary_thread_init) 16914cf11afSPaul Mackerras mr r24,r3 17014cf11afSPaul Mackerras 17114cf11afSPaul Mackerras /* turn on 64-bit mode */ 17214cf11afSPaul Mackerras bl .enable_64b_mode 17314cf11afSPaul Mackerras 174*2d27cfd3SBenjamin Herrenschmidt /* get a valid TOC pointer, wherever we're mapped at */ 175e31aa453SPaul Mackerras bl .relative_toc 176e31aa453SPaul Mackerras 177*2d27cfd3SBenjamin Herrenschmidt#ifdef CONFIG_PPC_BOOK3E 178*2d27cfd3SBenjamin Herrenschmidt /* Book3E initialization */ 179*2d27cfd3SBenjamin Herrenschmidt mr r3,r24 180*2d27cfd3SBenjamin Herrenschmidt bl .book3e_secondary_thread_init 181*2d27cfd3SBenjamin Herrenschmidt#endif 182*2d27cfd3SBenjamin Herrenschmidt b generic_secondary_common_init 183*2d27cfd3SBenjamin Herrenschmidt 184*2d27cfd3SBenjamin Herrenschmidt/* 185*2d27cfd3SBenjamin Herrenschmidt * On pSeries and most other platforms, secondary processors spin 186*2d27cfd3SBenjamin Herrenschmidt * in the following code. 187*2d27cfd3SBenjamin Herrenschmidt * At entry, r3 = this processor's number (physical cpu id) 188*2d27cfd3SBenjamin Herrenschmidt * 189*2d27cfd3SBenjamin Herrenschmidt * On Book3E, r4 = 1 to indicate that the initial TLB entry for 190*2d27cfd3SBenjamin Herrenschmidt * this core already exists (setup via some other mechanism such 191*2d27cfd3SBenjamin Herrenschmidt * as SCOM before entry). 192*2d27cfd3SBenjamin Herrenschmidt */ 193*2d27cfd3SBenjamin Herrenschmidt_GLOBAL(generic_secondary_smp_init) 194*2d27cfd3SBenjamin Herrenschmidt mr r24,r3 195*2d27cfd3SBenjamin Herrenschmidt mr r25,r4 196*2d27cfd3SBenjamin Herrenschmidt 197*2d27cfd3SBenjamin Herrenschmidt /* turn on 64-bit mode */ 198*2d27cfd3SBenjamin Herrenschmidt bl .enable_64b_mode 199*2d27cfd3SBenjamin Herrenschmidt 200*2d27cfd3SBenjamin Herrenschmidt /* get a valid TOC pointer, wherever we're mapped at */ 201*2d27cfd3SBenjamin Herrenschmidt bl .relative_toc 202*2d27cfd3SBenjamin Herrenschmidt 203*2d27cfd3SBenjamin Herrenschmidt#ifdef CONFIG_PPC_BOOK3E 204*2d27cfd3SBenjamin Herrenschmidt /* Book3E initialization */ 205*2d27cfd3SBenjamin Herrenschmidt mr r3,r24 206*2d27cfd3SBenjamin Herrenschmidt mr r4,r25 207*2d27cfd3SBenjamin Herrenschmidt bl .book3e_secondary_core_init 208*2d27cfd3SBenjamin Herrenschmidt#endif 209*2d27cfd3SBenjamin Herrenschmidt 210*2d27cfd3SBenjamin Herrenschmidtgeneric_secondary_common_init: 21114cf11afSPaul Mackerras /* Set up a paca value for this processor. Since we have the 21214cf11afSPaul Mackerras * physical cpu id in r24, we need to search the pacas to find 21314cf11afSPaul Mackerras * which logical id maps to our physical one. 21414cf11afSPaul Mackerras */ 215e31aa453SPaul Mackerras LOAD_REG_ADDR(r13, paca) /* Get base vaddr of paca array */ 21614cf11afSPaul Mackerras li r5,0 /* logical cpu id */ 21714cf11afSPaul Mackerras1: lhz r6,PACAHWCPUID(r13) /* Load HW procid from paca */ 21814cf11afSPaul Mackerras cmpw r6,r24 /* Compare to our id */ 21914cf11afSPaul Mackerras beq 2f 22014cf11afSPaul Mackerras addi r13,r13,PACA_SIZE /* Loop to next PACA on miss */ 22114cf11afSPaul Mackerras addi r5,r5,1 22214cf11afSPaul Mackerras cmpwi r5,NR_CPUS 22314cf11afSPaul Mackerras blt 1b 22414cf11afSPaul Mackerras 22514cf11afSPaul Mackerras mr r3,r24 /* not found, copy phys to r3 */ 22614cf11afSPaul Mackerras b .kexec_wait /* next kernel might do better */ 22714cf11afSPaul Mackerras 228ee43eb78SBenjamin Herrenschmidt2: mtspr SPRN_SPRG_PACA,r13 /* Save vaddr of paca in an SPRG */ 229*2d27cfd3SBenjamin Herrenschmidt#ifdef CONFIG_PPC_BOOK3E 230*2d27cfd3SBenjamin Herrenschmidt addi r12,r13,PACA_EXTLB /* and TLB exc frame in another */ 231*2d27cfd3SBenjamin Herrenschmidt mtspr SPRN_SPRG_TLB_EXFRAME,r12 232*2d27cfd3SBenjamin Herrenschmidt#endif 233*2d27cfd3SBenjamin Herrenschmidt 23414cf11afSPaul Mackerras /* From now on, r24 is expected to be logical cpuid */ 23514cf11afSPaul Mackerras mr r24,r5 23614cf11afSPaul Mackerras3: HMT_LOW 23714cf11afSPaul Mackerras lbz r23,PACAPROCSTART(r13) /* Test if this processor should */ 23814cf11afSPaul Mackerras /* start. */ 23914cf11afSPaul Mackerras 240f39b7a55SOlof Johansson#ifndef CONFIG_SMP 241f39b7a55SOlof Johansson b 3b /* Never go on non-SMP */ 242f39b7a55SOlof Johansson#else 243f39b7a55SOlof Johansson cmpwi 0,r23,0 244f39b7a55SOlof Johansson beq 3b /* Loop until told to go */ 245f39b7a55SOlof Johansson 246b6f6b98aSSonny Rao sync /* order paca.run and cur_cpu_spec */ 247b6f6b98aSSonny Rao 248f39b7a55SOlof Johansson /* See if we need to call a cpu state restore handler */ 249e31aa453SPaul Mackerras LOAD_REG_ADDR(r23, cur_cpu_spec) 250f39b7a55SOlof Johansson ld r23,0(r23) 251f39b7a55SOlof Johansson ld r23,CPU_SPEC_RESTORE(r23) 252f39b7a55SOlof Johansson cmpdi 0,r23,0 253f39b7a55SOlof Johansson beq 4f 254f39b7a55SOlof Johansson ld r23,0(r23) 255f39b7a55SOlof Johansson mtctr r23 256f39b7a55SOlof Johansson bctrl 257f39b7a55SOlof Johansson 258f39b7a55SOlof Johansson4: /* Create a temp kernel stack for use before relocation is on. */ 25914cf11afSPaul Mackerras ld r1,PACAEMERGSP(r13) 26014cf11afSPaul Mackerras subi r1,r1,STACK_FRAME_OVERHEAD 26114cf11afSPaul Mackerras 262c705677eSStephen Rothwell b __secondary_start 26314cf11afSPaul Mackerras#endif 26414cf11afSPaul Mackerras 265e31aa453SPaul Mackerras/* 266e31aa453SPaul Mackerras * Turn the MMU off. 267e31aa453SPaul Mackerras * Assumes we're mapped EA == RA if the MMU is on. 268e31aa453SPaul Mackerras */ 269*2d27cfd3SBenjamin Herrenschmidt#ifdef CONFIG_PPC_BOOK3S 27014cf11afSPaul Mackerras_STATIC(__mmu_off) 27114cf11afSPaul Mackerras mfmsr r3 27214cf11afSPaul Mackerras andi. r0,r3,MSR_IR|MSR_DR 27314cf11afSPaul Mackerras beqlr 274e31aa453SPaul Mackerras mflr r4 27514cf11afSPaul Mackerras andc r3,r3,r0 27614cf11afSPaul Mackerras mtspr SPRN_SRR0,r4 27714cf11afSPaul Mackerras mtspr SPRN_SRR1,r3 27814cf11afSPaul Mackerras sync 27914cf11afSPaul Mackerras rfid 28014cf11afSPaul Mackerras b . /* prevent speculative execution */ 281*2d27cfd3SBenjamin Herrenschmidt#endif 28214cf11afSPaul Mackerras 28314cf11afSPaul Mackerras 28414cf11afSPaul Mackerras/* 28514cf11afSPaul Mackerras * Here is our main kernel entry point. We support currently 2 kind of entries 28614cf11afSPaul Mackerras * depending on the value of r5. 28714cf11afSPaul Mackerras * 28814cf11afSPaul Mackerras * r5 != NULL -> OF entry, we go to prom_init, "legacy" parameter content 28914cf11afSPaul Mackerras * in r3...r7 29014cf11afSPaul Mackerras * 29114cf11afSPaul Mackerras * r5 == NULL -> kexec style entry. r3 is a physical pointer to the 29214cf11afSPaul Mackerras * DT block, r4 is a physical pointer to the kernel itself 29314cf11afSPaul Mackerras * 29414cf11afSPaul Mackerras */ 29514cf11afSPaul Mackerras_GLOBAL(__start_initialization_multiplatform) 296e31aa453SPaul Mackerras /* Make sure we are running in 64 bits mode */ 297e31aa453SPaul Mackerras bl .enable_64b_mode 298e31aa453SPaul Mackerras 299e31aa453SPaul Mackerras /* Get TOC pointer (current runtime address) */ 300e31aa453SPaul Mackerras bl .relative_toc 301e31aa453SPaul Mackerras 302e31aa453SPaul Mackerras /* find out where we are now */ 303e31aa453SPaul Mackerras bcl 20,31,$+4 304e31aa453SPaul Mackerras0: mflr r26 /* r26 = runtime addr here */ 305e31aa453SPaul Mackerras addis r26,r26,(_stext - 0b)@ha 306e31aa453SPaul Mackerras addi r26,r26,(_stext - 0b)@l /* current runtime base addr */ 307e31aa453SPaul Mackerras 30814cf11afSPaul Mackerras /* 30914cf11afSPaul Mackerras * Are we booted from a PROM Of-type client-interface ? 31014cf11afSPaul Mackerras */ 31114cf11afSPaul Mackerras cmpldi cr0,r5,0 312939e60f6SStephen Rothwell beq 1f 313939e60f6SStephen Rothwell b .__boot_from_prom /* yes -> prom */ 314939e60f6SStephen Rothwell1: 31514cf11afSPaul Mackerras /* Save parameters */ 31614cf11afSPaul Mackerras mr r31,r3 31714cf11afSPaul Mackerras mr r30,r4 31814cf11afSPaul Mackerras 319*2d27cfd3SBenjamin Herrenschmidt#ifdef CONFIG_PPC_BOOK3E 320*2d27cfd3SBenjamin Herrenschmidt bl .start_initialization_book3e 321*2d27cfd3SBenjamin Herrenschmidt b .__after_prom_start 322*2d27cfd3SBenjamin Herrenschmidt#else 32314cf11afSPaul Mackerras /* Setup some critical 970 SPRs before switching MMU off */ 324f39b7a55SOlof Johansson mfspr r0,SPRN_PVR 325f39b7a55SOlof Johansson srwi r0,r0,16 326f39b7a55SOlof Johansson cmpwi r0,0x39 /* 970 */ 327f39b7a55SOlof Johansson beq 1f 328f39b7a55SOlof Johansson cmpwi r0,0x3c /* 970FX */ 329f39b7a55SOlof Johansson beq 1f 330f39b7a55SOlof Johansson cmpwi r0,0x44 /* 970MP */ 331190a24f5SOlof Johansson beq 1f 332190a24f5SOlof Johansson cmpwi r0,0x45 /* 970GX */ 333f39b7a55SOlof Johansson bne 2f 334f39b7a55SOlof Johansson1: bl .__cpu_preinit_ppc970 335f39b7a55SOlof Johansson2: 33614cf11afSPaul Mackerras 337e31aa453SPaul Mackerras /* Switch off MMU if not already off */ 33814cf11afSPaul Mackerras bl .__mmu_off 33914cf11afSPaul Mackerras b .__after_prom_start 340*2d27cfd3SBenjamin Herrenschmidt#endif /* CONFIG_PPC_BOOK3E */ 34114cf11afSPaul Mackerras 342939e60f6SStephen Rothwell_INIT_STATIC(__boot_from_prom) 34328794d34SBenjamin Herrenschmidt#ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE 34414cf11afSPaul Mackerras /* Save parameters */ 34514cf11afSPaul Mackerras mr r31,r3 34614cf11afSPaul Mackerras mr r30,r4 34714cf11afSPaul Mackerras mr r29,r5 34814cf11afSPaul Mackerras mr r28,r6 34914cf11afSPaul Mackerras mr r27,r7 35014cf11afSPaul Mackerras 3516088857bSOlaf Hering /* 3526088857bSOlaf Hering * Align the stack to 16-byte boundary 3536088857bSOlaf Hering * Depending on the size and layout of the ELF sections in the initial 354e31aa453SPaul Mackerras * boot binary, the stack pointer may be unaligned on PowerMac 3556088857bSOlaf Hering */ 356c05b4770SLinus Torvalds rldicr r1,r1,0,59 357c05b4770SLinus Torvalds 358549e8152SPaul Mackerras#ifdef CONFIG_RELOCATABLE 359549e8152SPaul Mackerras /* Relocate code for where we are now */ 360549e8152SPaul Mackerras mr r3,r26 361549e8152SPaul Mackerras bl .relocate 362549e8152SPaul Mackerras#endif 363549e8152SPaul Mackerras 36414cf11afSPaul Mackerras /* Restore parameters */ 36514cf11afSPaul Mackerras mr r3,r31 36614cf11afSPaul Mackerras mr r4,r30 36714cf11afSPaul Mackerras mr r5,r29 36814cf11afSPaul Mackerras mr r6,r28 36914cf11afSPaul Mackerras mr r7,r27 37014cf11afSPaul Mackerras 37114cf11afSPaul Mackerras /* Do all of the interaction with OF client interface */ 372549e8152SPaul Mackerras mr r8,r26 37314cf11afSPaul Mackerras bl .prom_init 37428794d34SBenjamin Herrenschmidt#endif /* #CONFIG_PPC_OF_BOOT_TRAMPOLINE */ 37528794d34SBenjamin Herrenschmidt 37628794d34SBenjamin Herrenschmidt /* We never return. We also hit that trap if trying to boot 37728794d34SBenjamin Herrenschmidt * from OF while CONFIG_PPC_OF_BOOT_TRAMPOLINE isn't selected */ 37814cf11afSPaul Mackerras trap 37914cf11afSPaul Mackerras 38014cf11afSPaul Mackerras_STATIC(__after_prom_start) 381549e8152SPaul Mackerras#ifdef CONFIG_RELOCATABLE 382549e8152SPaul Mackerras /* process relocations for the final address of the kernel */ 383549e8152SPaul Mackerras lis r25,PAGE_OFFSET@highest /* compute virtual base of kernel */ 384549e8152SPaul Mackerras sldi r25,r25,32 38554622f10SMohan Kumar M#ifdef CONFIG_CRASH_DUMP 3868b8b0cc1SMilton Miller lwz r7,__run_at_load-_stext(r26) 3878b8b0cc1SMilton Miller cmplwi cr0,r7,1 /* kdump kernel ? - stay where we are */ 38854622f10SMohan Kumar M bne 1f 38954622f10SMohan Kumar M add r25,r25,r26 39054622f10SMohan Kumar M#endif 39154622f10SMohan Kumar M1: mr r3,r25 392549e8152SPaul Mackerras bl .relocate 393549e8152SPaul Mackerras#endif 39414cf11afSPaul Mackerras 39514cf11afSPaul Mackerras/* 396e31aa453SPaul Mackerras * We need to run with _stext at physical address PHYSICAL_START. 39714cf11afSPaul Mackerras * This will leave some code in the first 256B of 39814cf11afSPaul Mackerras * real memory, which are reserved for software use. 39914cf11afSPaul Mackerras * 40014cf11afSPaul Mackerras * Note: This process overwrites the OF exception vectors. 40114cf11afSPaul Mackerras */ 402549e8152SPaul Mackerras li r3,0 /* target addr */ 403*2d27cfd3SBenjamin Herrenschmidt#ifdef CONFIG_PPC_BOOK3E 404*2d27cfd3SBenjamin Herrenschmidt tovirt(r3,r3) /* on booke, we already run at PAGE_OFFSET */ 405*2d27cfd3SBenjamin Herrenschmidt#endif 406549e8152SPaul Mackerras mr. r4,r26 /* In some cases the loader may */ 407e31aa453SPaul Mackerras beq 9f /* have already put us at zero */ 40814cf11afSPaul Mackerras li r6,0x100 /* Start offset, the first 0x100 */ 40914cf11afSPaul Mackerras /* bytes were copied earlier. */ 410*2d27cfd3SBenjamin Herrenschmidt#ifdef CONFIG_PPC_BOOK3E 411*2d27cfd3SBenjamin Herrenschmidt tovirt(r6,r6) /* on booke, we already run at PAGE_OFFSET */ 412*2d27cfd3SBenjamin Herrenschmidt#endif 41314cf11afSPaul Mackerras 41454622f10SMohan Kumar M#ifdef CONFIG_CRASH_DUMP 41554622f10SMohan Kumar M/* 41654622f10SMohan Kumar M * Check if the kernel has to be running as relocatable kernel based on the 4178b8b0cc1SMilton Miller * variable __run_at_load, if it is set the kernel is treated as relocatable 41854622f10SMohan Kumar M * kernel, otherwise it will be moved to PHYSICAL_START 41954622f10SMohan Kumar M */ 4208b8b0cc1SMilton Miller lwz r7,__run_at_load-_stext(r26) 4218b8b0cc1SMilton Miller cmplwi cr0,r7,1 42254622f10SMohan Kumar M bne 3f 42354622f10SMohan Kumar M 42454622f10SMohan Kumar M li r5,__end_interrupts - _stext /* just copy interrupts */ 42554622f10SMohan Kumar M b 5f 42654622f10SMohan Kumar M3: 42754622f10SMohan Kumar M#endif 42854622f10SMohan Kumar M lis r5,(copy_to_here - _stext)@ha 42954622f10SMohan Kumar M addi r5,r5,(copy_to_here - _stext)@l /* # bytes of memory to copy */ 43054622f10SMohan Kumar M 43114cf11afSPaul Mackerras bl .copy_and_flush /* copy the first n bytes */ 43214cf11afSPaul Mackerras /* this includes the code being */ 43314cf11afSPaul Mackerras /* executed here. */ 434e31aa453SPaul Mackerras addis r8,r3,(4f - _stext)@ha /* Jump to the copy of this code */ 435e31aa453SPaul Mackerras addi r8,r8,(4f - _stext)@l /* that we just made */ 436e31aa453SPaul Mackerras mtctr r8 43714cf11afSPaul Mackerras bctr 43814cf11afSPaul Mackerras 43954622f10SMohan Kumar Mp_end: .llong _end - _stext 44054622f10SMohan Kumar M 441e31aa453SPaul Mackerras4: /* Now copy the rest of the kernel up to _end */ 442e31aa453SPaul Mackerras addis r5,r26,(p_end - _stext)@ha 443e31aa453SPaul Mackerras ld r5,(p_end - _stext)@l(r5) /* get _end */ 44454622f10SMohan Kumar M5: bl .copy_and_flush /* copy the rest */ 445e31aa453SPaul Mackerras 446e31aa453SPaul Mackerras9: b .start_here_multiplatform 447e31aa453SPaul Mackerras 44814cf11afSPaul Mackerras/* 44914cf11afSPaul Mackerras * Copy routine used to copy the kernel to start at physical address 0 45014cf11afSPaul Mackerras * and flush and invalidate the caches as needed. 45114cf11afSPaul Mackerras * r3 = dest addr, r4 = source addr, r5 = copy limit, r6 = start offset 45214cf11afSPaul Mackerras * on exit, r3, r4, r5 are unchanged, r6 is updated to be >= r5. 45314cf11afSPaul Mackerras * 45414cf11afSPaul Mackerras * Note: this routine *only* clobbers r0, r6 and lr 45514cf11afSPaul Mackerras */ 45614cf11afSPaul Mackerras_GLOBAL(copy_and_flush) 45714cf11afSPaul Mackerras addi r5,r5,-8 45814cf11afSPaul Mackerras addi r6,r6,-8 4595a2fe38dSOlof Johansson4: li r0,8 /* Use the smallest common */ 46014cf11afSPaul Mackerras /* denominator cache line */ 46114cf11afSPaul Mackerras /* size. This results in */ 46214cf11afSPaul Mackerras /* extra cache line flushes */ 46314cf11afSPaul Mackerras /* but operation is correct. */ 46414cf11afSPaul Mackerras /* Can't get cache line size */ 46514cf11afSPaul Mackerras /* from NACA as it is being */ 46614cf11afSPaul Mackerras /* moved too. */ 46714cf11afSPaul Mackerras 46814cf11afSPaul Mackerras mtctr r0 /* put # words/line in ctr */ 46914cf11afSPaul Mackerras3: addi r6,r6,8 /* copy a cache line */ 47014cf11afSPaul Mackerras ldx r0,r6,r4 47114cf11afSPaul Mackerras stdx r0,r6,r3 47214cf11afSPaul Mackerras bdnz 3b 47314cf11afSPaul Mackerras dcbst r6,r3 /* write it to memory */ 47414cf11afSPaul Mackerras sync 47514cf11afSPaul Mackerras icbi r6,r3 /* flush the icache line */ 47614cf11afSPaul Mackerras cmpld 0,r6,r5 47714cf11afSPaul Mackerras blt 4b 47814cf11afSPaul Mackerras sync 47914cf11afSPaul Mackerras addi r5,r5,8 48014cf11afSPaul Mackerras addi r6,r6,8 48114cf11afSPaul Mackerras blr 48214cf11afSPaul Mackerras 48314cf11afSPaul Mackerras.align 8 48414cf11afSPaul Mackerrascopy_to_here: 48514cf11afSPaul Mackerras 48614cf11afSPaul Mackerras#ifdef CONFIG_SMP 48714cf11afSPaul Mackerras#ifdef CONFIG_PPC_PMAC 48814cf11afSPaul Mackerras/* 48914cf11afSPaul Mackerras * On PowerMac, secondary processors starts from the reset vector, which 49014cf11afSPaul Mackerras * is temporarily turned into a call to one of the functions below. 49114cf11afSPaul Mackerras */ 49214cf11afSPaul Mackerras .section ".text"; 49314cf11afSPaul Mackerras .align 2 ; 49414cf11afSPaul Mackerras 49535499c01SPaul Mackerras .globl __secondary_start_pmac_0 49635499c01SPaul Mackerras__secondary_start_pmac_0: 49735499c01SPaul Mackerras /* NB the entries for cpus 0, 1, 2 must each occupy 8 bytes. */ 49835499c01SPaul Mackerras li r24,0 49935499c01SPaul Mackerras b 1f 50014cf11afSPaul Mackerras li r24,1 50135499c01SPaul Mackerras b 1f 50214cf11afSPaul Mackerras li r24,2 50335499c01SPaul Mackerras b 1f 50414cf11afSPaul Mackerras li r24,3 50535499c01SPaul Mackerras1: 50614cf11afSPaul Mackerras 50714cf11afSPaul Mackerras_GLOBAL(pmac_secondary_start) 50814cf11afSPaul Mackerras /* turn on 64-bit mode */ 50914cf11afSPaul Mackerras bl .enable_64b_mode 51014cf11afSPaul Mackerras 511c478b581SBenjamin Herrenschmidt li r0,0 512c478b581SBenjamin Herrenschmidt mfspr r3,SPRN_HID4 513c478b581SBenjamin Herrenschmidt rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */ 514c478b581SBenjamin Herrenschmidt sync 515c478b581SBenjamin Herrenschmidt mtspr SPRN_HID4,r3 516c478b581SBenjamin Herrenschmidt isync 517c478b581SBenjamin Herrenschmidt sync 518c478b581SBenjamin Herrenschmidt slbia 519c478b581SBenjamin Herrenschmidt 520e31aa453SPaul Mackerras /* get TOC pointer (real address) */ 521e31aa453SPaul Mackerras bl .relative_toc 522e31aa453SPaul Mackerras 52314cf11afSPaul Mackerras /* Copy some CPU settings from CPU 0 */ 524f39b7a55SOlof Johansson bl .__restore_cpu_ppc970 52514cf11afSPaul Mackerras 52614cf11afSPaul Mackerras /* pSeries do that early though I don't think we really need it */ 52714cf11afSPaul Mackerras mfmsr r3 52814cf11afSPaul Mackerras ori r3,r3,MSR_RI 52914cf11afSPaul Mackerras mtmsrd r3 /* RI on */ 53014cf11afSPaul Mackerras 53114cf11afSPaul Mackerras /* Set up a paca value for this processor. */ 532e31aa453SPaul Mackerras LOAD_REG_ADDR(r4,paca) /* Get base vaddr of paca array */ 53314cf11afSPaul Mackerras mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */ 53414cf11afSPaul Mackerras add r13,r13,r4 /* for this processor. */ 535ee43eb78SBenjamin Herrenschmidt mtspr SPRN_SPRG_PACA,r13 /* Save vaddr of paca in an SPRG*/ 53614cf11afSPaul Mackerras 53714cf11afSPaul Mackerras /* Create a temp kernel stack for use before relocation is on. */ 53814cf11afSPaul Mackerras ld r1,PACAEMERGSP(r13) 53914cf11afSPaul Mackerras subi r1,r1,STACK_FRAME_OVERHEAD 54014cf11afSPaul Mackerras 541c705677eSStephen Rothwell b __secondary_start 54214cf11afSPaul Mackerras 54314cf11afSPaul Mackerras#endif /* CONFIG_PPC_PMAC */ 54414cf11afSPaul Mackerras 54514cf11afSPaul Mackerras/* 54614cf11afSPaul Mackerras * This function is called after the master CPU has released the 54714cf11afSPaul Mackerras * secondary processors. The execution environment is relocation off. 54814cf11afSPaul Mackerras * The paca for this processor has the following fields initialized at 54914cf11afSPaul Mackerras * this point: 55014cf11afSPaul Mackerras * 1. Processor number 55114cf11afSPaul Mackerras * 2. Segment table pointer (virtual address) 55214cf11afSPaul Mackerras * On entry the following are set: 55314cf11afSPaul Mackerras * r1 = stack pointer. vaddr for iSeries, raddr (temp stack) for pSeries 55414cf11afSPaul Mackerras * r24 = cpu# (in Linux terms) 55514cf11afSPaul Mackerras * r13 = paca virtual address 556ee43eb78SBenjamin Herrenschmidt * SPRG_PACA = paca virtual address 55714cf11afSPaul Mackerras */ 558*2d27cfd3SBenjamin Herrenschmidt .section ".text"; 559*2d27cfd3SBenjamin Herrenschmidt .align 2 ; 560*2d27cfd3SBenjamin Herrenschmidt 561fc68e869SStephen Rothwell .globl __secondary_start 562c705677eSStephen Rothwell__secondary_start: 563799d6046SPaul Mackerras /* Set thread priority to MEDIUM */ 564799d6046SPaul Mackerras HMT_MEDIUM 56514cf11afSPaul Mackerras 566799d6046SPaul Mackerras /* Do early setup for that CPU (stab, slb, hash table pointer) */ 567799d6046SPaul Mackerras bl .early_setup_secondary 56814cf11afSPaul Mackerras 56914cf11afSPaul Mackerras /* Initialize the kernel stack. Just a repeat for iSeries. */ 570e58c3495SDavid Gibson LOAD_REG_ADDR(r3, current_set) 57114cf11afSPaul Mackerras sldi r28,r24,3 /* get current_set[cpu#] */ 57214cf11afSPaul Mackerras ldx r1,r3,r28 57314cf11afSPaul Mackerras addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD 57414cf11afSPaul Mackerras std r1,PACAKSAVE(r13) 57514cf11afSPaul Mackerras 576799d6046SPaul Mackerras /* Clear backchain so we get nice backtraces */ 57714cf11afSPaul Mackerras li r7,0 57814cf11afSPaul Mackerras mtlr r7 57914cf11afSPaul Mackerras 58014cf11afSPaul Mackerras /* enable MMU and jump to start_secondary */ 581e58c3495SDavid Gibson LOAD_REG_ADDR(r3, .start_secondary_prolog) 582e58c3495SDavid Gibson LOAD_REG_IMMEDIATE(r4, MSR_KERNEL) 583d04c56f7SPaul Mackerras#ifdef CONFIG_PPC_ISERIES 5843f639ee8SStephen RothwellBEGIN_FW_FTR_SECTION 58514cf11afSPaul Mackerras ori r4,r4,MSR_EE 586ff3da2e0SBenjamin Herrenschmidt li r8,1 587ff3da2e0SBenjamin Herrenschmidt stb r8,PACAHARDIRQEN(r13) 5883f639ee8SStephen RothwellEND_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 58914cf11afSPaul Mackerras#endif 590d04c56f7SPaul MackerrasBEGIN_FW_FTR_SECTION 591d04c56f7SPaul Mackerras stb r7,PACAHARDIRQEN(r13) 592d04c56f7SPaul MackerrasEND_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES) 593ff3da2e0SBenjamin Herrenschmidt stb r7,PACASOFTIRQEN(r13) 594d04c56f7SPaul Mackerras 595b5bbeb23SPaul Mackerras mtspr SPRN_SRR0,r3 596b5bbeb23SPaul Mackerras mtspr SPRN_SRR1,r4 597*2d27cfd3SBenjamin Herrenschmidt RFI 59814cf11afSPaul Mackerras b . /* prevent speculative execution */ 59914cf11afSPaul Mackerras 60014cf11afSPaul Mackerras/* 60114cf11afSPaul Mackerras * Running with relocation on at this point. All we want to do is 602e31aa453SPaul Mackerras * zero the stack back-chain pointer and get the TOC virtual address 603e31aa453SPaul Mackerras * before going into C code. 60414cf11afSPaul Mackerras */ 60514cf11afSPaul Mackerras_GLOBAL(start_secondary_prolog) 606e31aa453SPaul Mackerras ld r2,PACATOC(r13) 60714cf11afSPaul Mackerras li r3,0 60814cf11afSPaul Mackerras std r3,0(r1) /* Zero the stack frame pointer */ 60914cf11afSPaul Mackerras bl .start_secondary 610799d6046SPaul Mackerras b . 61114cf11afSPaul Mackerras#endif 61214cf11afSPaul Mackerras 61314cf11afSPaul Mackerras/* 61414cf11afSPaul Mackerras * This subroutine clobbers r11 and r12 61514cf11afSPaul Mackerras */ 61614cf11afSPaul Mackerras_GLOBAL(enable_64b_mode) 61714cf11afSPaul Mackerras mfmsr r11 /* grab the current MSR */ 618*2d27cfd3SBenjamin Herrenschmidt#ifdef CONFIG_PPC_BOOK3E 619*2d27cfd3SBenjamin Herrenschmidt oris r11,r11,0x8000 /* CM bit set, we'll set ICM later */ 620*2d27cfd3SBenjamin Herrenschmidt mtmsr r11 621*2d27cfd3SBenjamin Herrenschmidt#else /* CONFIG_PPC_BOOK3E */ 622e31aa453SPaul Mackerras li r12,(MSR_SF | MSR_ISF)@highest 623e31aa453SPaul Mackerras sldi r12,r12,48 62414cf11afSPaul Mackerras or r11,r11,r12 62514cf11afSPaul Mackerras mtmsrd r11 62614cf11afSPaul Mackerras isync 627*2d27cfd3SBenjamin Herrenschmidt#endif 62814cf11afSPaul Mackerras blr 62914cf11afSPaul Mackerras 63014cf11afSPaul Mackerras/* 631e31aa453SPaul Mackerras * This puts the TOC pointer into r2, offset by 0x8000 (as expected 632e31aa453SPaul Mackerras * by the toolchain). It computes the correct value for wherever we 633e31aa453SPaul Mackerras * are running at the moment, using position-independent code. 634e31aa453SPaul Mackerras */ 635e31aa453SPaul Mackerras_GLOBAL(relative_toc) 636e31aa453SPaul Mackerras mflr r0 637e31aa453SPaul Mackerras bcl 20,31,$+4 638e31aa453SPaul Mackerras0: mflr r9 639e31aa453SPaul Mackerras ld r2,(p_toc - 0b)(r9) 640e31aa453SPaul Mackerras add r2,r2,r9 641e31aa453SPaul Mackerras mtlr r0 642e31aa453SPaul Mackerras blr 643e31aa453SPaul Mackerras 644e31aa453SPaul Mackerrasp_toc: .llong __toc_start + 0x8000 - 0b 645e31aa453SPaul Mackerras 646e31aa453SPaul Mackerras/* 64714cf11afSPaul Mackerras * This is where the main kernel code starts. 64814cf11afSPaul Mackerras */ 649939e60f6SStephen Rothwell_INIT_STATIC(start_here_multiplatform) 650e31aa453SPaul Mackerras /* set up the TOC (real address) */ 651e31aa453SPaul Mackerras bl .relative_toc 65214cf11afSPaul Mackerras 65314cf11afSPaul Mackerras /* Clear out the BSS. It may have been done in prom_init, 65414cf11afSPaul Mackerras * already but that's irrelevant since prom_init will soon 65514cf11afSPaul Mackerras * be detached from the kernel completely. Besides, we need 65614cf11afSPaul Mackerras * to clear it now for kexec-style entry. 65714cf11afSPaul Mackerras */ 658e31aa453SPaul Mackerras LOAD_REG_ADDR(r11,__bss_stop) 659e31aa453SPaul Mackerras LOAD_REG_ADDR(r8,__bss_start) 66014cf11afSPaul Mackerras sub r11,r11,r8 /* bss size */ 66114cf11afSPaul Mackerras addi r11,r11,7 /* round up to an even double word */ 662e31aa453SPaul Mackerras srdi. r11,r11,3 /* shift right by 3 */ 66314cf11afSPaul Mackerras beq 4f 66414cf11afSPaul Mackerras addi r8,r8,-8 66514cf11afSPaul Mackerras li r0,0 66614cf11afSPaul Mackerras mtctr r11 /* zero this many doublewords */ 66714cf11afSPaul Mackerras3: stdu r0,8(r8) 66814cf11afSPaul Mackerras bdnz 3b 66914cf11afSPaul Mackerras4: 67014cf11afSPaul Mackerras 671*2d27cfd3SBenjamin Herrenschmidt#ifndef CONFIG_PPC_BOOK3E 67214cf11afSPaul Mackerras mfmsr r6 67314cf11afSPaul Mackerras ori r6,r6,MSR_RI 67414cf11afSPaul Mackerras mtmsrd r6 /* RI on */ 675*2d27cfd3SBenjamin Herrenschmidt#endif 67614cf11afSPaul Mackerras 677549e8152SPaul Mackerras#ifdef CONFIG_RELOCATABLE 678549e8152SPaul Mackerras /* Save the physical address we're running at in kernstart_addr */ 679549e8152SPaul Mackerras LOAD_REG_ADDR(r4, kernstart_addr) 680549e8152SPaul Mackerras clrldi r0,r25,2 681549e8152SPaul Mackerras std r0,0(r4) 682549e8152SPaul Mackerras#endif 683549e8152SPaul Mackerras 684e31aa453SPaul Mackerras /* The following gets the stack set up with the regs */ 68514cf11afSPaul Mackerras /* pointing to the real addr of the kernel stack. This is */ 68614cf11afSPaul Mackerras /* all done to support the C function call below which sets */ 68714cf11afSPaul Mackerras /* up the htab. This is done because we have relocated the */ 68814cf11afSPaul Mackerras /* kernel but are still running in real mode. */ 68914cf11afSPaul Mackerras 690e31aa453SPaul Mackerras LOAD_REG_ADDR(r3,init_thread_union) 69114cf11afSPaul Mackerras 692e31aa453SPaul Mackerras /* set up a stack pointer */ 69314cf11afSPaul Mackerras addi r1,r3,THREAD_SIZE 69414cf11afSPaul Mackerras li r0,0 69514cf11afSPaul Mackerras stdu r0,-STACK_FRAME_OVERHEAD(r1) 69614cf11afSPaul Mackerras 69714cf11afSPaul Mackerras /* Do very early kernel initializations, including initial hash table, 69814cf11afSPaul Mackerras * stab and slb setup before we turn on relocation. */ 69914cf11afSPaul Mackerras 70014cf11afSPaul Mackerras /* Restore parameters passed from prom_init/kexec */ 70114cf11afSPaul Mackerras mr r3,r31 702ee43eb78SBenjamin Herrenschmidt bl .early_setup /* also sets r13 and SPRG_PACA */ 70314cf11afSPaul Mackerras 704e31aa453SPaul Mackerras LOAD_REG_ADDR(r3, .start_here_common) 705e31aa453SPaul Mackerras ld r4,PACAKMSR(r13) 706b5bbeb23SPaul Mackerras mtspr SPRN_SRR0,r3 707b5bbeb23SPaul Mackerras mtspr SPRN_SRR1,r4 708*2d27cfd3SBenjamin Herrenschmidt RFI 70914cf11afSPaul Mackerras b . /* prevent speculative execution */ 71014cf11afSPaul Mackerras 71114cf11afSPaul Mackerras /* This is where all platforms converge execution */ 712fc68e869SStephen Rothwell_INIT_GLOBAL(start_here_common) 71314cf11afSPaul Mackerras /* relocation is on at this point */ 71414cf11afSPaul Mackerras std r1,PACAKSAVE(r13) 71514cf11afSPaul Mackerras 716e31aa453SPaul Mackerras /* Load the TOC (virtual address) */ 717e31aa453SPaul Mackerras ld r2,PACATOC(r13) 718e31aa453SPaul Mackerras 71914cf11afSPaul Mackerras bl .setup_system 72014cf11afSPaul Mackerras 72114cf11afSPaul Mackerras /* Load up the kernel context */ 72214cf11afSPaul Mackerras5: 72314cf11afSPaul Mackerras li r5,0 724d04c56f7SPaul Mackerras stb r5,PACASOFTIRQEN(r13) /* Soft Disabled */ 725d04c56f7SPaul Mackerras#ifdef CONFIG_PPC_ISERIES 726d04c56f7SPaul MackerrasBEGIN_FW_FTR_SECTION 72714cf11afSPaul Mackerras mfmsr r5 728ff3da2e0SBenjamin Herrenschmidt ori r5,r5,MSR_EE /* Hard Enabled on iSeries*/ 72914cf11afSPaul Mackerras mtmsrd r5 730ff3da2e0SBenjamin Herrenschmidt li r5,1 7313f639ee8SStephen RothwellEND_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 73214cf11afSPaul Mackerras#endif 733ff3da2e0SBenjamin Herrenschmidt stb r5,PACAHARDIRQEN(r13) /* Hard Disabled on others */ 73414cf11afSPaul Mackerras 73514cf11afSPaul Mackerras bl .start_kernel 73614cf11afSPaul Mackerras 737f1870f77SAnton Blanchard /* Not reached */ 738f1870f77SAnton Blanchard BUG_OPCODE 73914cf11afSPaul Mackerras 74014cf11afSPaul Mackerras/* 74114cf11afSPaul Mackerras * We put a few things here that have to be page-aligned. 74214cf11afSPaul Mackerras * This stuff goes at the beginning of the bss, which is page-aligned. 74314cf11afSPaul Mackerras */ 74414cf11afSPaul Mackerras .section ".bss" 74514cf11afSPaul Mackerras 74614cf11afSPaul Mackerras .align PAGE_SHIFT 74714cf11afSPaul Mackerras 74814cf11afSPaul Mackerras .globl empty_zero_page 74914cf11afSPaul Mackerrasempty_zero_page: 75014cf11afSPaul Mackerras .space PAGE_SIZE 75114cf11afSPaul Mackerras 75214cf11afSPaul Mackerras .globl swapper_pg_dir 75314cf11afSPaul Mackerrasswapper_pg_dir: 754ee7a76daSStephen Rothwell .space PGD_TABLE_SIZE 755