[PATCH] ocfs2: fix oops in mmap_truncate testing
[pandora-kernel.git] / arch / ppc / kernel / head.S
index c5a890d..e7e642b 100644 (file)
@@ -22,7 +22,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
 #include <asm/ppc_asm.h>
 #include <asm/asm-offsets.h>
 
-#ifdef CONFIG_APUS
-#include <asm/amigappc.h>
-#endif
-
-#ifdef CONFIG_PPC64BRIDGE
-#define LOAD_BAT(n, reg, RA, RB)       \
-       ld      RA,(n*32)+0(reg);       \
-       ld      RB,(n*32)+8(reg);       \
-       mtspr   SPRN_IBAT##n##U,RA;     \
-       mtspr   SPRN_IBAT##n##L,RB;     \
-       ld      RA,(n*32)+16(reg);      \
-       ld      RB,(n*32)+24(reg);      \
-       mtspr   SPRN_DBAT##n##U,RA;     \
-       mtspr   SPRN_DBAT##n##L,RB;     \
-
-#else /* CONFIG_PPC64BRIDGE */
-
 /* 601 only have IBAT; cr0.eq is set on 601 when using this macro */
 #define LOAD_BAT(n, reg, RA, RB)       \
        /* see the comment for clear_bats() -- Cort */ \
@@ -66,7 +48,6 @@
        mtspr   SPRN_DBAT##n##U,RA;     \
        mtspr   SPRN_DBAT##n##L,RB;     \
 1:
-#endif /* CONFIG_PPC64BRIDGE */
 
        .text
        .stabs  "arch/ppc/kernel/",N_SO,0,0,0f
@@ -129,11 +110,6 @@ _start:
 
        .globl  __start
 __start:
-/*
- * We have to do any OF calls before we map ourselves to KERNELBASE,
- * because OF may have I/O devices mapped into that area
- * (particularly on CHRP).
- */
        mr      r31,r3                  /* save parameters */
        mr      r30,r4
        mr      r29,r5
@@ -148,39 +124,18 @@ __start:
  */
        bl      early_init
 
-/*
- * On POWER4, we first need to tweak some CPU configuration registers
- * like real mode cache inhibit or exception base
- */
-#ifdef CONFIG_POWER4
-       bl      __970_cpu_preinit
-#endif /* CONFIG_POWER4 */
-
-#ifdef CONFIG_APUS
-/* On APUS the __va/__pa constants need to be set to the correct
- * values before continuing.
- */
-       mr      r4,r30
-       bl      fix_mem_constants
-#endif /* CONFIG_APUS */
-
 /* Switch MMU off, clear BATs and flush TLB. At this point, r3 contains
  * the physical address we are running at, returned by early_init()
  */
        bl      mmu_off
 __after_mmu_off:
-#ifndef CONFIG_POWER4
        bl      clear_bats
        bl      flush_tlbs
 
        bl      initial_bats
-#if !defined(CONFIG_APUS) && defined(CONFIG_BOOTX_TEXT)
+#ifdef CONFIG_BOOTX_TEXT
        bl      setup_disp_bat
 #endif
-#else /* CONFIG_POWER4 */
-       bl      reloc_offset
-       bl      initial_mm_power4
-#endif /* CONFIG_POWER4 */
 
 /*
  * Call setup_cpu for CPU 0 and initialize 6xx Idle
@@ -192,18 +147,10 @@ __after_mmu_off:
        bl      reloc_offset
        bl      init_idle_6xx
 #endif /* CONFIG_6xx */
-#ifdef CONFIG_POWER4
-       bl      reloc_offset
-       bl      init_idle_power4
-#endif /* CONFIG_POWER4 */
 
 
-#ifndef CONFIG_APUS
 /*
  * We need to run with _start at physical address 0.
- * On CHRP, we are loaded at 0x10000 since OF on CHRP uses
- * the exception vectors at 0 (and therefore this copy
- * overwrites OF's exception vectors with our own).
  * If the MMU is already turned on, we copy stuff to KERNELBASE,
  * otherwise we copy it to 0.
  */
@@ -212,7 +159,7 @@ __after_mmu_off:
        addis   r4,r3,KERNELBASE@h      /* current address of _start */
        cmpwi   0,r4,0                  /* are we already running at 0? */
        bne     relocate_kernel
-#endif /* CONFIG_APUS */
+
 /*
  * we now have the 1st 16M of ram mapped with the bats.
  * prep needs the mmu to be turned on here, but pmac already has it on.
@@ -350,59 +297,22 @@ i##n:                                                             \
 /* System reset */
 /* core99 pmac starts the seconary here by changing the vector, and
    putting it back to what it was (unknown_exception) when done.  */
-#if defined(CONFIG_GEMINI) && defined(CONFIG_SMP)
-       . = 0x100
-       b       __secondary_start_gemini
-#else
        EXCEPTION(0x100, Reset, unknown_exception, EXC_XFER_STD)
-#endif
 
 /* Machine check */
-/*
- * On CHRP, this is complicated by the fact that we could get a
- * machine check inside RTAS, and we have no guarantee that certain
- * critical registers will have the values we expect.  The set of
- * registers that might have bad values includes all the GPRs
- * and all the BATs.  We indicate that we are in RTAS by putting
- * a non-zero value, the address of the exception frame to use,
- * in SPRG2.  The machine check handler checks SPRG2 and uses its
- * value if it is non-zero.  If we ever needed to free up SPRG2,
- * we could use a field in the thread_info or thread_struct instead.
- * (Other exception handlers assume that r1 is a valid kernel stack
- * pointer when we take an exception from supervisor mode.)
- *     -- paulus.
- */
        . = 0x200
        mtspr   SPRN_SPRG0,r10
        mtspr   SPRN_SPRG1,r11
        mfcr    r10
-#ifdef CONFIG_PPC_CHRP
-       mfspr   r11,SPRN_SPRG2
-       cmpwi   0,r11,0
-       bne     7f
-#endif /* CONFIG_PPC_CHRP */
        EXCEPTION_PROLOG_1
 7:     EXCEPTION_PROLOG_2
        addi    r3,r1,STACK_FRAME_OVERHEAD
-#ifdef CONFIG_PPC_CHRP
-       mfspr   r4,SPRN_SPRG2
-       cmpwi   cr1,r4,0
-       bne     cr1,1f
-#endif
        EXC_XFER_STD(0x200, machine_check_exception)
-#ifdef CONFIG_PPC_CHRP
-1:     b       machine_check_in_rtas
-#endif
 
 /* Data access exception. */
        . = 0x300
-#ifdef CONFIG_PPC64BRIDGE
-       b       DataAccess
-DataAccessCont:
-#else
 DataAccess:
        EXCEPTION_PROLOG
-#endif /* CONFIG_PPC64BRIDGE */
        mfspr   r10,SPRN_DSISR
        andis.  r0,r10,0xa470           /* weird error? */
        bne     1f                      /* if not, try to put a PTE */
@@ -414,21 +324,10 @@ DataAccess:
        mfspr   r4,SPRN_DAR
        EXC_XFER_EE_LITE(0x300, handle_page_fault)
 
-#ifdef CONFIG_PPC64BRIDGE
-/* SLB fault on data access. */
-       . = 0x380
-       b       DataSegment
-#endif /* CONFIG_PPC64BRIDGE */
-
 /* Instruction access exception. */
        . = 0x400
-#ifdef CONFIG_PPC64BRIDGE
-       b       InstructionAccess
-InstructionAccessCont:
-#else
 InstructionAccess:
        EXCEPTION_PROLOG
-#endif /* CONFIG_PPC64BRIDGE */
        andis.  r0,r9,0x4000            /* no pte found? */
        beq     1f                      /* if so, try to put a PTE */
        li      r3,0                    /* into the hash table */
@@ -438,12 +337,6 @@ InstructionAccess:
        mr      r5,r9
        EXC_XFER_EE_LITE(0x400, handle_page_fault)
 
-#ifdef CONFIG_PPC64BRIDGE
-/* SLB fault on instruction access. */
-       . = 0x480
-       b       InstructionSegment
-#endif /* CONFIG_PPC64BRIDGE */
-
 /* External interrupt */
        EXCEPTION(0x500, HardwareInterrupt, do_IRQ, EXC_XFER_LITE)
 
@@ -708,15 +601,9 @@ DataStoreTLBMiss:
        EXCEPTION(0x1300, Trap_13, instruction_breakpoint_exception, EXC_XFER_EE)
        EXCEPTION(0x1400, SMI, SMIException, EXC_XFER_EE)
        EXCEPTION(0x1500, Trap_15, unknown_exception, EXC_XFER_EE)
-#ifdef CONFIG_POWER4
-       EXCEPTION(0x1600, Trap_16, unknown_exception, EXC_XFER_EE)
-       EXCEPTION(0x1700, Trap_17, altivec_assist_exception, EXC_XFER_EE)
-       EXCEPTION(0x1800, Trap_18, TAUException, EXC_XFER_STD)
-#else /* !CONFIG_POWER4 */
        EXCEPTION(0x1600, Trap_16, altivec_assist_exception, EXC_XFER_EE)
        EXCEPTION(0x1700, Trap_17, TAUException, EXC_XFER_STD)
        EXCEPTION(0x1800, Trap_18, unknown_exception, EXC_XFER_EE)
-#endif /* CONFIG_POWER4 */
        EXCEPTION(0x1900, Trap_19, unknown_exception, EXC_XFER_EE)
        EXCEPTION(0x1a00, Trap_1a, unknown_exception, EXC_XFER_EE)
        EXCEPTION(0x1b00, Trap_1b, unknown_exception, EXC_XFER_EE)
@@ -751,29 +638,8 @@ AltiVecUnavailable:
 #ifdef CONFIG_ALTIVEC
        bne     load_up_altivec         /* if from user, just load it up */
 #endif /* CONFIG_ALTIVEC */
-       EXC_XFER_EE_LITE(0xf20, altivec_unavailable_exception)
-
-#ifdef CONFIG_PPC64BRIDGE
-DataAccess:
-       EXCEPTION_PROLOG
-       b       DataAccessCont
-
-InstructionAccess:
-       EXCEPTION_PROLOG
-       b       InstructionAccessCont
-
-DataSegment:
-       EXCEPTION_PROLOG
-       addi    r3,r1,STACK_FRAME_OVERHEAD
-       mfspr   r4,SPRN_DAR
-       stw     r4,_DAR(r11)
-       EXC_XFER_STD(0x380, unknown_exception)
-
-InstructionSegment:
-       EXCEPTION_PROLOG
        addi    r3,r1,STACK_FRAME_OVERHEAD
-       EXC_XFER_STD(0x480, unknown_exception)
-#endif /* CONFIG_PPC64BRIDGE */
+       EXC_XFER_EE_LITE(0xf20, altivec_unavailable_exception)
 
 #ifdef CONFIG_ALTIVEC
 /* Note that the AltiVec support is closely modeled after the FP
@@ -834,23 +700,6 @@ load_up_altivec:
        /* we haven't used ctr or xer or lr */
        b       fast_exception_return
 
-/*
- * AltiVec unavailable trap from kernel - print a message, but let
- * the task use AltiVec in the kernel until it returns to user mode.
- */
-KernelAltiVec:
-       lwz     r3,_MSR(r1)
-       oris    r3,r3,MSR_VEC@h
-       stw     r3,_MSR(r1)     /* enable use of AltiVec after return */
-       lis     r3,87f@h
-       ori     r3,r3,87f@l
-       mr      r4,r2           /* current */
-       lwz     r5,_NIP(r1)
-       bl      printk
-       b       ret_from_except
-87:    .string "AltiVec used in kernel  (task=%p, pc=%x)  \n"
-       .align  4,0
-
 /*
  * giveup_altivec(tsk)
  * Disable AltiVec for the task given as the argument,
@@ -933,99 +782,7 @@ copy_and_flush:
        addi    r6,r6,4
        blr
 
-#ifdef CONFIG_APUS
-/*
- * On APUS the physical base address of the kernel is not known at compile
- * time, which means the __pa/__va constants used are incorrect. In the
- * __init section is recorded the virtual addresses of instructions using
- * these constants, so all that has to be done is fix these before
- * continuing the kernel boot.
- *
- * r4 = The physical address of the kernel base.
- */
-fix_mem_constants:
-       mr      r10,r4
-       addis   r10,r10,-KERNELBASE@h    /* virt_to_phys constant */
-       neg     r11,r10                  /* phys_to_virt constant */
-
-       lis     r12,__vtop_table_begin@h
-       ori     r12,r12,__vtop_table_begin@l
-       add     r12,r12,r10              /* table begin phys address */
-       lis     r13,__vtop_table_end@h
-       ori     r13,r13,__vtop_table_end@l
-       add     r13,r13,r10              /* table end phys address */
-       subi    r12,r12,4
-       subi    r13,r13,4
-1:     lwzu    r14,4(r12)               /* virt address of instruction */
-       add     r14,r14,r10              /* phys address of instruction */
-       lwz     r15,0(r14)               /* instruction, now insert top */
-       rlwimi  r15,r10,16,16,31         /* half of vp const in low half */
-       stw     r15,0(r14)               /* of instruction and restore. */
-       dcbst   r0,r14                   /* write it to memory */
-       sync
-       icbi    r0,r14                   /* flush the icache line */
-       cmpw    r12,r13
-       bne     1b
-       sync                            /* additional sync needed on g4 */
-       isync
-
-/*
- * Map the memory where the exception handlers will
- * be copied to when hash constants have been patched.
- */
-#ifdef CONFIG_APUS_FAST_EXCEPT
-       lis     r8,0xfff0
-#else
-       lis     r8,0
-#endif
-       ori     r8,r8,0x2               /* 128KB, supervisor */
-       mtspr   SPRN_DBAT3U,r8
-       mtspr   SPRN_DBAT3L,r8
-
-       lis     r12,__ptov_table_begin@h
-       ori     r12,r12,__ptov_table_begin@l
-       add     r12,r12,r10              /* table begin phys address */
-       lis     r13,__ptov_table_end@h
-       ori     r13,r13,__ptov_table_end@l
-       add     r13,r13,r10              /* table end phys address */
-       subi    r12,r12,4
-       subi    r13,r13,4
-1:     lwzu    r14,4(r12)               /* virt address of instruction */
-       add     r14,r14,r10              /* phys address of instruction */
-       lwz     r15,0(r14)               /* instruction, now insert top */
-       rlwimi  r15,r11,16,16,31         /* half of pv const in low half*/
-       stw     r15,0(r14)               /* of instruction and restore. */
-       dcbst   r0,r14                   /* write it to memory */
-       sync
-       icbi    r0,r14                   /* flush the icache line */
-       cmpw    r12,r13
-       bne     1b
-
-       sync                            /* additional sync needed on g4 */
-       isync                           /* No speculative loading until now */
-       blr
-
-/***********************************************************************
- *  Please note that on APUS the exception handlers are located at the
- *  physical address 0xfff0000. For this reason, the exception handlers
- *  cannot use relative branches to access the code below.
- ***********************************************************************/
-#endif /* CONFIG_APUS */
-
 #ifdef CONFIG_SMP
-#ifdef CONFIG_GEMINI
-       .globl  __secondary_start_gemini
-__secondary_start_gemini:
-        mfspr   r4,SPRN_HID0
-        ori     r4,r4,HID0_ICFI
-        li      r3,0
-        ori     r3,r3,HID0_ICE
-        andc    r4,r4,r3
-        mtspr   SPRN_HID0,r4
-        sync
-        b       __secondary_start
-#endif /* CONFIG_GEMINI */
-
        .globl  __secondary_start_pmac_0
 __secondary_start_pmac_0:
        /* NB the entries for cpus 0, 1, 2 must each occupy 8 bytes. */
@@ -1047,13 +804,6 @@ __secondary_start_pmac_0:
 
        .globl  __secondary_start
 __secondary_start:
-#ifdef CONFIG_PPC64BRIDGE
-       mfmsr   r0
-       clrldi  r0,r0,1                 /* make sure it's in 32-bit mode */
-       SYNC
-       MTMSRD(r0)
-       isync
-#endif
        /* Copy some CPU settings from CPU 0 */
        bl      __restore_cpu_setup
 
@@ -1064,10 +814,6 @@ __secondary_start:
        lis     r3,-KERNELBASE@h
        bl      init_idle_6xx
 #endif /* CONFIG_6xx */
-#ifdef CONFIG_POWER4
-       lis     r3,-KERNELBASE@h
-       bl      init_idle_power4
-#endif /* CONFIG_POWER4 */
 
        /* get current_thread_info and current */
        lis     r1,secondary_ti@ha
@@ -1108,12 +854,12 @@ __secondary_start:
  * Those generic dummy functions are kept for CPUs not
  * included in CONFIG_6xx
  */
-#if !defined(CONFIG_6xx) && !defined(CONFIG_POWER4)
+#if !defined(CONFIG_6xx)
 _GLOBAL(__save_cpu_setup)
        blr
 _GLOBAL(__restore_cpu_setup)
        blr
-#endif /* !defined(CONFIG_6xx) && !defined(CONFIG_POWER4) */
+#endif /* !defined(CONFIG_6xx) */
 
 
 /*
@@ -1131,11 +877,6 @@ load_up_mmu:
        tophys(r6,r6)
        lwz     r6,_SDR1@l(r6)
        mtspr   SPRN_SDR1,r6
-#ifdef CONFIG_PPC64BRIDGE
-       /* clear the ASR so we only use the pseudo-segment registers. */
-       li      r6,0
-       mtasr   r6
-#endif /* CONFIG_PPC64BRIDGE */
        li      r0,16           /* load up segment register values */
        mtctr   r0              /* for context 0 */
        lis     r3,0x2000       /* Ku = 1, VSID = 0 */
@@ -1144,7 +885,7 @@ load_up_mmu:
        addi    r3,r3,0x111     /* increment VSID */
        addis   r4,r4,0x1000    /* address of next segment */
        bdnz    3b
-#ifndef CONFIG_POWER4
+
 /* Load the BAT registers with the values set up by MMU_init.
    MMU_init takes care of whether we're on a 601 or not. */
        mfpvr   r3
@@ -1157,7 +898,7 @@ load_up_mmu:
        LOAD_BAT(1,r3,r4,r5)
        LOAD_BAT(2,r3,r4,r5)
        LOAD_BAT(3,r3,r4,r5)
-#endif /* CONFIG_POWER4 */
+
        blr
 
 /*
@@ -1193,19 +934,6 @@ start_here:
        bl      machine_init
        bl      MMU_init
 
-#ifdef CONFIG_APUS
-       /* Copy exception code to exception vector base on APUS. */
-       lis     r4,KERNELBASE@h
-#ifdef CONFIG_APUS_FAST_EXCEPT
-       lis     r3,0xfff0               /* Copy to 0xfff00000 */
-#else
-       lis     r3,0                    /* Copy to 0x00000000 */
-#endif
-       li      r5,0x4000               /* # bytes of memory to copy */
-       li      r6,0
-       bl      copy_and_flush          /* copy the first 0x4000 bytes */
-#endif  /* CONFIG_APUS */
-
 /*
  * Go back to running unmapped so we can load up new values
  * for SDR1 (hash table pointer) and the segment registers
@@ -1268,9 +996,6 @@ _GLOBAL(set_context)
        li      r4,0
        isync
 3:
-#ifdef CONFIG_PPC64BRIDGE
-       slbie   r4
-#endif /* CONFIG_PPC64BRIDGE */
        mtsrin  r3,r4
        addi    r3,r3,0x111     /* next VSID */
        rlwinm  r3,r3,0,8,3     /* clear out any overflow from VSID field */
@@ -1357,7 +1082,6 @@ mmu_off:
        sync
        RFI
 
-#ifndef CONFIG_POWER4
 /*
  * Use the first pair of BAT registers to map the 1st 16MB
  * of RAM to KERNELBASE.  From this point on we can't safely
@@ -1365,7 +1089,6 @@ mmu_off:
  */
 initial_bats:
        lis     r11,KERNELBASE@h
-#ifndef CONFIG_PPC64BRIDGE
        mfspr   r9,SPRN_PVR
        rlwinm  r9,r9,16,16,31          /* r9 = 1 for 601, 4 for 604 */
        cmpwi   0,r9,1
@@ -1380,7 +1103,6 @@ initial_bats:
        mtspr   SPRN_IBAT1L,r10
        isync
        blr
-#endif /* CONFIG_PPC64BRIDGE */
 
 4:     tophys(r8,r11)
 #ifdef CONFIG_SMP
@@ -1388,17 +1110,8 @@ initial_bats:
 #else
        ori     r8,r8,2                 /* R/W access */
 #endif /* CONFIG_SMP */
-#ifdef CONFIG_APUS
-       ori     r11,r11,BL_8M<<2|0x2    /* set up 8MB BAT registers for 604 */
-#else
        ori     r11,r11,BL_256M<<2|0x2  /* set up BAT registers for 604 */
-#endif /* CONFIG_APUS */
 
-#ifdef CONFIG_PPC64BRIDGE
-       /* clear out the high 32 bits in the BAT */
-       clrldi  r11,r11,32
-       clrldi  r8,r8,32
-#endif /* CONFIG_PPC64BRIDGE */
        mtspr   SPRN_DBAT0L,r8          /* N.B. 6xx (not 601) have valid */
        mtspr   SPRN_DBAT0U,r11         /* bit in upper BAT register */
        mtspr   SPRN_IBAT0L,r8
@@ -1406,7 +1119,7 @@ initial_bats:
        isync
        blr
 
-#if !defined(CONFIG_APUS) && defined(CONFIG_BOOTX_TEXT)
+#ifdef CONFIG_BOOTX_TEXT
 setup_disp_bat:
        /*
         * setup the display bat prepared for us in prom.c
@@ -1429,39 +1142,7 @@ setup_disp_bat:
        mtspr   SPRN_IBAT3U,r11
        blr
 
-#endif /* !defined(CONFIG_APUS) && defined(CONFIG_BOOTX_TEXT) */
-
-#else /* CONFIG_POWER4 */
-/*
- * Load up the SDR1 and segment register values now
- * since we don't have the BATs.
- * Also make sure we are running in 32-bit mode.
- */
-
-initial_mm_power4:
-       addis   r14,r3,_SDR1@ha         /* get the value from _SDR1 */
-       lwz     r14,_SDR1@l(r14)        /* assume hash table below 4GB */
-       mtspr   SPRN_SDR1,r14
-       slbia
-       lis     r4,0x2000               /* set pseudo-segment reg 12 */
-       ori     r5,r4,0x0ccc
-       mtsr    12,r5
-#if 0
-       ori     r5,r4,0x0888            /* set pseudo-segment reg 8 */
-       mtsr    8,r5                    /* (for access to serial port) */
-#endif
-#ifdef CONFIG_BOOTX_TEXT
-       ori     r5,r4,0x0999            /* set pseudo-segment reg 9 */
-       mtsr    9,r5                    /* (for access to screen) */
-#endif
-       mfmsr   r0
-       clrldi  r0,r0,1
-       sync
-       mtmsr   r0
-       isync
-       blr
-
-#endif /* CONFIG_POWER4 */
+#endif /* defined(CONFIG_BOOTX_TEXT) */
 
 #ifdef CONFIG_8260
 /* Jump into the system reset for the rom.