📄 start.s
字号:
/* $Id: start.S,v 1.5 2002/11/15 22:39:57 patrik Exp $ *//* * Copyright (c) 2000 Opsycon AB (www.opsycon.se) * Copyright (c) 2001 ipUnplugged AB (www.ipunplugged.com) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by ipUnplugged AB. * This product includes software developed by Opsycon AB. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */#include "target/pmon_target.h"#include <include/powerpmc230.h>#include <powerpc.h>#include <pmon/dev/mpc107reg.h> .space 0x100 .globl _start .globl start_start:start: .globl pmon_stackstack = start - 0x4000 /* 16K PMON stack */pmon_stack = start /* Top of stack */ .globl pmon_intstackintstack = stack - 0x2000 /* 8k PMON interrupt stack */pmon_intstack = stack /* Top of stack */ /* Clear MSR to diable interrupts and checks */ andi. 1, 1, 0x0 sync mtmsr 1 /* Clear MSR */ isync /* Zero-out registers */ andi. 0, 0, 0 mtspr SPRG0, 0 mtspr SPRG1, 0 mtspr SPRG2, 0 mtspr SPRG3, 0 /* Set HID0 to known state */ lis 3, HI(HID0_NHR) ori 3, 3, LO(HID0_NHR) mfspr 4, HID0 and 3, 4, 3 /* Clear other bits */ mtspr HID0, 3 sync /* Set MPU/MSR to a known state. Turn on FP */ lis 3, HI(PPC_MSR_FP) ori 3, 3, LO(PPC_MSR_FP) sync mtmsr 3 isync /* Init the floating point control/status register */ mtfsfi 7,0x0 mtfsfi 6,0x0 mtfsfi 5,0x0 mtfsfi 4,0x0 mtfsfi 3,0x0 mtfsfi 2,0x0 mtfsfi 1,0x0 mtfsfi 0,0x0 isync /* Initialize floating point data regs to known state */ bl ifpdr_value .long 0x3f800000 # 1.0 ifpdr_value: mfspr 3,8 lfs 0,0(3) lfs 1,0(3) lfs 2,0(3) lfs 3,0(3) lfs 4,0(3) lfs 5,0(3) lfs 6,0(3) lfs 7,0(3) lfs 8,0(3) lfs 9,0(3) lfs 10,0(3) lfs 11,0(3) lfs 12,0(3) lfs 13,0(3) lfs 14,0(3) lfs 15,0(3) lfs 16,0(3) lfs 17,0(3) lfs 18,0(3) lfs 19,0(3) lfs 20,0(3) lfs 21,0(3) lfs 22,0(3) lfs 23,0(3) lfs 24,0(3) lfs 25,0(3) lfs 26,0(3) lfs 27,0(3) lfs 28,0(3) lfs 29,0(3) lfs 30,0(3) lfs 31,0(3) sync /* Clear BAT and Segment mapping registers */ andi. 1, 1, 0x0 mtibatu 0, 1 mtibatu 1, 1 mtibatu 2, 1 mtibatu 3, 1 mtdbatu 0, 1 mtdbatu 1, 1 mtdbatu 2, 1 mtdbatu 3, 1 isync sync sync lis 1, 0x8000 isync mtsr 0, 1 mtsr 1, 1 mtsr 2, 1 mtsr 3, 1 mtsr 4, 1 mtsr 5, 1 mtsr 6, 1 mtsr 7, 1 mtsr 8, 1 mtsr 9, 1 mtsr 10, 1 mtsr 11, 1 mtsr 12, 1 mtsr 13, 1 mtsr 14, 1 mtsr 15, 1 isync sync sync /* Turn off caches and invalidate them */ mfspr 3, L2CR rlwinm 3, 3, 0, 1, 31 /* turn off the L2 enable bit */ mtspr L2CR, 3 isync oris 3, 3, HI(L2CR_L2I) mtspr L2CR, 3 sync1: mfspr 3, L2CR andi. 3, 3, LO(L2CR_L2IP) cmpwi 3, LO(L2CR_L2IP) beq 1b /* Wait for invalidate done */ /* Invalidate L1 Cache */ mfspr 3, HID0 isync rlwinm 4, 3, 0, 18, 15 /* Clear d16 and d17 to disable L1 cache */ sync isync mtspr HID0, 4 /* turn off caches */ isync lis 3, 0 ori 3, 3, LO(HID0_ICFI) /* Invalidates instruction caches */ or 4, 4, 3 sync isync mtspr HID0, 4 andc 4, 4, 3 isync lis 3, 0 ori 3, 3, LO(HID0_DCFI) /* Invalidates data caches */ or 4, 4, 3 sync isync mtspr HID0, 4 andc 4, 4, 3 isync li 11, 0x2000 /* No harm */ mtspr CTR, 111: bdnz 1b isync mfspr 4, HID0 isync ori 4, 4, (HID0_ICE | HID0_ICFI) isync mtspr HID0, 4 /* turn on i-cache for speed */ rlwinm 4, 4, 0, 21, 19 /* clear the ICFI bit */ isync mtspr HID0, 4 /* Get CPU type */ mfspr 28, PVR rlwinm 28, 28, 16, 16, 31 /* Set r16 to the load vs link offset. */ bl 1f1: mflr 3 lis 16, 0xffff and. 16, 16, 3 lis 4, HI(start) sub 16, 16, 4 /* R16 is now load offset */ /* * Find out if executing in ROM or RAM. Note memory size wired to 256 Mb. */ lis 15, 0x1000 /* Memory size accumulator = 256 MB */ lis 4, 0xf000 /* Last segment */ and. 4, 4, 3 beq in_ram /* We are ram loaded! *//* * This is a cold boot startup. Do HW initialisation */ /* Fixed regs 20 = PCI CONFIG ADDR, 21 = PCI_CONFIG_DATA, 22 = CONF DEV */ lis 20, HI(MPC107_CONF_ADDR) lis 21, HI(MPC107_CONF_DATA) lis 22, 0x8000 /* config space access enable */ /* Set EUMBBAR to default value */ MPC_CFG_WR(MPC107_CFG_EUMBBAR, MPC107_EUMBAR) MPC_CFG_WR(MPC107_CFG_PCSRBAR, MPC107_EUMBAR) /* Set up PCI Arbiter Control Register */ MPC_CFG_RD(MPC107_CFG_PACR) lis 0, 0x0000 ori 0, 0, 0xffff and 4, 4, 0 lis 0, 0x0000 /* Disable internal bus arbiter */ or 4, 4, 0 MPC_CFG_RWR(MPC107_CFG_PACR) /* Set up Processor Interface Configuration Register 1 */ MPC_CFG_RD(MPC107_CFG_PICR1) lis 0, 0xff38 ori 0, 0, 0x0300 and 4, 4, 0 lis 0, 0x0004 /* CPU type = 603/7xx/74xx and MAP B */ ori 0, 0, 0x1890 or 4, 4, 0 MPC_CFG_RWR(MPC107_CFG_PICR1) sync /* Set up Processor Interface Configuration Register 2 */ MPC_CFG_RD(MPC107_CFG_PICR2) lis 0, 0xd1f3 ori 0, 0, 0xf9f3 and 4, 4, 0 lis 0, 0x00c0 ori 0, 0, 0x060c /* CF_LBCLAIM_WS = 3 clk cycles */ or 4, 4, 0 MPC_CFG_RWR(MPC107_CFG_PICR2) sync /* Set up the Address Map B Option register */ MPC_CFG_AD(MPC107_CFG_AMBOR) lbz 4, 0(21) andi. 4, 4, 0x00 stb 4, 0(21) IORDER /* Set PCI command to default values and clear any error status. */ MPC_CFG_RD(MPC107_PCI_CMD) lis 0, 0xffff ori 0, 0, 0xfca0 and 4, 4, 0 /* Preserve bits */ ori 4, 4, 0x0106 /* SERR, MASTER, MEMORY ENABLE */ MPC_CFG_RWR(MPC107_PCI_CMD) /* Disable error reporting */ MPC_CFG_AD(MPC107_CFG_ERR_EN1) lbz 4, 0(21) andi. 4, 4, 0xfb stb 4, 0(21) IORDER /* Disable error reporting */ MPC_CFG_AD(MPC107_CFG_ERR_EN2) lbz 4, 0(21) andi. 4, 4, 0xf7 stb 4, 0(21) IORDER/* * We only use bank zero on the 107 chip. However, the manual states that each bank, * enabled or not, must be mapped to an unused address. * * Since our current Maximum is 256MB, set each bank based on this. * Code executed later, will size for 256 or 128 and change the bank zero settings * if required. * * bank Start Addr End Addr * 0 0 0x0FFFFFFF (256MB) * 1 0x10000000 0x13FFFFFF * 2 0x14000000 0x17FFFFFF * 3 0x18000000 0x1FFFFFFF * 4 0x20000000 0x27FFFFFF * 5 0x28000000 0x2FFFFFFF * 6 0x30000000 0x37FFFFFF * 7 0x38000000 0x3FFFFFFF */ MPC_CFG_WR(MPC107_CFG_MSTA_03, 0x80400000) MPC_CFG_WR(MPC107_CFG_MSTA_47, 0x80008000) MPC_CFG_WR(MPC107_CFG_EMSTA_03, 0x00000000) MPC_CFG_WR(MPC107_CFG_EMSTA_47, 0x00000000) MPC_CFG_WR(MPC107_CFG_MEND_03, 0xff7f3fff) MPC_CFG_WR(MPC107_CFG_MEND_47, 0xff7fff7f) MPC_CFG_WR(MPC107_CFG_EMEND_03, 0x00000000) MPC_CFG_WR(MPC107_CFG_EMEND_47, 0x00000000) li 4, 0x01 /* Only Enable Bank 0 */ MPC_CFG_AD(MPC107_CFG_MBEN) /* Bank enables */ stb 4, (MPC107_CFG_MBEN & 3)(21) sync /* Set up Memory Page Mode Register */ MPC_CFG_AD(MPC107_CFG_MPMR) li 4, 0x32 /* 100Mhz */ stb 4, (MPC107_CFG_MPMR & 3)(21) sync /* Turn off MEMGO to disable memory controller */ MPC_CFG_RD(MPC107_CFG_MCFG1) lis 0, 0x0008 andc 4, 4, 0 MPC_CFG_RWR(MPC107_CFG_MCFG1)#ifdef ECC_MEMORY /* Set up Memory Control Configuration Register 1 */ MPC_CFG_WR(MPC107_CFG_MCFG1, 0x25740002) /* Set up Memory Control Configuration Register 2 */ MPC_CFG_WR(MPC107_CFG_MCFG2, 0x6e8C1381) /* Set up Memory Control Configuration Register 3 */ MPC_CFG_WR(MPC107_CFG_MCFG3, 0x07400000) /* Set up Memory Control Configuration Register 4 */ MPC_CFG_WR(MPC107_CFG_MCFG4, 0x25662220)#else /* Set up Memory Control Configuration Register 1 */ MPC_CFG_RD(MPC107_CFG_MCFG1) lis 0, 0x2574 ori 0, 0, 0x0002 and 4, 4, 0 or 4, 4, 0 MPC_CFG_RWR(MPC107_CFG_MCFG1) /* Set up Memory Control Configuration Register 2 */ lis 4, 0x6e80 ori 4, 4, 0x1380 MPC_CFG_RWR(MPC107_CFG_MCFG2) /* Set up Memory Control Configuration Register 3 */ MPC_CFG_RD(MPC107_CFG_MCFG3)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -