xref: /openbmc/linux/arch/powerpc/kernel/head_44x.S (revision 795033c344d88dc6aa5106d0cc358656f29bd722)
114cf11afSPaul Mackerras/*
214cf11afSPaul Mackerras * Kernel execution entry point code.
314cf11afSPaul Mackerras *
414cf11afSPaul Mackerras *    Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
514cf11afSPaul Mackerras *      Initial PowerPC version.
614cf11afSPaul Mackerras *    Copyright (c) 1996 Cort Dougan <cort@cs.nmt.edu>
714cf11afSPaul Mackerras *      Rewritten for PReP
814cf11afSPaul Mackerras *    Copyright (c) 1996 Paul Mackerras <paulus@cs.anu.edu.au>
914cf11afSPaul Mackerras *      Low-level exception handers, MMU support, and rewrite.
1014cf11afSPaul Mackerras *    Copyright (c) 1997 Dan Malek <dmalek@jlc.net>
1114cf11afSPaul Mackerras *      PowerPC 8xx modifications.
1214cf11afSPaul Mackerras *    Copyright (c) 1998-1999 TiVo, Inc.
1314cf11afSPaul Mackerras *      PowerPC 403GCX modifications.
1414cf11afSPaul Mackerras *    Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
1514cf11afSPaul Mackerras *      PowerPC 403GCX/405GP modifications.
1614cf11afSPaul Mackerras *    Copyright 2000 MontaVista Software Inc.
1714cf11afSPaul Mackerras *	PPC405 modifications
1814cf11afSPaul Mackerras *      PowerPC 403GCX/405GP modifications.
1914cf11afSPaul Mackerras * 	Author: MontaVista Software, Inc.
2014cf11afSPaul Mackerras *         	frank_rowand@mvista.com or source@mvista.com
2114cf11afSPaul Mackerras * 	   	debbie_chu@mvista.com
2214cf11afSPaul Mackerras *    Copyright 2002-2005 MontaVista Software, Inc.
2314cf11afSPaul Mackerras *      PowerPC 44x support, Matt Porter <mporter@kernel.crashing.org>
2414cf11afSPaul Mackerras *
2514cf11afSPaul Mackerras * This program is free software; you can redistribute  it and/or modify it
2614cf11afSPaul Mackerras * under  the terms of  the GNU General  Public License as published by the
2714cf11afSPaul Mackerras * Free Software Foundation;  either version 2 of the  License, or (at your
2814cf11afSPaul Mackerras * option) any later version.
2914cf11afSPaul Mackerras */
3014cf11afSPaul Mackerras
31e7039845STim Abbott#include <linux/init.h>
3214cf11afSPaul Mackerras#include <asm/processor.h>
3314cf11afSPaul Mackerras#include <asm/page.h>
3414cf11afSPaul Mackerras#include <asm/mmu.h>
3514cf11afSPaul Mackerras#include <asm/pgtable.h>
3614cf11afSPaul Mackerras#include <asm/cputable.h>
3714cf11afSPaul Mackerras#include <asm/thread_info.h>
3814cf11afSPaul Mackerras#include <asm/ppc_asm.h>
3914cf11afSPaul Mackerras#include <asm/asm-offsets.h>
4014cf11afSPaul Mackerras#include "head_booke.h"
4114cf11afSPaul Mackerras
4214cf11afSPaul Mackerras
4314cf11afSPaul Mackerras/* As with the other PowerPC ports, it is expected that when code
4414cf11afSPaul Mackerras * execution begins here, the following registers contain valid, yet
4514cf11afSPaul Mackerras * optional, information:
4614cf11afSPaul Mackerras *
4714cf11afSPaul Mackerras *   r3 - Board info structure pointer (DRAM, frequency, MAC address, etc.)
4814cf11afSPaul Mackerras *   r4 - Starting address of the init RAM disk
4914cf11afSPaul Mackerras *   r5 - Ending address of the init RAM disk
5014cf11afSPaul Mackerras *   r6 - Start of kernel command line string (e.g. "mem=128")
5114cf11afSPaul Mackerras *   r7 - End of kernel command line string
5214cf11afSPaul Mackerras *
5314cf11afSPaul Mackerras */
54e7039845STim Abbott	__HEAD
55748a7683SKumar Gala_ENTRY(_stext);
56748a7683SKumar Gala_ENTRY(_start);
5714cf11afSPaul Mackerras	/*
5814cf11afSPaul Mackerras	 * Reserve a word at a fixed location to store the address
5914cf11afSPaul Mackerras	 * of abatron_pteptrs
6014cf11afSPaul Mackerras	 */
6114cf11afSPaul Mackerras	nop
6214cf11afSPaul Mackerras/*
6314cf11afSPaul Mackerras * Save parameters we are passed
6414cf11afSPaul Mackerras */
6514cf11afSPaul Mackerras	mr	r31,r3
6614cf11afSPaul Mackerras	mr	r30,r4
6714cf11afSPaul Mackerras	mr	r29,r5
6814cf11afSPaul Mackerras	mr	r28,r6
6914cf11afSPaul Mackerras	mr	r27,r7
7014cf11afSPaul Mackerras	li	r24,0		/* CPU number */
7114cf11afSPaul Mackerras
72*795033c3SDave Kleikamp	bl	init_cpu_state
7314cf11afSPaul Mackerras
7414cf11afSPaul Mackerras	/*
7514cf11afSPaul Mackerras	 * This is where the main kernel code starts.
7614cf11afSPaul Mackerras	 */
7714cf11afSPaul Mackerras
7814cf11afSPaul Mackerras	/* ptr to current */
7914cf11afSPaul Mackerras	lis	r2,init_task@h
8014cf11afSPaul Mackerras	ori	r2,r2,init_task@l
8114cf11afSPaul Mackerras
8214cf11afSPaul Mackerras	/* ptr to current thread */
8314cf11afSPaul Mackerras	addi	r4,r2,THREAD	/* init task's THREAD */
84ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_THREAD,r4
8514cf11afSPaul Mackerras
8614cf11afSPaul Mackerras	/* stack */
8714cf11afSPaul Mackerras	lis	r1,init_thread_union@h
8814cf11afSPaul Mackerras	ori	r1,r1,init_thread_union@l
8914cf11afSPaul Mackerras	li	r0,0
9014cf11afSPaul Mackerras	stwu	r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1)
9114cf11afSPaul Mackerras
9214cf11afSPaul Mackerras	bl	early_init
9314cf11afSPaul Mackerras
9414cf11afSPaul Mackerras/*
9514cf11afSPaul Mackerras * Decide what sort of machine this is and initialize the MMU.
9614cf11afSPaul Mackerras */
9714cf11afSPaul Mackerras	mr	r3,r31
9814cf11afSPaul Mackerras	mr	r4,r30
9914cf11afSPaul Mackerras	mr	r5,r29
10014cf11afSPaul Mackerras	mr	r6,r28
10114cf11afSPaul Mackerras	mr	r7,r27
10214cf11afSPaul Mackerras	bl	machine_init
10314cf11afSPaul Mackerras	bl	MMU_init
10414cf11afSPaul Mackerras
10514cf11afSPaul Mackerras	/* Setup PTE pointers for the Abatron bdiGDB */
10614cf11afSPaul Mackerras	lis	r6, swapper_pg_dir@h
10714cf11afSPaul Mackerras	ori	r6, r6, swapper_pg_dir@l
10814cf11afSPaul Mackerras	lis	r5, abatron_pteptrs@h
10914cf11afSPaul Mackerras	ori	r5, r5, abatron_pteptrs@l
11014cf11afSPaul Mackerras	lis	r4, KERNELBASE@h
11114cf11afSPaul Mackerras	ori	r4, r4, KERNELBASE@l
11214cf11afSPaul Mackerras	stw	r5, 0(r4)	/* Save abatron_pteptrs at a fixed location */
11314cf11afSPaul Mackerras	stw	r6, 0(r5)
11414cf11afSPaul Mackerras
11514cf11afSPaul Mackerras	/* Let's move on */
11614cf11afSPaul Mackerras	lis	r4,start_kernel@h
11714cf11afSPaul Mackerras	ori	r4,r4,start_kernel@l
11814cf11afSPaul Mackerras	lis	r3,MSR_KERNEL@h
11914cf11afSPaul Mackerras	ori	r3,r3,MSR_KERNEL@l
12014cf11afSPaul Mackerras	mtspr	SPRN_SRR0,r4
12114cf11afSPaul Mackerras	mtspr	SPRN_SRR1,r3
12214cf11afSPaul Mackerras	rfi			/* change context and jump to start_kernel */
12314cf11afSPaul Mackerras
12414cf11afSPaul Mackerras/*
12514cf11afSPaul Mackerras * Interrupt vector entry code
12614cf11afSPaul Mackerras *
12714cf11afSPaul Mackerras * The Book E MMUs are always on so we don't need to handle
12814cf11afSPaul Mackerras * interrupts in real mode as with previous PPC processors. In
12914cf11afSPaul Mackerras * this case we handle interrupts in the kernel virtual address
13014cf11afSPaul Mackerras * space.
13114cf11afSPaul Mackerras *
13214cf11afSPaul Mackerras * Interrupt vectors are dynamically placed relative to the
13314cf11afSPaul Mackerras * interrupt prefix as determined by the address of interrupt_base.
13414cf11afSPaul Mackerras * The interrupt vectors offsets are programmed using the labels
13514cf11afSPaul Mackerras * for each interrupt vector entry.
13614cf11afSPaul Mackerras *
13714cf11afSPaul Mackerras * Interrupt vectors must be aligned on a 16 byte boundary.
13814cf11afSPaul Mackerras * We align on a 32 byte cache line boundary for good measure.
13914cf11afSPaul Mackerras */
14014cf11afSPaul Mackerras
14114cf11afSPaul Mackerrasinterrupt_base:
14214cf11afSPaul Mackerras	/* Critical Input Interrupt */
143dc1c1ca3SStephen Rothwell	CRITICAL_EXCEPTION(0x0100, CriticalInput, unknown_exception)
14414cf11afSPaul Mackerras
14514cf11afSPaul Mackerras	/* Machine Check Interrupt */
146dc1c1ca3SStephen Rothwell	CRITICAL_EXCEPTION(0x0200, MachineCheck, machine_check_exception)
14747c0bd1aSBenjamin Herrenschmidt	MCHECK_EXCEPTION(0x0210, MachineCheckA, machine_check_exception)
14814cf11afSPaul Mackerras
14914cf11afSPaul Mackerras	/* Data Storage Interrupt */
1501bc54c03SBenjamin Herrenschmidt	DATA_STORAGE_EXCEPTION
15114cf11afSPaul Mackerras
15214cf11afSPaul Mackerras		/* Instruction Storage Interrupt */
15314cf11afSPaul Mackerras	INSTRUCTION_STORAGE_EXCEPTION
15414cf11afSPaul Mackerras
15514cf11afSPaul Mackerras	/* External Input Interrupt */
15614cf11afSPaul Mackerras	EXCEPTION(0x0500, ExternalInput, do_IRQ, EXC_XFER_LITE)
15714cf11afSPaul Mackerras
15814cf11afSPaul Mackerras	/* Alignment Interrupt */
15914cf11afSPaul Mackerras	ALIGNMENT_EXCEPTION
16014cf11afSPaul Mackerras
16114cf11afSPaul Mackerras	/* Program Interrupt */
16214cf11afSPaul Mackerras	PROGRAM_EXCEPTION
16314cf11afSPaul Mackerras
16414cf11afSPaul Mackerras	/* Floating Point Unavailable Interrupt */
16514cf11afSPaul Mackerras#ifdef CONFIG_PPC_FPU
16614cf11afSPaul Mackerras	FP_UNAVAILABLE_EXCEPTION
16714cf11afSPaul Mackerras#else
168dc1c1ca3SStephen Rothwell	EXCEPTION(0x2010, FloatingPointUnavailable, unknown_exception, EXC_XFER_EE)
16914cf11afSPaul Mackerras#endif
17014cf11afSPaul Mackerras	/* System Call Interrupt */
17114cf11afSPaul Mackerras	START_EXCEPTION(SystemCall)
17214cf11afSPaul Mackerras	NORMAL_EXCEPTION_PROLOG
17314cf11afSPaul Mackerras	EXC_XFER_EE_LITE(0x0c00, DoSyscall)
17414cf11afSPaul Mackerras
17514cf11afSPaul Mackerras	/* Auxillary Processor Unavailable Interrupt */
176dc1c1ca3SStephen Rothwell	EXCEPTION(0x2020, AuxillaryProcessorUnavailable, unknown_exception, EXC_XFER_EE)
17714cf11afSPaul Mackerras
17814cf11afSPaul Mackerras	/* Decrementer Interrupt */
17914cf11afSPaul Mackerras	DECREMENTER_EXCEPTION
18014cf11afSPaul Mackerras
18114cf11afSPaul Mackerras	/* Fixed Internal Timer Interrupt */
18214cf11afSPaul Mackerras	/* TODO: Add FIT support */
183dc1c1ca3SStephen Rothwell	EXCEPTION(0x1010, FixedIntervalTimer, unknown_exception, EXC_XFER_EE)
18414cf11afSPaul Mackerras
18514cf11afSPaul Mackerras	/* Watchdog Timer Interrupt */
18614cf11afSPaul Mackerras	/* TODO: Add watchdog support */
18714cf11afSPaul Mackerras#ifdef CONFIG_BOOKE_WDT
18814cf11afSPaul Mackerras	CRITICAL_EXCEPTION(0x1020, WatchdogTimer, WatchdogException)
18914cf11afSPaul Mackerras#else
190dc1c1ca3SStephen Rothwell	CRITICAL_EXCEPTION(0x1020, WatchdogTimer, unknown_exception)
19114cf11afSPaul Mackerras#endif
19214cf11afSPaul Mackerras
19314cf11afSPaul Mackerras	/* Data TLB Error Interrupt */
19414cf11afSPaul Mackerras	START_EXCEPTION(DataTLBError)
195ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH0, r10		/* Save some working registers */
196ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH1, r11
197ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH2, r12
198ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH3, r13
19914cf11afSPaul Mackerras	mfcr	r11
200ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH4, r11
20114cf11afSPaul Mackerras	mfspr	r10, SPRN_DEAR		/* Get faulting address */
20214cf11afSPaul Mackerras
20314cf11afSPaul Mackerras	/* If we are faulting a kernel address, we have to use the
20414cf11afSPaul Mackerras	 * kernel page tables.
20514cf11afSPaul Mackerras	 */
2068a13c4f9SKumar Gala	lis	r11, PAGE_OFFSET@h
20714cf11afSPaul Mackerras	cmplw	r10, r11
20814cf11afSPaul Mackerras	blt+	3f
20914cf11afSPaul Mackerras	lis	r11, swapper_pg_dir@h
21014cf11afSPaul Mackerras	ori	r11, r11, swapper_pg_dir@l
21114cf11afSPaul Mackerras
21214cf11afSPaul Mackerras	mfspr	r12,SPRN_MMUCR
21314cf11afSPaul Mackerras	rlwinm	r12,r12,0,0,23		/* Clear TID */
21414cf11afSPaul Mackerras
21514cf11afSPaul Mackerras	b	4f
21614cf11afSPaul Mackerras
21714cf11afSPaul Mackerras	/* Get the PGD for the current thread */
21814cf11afSPaul Mackerras3:
219ee43eb78SBenjamin Herrenschmidt	mfspr	r11,SPRN_SPRG_THREAD
22014cf11afSPaul Mackerras	lwz	r11,PGDIR(r11)
22114cf11afSPaul Mackerras
22214cf11afSPaul Mackerras	/* Load PID into MMUCR TID */
22314cf11afSPaul Mackerras	mfspr	r12,SPRN_MMUCR
22414cf11afSPaul Mackerras	mfspr   r13,SPRN_PID		/* Get PID */
22514cf11afSPaul Mackerras	rlwimi	r12,r13,0,24,31		/* Set TID */
22614cf11afSPaul Mackerras
22714cf11afSPaul Mackerras4:
22814cf11afSPaul Mackerras	mtspr	SPRN_MMUCR,r12
22914cf11afSPaul Mackerras
2301bc54c03SBenjamin Herrenschmidt	/* Mask of required permission bits. Note that while we
2311bc54c03SBenjamin Herrenschmidt	 * do copy ESR:ST to _PAGE_RW position as trying to write
2321bc54c03SBenjamin Herrenschmidt	 * to an RO page is pretty common, we don't do it with
2331bc54c03SBenjamin Herrenschmidt	 * _PAGE_DIRTY. We could do it, but it's a fairly rare
2341bc54c03SBenjamin Herrenschmidt	 * event so I'd rather take the overhead when it happens
2351bc54c03SBenjamin Herrenschmidt	 * rather than adding an instruction here. We should measure
2361bc54c03SBenjamin Herrenschmidt	 * whether the whole thing is worth it in the first place
2371bc54c03SBenjamin Herrenschmidt	 * as we could avoid loading SPRN_ESR completely in the first
2381bc54c03SBenjamin Herrenschmidt	 * place...
2391bc54c03SBenjamin Herrenschmidt	 *
2401bc54c03SBenjamin Herrenschmidt	 * TODO: Is it worth doing that mfspr & rlwimi in the first
2411bc54c03SBenjamin Herrenschmidt	 *       place or can we save a couple of instructions here ?
2421bc54c03SBenjamin Herrenschmidt	 */
2431bc54c03SBenjamin Herrenschmidt	mfspr	r12,SPRN_ESR
2441bc54c03SBenjamin Herrenschmidt	li	r13,_PAGE_PRESENT|_PAGE_ACCESSED
2451bc54c03SBenjamin Herrenschmidt	rlwimi	r13,r12,10,30,30
2461bc54c03SBenjamin Herrenschmidt
2471bc54c03SBenjamin Herrenschmidt	/* Load the PTE */
248ca9153a3SIlya Yanok	/* Compute pgdir/pmd offset */
249ca9153a3SIlya Yanok	rlwinm  r12, r10, PPC44x_PGD_OFF_SHIFT, PPC44x_PGD_OFF_MASK_BIT, 29
25014cf11afSPaul Mackerras	lwzx	r11, r12, r11		/* Get pgd/pmd entry */
25114cf11afSPaul Mackerras	rlwinm.	r12, r11, 0, 0, 20	/* Extract pt base address */
25214cf11afSPaul Mackerras	beq	2f			/* Bail if no table */
25314cf11afSPaul Mackerras
254ca9153a3SIlya Yanok	/* Compute pte address */
255ca9153a3SIlya Yanok	rlwimi  r12, r10, PPC44x_PTE_ADD_SHIFT, PPC44x_PTE_ADD_MASK_BIT, 28
2561bc54c03SBenjamin Herrenschmidt	lwz	r11, 0(r12)		/* Get high word of pte entry */
2571bc54c03SBenjamin Herrenschmidt	lwz	r12, 4(r12)		/* Get low word of pte entry */
25814cf11afSPaul Mackerras
2591bc54c03SBenjamin Herrenschmidt	lis	r10,tlb_44x_index@ha
2601bc54c03SBenjamin Herrenschmidt
2611bc54c03SBenjamin Herrenschmidt	andc.	r13,r13,r12		/* Check permission */
2621bc54c03SBenjamin Herrenschmidt
2631bc54c03SBenjamin Herrenschmidt	/* Load the next available TLB index */
2641bc54c03SBenjamin Herrenschmidt	lwz	r13,tlb_44x_index@l(r10)
2651bc54c03SBenjamin Herrenschmidt
2661bc54c03SBenjamin Herrenschmidt	bne	2f			/* Bail if permission mismach */
2671bc54c03SBenjamin Herrenschmidt
2681bc54c03SBenjamin Herrenschmidt	/* Increment, rollover, and store TLB index */
2691bc54c03SBenjamin Herrenschmidt	addi	r13,r13,1
2701bc54c03SBenjamin Herrenschmidt
2711bc54c03SBenjamin Herrenschmidt	/* Compare with watermark (instruction gets patched) */
2721bc54c03SBenjamin Herrenschmidt	.globl tlb_44x_patch_hwater_D
2731bc54c03SBenjamin Herrenschmidttlb_44x_patch_hwater_D:
2741bc54c03SBenjamin Herrenschmidt	cmpwi	0,r13,1			/* reserve entries */
2751bc54c03SBenjamin Herrenschmidt	ble	5f
2761bc54c03SBenjamin Herrenschmidt	li	r13,0
2771bc54c03SBenjamin Herrenschmidt5:
2781bc54c03SBenjamin Herrenschmidt	/* Store the next available TLB index */
2791bc54c03SBenjamin Herrenschmidt	stw	r13,tlb_44x_index@l(r10)
2801bc54c03SBenjamin Herrenschmidt
2811bc54c03SBenjamin Herrenschmidt	/* Re-load the faulting address */
2821bc54c03SBenjamin Herrenschmidt	mfspr	r10,SPRN_DEAR
28314cf11afSPaul Mackerras
28414cf11afSPaul Mackerras	 /* Jump to common tlb load */
28514cf11afSPaul Mackerras	b	finish_tlb_load
28614cf11afSPaul Mackerras
28714cf11afSPaul Mackerras2:
28814cf11afSPaul Mackerras	/* The bailout.  Restore registers to pre-exception conditions
28914cf11afSPaul Mackerras	 * and call the heavyweights to help us out.
29014cf11afSPaul Mackerras	 */
291ee43eb78SBenjamin Herrenschmidt	mfspr	r11, SPRN_SPRG_RSCRATCH4
29214cf11afSPaul Mackerras	mtcr	r11
293ee43eb78SBenjamin Herrenschmidt	mfspr	r13, SPRN_SPRG_RSCRATCH3
294ee43eb78SBenjamin Herrenschmidt	mfspr	r12, SPRN_SPRG_RSCRATCH2
295ee43eb78SBenjamin Herrenschmidt	mfspr	r11, SPRN_SPRG_RSCRATCH1
296ee43eb78SBenjamin Herrenschmidt	mfspr	r10, SPRN_SPRG_RSCRATCH0
2971bc54c03SBenjamin Herrenschmidt	b	DataStorage
29814cf11afSPaul Mackerras
29914cf11afSPaul Mackerras	/* Instruction TLB Error Interrupt */
30014cf11afSPaul Mackerras	/*
30114cf11afSPaul Mackerras	 * Nearly the same as above, except we get our
30214cf11afSPaul Mackerras	 * information from different registers and bailout
30314cf11afSPaul Mackerras	 * to a different point.
30414cf11afSPaul Mackerras	 */
30514cf11afSPaul Mackerras	START_EXCEPTION(InstructionTLBError)
306ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */
307ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH1, r11
308ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH2, r12
309ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH3, r13
31014cf11afSPaul Mackerras	mfcr	r11
311ee43eb78SBenjamin Herrenschmidt	mtspr	SPRN_SPRG_WSCRATCH4, r11
31214cf11afSPaul Mackerras	mfspr	r10, SPRN_SRR0		/* Get faulting address */
31314cf11afSPaul Mackerras
31414cf11afSPaul Mackerras	/* If we are faulting a kernel address, we have to use the
31514cf11afSPaul Mackerras	 * kernel page tables.
31614cf11afSPaul Mackerras	 */
3178a13c4f9SKumar Gala	lis	r11, PAGE_OFFSET@h
31814cf11afSPaul Mackerras	cmplw	r10, r11
31914cf11afSPaul Mackerras	blt+	3f
32014cf11afSPaul Mackerras	lis	r11, swapper_pg_dir@h
32114cf11afSPaul Mackerras	ori	r11, r11, swapper_pg_dir@l
32214cf11afSPaul Mackerras
32314cf11afSPaul Mackerras	mfspr	r12,SPRN_MMUCR
32414cf11afSPaul Mackerras	rlwinm	r12,r12,0,0,23		/* Clear TID */
32514cf11afSPaul Mackerras
32614cf11afSPaul Mackerras	b	4f
32714cf11afSPaul Mackerras
32814cf11afSPaul Mackerras	/* Get the PGD for the current thread */
32914cf11afSPaul Mackerras3:
330ee43eb78SBenjamin Herrenschmidt	mfspr	r11,SPRN_SPRG_THREAD
33114cf11afSPaul Mackerras	lwz	r11,PGDIR(r11)
33214cf11afSPaul Mackerras
33314cf11afSPaul Mackerras	/* Load PID into MMUCR TID */
33414cf11afSPaul Mackerras	mfspr	r12,SPRN_MMUCR
33514cf11afSPaul Mackerras	mfspr   r13,SPRN_PID		/* Get PID */
33614cf11afSPaul Mackerras	rlwimi	r12,r13,0,24,31		/* Set TID */
33714cf11afSPaul Mackerras
33814cf11afSPaul Mackerras4:
33914cf11afSPaul Mackerras	mtspr	SPRN_MMUCR,r12
34014cf11afSPaul Mackerras
3411bc54c03SBenjamin Herrenschmidt	/* Make up the required permissions */
342ea3cc330SBenjamin Herrenschmidt	li	r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
3431bc54c03SBenjamin Herrenschmidt
344ca9153a3SIlya Yanok	/* Compute pgdir/pmd offset */
345ca9153a3SIlya Yanok	rlwinm 	r12, r10, PPC44x_PGD_OFF_SHIFT, PPC44x_PGD_OFF_MASK_BIT, 29
34614cf11afSPaul Mackerras	lwzx	r11, r12, r11		/* Get pgd/pmd entry */
34714cf11afSPaul Mackerras	rlwinm.	r12, r11, 0, 0, 20	/* Extract pt base address */
34814cf11afSPaul Mackerras	beq	2f			/* Bail if no table */
34914cf11afSPaul Mackerras
350ca9153a3SIlya Yanok	/* Compute pte address */
351ca9153a3SIlya Yanok	rlwimi	r12, r10, PPC44x_PTE_ADD_SHIFT, PPC44x_PTE_ADD_MASK_BIT, 28
3521bc54c03SBenjamin Herrenschmidt	lwz	r11, 0(r12)		/* Get high word of pte entry */
3531bc54c03SBenjamin Herrenschmidt	lwz	r12, 4(r12)		/* Get low word of pte entry */
35414cf11afSPaul Mackerras
3551bc54c03SBenjamin Herrenschmidt	lis	r10,tlb_44x_index@ha
3561bc54c03SBenjamin Herrenschmidt
3571bc54c03SBenjamin Herrenschmidt	andc.	r13,r13,r12		/* Check permission */
3581bc54c03SBenjamin Herrenschmidt
3591bc54c03SBenjamin Herrenschmidt	/* Load the next available TLB index */
3601bc54c03SBenjamin Herrenschmidt	lwz	r13,tlb_44x_index@l(r10)
3611bc54c03SBenjamin Herrenschmidt
3621bc54c03SBenjamin Herrenschmidt	bne	2f			/* Bail if permission mismach */
3631bc54c03SBenjamin Herrenschmidt
3641bc54c03SBenjamin Herrenschmidt	/* Increment, rollover, and store TLB index */
3651bc54c03SBenjamin Herrenschmidt	addi	r13,r13,1
3661bc54c03SBenjamin Herrenschmidt
3671bc54c03SBenjamin Herrenschmidt	/* Compare with watermark (instruction gets patched) */
3681bc54c03SBenjamin Herrenschmidt	.globl tlb_44x_patch_hwater_I
3691bc54c03SBenjamin Herrenschmidttlb_44x_patch_hwater_I:
3701bc54c03SBenjamin Herrenschmidt	cmpwi	0,r13,1			/* reserve entries */
3711bc54c03SBenjamin Herrenschmidt	ble	5f
3721bc54c03SBenjamin Herrenschmidt	li	r13,0
3731bc54c03SBenjamin Herrenschmidt5:
3741bc54c03SBenjamin Herrenschmidt	/* Store the next available TLB index */
3751bc54c03SBenjamin Herrenschmidt	stw	r13,tlb_44x_index@l(r10)
3761bc54c03SBenjamin Herrenschmidt
3771bc54c03SBenjamin Herrenschmidt	/* Re-load the faulting address */
3781bc54c03SBenjamin Herrenschmidt	mfspr	r10,SPRN_SRR0
37914cf11afSPaul Mackerras
38014cf11afSPaul Mackerras	/* Jump to common TLB load point */
38114cf11afSPaul Mackerras	b	finish_tlb_load
38214cf11afSPaul Mackerras
38314cf11afSPaul Mackerras2:
38414cf11afSPaul Mackerras	/* The bailout.  Restore registers to pre-exception conditions
38514cf11afSPaul Mackerras	 * and call the heavyweights to help us out.
38614cf11afSPaul Mackerras	 */
387ee43eb78SBenjamin Herrenschmidt	mfspr	r11, SPRN_SPRG_RSCRATCH4
38814cf11afSPaul Mackerras	mtcr	r11
389ee43eb78SBenjamin Herrenschmidt	mfspr	r13, SPRN_SPRG_RSCRATCH3
390ee43eb78SBenjamin Herrenschmidt	mfspr	r12, SPRN_SPRG_RSCRATCH2
391ee43eb78SBenjamin Herrenschmidt	mfspr	r11, SPRN_SPRG_RSCRATCH1
392ee43eb78SBenjamin Herrenschmidt	mfspr	r10, SPRN_SPRG_RSCRATCH0
39314cf11afSPaul Mackerras	b	InstructionStorage
39414cf11afSPaul Mackerras
39514cf11afSPaul Mackerras	/* Debug Interrupt */
396eb0cd5fdSKumar Gala	DEBUG_CRIT_EXCEPTION
39714cf11afSPaul Mackerras
39814cf11afSPaul Mackerras/*
39914cf11afSPaul Mackerras * Local functions
40014cf11afSPaul Mackerras  */
40114cf11afSPaul Mackerras
40214cf11afSPaul Mackerras/*
40314cf11afSPaul Mackerras
40414cf11afSPaul Mackerras * Both the instruction and data TLB miss get to this
40514cf11afSPaul Mackerras * point to load the TLB.
40614cf11afSPaul Mackerras * 	r10 - EA of fault
4071bc54c03SBenjamin Herrenschmidt * 	r11 - PTE high word value
4081bc54c03SBenjamin Herrenschmidt *	r12 - PTE low word value
4091bc54c03SBenjamin Herrenschmidt *	r13 - TLB index
41014cf11afSPaul Mackerras *	MMUCR - loaded with proper value when we get here
41114cf11afSPaul Mackerras *	Upon exit, we reload everything and RFI.
41214cf11afSPaul Mackerras */
41314cf11afSPaul Mackerrasfinish_tlb_load:
4141bc54c03SBenjamin Herrenschmidt	/* Combine RPN & ERPN an write WS 0 */
415ca9153a3SIlya Yanok	rlwimi	r11,r12,0,0,31-PAGE_SHIFT
4161bc54c03SBenjamin Herrenschmidt	tlbwe	r11,r13,PPC44x_TLB_XLAT
41714cf11afSPaul Mackerras
41814cf11afSPaul Mackerras	/*
4191bc54c03SBenjamin Herrenschmidt	 * Create WS1. This is the faulting address (EPN),
42014cf11afSPaul Mackerras	 * page size, and valid flag.
42114cf11afSPaul Mackerras	 */
422ca9153a3SIlya Yanok	li	r11,PPC44x_TLB_VALID | PPC44x_TLBE_SIZE
423ca9153a3SIlya Yanok	/* Insert valid and page size */
424ca9153a3SIlya Yanok	rlwimi	r10,r11,0,PPC44x_PTE_ADD_MASK_BIT,31
42514cf11afSPaul Mackerras	tlbwe	r10,r13,PPC44x_TLB_PAGEID	/* Write PAGEID */
42614cf11afSPaul Mackerras
4271bc54c03SBenjamin Herrenschmidt	/* And WS 2 */
4281bc54c03SBenjamin Herrenschmidt	li	r10,0xf85			/* Mask to apply from PTE */
4291bc54c03SBenjamin Herrenschmidt	rlwimi	r10,r12,29,30,30		/* DIRTY -> SW position */
4301bc54c03SBenjamin Herrenschmidt	and	r11,r12,r10			/* Mask PTE bits to keep */
4311bc54c03SBenjamin Herrenschmidt	andi.	r10,r12,_PAGE_USER		/* User page ? */
4321bc54c03SBenjamin Herrenschmidt	beq	1f				/* nope, leave U bits empty */
4331bc54c03SBenjamin Herrenschmidt	rlwimi	r11,r11,3,26,28			/* yes, copy S bits to U */
4341bc54c03SBenjamin Herrenschmidt1:	tlbwe	r11,r13,PPC44x_TLB_ATTRIB	/* Write ATTRIB */
43514cf11afSPaul Mackerras
43614cf11afSPaul Mackerras	/* Done...restore registers and get out of here.
43714cf11afSPaul Mackerras	*/
438ee43eb78SBenjamin Herrenschmidt	mfspr	r11, SPRN_SPRG_RSCRATCH4
43914cf11afSPaul Mackerras	mtcr	r11
440ee43eb78SBenjamin Herrenschmidt	mfspr	r13, SPRN_SPRG_RSCRATCH3
441ee43eb78SBenjamin Herrenschmidt	mfspr	r12, SPRN_SPRG_RSCRATCH2
442ee43eb78SBenjamin Herrenschmidt	mfspr	r11, SPRN_SPRG_RSCRATCH1
443ee43eb78SBenjamin Herrenschmidt	mfspr	r10, SPRN_SPRG_RSCRATCH0
44414cf11afSPaul Mackerras	rfi					/* Force context change */
44514cf11afSPaul Mackerras
44614cf11afSPaul Mackerras/*
44714cf11afSPaul Mackerras * Global functions
44814cf11afSPaul Mackerras */
44914cf11afSPaul Mackerras
45014cf11afSPaul Mackerras/*
45147c0bd1aSBenjamin Herrenschmidt * Adjust the machine check IVOR on 440A cores
45247c0bd1aSBenjamin Herrenschmidt */
45347c0bd1aSBenjamin Herrenschmidt_GLOBAL(__fixup_440A_mcheck)
45447c0bd1aSBenjamin Herrenschmidt	li	r3,MachineCheckA@l
45547c0bd1aSBenjamin Herrenschmidt	mtspr	SPRN_IVOR1,r3
45647c0bd1aSBenjamin Herrenschmidt	sync
45747c0bd1aSBenjamin Herrenschmidt	blr
45847c0bd1aSBenjamin Herrenschmidt
45947c0bd1aSBenjamin Herrenschmidt/*
46014cf11afSPaul Mackerras * extern void giveup_altivec(struct task_struct *prev)
46114cf11afSPaul Mackerras *
46214cf11afSPaul Mackerras * The 44x core does not have an AltiVec unit.
46314cf11afSPaul Mackerras */
46414cf11afSPaul Mackerras_GLOBAL(giveup_altivec)
46514cf11afSPaul Mackerras	blr
46614cf11afSPaul Mackerras
46714cf11afSPaul Mackerras/*
46814cf11afSPaul Mackerras * extern void giveup_fpu(struct task_struct *prev)
46914cf11afSPaul Mackerras *
47014cf11afSPaul Mackerras * The 44x core does not have an FPU.
47114cf11afSPaul Mackerras */
47214cf11afSPaul Mackerras#ifndef CONFIG_PPC_FPU
47314cf11afSPaul Mackerras_GLOBAL(giveup_fpu)
47414cf11afSPaul Mackerras	blr
47514cf11afSPaul Mackerras#endif
47614cf11afSPaul Mackerras
47714cf11afSPaul Mackerras_GLOBAL(set_context)
47814cf11afSPaul Mackerras
47914cf11afSPaul Mackerras#ifdef CONFIG_BDI_SWITCH
48014cf11afSPaul Mackerras	/* Context switch the PTE pointer for the Abatron BDI2000.
48114cf11afSPaul Mackerras	 * The PGDIR is the second parameter.
48214cf11afSPaul Mackerras	 */
48314cf11afSPaul Mackerras	lis	r5, abatron_pteptrs@h
48414cf11afSPaul Mackerras	ori	r5, r5, abatron_pteptrs@l
48514cf11afSPaul Mackerras	stw	r4, 0x4(r5)
48614cf11afSPaul Mackerras#endif
48714cf11afSPaul Mackerras	mtspr	SPRN_PID,r3
48814cf11afSPaul Mackerras	isync			/* Force context change */
48914cf11afSPaul Mackerras	blr
49014cf11afSPaul Mackerras
49114cf11afSPaul Mackerras/*
492*795033c3SDave Kleikamp * Init CPU state. This is called at boot time or for secondary CPUs
493*795033c3SDave Kleikamp * to setup initial TLB entries, setup IVORs, etc...
494*795033c3SDave Kleikamp */
495*795033c3SDave Kleikamp_GLOBAL(init_cpu_state)
496*795033c3SDave Kleikamp	mflr	r22
497*795033c3SDave Kleikamp/*
498*795033c3SDave Kleikamp * In case the firmware didn't do it, we apply some workarounds
499*795033c3SDave Kleikamp * that are good for all 440 core variants here
500*795033c3SDave Kleikamp */
501*795033c3SDave Kleikamp	mfspr	r3,SPRN_CCR0
502*795033c3SDave Kleikamp	rlwinm	r3,r3,0,0,27	/* disable icache prefetch */
503*795033c3SDave Kleikamp	isync
504*795033c3SDave Kleikamp	mtspr	SPRN_CCR0,r3
505*795033c3SDave Kleikamp	isync
506*795033c3SDave Kleikamp	sync
507*795033c3SDave Kleikamp
508*795033c3SDave Kleikamp/*
509*795033c3SDave Kleikamp * Set up the initial MMU state
510*795033c3SDave Kleikamp *
511*795033c3SDave Kleikamp * We are still executing code at the virtual address
512*795033c3SDave Kleikamp * mappings set by the firmware for the base of RAM.
513*795033c3SDave Kleikamp *
514*795033c3SDave Kleikamp * We first invalidate all TLB entries but the one
515*795033c3SDave Kleikamp * we are running from.  We then load the KERNELBASE
516*795033c3SDave Kleikamp * mappings so we can begin to use kernel addresses
517*795033c3SDave Kleikamp * natively and so the interrupt vector locations are
518*795033c3SDave Kleikamp * permanently pinned (necessary since Book E
519*795033c3SDave Kleikamp * implementations always have translation enabled).
520*795033c3SDave Kleikamp *
521*795033c3SDave Kleikamp * TODO: Use the known TLB entry we are running from to
522*795033c3SDave Kleikamp *	 determine which physical region we are located
523*795033c3SDave Kleikamp *	 in.  This can be used to determine where in RAM
524*795033c3SDave Kleikamp *	 (on a shared CPU system) or PCI memory space
525*795033c3SDave Kleikamp *	 (on a DRAMless system) we are located.
526*795033c3SDave Kleikamp *       For now, we assume a perfect world which means
527*795033c3SDave Kleikamp *	 we are located at the base of DRAM (physical 0).
528*795033c3SDave Kleikamp */
529*795033c3SDave Kleikamp
530*795033c3SDave Kleikamp/*
531*795033c3SDave Kleikamp * Search TLB for entry that we are currently using.
532*795033c3SDave Kleikamp * Invalidate all entries but the one we are using.
533*795033c3SDave Kleikamp */
534*795033c3SDave Kleikamp	/* Load our current PID->MMUCR TID and MSR IS->MMUCR STS */
535*795033c3SDave Kleikamp	mfspr	r3,SPRN_PID			/* Get PID */
536*795033c3SDave Kleikamp	mfmsr	r4				/* Get MSR */
537*795033c3SDave Kleikamp	andi.	r4,r4,MSR_IS@l			/* TS=1? */
538*795033c3SDave Kleikamp	beq	wmmucr				/* If not, leave STS=0 */
539*795033c3SDave Kleikamp	oris	r3,r3,PPC44x_MMUCR_STS@h	/* Set STS=1 */
540*795033c3SDave Kleikampwmmucr:	mtspr	SPRN_MMUCR,r3			/* Put MMUCR */
541*795033c3SDave Kleikamp	sync
542*795033c3SDave Kleikamp
543*795033c3SDave Kleikamp	bl	invstr				/* Find our address */
544*795033c3SDave Kleikampinvstr:	mflr	r5				/* Make it accessible */
545*795033c3SDave Kleikamp	tlbsx	r23,0,r5			/* Find entry we are in */
546*795033c3SDave Kleikamp	li	r4,0				/* Start at TLB entry 0 */
547*795033c3SDave Kleikamp	li	r3,0				/* Set PAGEID inval value */
548*795033c3SDave Kleikamp1:	cmpw	r23,r4				/* Is this our entry? */
549*795033c3SDave Kleikamp	beq	skpinv				/* If so, skip the inval */
550*795033c3SDave Kleikamp	tlbwe	r3,r4,PPC44x_TLB_PAGEID		/* If not, inval the entry */
551*795033c3SDave Kleikampskpinv:	addi	r4,r4,1				/* Increment */
552*795033c3SDave Kleikamp	cmpwi	r4,64				/* Are we done? */
553*795033c3SDave Kleikamp	bne	1b				/* If not, repeat */
554*795033c3SDave Kleikamp	isync					/* If so, context change */
555*795033c3SDave Kleikamp
556*795033c3SDave Kleikamp/*
557*795033c3SDave Kleikamp * Configure and load pinned entry into TLB slot 63.
558*795033c3SDave Kleikamp */
559*795033c3SDave Kleikamp
560*795033c3SDave Kleikamp	lis	r3,PAGE_OFFSET@h
561*795033c3SDave Kleikamp	ori	r3,r3,PAGE_OFFSET@l
562*795033c3SDave Kleikamp
563*795033c3SDave Kleikamp	/* Kernel is at the base of RAM */
564*795033c3SDave Kleikamp	li r4, 0			/* Load the kernel physical address */
565*795033c3SDave Kleikamp
566*795033c3SDave Kleikamp	/* Load the kernel PID = 0 */
567*795033c3SDave Kleikamp	li	r0,0
568*795033c3SDave Kleikamp	mtspr	SPRN_PID,r0
569*795033c3SDave Kleikamp	sync
570*795033c3SDave Kleikamp
571*795033c3SDave Kleikamp	/* Initialize MMUCR */
572*795033c3SDave Kleikamp	li	r5,0
573*795033c3SDave Kleikamp	mtspr	SPRN_MMUCR,r5
574*795033c3SDave Kleikamp	sync
575*795033c3SDave Kleikamp
576*795033c3SDave Kleikamp	/* pageid fields */
577*795033c3SDave Kleikamp	clrrwi	r3,r3,10		/* Mask off the effective page number */
578*795033c3SDave Kleikamp	ori	r3,r3,PPC44x_TLB_VALID | PPC44x_TLB_256M
579*795033c3SDave Kleikamp
580*795033c3SDave Kleikamp	/* xlat fields */
581*795033c3SDave Kleikamp	clrrwi	r4,r4,10		/* Mask off the real page number */
582*795033c3SDave Kleikamp					/* ERPN is 0 for first 4GB page */
583*795033c3SDave Kleikamp
584*795033c3SDave Kleikamp	/* attrib fields */
585*795033c3SDave Kleikamp	/* Added guarded bit to protect against speculative loads/stores */
586*795033c3SDave Kleikamp	li	r5,0
587*795033c3SDave Kleikamp	ori	r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G)
588*795033c3SDave Kleikamp
589*795033c3SDave Kleikamp        li      r0,63                    /* TLB slot 63 */
590*795033c3SDave Kleikamp
591*795033c3SDave Kleikamp	tlbwe	r3,r0,PPC44x_TLB_PAGEID	/* Load the pageid fields */
592*795033c3SDave Kleikamp	tlbwe	r4,r0,PPC44x_TLB_XLAT	/* Load the translation fields */
593*795033c3SDave Kleikamp	tlbwe	r5,r0,PPC44x_TLB_ATTRIB	/* Load the attrib/access fields */
594*795033c3SDave Kleikamp
595*795033c3SDave Kleikamp	/* Force context change */
596*795033c3SDave Kleikamp	mfmsr	r0
597*795033c3SDave Kleikamp	mtspr	SPRN_SRR1, r0
598*795033c3SDave Kleikamp	lis	r0,3f@h
599*795033c3SDave Kleikamp	ori	r0,r0,3f@l
600*795033c3SDave Kleikamp	mtspr	SPRN_SRR0,r0
601*795033c3SDave Kleikamp	sync
602*795033c3SDave Kleikamp	rfi
603*795033c3SDave Kleikamp
604*795033c3SDave Kleikamp	/* If necessary, invalidate original entry we used */
605*795033c3SDave Kleikamp3:	cmpwi	r23,63
606*795033c3SDave Kleikamp	beq	4f
607*795033c3SDave Kleikamp	li	r6,0
608*795033c3SDave Kleikamp	tlbwe   r6,r23,PPC44x_TLB_PAGEID
609*795033c3SDave Kleikamp	isync
610*795033c3SDave Kleikamp
611*795033c3SDave Kleikamp4:
612*795033c3SDave Kleikamp#ifdef CONFIG_PPC_EARLY_DEBUG_44x
613*795033c3SDave Kleikamp	/* Add UART mapping for early debug. */
614*795033c3SDave Kleikamp
615*795033c3SDave Kleikamp	/* pageid fields */
616*795033c3SDave Kleikamp	lis	r3,PPC44x_EARLY_DEBUG_VIRTADDR@h
617*795033c3SDave Kleikamp	ori	r3,r3,PPC44x_TLB_VALID|PPC44x_TLB_TS|PPC44x_TLB_64K
618*795033c3SDave Kleikamp
619*795033c3SDave Kleikamp	/* xlat fields */
620*795033c3SDave Kleikamp	lis	r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSLOW@h
621*795033c3SDave Kleikamp	ori	r4,r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSHIGH
622*795033c3SDave Kleikamp
623*795033c3SDave Kleikamp	/* attrib fields */
624*795033c3SDave Kleikamp	li	r5,(PPC44x_TLB_SW|PPC44x_TLB_SR|PPC44x_TLB_I|PPC44x_TLB_G)
625*795033c3SDave Kleikamp        li      r0,62                    /* TLB slot 0 */
626*795033c3SDave Kleikamp
627*795033c3SDave Kleikamp	tlbwe	r3,r0,PPC44x_TLB_PAGEID
628*795033c3SDave Kleikamp	tlbwe	r4,r0,PPC44x_TLB_XLAT
629*795033c3SDave Kleikamp	tlbwe	r5,r0,PPC44x_TLB_ATTRIB
630*795033c3SDave Kleikamp
631*795033c3SDave Kleikamp	/* Force context change */
632*795033c3SDave Kleikamp	isync
633*795033c3SDave Kleikamp#endif /* CONFIG_PPC_EARLY_DEBUG_44x */
634*795033c3SDave Kleikamp
635*795033c3SDave Kleikamp	/* Establish the interrupt vector offsets */
636*795033c3SDave Kleikamp	SET_IVOR(0,  CriticalInput);
637*795033c3SDave Kleikamp	SET_IVOR(1,  MachineCheck);
638*795033c3SDave Kleikamp	SET_IVOR(2,  DataStorage);
639*795033c3SDave Kleikamp	SET_IVOR(3,  InstructionStorage);
640*795033c3SDave Kleikamp	SET_IVOR(4,  ExternalInput);
641*795033c3SDave Kleikamp	SET_IVOR(5,  Alignment);
642*795033c3SDave Kleikamp	SET_IVOR(6,  Program);
643*795033c3SDave Kleikamp	SET_IVOR(7,  FloatingPointUnavailable);
644*795033c3SDave Kleikamp	SET_IVOR(8,  SystemCall);
645*795033c3SDave Kleikamp	SET_IVOR(9,  AuxillaryProcessorUnavailable);
646*795033c3SDave Kleikamp	SET_IVOR(10, Decrementer);
647*795033c3SDave Kleikamp	SET_IVOR(11, FixedIntervalTimer);
648*795033c3SDave Kleikamp	SET_IVOR(12, WatchdogTimer);
649*795033c3SDave Kleikamp	SET_IVOR(13, DataTLBError);
650*795033c3SDave Kleikamp	SET_IVOR(14, InstructionTLBError);
651*795033c3SDave Kleikamp	SET_IVOR(15, DebugCrit);
652*795033c3SDave Kleikamp
653*795033c3SDave Kleikamp	/* Establish the interrupt vector base */
654*795033c3SDave Kleikamp	lis	r4,interrupt_base@h	/* IVPR only uses the high 16-bits */
655*795033c3SDave Kleikamp	mtspr	SPRN_IVPR,r4
656*795033c3SDave Kleikamp
657*795033c3SDave Kleikamp	addis	r22,r22,KERNELBASE@h
658*795033c3SDave Kleikamp	mtlr	r22
659*795033c3SDave Kleikamp	blr
660*795033c3SDave Kleikamp
661*795033c3SDave Kleikamp/*
66214cf11afSPaul Mackerras * We put a few things here that have to be page-aligned. This stuff
66314cf11afSPaul Mackerras * goes at the beginning of the data segment, which is page-aligned.
66414cf11afSPaul Mackerras */
66514cf11afSPaul Mackerras	.data
666ca9153a3SIlya Yanok	.align	PAGE_SHIFT
667ea703ce2SKumar Gala	.globl	sdata
668ea703ce2SKumar Galasdata:
669ea703ce2SKumar Gala	.globl	empty_zero_page
670ea703ce2SKumar Galaempty_zero_page:
671ca9153a3SIlya Yanok	.space	PAGE_SIZE
67214cf11afSPaul Mackerras
67314cf11afSPaul Mackerras/*
67414cf11afSPaul Mackerras * To support >32-bit physical addresses, we use an 8KB pgdir.
67514cf11afSPaul Mackerras */
676ea703ce2SKumar Gala	.globl	swapper_pg_dir
677ea703ce2SKumar Galaswapper_pg_dir:
678bee86f14SKumar Gala	.space	PGD_TABLE_SIZE
67914cf11afSPaul Mackerras
68014cf11afSPaul Mackerras/*
68114cf11afSPaul Mackerras * Room for two PTE pointers, usually the kernel and current user pointers
68214cf11afSPaul Mackerras * to their respective root page table.
68314cf11afSPaul Mackerras */
68414cf11afSPaul Mackerrasabatron_pteptrs:
68514cf11afSPaul Mackerras	.space	8
686