head_4xx.s
来自「Linux Kernel 2.6.9 for OMAP1710」· S 代码 · 共 1,031 行 · 第 1/2 页
S
1,031 行
/* If we are faulting a kernel address, we have to use the * kernel page tables. */ andis. r11, r10, 0x8000 beq 3f lis r11, swapper_pg_dir@h ori r11, r11, swapper_pg_dir@l li r9, 0 mtspr SPRN_PID, r9 /* TLB will have 0 TID */ b 4f /* Get the PGD for the current thread. */3: mfspr r11,SPRG3 lwz r11,PGDIR(r11)4: tophys(r11, r11) rlwimi r11, r10, 12, 20, 29 /* Create L1 (pgdir/pmd) address */ lwz r12, 0(r11) /* Get L1 entry */ andi. r9, r12, _PMD_PRESENT /* Check if it points to a PTE page */ beq 2f /* Bail if no table */ rlwimi r12, r10, 22, 20, 29 /* Compute PTE address */ lwz r11, 0(r12) /* Get Linux PTE */ andi. r9, r11, _PAGE_PRESENT beq 5f ori r11, r11, _PAGE_ACCESSED stw r11, 0(r12) /* Create TLB tag. This is the faulting address plus a static * set of bits. These are size, valid, E, U0. */ li r12, 0x00c0 rlwimi r10, r12, 0, 20, 31 b finish_tlb_load2: /* Check for possible large-page pmd entry */ rlwinm. r9, r12, 2, 22, 24 beq 5f /* Create TLB tag. This is the faulting address, plus a static * set of bits (valid, E, U0) plus the size from the PMD. */ ori r9, r9, 0x40 rlwimi r10, r9, 0, 20, 31 mr r11, r12 b finish_tlb_load5: /* The bailout. Restore registers to pre-exception conditions * and call the heavyweights to help us out. */#ifdef CONFIG_403GCX lwz r12, 12(r0) lwz r11, 8(r0) mtspr SPRN_PID, r12 mtcr r11 lwz r9, 4(r0) lwz r12, 0(r0)#else mfspr r12, SPRG6 mfspr r11, SPRG7 mtspr SPRN_PID, r12 mtcr r11 mfspr r9, SPRG5 mfspr r12, SPRG4#endif mfspr r11, SPRG1 mfspr r10, SPRG0 b DataAccess/* 0x1200 - Instruction TLB Miss Exception * Nearly the same as above, except we get our information from different * registers and bailout to a different point. */ START_EXCEPTION(0x1200, ITLBMiss) mtspr SPRG0, r10 /* Save some working registers */ mtspr SPRG1, r11#ifdef CONFIG_403GCX stw r12, 0(r0) stw r9, 4(r0) mfcr r11 mfspr r12, SPRN_PID stw r11, 8(r0) stw r12, 12(r0)#else mtspr SPRG4, r12 mtspr SPRG5, r9 mfcr r11 mfspr r12, SPRN_PID mtspr SPRG7, r11 mtspr SPRG6, r12#endif mfspr r10, SRR0 /* Get faulting address */ /* If we are faulting a kernel address, we have to use the * kernel page tables. */ andis. r11, r10, 0x8000 beq 3f lis r11, swapper_pg_dir@h ori r11, r11, swapper_pg_dir@l li r9, 0 mtspr SPRN_PID, r9 /* TLB will have 0 TID */ b 4f /* Get the PGD for the current thread. */3: mfspr r11,SPRG3 lwz r11,PGDIR(r11)4: tophys(r11, r11) rlwimi r11, r10, 12, 20, 29 /* Create L1 (pgdir/pmd) address */ lwz r12, 0(r11) /* Get L1 entry */ andi. r9, r12, _PMD_PRESENT /* Check if it points to a PTE page */ beq 2f /* Bail if no table */ rlwimi r12, r10, 22, 20, 29 /* Compute PTE address */ lwz r11, 0(r12) /* Get Linux PTE */ andi. r9, r11, _PAGE_PRESENT beq 5f ori r11, r11, _PAGE_ACCESSED stw r11, 0(r12) /* Create TLB tag. This is the faulting address plus a static * set of bits. These are size, valid, E, U0. */ li r12, 0x00c0 rlwimi r10, r12, 0, 20, 31 b finish_tlb_load2: /* Check for possible large-page pmd entry */ rlwinm. r9, r12, 2, 22, 24 beq 5f /* Create TLB tag. This is the faulting address, plus a static * set of bits (valid, E, U0) plus the size from the PMD. */ ori r9, r9, 0x40 rlwimi r10, r9, 0, 20, 31 mr r11, r12 b finish_tlb_load5: /* The bailout. Restore registers to pre-exception conditions * and call the heavyweights to help us out. */#ifdef CONFIG_403GCX lwz r12, 12(r0) lwz r11, 8(r0) mtspr SPRN_PID, r12 mtcr r11 lwz r9, 4(r0) lwz r12, 0(r0)#else mfspr r12, SPRG6 mfspr r11, SPRG7 mtspr SPRN_PID, r12 mtcr r11 mfspr r9, SPRG5 mfspr r12, SPRG4#endif mfspr r11, SPRG1 mfspr r10, SPRG0 b InstructionAccess EXCEPTION(0x1300, Trap_13, UnknownException, EXC_XFER_EE) EXCEPTION(0x1400, Trap_14, UnknownException, EXC_XFER_EE) EXCEPTION(0x1500, Trap_15, UnknownException, EXC_XFER_EE) EXCEPTION(0x1600, Trap_16, UnknownException, EXC_XFER_EE)#ifdef CONFIG_IBM405_ERR51 /* 405GP errata 51 */ START_EXCEPTION(0x1700, Trap_17) b DTLBMiss#else EXCEPTION(0x1700, Trap_17, UnknownException, EXC_XFER_EE)#endif EXCEPTION(0x1800, Trap_18, UnknownException, EXC_XFER_EE) EXCEPTION(0x1900, Trap_19, UnknownException, EXC_XFER_EE) EXCEPTION(0x1A00, Trap_1A, UnknownException, EXC_XFER_EE) EXCEPTION(0x1B00, Trap_1B, UnknownException, EXC_XFER_EE) EXCEPTION(0x1C00, Trap_1C, UnknownException, EXC_XFER_EE) EXCEPTION(0x1D00, Trap_1D, UnknownException, EXC_XFER_EE) EXCEPTION(0x1E00, Trap_1E, UnknownException, EXC_XFER_EE) EXCEPTION(0x1F00, Trap_1F, UnknownException, EXC_XFER_EE)/* 0x2000 - Debug Exception*/ START_EXCEPTION(0x2000, DebugTrap) CRITICAL_EXCEPTION_PROLOG /* * If this is a single step or branch-taken exception in an * exception entry sequence, it was probably meant to apply to * the code where the exception occurred (since exception entry * doesn't turn off DE automatically). We simulate the effect * of turning off DE on entry to an exception handler by turning * off DE in the SRR3 value and clearing the debug status. */ mfspr r10,SPRN_DBSR /* check single-step/branch taken */ andis. r10,r10,(DBSR_IC|DBSR_BT)@h beq+ 1f andi. r0,r9,MSR_IR|MSR_PR /* check supervisor + MMU off */ beq 2f /* branch if we need to fix it up... */ /* continue normal handling for a critical exception... */1: mfspr r4,SPRN_DBSR addi r3,r1,STACK_FRAME_OVERHEAD EXC_XFER_TEMPLATE(DebugException, 0x2002, \ (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \ NOCOPY, crit_transfer_to_handler, ret_from_crit_exc) /* here it looks like we got an inappropriate debug exception. */2: rlwinm r9,r9,0,~MSR_DE /* clear DE in the SRR3 value */ mtspr SPRN_DBSR,r10 /* clear the IC/BT debug intr status */ /* restore state and get out */ lwz r10,_CCR(r11) lwz r0,GPR0(r11) lwz r1,GPR1(r11) mtcrf 0x80,r10 mtspr SRR2,r12 mtspr SRR3,r9 lwz r9,GPR9(r11) lwz r12,GPR12(r11) lwz r10,crit_r10@l(0) lwz r11,crit_r11@l(0) PPC405_ERR77_SYNC rfci b ./* * The other Data TLB exceptions bail out to this point * if they can't resolve the lightweight TLB fault. */DataAccess: NORMAL_EXCEPTION_PROLOG mfspr r5,SPRN_ESR /* Grab the ESR, save it, pass arg3 */ stw r5,_ESR(r11) mfspr r4,SPRN_DEAR /* Grab the DEAR, save it, pass arg2 */ EXC_XFER_EE_LITE(0x300, handle_page_fault)/* Other PowerPC processors, namely those derived from the 6xx-series * have vectors from 0x2100 through 0x2F00 defined, but marked as reserved. * However, for the 4xx-series processors these are neither defined nor * reserved. */ /* Damn, I came up one instruction too many to fit into the * exception space :-). Both the instruction and data TLB * miss get to this point to load the TLB. * r10 - TLB_TAG value * r11 - Linux PTE * r12, r9 - avilable to use * PID - loaded with proper value when we get here * Upon exit, we reload everything and RFI. * Actually, it will fit now, but oh well.....a common place * to load the TLB. */tlb_4xx_index: .long 0finish_tlb_load: /* load the next available TLB index. */ lwz r9, tlb_4xx_index@l(0) addi r9, r9, 1 andi. r9, r9, (PPC4XX_TLB_SIZE-1) stw r9, tlb_4xx_index@l(0)6: /* * Clear out the software-only bits in the PTE to generate the * TLB_DATA value. These are the bottom 2 bits of the RPM, the * top 3 bits of the zone field, and M. */ li r12, 0x0ce2 andc r11, r11, r12 tlbwe r11, r9, TLB_DATA /* Load TLB LO */ tlbwe r10, r9, TLB_TAG /* Load TLB HI */ /* Done...restore registers and get out of here. */#ifdef CONFIG_403GCX lwz r12, 12(r0) lwz r11, 8(r0) mtspr SPRN_PID, r12 mtcr r11 lwz r9, 4(r0) lwz r12, 0(r0)#else mfspr r12, SPRG6 mfspr r11, SPRG7 mtspr SPRN_PID, r12 mtcr r11 mfspr r9, SPRG5 mfspr r12, SPRG4#endif mfspr r11, SPRG1 mfspr r10, SPRG0 PPC405_ERR77_SYNC rfi /* Should sync shadow TLBs */ b . /* prevent prefetch past rfi *//* extern void giveup_fpu(struct task_struct *prev) * * The PowerPC 4xx family of processors do not have an FPU, so this just * returns. */_GLOBAL(giveup_fpu) blr/* This is where the main kernel code starts. */start_here: /* ptr to current */ lis r2,init_task@h ori r2,r2,init_task@l /* ptr to phys current thread */ tophys(r4,r2) addi r4,r4,THREAD /* init task's THREAD */ mtspr SPRG3,r4 /* stack */ lis r1,init_thread_union@ha addi r1,r1,init_thread_union@l li r0,0 stwu r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1) bl early_init /* We have to do this with MMU on *//* * Decide what sort of machine this is and initialize the MMU. */ mr r3,r31 mr r4,r30 mr r5,r29 mr r6,r28 mr r7,r27 bl machine_init bl MMU_init/* Go back to running unmapped so we can load up new values * and change to using our exception vectors. * On the 4xx, all we have to do is invalidate the TLB to clear * the old 16M byte TLB mappings. */ lis r4,2f@h ori r4,r4,2f@l tophys(r4,r4) lis r3,(MSR_KERNEL & ~(MSR_IR|MSR_DR))@h ori r3,r3,(MSR_KERNEL & ~(MSR_IR|MSR_DR))@l mtspr SRR0,r4 mtspr SRR1,r3 rfi b . /* prevent prefetch past rfi *//* Load up the kernel context */2: sync /* Flush to memory before changing TLB */ tlbia isync /* Flush shadow TLBs */ /* set up the PTE pointers for the Abatron bdiGDB. */ lis r6, swapper_pg_dir@h ori r6, r6, swapper_pg_dir@l lis r5, abatron_pteptrs@h ori r5, r5, abatron_pteptrs@l stw r5, 0xf0(r0) /* Must match your Abatron config file */ tophys(r5,r5) stw r6, 0(r5)/* Now turn on the MMU for real! */ lis r4,MSR_KERNEL@h ori r4,r4,MSR_KERNEL@l lis r3,start_kernel@h ori r3,r3,start_kernel@l mtspr SRR0,r3 mtspr SRR1,r4 rfi /* enable MMU and jump to start_kernel */ b . /* prevent prefetch past rfi *//* Set up the initial MMU state so we can do the first level of * kernel initialization. This maps the first 16 MBytes of memory 1:1 * virtual to physical and more importantly sets the cache mode. */initial_mmu: tlbia /* Invalidate all TLB entries */ isync /* We should still be executing code at physical address 0x0000xxxx * at this point. However, start_here is at virtual address * 0xC000xxxx. So, set up a TLB mapping to cover this once * translation is enabled. */ lis r3,KERNELBASE@h /* Load the kernel virtual address */ ori r3,r3,KERNELBASE@l tophys(r4,r3) /* Load the kernel physical address */ iccci r0,r3 /* Invalidate the i-cache before use */ /* Load the kernel PID. */ li r0,0 mtspr SPRN_PID,r0 sync /* Configure and load two entries into TLB slots 62 and 63. * In case we are pinning TLBs, these are reserved in by the * other TLB functions. If not reserving, then it doesn't * matter where they are loaded. */ clrrwi r4,r4,10 /* Mask off the real page number */ ori r4,r4,(TLB_WR | TLB_EX) /* Set the write and execute bits */ clrrwi r3,r3,10 /* Mask off the effective page number */ ori r3,r3,(TLB_VALID | TLB_PAGESZ(PAGESZ_16M)) li r0,63 /* TLB slot 63 */ tlbwe r4,r0,TLB_DATA /* Load the data portion of the entry */ tlbwe r3,r0,TLB_TAG /* Load the tag portion of the entry */#if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(SERIAL_DEBUG_IO_BASE) /* Load a TLB entry for the UART, so that ppc4xx_progress() can use * the UARTs nice and early. We use a 4k real==virtual mapping. */ lis r3,SERIAL_DEBUG_IO_BASE@h ori r3,r3,SERIAL_DEBUG_IO_BASE@l mr r4,r3 clrrwi r4,r4,12 ori r4,r4,(TLB_WR|TLB_I|TLB_M|TLB_G) clrrwi r3,r3,12 ori r3,r3,(TLB_VALID | TLB_PAGESZ(PAGESZ_4K)) li r0,0 /* TLB slot 0 */ tlbwe r4,r0,TLB_DATA tlbwe r3,r0,TLB_TAG#endif /* CONFIG_SERIAL_DEBUG_TEXT && SERIAL_DEBUG_IO_BASE */ isync /* Establish the exception vector base */ lis r4,KERNELBASE@h /* EVPR only uses the high 16-bits */ tophys(r0,r4) /* Use the physical address */ mtspr SPRN_EVPR,r0 blr_GLOBAL(abort) mfspr r13,SPRN_DBCR0 oris r13,r13,DBCR0_RST_SYSTEM@h mtspr SPRN_DBCR0,r13_GLOBAL(set_context)#ifdef CONFIG_BDI_SWITCH /* Context switch the PTE pointer for the Abatron BDI2000. * The PGDIR is the second parameter. */ lis r5, KERNELBASE@h lwz r5, 0xf0(r5) stw r4, 0x4(r5)#endif sync mtspr SPRN_PID,r3 isync /* Need an isync to flush shadow */ /* TLBs after changing PID */ blr/* We put a few things here that have to be page-aligned. This stuff * goes at the beginning of the data segment, which is page-aligned. */ .data_GLOBAL(sdata)_GLOBAL(empty_zero_page) .space 4096_GLOBAL(swapper_pg_dir) .space 4096/* Stack for handling critical exceptions from kernel mode */ .section .bsscritical_stack_bottom: .space 4096critical_stack_top: .previous/* This space gets a copy of optional info passed to us by the bootstrap * which is used to pass parameters into the kernel like root=/dev/sda1, etc. */_GLOBAL(cmd_line) .space 512/* Room for two PTE pointers, usually the kernel and current user pointers * to their respective root page table. */abatron_pteptrs: .space 8
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?