Path: blob/master/arch/powerpc/kernel/head_fsl_booke.S
10818 views
/*1* Kernel execution entry point code.2*3* Copyright (c) 1995-1996 Gary Thomas <[email protected]>4* Initial PowerPC version.5* Copyright (c) 1996 Cort Dougan <[email protected]>6* Rewritten for PReP7* Copyright (c) 1996 Paul Mackerras <[email protected]>8* Low-level exception handers, MMU support, and rewrite.9* Copyright (c) 1997 Dan Malek <[email protected]>10* PowerPC 8xx modifications.11* Copyright (c) 1998-1999 TiVo, Inc.12* PowerPC 403GCX modifications.13* Copyright (c) 1999 Grant Erickson <[email protected]>14* PowerPC 403GCX/405GP modifications.15* Copyright 2000 MontaVista Software Inc.16* PPC405 modifications17* PowerPC 403GCX/405GP modifications.18* Author: MontaVista Software, Inc.19* [email protected] or [email protected]20* [email protected]21* Copyright 2002-2004 MontaVista Software, Inc.22* PowerPC 44x support, Matt Porter <[email protected]>23* Copyright 2004 Freescale Semiconductor, Inc24* PowerPC e500 modifications, Kumar Gala <[email protected]>25*26* This program is free software; you can redistribute it and/or modify it27* under the terms of the GNU General Public License as published by the28* Free Software Foundation; either version 2 of the License, or (at your29* option) any later version.30*/3132#include <linux/init.h>33#include <linux/threads.h>34#include <asm/processor.h>35#include <asm/page.h>36#include <asm/mmu.h>37#include <asm/pgtable.h>38#include <asm/cputable.h>39#include <asm/thread_info.h>40#include <asm/ppc_asm.h>41#include <asm/asm-offsets.h>42#include <asm/cache.h>43#include <asm/ptrace.h>44#include "head_booke.h"4546/* As with the other PowerPC ports, it is expected that when code47* execution begins here, the following registers contain valid, yet48* optional, information:49*50* r3 - Board info structure pointer (DRAM, frequency, MAC address, etc.)51* r4 - Starting address of the init RAM disk52* r5 - Ending address of the init RAM disk53* r6 - Start of kernel command line string (e.g. "mem=128")54* r7 - End of kernel command line string55*56*/57__HEAD58_ENTRY(_stext);59_ENTRY(_start);60/*61* Reserve a word at a fixed location to store the address62* of abatron_pteptrs63*/64nop65/*66* Save parameters we are passed67*/68mr r31,r369mr r30,r470mr r29,r571mr r28,r672mr r27,r773li r25,0 /* phys kernel start (low) */74li r24,0 /* CPU number */75li r23,0 /* phys kernel start (high) */7677/* We try to not make any assumptions about how the boot loader78* setup or used the TLBs. We invalidate all mappings from the79* boot loader and load a single entry in TLB1[0] to map the80* first 64M of kernel memory. Any boot info passed from the81* bootloader needs to live in this first 64M.82*83* Requirement on bootloader:84* - The page we're executing in needs to reside in TLB1 and85* have IPROT=1. If not an invalidate broadcast could86* evict the entry we're currently executing in.87*88* r3 = Index of TLB1 were executing in89* r4 = Current MSR[IS]90* r5 = Index of TLB1 temp mapping91*92* Later in mapin_ram we will correctly map lowmem, and resize TLB1[0]93* if needed94*/9596_ENTRY(__early_start)9798#define ENTRY_MAPPING_BOOT_SETUP99#include "fsl_booke_entry_mapping.S"100#undef ENTRY_MAPPING_BOOT_SETUP101102/* Establish the interrupt vector offsets */103SET_IVOR(0, CriticalInput);104SET_IVOR(1, MachineCheck);105SET_IVOR(2, DataStorage);106SET_IVOR(3, InstructionStorage);107SET_IVOR(4, ExternalInput);108SET_IVOR(5, Alignment);109SET_IVOR(6, Program);110SET_IVOR(7, FloatingPointUnavailable);111SET_IVOR(8, SystemCall);112SET_IVOR(9, AuxillaryProcessorUnavailable);113SET_IVOR(10, Decrementer);114SET_IVOR(11, FixedIntervalTimer);115SET_IVOR(12, WatchdogTimer);116SET_IVOR(13, DataTLBError);117SET_IVOR(14, InstructionTLBError);118SET_IVOR(15, DebugCrit);119120/* Establish the interrupt vector base */121lis r4,interrupt_base@h /* IVPR only uses the high 16-bits */122mtspr SPRN_IVPR,r4123124/* Setup the defaults for TLB entries */125li r2,(MAS4_TSIZED(BOOK3E_PAGESZ_4K))@l126#ifdef CONFIG_E200127oris r2,r2,MAS4_TLBSELD(1)@h128#endif129mtspr SPRN_MAS4, r2130131#if 0132/* Enable DOZE */133mfspr r2,SPRN_HID0134oris r2,r2,HID0_DOZE@h135mtspr SPRN_HID0, r2136#endif137138#if !defined(CONFIG_BDI_SWITCH)139/*140* The Abatron BDI JTAG debugger does not tolerate others141* mucking with the debug registers.142*/143lis r2,DBCR0_IDM@h144mtspr SPRN_DBCR0,r2145isync146/* clear any residual debug events */147li r2,-1148mtspr SPRN_DBSR,r2149#endif150151#ifdef CONFIG_SMP152/* Check to see if we're the second processor, and jump153* to the secondary_start code if so154*/155lis r24, boot_cpuid@h156ori r24, r24, boot_cpuid@l157lwz r24, 0(r24)158cmpwi r24, -1159mfspr r24,SPRN_PIR160bne __secondary_start161#endif162163/*164* This is where the main kernel code starts.165*/166167/* ptr to current */168lis r2,init_task@h169ori r2,r2,init_task@l170171/* ptr to current thread */172addi r4,r2,THREAD /* init task's THREAD */173mtspr SPRN_SPRG_THREAD,r4174175/* stack */176lis r1,init_thread_union@h177ori r1,r1,init_thread_union@l178li r0,0179stwu r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1)180181rlwinm r22,r1,0,0,31-THREAD_SHIFT /* current thread_info */182stw r24, TI_CPU(r22)183184bl early_init185186#ifdef CONFIG_RELOCATABLE187lis r3,kernstart_addr@ha188la r3,kernstart_addr@l(r3)189#ifdef CONFIG_PHYS_64BIT190stw r23,0(r3)191stw r25,4(r3)192#else193stw r25,0(r3)194#endif195#endif196197/*198* Decide what sort of machine this is and initialize the MMU.199*/200mr r3,r31201mr r4,r30202mr r5,r29203mr r6,r28204mr r7,r27205bl machine_init206bl MMU_init207208/* Setup PTE pointers for the Abatron bdiGDB */209lis r6, swapper_pg_dir@h210ori r6, r6, swapper_pg_dir@l211lis r5, abatron_pteptrs@h212ori r5, r5, abatron_pteptrs@l213lis r4, KERNELBASE@h214ori r4, r4, KERNELBASE@l215stw r5, 0(r4) /* Save abatron_pteptrs at a fixed location */216stw r6, 0(r5)217218/* Let's move on */219lis r4,start_kernel@h220ori r4,r4,start_kernel@l221lis r3,MSR_KERNEL@h222ori r3,r3,MSR_KERNEL@l223mtspr SPRN_SRR0,r4224mtspr SPRN_SRR1,r3225rfi /* change context and jump to start_kernel */226227/* Macros to hide the PTE size differences228*229* FIND_PTE -- walks the page tables given EA & pgdir pointer230* r10 -- EA of fault231* r11 -- PGDIR pointer232* r12 -- free233* label 2: is the bailout case234*235* if we find the pte (fall through):236* r11 is low pte word237* r12 is pointer to the pte238*/239#ifdef CONFIG_PTE_64BIT240#define FIND_PTE \241rlwinm r12, r10, 13, 19, 29; /* Compute pgdir/pmd offset */ \242lwzx r11, r12, r11; /* Get pgd/pmd entry */ \243rlwinm. r12, r11, 0, 0, 20; /* Extract pt base address */ \244beq 2f; /* Bail if no table */ \245rlwimi r12, r10, 23, 20, 28; /* Compute pte address */ \246lwz r11, 4(r12); /* Get pte entry */247#else248#define FIND_PTE \249rlwimi r11, r10, 12, 20, 29; /* Create L1 (pgdir/pmd) address */ \250lwz r11, 0(r11); /* Get L1 entry */ \251rlwinm. r12, r11, 0, 0, 19; /* Extract L2 (pte) base address */ \252beq 2f; /* Bail if no table */ \253rlwimi r12, r10, 22, 20, 29; /* Compute PTE address */ \254lwz r11, 0(r12); /* Get Linux PTE */255#endif256257/*258* Interrupt vector entry code259*260* The Book E MMUs are always on so we don't need to handle261* interrupts in real mode as with previous PPC processors. In262* this case we handle interrupts in the kernel virtual address263* space.264*265* Interrupt vectors are dynamically placed relative to the266* interrupt prefix as determined by the address of interrupt_base.267* The interrupt vectors offsets are programmed using the labels268* for each interrupt vector entry.269*270* Interrupt vectors must be aligned on a 16 byte boundary.271* We align on a 32 byte cache line boundary for good measure.272*/273274interrupt_base:275/* Critical Input Interrupt */276CRITICAL_EXCEPTION(0x0100, CriticalInput, unknown_exception)277278/* Machine Check Interrupt */279#ifdef CONFIG_E200280/* no RFMCI, MCSRRs on E200 */281CRITICAL_EXCEPTION(0x0200, MachineCheck, machine_check_exception)282#else283MCHECK_EXCEPTION(0x0200, MachineCheck, machine_check_exception)284#endif285286/* Data Storage Interrupt */287START_EXCEPTION(DataStorage)288NORMAL_EXCEPTION_PROLOG289mfspr r5,SPRN_ESR /* Grab the ESR, save it, pass arg3 */290stw r5,_ESR(r11)291mfspr r4,SPRN_DEAR /* Grab the DEAR, save it, pass arg2 */292andis. r10,r5,(ESR_ILK|ESR_DLK)@h293bne 1f294EXC_XFER_EE_LITE(0x0300, handle_page_fault)2951:296addi r3,r1,STACK_FRAME_OVERHEAD297EXC_XFER_EE_LITE(0x0300, CacheLockingException)298299/* Instruction Storage Interrupt */300INSTRUCTION_STORAGE_EXCEPTION301302/* External Input Interrupt */303EXCEPTION(0x0500, ExternalInput, do_IRQ, EXC_XFER_LITE)304305/* Alignment Interrupt */306ALIGNMENT_EXCEPTION307308/* Program Interrupt */309PROGRAM_EXCEPTION310311/* Floating Point Unavailable Interrupt */312#ifdef CONFIG_PPC_FPU313FP_UNAVAILABLE_EXCEPTION314#else315#ifdef CONFIG_E200316/* E200 treats 'normal' floating point instructions as FP Unavail exception */317EXCEPTION(0x0800, FloatingPointUnavailable, program_check_exception, EXC_XFER_EE)318#else319EXCEPTION(0x0800, FloatingPointUnavailable, unknown_exception, EXC_XFER_EE)320#endif321#endif322323/* System Call Interrupt */324START_EXCEPTION(SystemCall)325NORMAL_EXCEPTION_PROLOG326EXC_XFER_EE_LITE(0x0c00, DoSyscall)327328/* Auxiliary Processor Unavailable Interrupt */329EXCEPTION(0x2900, AuxillaryProcessorUnavailable, unknown_exception, EXC_XFER_EE)330331/* Decrementer Interrupt */332DECREMENTER_EXCEPTION333334/* Fixed Internal Timer Interrupt */335/* TODO: Add FIT support */336EXCEPTION(0x3100, FixedIntervalTimer, unknown_exception, EXC_XFER_EE)337338/* Watchdog Timer Interrupt */339#ifdef CONFIG_BOOKE_WDT340CRITICAL_EXCEPTION(0x3200, WatchdogTimer, WatchdogException)341#else342CRITICAL_EXCEPTION(0x3200, WatchdogTimer, unknown_exception)343#endif344345/* Data TLB Error Interrupt */346START_EXCEPTION(DataTLBError)347mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */348mtspr SPRN_SPRG_WSCRATCH1, r11349mtspr SPRN_SPRG_WSCRATCH2, r12350mtspr SPRN_SPRG_WSCRATCH3, r13351mfcr r11352mtspr SPRN_SPRG_WSCRATCH4, r11353mfspr r10, SPRN_DEAR /* Get faulting address */354355/* If we are faulting a kernel address, we have to use the356* kernel page tables.357*/358lis r11, PAGE_OFFSET@h359cmplw 5, r10, r11360blt 5, 3f361lis r11, swapper_pg_dir@h362ori r11, r11, swapper_pg_dir@l363364mfspr r12,SPRN_MAS1 /* Set TID to 0 */365rlwinm r12,r12,0,16,1366mtspr SPRN_MAS1,r12367368b 4f369370/* Get the PGD for the current thread */3713:372mfspr r11,SPRN_SPRG_THREAD373lwz r11,PGDIR(r11)3743754:376/* Mask of required permission bits. Note that while we377* do copy ESR:ST to _PAGE_RW position as trying to write378* to an RO page is pretty common, we don't do it with379* _PAGE_DIRTY. We could do it, but it's a fairly rare380* event so I'd rather take the overhead when it happens381* rather than adding an instruction here. We should measure382* whether the whole thing is worth it in the first place383* as we could avoid loading SPRN_ESR completely in the first384* place...385*386* TODO: Is it worth doing that mfspr & rlwimi in the first387* place or can we save a couple of instructions here ?388*/389mfspr r12,SPRN_ESR390#ifdef CONFIG_PTE_64BIT391li r13,_PAGE_PRESENT392oris r13,r13,_PAGE_ACCESSED@h393#else394li r13,_PAGE_PRESENT|_PAGE_ACCESSED395#endif396rlwimi r13,r12,11,29,29397398FIND_PTE399andc. r13,r13,r11 /* Check permission */400401#ifdef CONFIG_PTE_64BIT402#ifdef CONFIG_SMP403subf r10,r11,r12 /* create false data dep */404lwzx r13,r11,r10 /* Get upper pte bits */405#else406lwz r13,0(r12) /* Get upper pte bits */407#endif408#endif409410bne 2f /* Bail if permission/valid mismach */411412/* Jump to common tlb load */413b finish_tlb_load4142:415/* The bailout. Restore registers to pre-exception conditions416* and call the heavyweights to help us out.417*/418mfspr r11, SPRN_SPRG_RSCRATCH4419mtcr r11420mfspr r13, SPRN_SPRG_RSCRATCH3421mfspr r12, SPRN_SPRG_RSCRATCH2422mfspr r11, SPRN_SPRG_RSCRATCH1423mfspr r10, SPRN_SPRG_RSCRATCH0424b DataStorage425426/* Instruction TLB Error Interrupt */427/*428* Nearly the same as above, except we get our429* information from different registers and bailout430* to a different point.431*/432START_EXCEPTION(InstructionTLBError)433mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */434mtspr SPRN_SPRG_WSCRATCH1, r11435mtspr SPRN_SPRG_WSCRATCH2, r12436mtspr SPRN_SPRG_WSCRATCH3, r13437mfcr r11438mtspr SPRN_SPRG_WSCRATCH4, r11439mfspr r10, SPRN_SRR0 /* Get faulting address */440441/* If we are faulting a kernel address, we have to use the442* kernel page tables.443*/444lis r11, PAGE_OFFSET@h445cmplw 5, r10, r11446blt 5, 3f447lis r11, swapper_pg_dir@h448ori r11, r11, swapper_pg_dir@l449450mfspr r12,SPRN_MAS1 /* Set TID to 0 */451rlwinm r12,r12,0,16,1452mtspr SPRN_MAS1,r12453454/* Make up the required permissions for kernel code */455#ifdef CONFIG_PTE_64BIT456li r13,_PAGE_PRESENT | _PAGE_BAP_SX457oris r13,r13,_PAGE_ACCESSED@h458#else459li r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC460#endif461b 4f462463/* Get the PGD for the current thread */4643:465mfspr r11,SPRN_SPRG_THREAD466lwz r11,PGDIR(r11)467468/* Make up the required permissions for user code */469#ifdef CONFIG_PTE_64BIT470li r13,_PAGE_PRESENT | _PAGE_BAP_UX471oris r13,r13,_PAGE_ACCESSED@h472#else473li r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC474#endif4754764:477FIND_PTE478andc. r13,r13,r11 /* Check permission */479480#ifdef CONFIG_PTE_64BIT481#ifdef CONFIG_SMP482subf r10,r11,r12 /* create false data dep */483lwzx r13,r11,r10 /* Get upper pte bits */484#else485lwz r13,0(r12) /* Get upper pte bits */486#endif487#endif488489bne 2f /* Bail if permission mismach */490491/* Jump to common TLB load point */492b finish_tlb_load4934942:495/* The bailout. Restore registers to pre-exception conditions496* and call the heavyweights to help us out.497*/498mfspr r11, SPRN_SPRG_RSCRATCH4499mtcr r11500mfspr r13, SPRN_SPRG_RSCRATCH3501mfspr r12, SPRN_SPRG_RSCRATCH2502mfspr r11, SPRN_SPRG_RSCRATCH1503mfspr r10, SPRN_SPRG_RSCRATCH0504b InstructionStorage505506#ifdef CONFIG_SPE507/* SPE Unavailable */508START_EXCEPTION(SPEUnavailable)509NORMAL_EXCEPTION_PROLOG510bne load_up_spe511addi r3,r1,STACK_FRAME_OVERHEAD512EXC_XFER_EE_LITE(0x2010, KernelSPE)513#else514EXCEPTION(0x2020, SPEUnavailable, unknown_exception, EXC_XFER_EE)515#endif /* CONFIG_SPE */516517/* SPE Floating Point Data */518#ifdef CONFIG_SPE519EXCEPTION(0x2030, SPEFloatingPointData, SPEFloatingPointException, EXC_XFER_EE);520521/* SPE Floating Point Round */522EXCEPTION(0x2050, SPEFloatingPointRound, SPEFloatingPointRoundException, EXC_XFER_EE)523#else524EXCEPTION(0x2040, SPEFloatingPointData, unknown_exception, EXC_XFER_EE)525EXCEPTION(0x2050, SPEFloatingPointRound, unknown_exception, EXC_XFER_EE)526#endif /* CONFIG_SPE */527528/* Performance Monitor */529EXCEPTION(0x2060, PerformanceMonitor, performance_monitor_exception, EXC_XFER_STD)530531EXCEPTION(0x2070, Doorbell, doorbell_exception, EXC_XFER_STD)532533CRITICAL_EXCEPTION(0x2080, CriticalDoorbell, unknown_exception)534535/* Debug Interrupt */536DEBUG_DEBUG_EXCEPTION537DEBUG_CRIT_EXCEPTION538539/*540* Local functions541*/542543/*544* Both the instruction and data TLB miss get to this545* point to load the TLB.546* r10 - available to use547* r11 - TLB (info from Linux PTE)548* r12 - available to use549* r13 - upper bits of PTE (if PTE_64BIT) or available to use550* CR5 - results of addr >= PAGE_OFFSET551* MAS0, MAS1 - loaded with proper value when we get here552* MAS2, MAS3 - will need additional info from Linux PTE553* Upon exit, we reload everything and RFI.554*/555finish_tlb_load:556/*557* We set execute, because we don't have the granularity to558* properly set this at the page level (Linux problem).559* Many of these bits are software only. Bits we don't set560* here we (properly should) assume have the appropriate value.561*/562563mfspr r12, SPRN_MAS2564#ifdef CONFIG_PTE_64BIT565rlwimi r12, r11, 32-19, 27, 31 /* extract WIMGE from pte */566#else567rlwimi r12, r11, 26, 27, 31 /* extract WIMGE from pte */568#endif569mtspr SPRN_MAS2, r12570571#ifdef CONFIG_PTE_64BIT572rlwinm r12, r11, 32-2, 26, 31 /* Move in perm bits */573andi. r10, r11, _PAGE_DIRTY574bne 1f575li r10, MAS3_SW | MAS3_UW576andc r12, r12, r105771: rlwimi r12, r13, 20, 0, 11 /* grab RPN[32:43] */578rlwimi r12, r11, 20, 12, 19 /* grab RPN[44:51] */579mtspr SPRN_MAS3, r12580BEGIN_MMU_FTR_SECTION581srwi r10, r13, 12 /* grab RPN[12:31] */582mtspr SPRN_MAS7, r10583END_MMU_FTR_SECTION_IFSET(MMU_FTR_BIG_PHYS)584#else585li r10, (_PAGE_EXEC | _PAGE_PRESENT)586rlwimi r10, r11, 31, 29, 29 /* extract _PAGE_DIRTY into SW */587and r12, r11, r10588andi. r10, r11, _PAGE_USER /* Test for _PAGE_USER */589slwi r10, r12, 1590or r10, r10, r12591iseleq r12, r12, r10592rlwimi r11, r12, 0, 20, 31 /* Extract RPN from PTE and merge with perms */593mtspr SPRN_MAS3, r11594#endif595#ifdef CONFIG_E200596/* Round robin TLB1 entries assignment */597mfspr r12, SPRN_MAS0598599/* Extract TLB1CFG(NENTRY) */600mfspr r11, SPRN_TLB1CFG601andi. r11, r11, 0xfff602603/* Extract MAS0(NV) */604andi. r13, r12, 0xfff605addi r13, r13, 1606cmpw 0, r13, r11607addi r12, r12, 1608609/* check if we need to wrap */610blt 7f611612/* wrap back to first free tlbcam entry */613lis r13, tlbcam_index@ha614lwz r13, tlbcam_index@l(r13)615rlwimi r12, r13, 0, 20, 316167:617mtspr SPRN_MAS0,r12618#endif /* CONFIG_E200 */619620tlbwe621622/* Done...restore registers and get out of here. */623mfspr r11, SPRN_SPRG_RSCRATCH4624mtcr r11625mfspr r13, SPRN_SPRG_RSCRATCH3626mfspr r12, SPRN_SPRG_RSCRATCH2627mfspr r11, SPRN_SPRG_RSCRATCH1628mfspr r10, SPRN_SPRG_RSCRATCH0629rfi /* Force context change */630631#ifdef CONFIG_SPE632/* Note that the SPE support is closely modeled after the AltiVec633* support. Changes to one are likely to be applicable to the634* other! */635load_up_spe:636/*637* Disable SPE for the task which had SPE previously,638* and save its SPE registers in its thread_struct.639* Enables SPE for use in the kernel on return.640* On SMP we know the SPE units are free, since we give it up every641* switch. -- Kumar642*/643mfmsr r5644oris r5,r5,MSR_SPE@h645mtmsr r5 /* enable use of SPE now */646isync647/*648* For SMP, we don't do lazy SPE switching because it just gets too649* horrendously complex, especially when a task switches from one CPU650* to another. Instead we call giveup_spe in switch_to.651*/652#ifndef CONFIG_SMP653lis r3,last_task_used_spe@ha654lwz r4,last_task_used_spe@l(r3)655cmpi 0,r4,0656beq 1f657addi r4,r4,THREAD /* want THREAD of last_task_used_spe */658SAVE_32EVRS(0,r10,r4)659evxor evr10, evr10, evr10 /* clear out evr10 */660evmwumiaa evr10, evr10, evr10 /* evr10 <- ACC = 0 * 0 + ACC */661li r5,THREAD_ACC662evstddx evr10, r4, r5 /* save off accumulator */663lwz r5,PT_REGS(r4)664lwz r4,_MSR-STACK_FRAME_OVERHEAD(r5)665lis r10,MSR_SPE@h666andc r4,r4,r10 /* disable SPE for previous task */667stw r4,_MSR-STACK_FRAME_OVERHEAD(r5)6681:669#endif /* !CONFIG_SMP */670/* enable use of SPE after return */671oris r9,r9,MSR_SPE@h672mfspr r5,SPRN_SPRG_THREAD /* current task's THREAD (phys) */673li r4,1674li r10,THREAD_ACC675stw r4,THREAD_USED_SPE(r5)676evlddx evr4,r10,r5677evmra evr4,evr4678REST_32EVRS(0,r10,r5)679#ifndef CONFIG_SMP680subi r4,r5,THREAD681stw r4,last_task_used_spe@l(r3)682#endif /* !CONFIG_SMP */683/* restore registers and return */6842: REST_4GPRS(3, r11)685lwz r10,_CCR(r11)686REST_GPR(1, r11)687mtcr r10688lwz r10,_LINK(r11)689mtlr r10690REST_GPR(10, r11)691mtspr SPRN_SRR1,r9692mtspr SPRN_SRR0,r12693REST_GPR(9, r11)694REST_GPR(12, r11)695lwz r11,GPR11(r11)696rfi697698/*699* SPE unavailable trap from kernel - print a message, but let700* the task use SPE in the kernel until it returns to user mode.701*/702KernelSPE:703lwz r3,_MSR(r1)704oris r3,r3,MSR_SPE@h705stw r3,_MSR(r1) /* enable use of SPE after return */706#ifdef CONFIG_PRINTK707lis r3,87f@h708ori r3,r3,87f@l709mr r4,r2 /* current */710lwz r5,_NIP(r1)711bl printk712#endif713b ret_from_except714#ifdef CONFIG_PRINTK71587: .string "SPE used in kernel (task=%p, pc=%x) \n"716#endif717.align 4,0718719#endif /* CONFIG_SPE */720721/*722* Global functions723*/724725/* Adjust or setup IVORs for e200 */726_GLOBAL(__setup_e200_ivors)727li r3,DebugDebug@l728mtspr SPRN_IVOR15,r3729li r3,SPEUnavailable@l730mtspr SPRN_IVOR32,r3731li r3,SPEFloatingPointData@l732mtspr SPRN_IVOR33,r3733li r3,SPEFloatingPointRound@l734mtspr SPRN_IVOR34,r3735sync736blr737738/* Adjust or setup IVORs for e500v1/v2 */739_GLOBAL(__setup_e500_ivors)740li r3,DebugCrit@l741mtspr SPRN_IVOR15,r3742li r3,SPEUnavailable@l743mtspr SPRN_IVOR32,r3744li r3,SPEFloatingPointData@l745mtspr SPRN_IVOR33,r3746li r3,SPEFloatingPointRound@l747mtspr SPRN_IVOR34,r3748li r3,PerformanceMonitor@l749mtspr SPRN_IVOR35,r3750sync751blr752753/* Adjust or setup IVORs for e500mc */754_GLOBAL(__setup_e500mc_ivors)755li r3,DebugDebug@l756mtspr SPRN_IVOR15,r3757li r3,PerformanceMonitor@l758mtspr SPRN_IVOR35,r3759li r3,Doorbell@l760mtspr SPRN_IVOR36,r3761li r3,CriticalDoorbell@l762mtspr SPRN_IVOR37,r3763sync764blr765766/*767* extern void giveup_altivec(struct task_struct *prev)768*769* The e500 core does not have an AltiVec unit.770*/771_GLOBAL(giveup_altivec)772blr773774#ifdef CONFIG_SPE775/*776* extern void giveup_spe(struct task_struct *prev)777*778*/779_GLOBAL(giveup_spe)780mfmsr r5781oris r5,r5,MSR_SPE@h782mtmsr r5 /* enable use of SPE now */783isync784cmpi 0,r3,0785beqlr- /* if no previous owner, done */786addi r3,r3,THREAD /* want THREAD of task */787lwz r5,PT_REGS(r3)788cmpi 0,r5,0789SAVE_32EVRS(0, r4, r3)790evxor evr6, evr6, evr6 /* clear out evr6 */791evmwumiaa evr6, evr6, evr6 /* evr6 <- ACC = 0 * 0 + ACC */792li r4,THREAD_ACC793evstddx evr6, r4, r3 /* save off accumulator */794mfspr r6,SPRN_SPEFSCR795stw r6,THREAD_SPEFSCR(r3) /* save spefscr register value */796beq 1f797lwz r4,_MSR-STACK_FRAME_OVERHEAD(r5)798lis r3,MSR_SPE@h799andc r4,r4,r3 /* disable SPE for previous task */800stw r4,_MSR-STACK_FRAME_OVERHEAD(r5)8011:802#ifndef CONFIG_SMP803li r5,0804lis r4,last_task_used_spe@ha805stw r5,last_task_used_spe@l(r4)806#endif /* !CONFIG_SMP */807blr808#endif /* CONFIG_SPE */809810/*811* extern void giveup_fpu(struct task_struct *prev)812*813* Not all FSL Book-E cores have an FPU814*/815#ifndef CONFIG_PPC_FPU816_GLOBAL(giveup_fpu)817blr818#endif819820/*821* extern void abort(void)822*823* At present, this routine just applies a system reset.824*/825_GLOBAL(abort)826li r13,0827mtspr SPRN_DBCR0,r13 /* disable all debug events */828isync829mfmsr r13830ori r13,r13,MSR_DE@l /* Enable Debug Events */831mtmsr r13832isync833mfspr r13,SPRN_DBCR0834lis r13,(DBCR0_IDM|DBCR0_RST_CHIP)@h835mtspr SPRN_DBCR0,r13836isync837838_GLOBAL(set_context)839840#ifdef CONFIG_BDI_SWITCH841/* Context switch the PTE pointer for the Abatron BDI2000.842* The PGDIR is the second parameter.843*/844lis r5, abatron_pteptrs@h845ori r5, r5, abatron_pteptrs@l846stw r4, 0x4(r5)847#endif848mtspr SPRN_PID,r3849isync /* Force context change */850blr851852_GLOBAL(flush_dcache_L1)853mfspr r3,SPRN_L1CFG0854855rlwinm r5,r3,9,3 /* Extract cache block size */856twlgti r5,1 /* Only 32 and 64 byte cache blocks857* are currently defined.858*/859li r4,32860subfic r6,r5,2 /* r6 = log2(1KiB / cache block size) -861* log2(number of ways)862*/863slw r5,r4,r5 /* r5 = cache block size */864865rlwinm r7,r3,0,0xff /* Extract number of KiB in the cache */866mulli r7,r7,13 /* An 8-way cache will require 13867* loads per set.868*/869slw r7,r7,r6870871/* save off HID0 and set DCFA */872mfspr r8,SPRN_HID0873ori r9,r8,HID0_DCFA@l874mtspr SPRN_HID0,r9875isync876877lis r4,KERNELBASE@h878mtctr r78798801: lwz r3,0(r4) /* Load... */881add r4,r4,r5882bdnz 1b883884msync885lis r4,KERNELBASE@h886mtctr r78878881: dcbf 0,r4 /* ...and flush. */889add r4,r4,r5890bdnz 1b891892/* restore HID0 */893mtspr SPRN_HID0,r8894isync895896blr897898#ifdef CONFIG_SMP899/* When we get here, r24 needs to hold the CPU # */900.globl __secondary_start901__secondary_start:902lis r3,__secondary_hold_acknowledge@h903ori r3,r3,__secondary_hold_acknowledge@l904stw r24,0(r3)905906li r3,0907mr r4,r24 /* Why? */908bl call_setup_cpu909910lis r3,tlbcam_index@ha911lwz r3,tlbcam_index@l(r3)912mtctr r3913li r26,0 /* r26 safe? */914915/* Load each CAM entry */9161: mr r3,r26917bl loadcam_entry918addi r26,r26,1919bdnz 1b920921/* get current_thread_info and current */922lis r1,secondary_ti@ha923lwz r1,secondary_ti@l(r1)924lwz r2,TI_TASK(r1)925926/* stack */927addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD928li r0,0929stw r0,0(r1)930931/* ptr to current thread */932addi r4,r2,THREAD /* address of our thread_struct */933mtspr SPRN_SPRG_THREAD,r4934935/* Setup the defaults for TLB entries */936li r4,(MAS4_TSIZED(BOOK3E_PAGESZ_4K))@l937mtspr SPRN_MAS4,r4938939/* Jump to start_secondary */940lis r4,MSR_KERNEL@h941ori r4,r4,MSR_KERNEL@l942lis r3,start_secondary@h943ori r3,r3,start_secondary@l944mtspr SPRN_SRR0,r3945mtspr SPRN_SRR1,r4946sync947rfi948sync949950.globl __secondary_hold_acknowledge951__secondary_hold_acknowledge:952.long -1953#endif954955/*956* We put a few things here that have to be page-aligned. This stuff957* goes at the beginning of the data segment, which is page-aligned.958*/959.data960.align 12961.globl sdata962sdata:963.globl empty_zero_page964empty_zero_page:965.space 4096966.globl swapper_pg_dir967swapper_pg_dir:968.space PGD_TABLE_SIZE969970/*971* Room for two PTE pointers, usually the kernel and current user pointers972* to their respective root page table.973*/974abatron_pteptrs:975.space 8976977978