📄 zipstart_init.s
字号:
/* ********************************************************************* * Broadcom Common Firmware Environment (CFE) * * CPU init module File: zipstart_init.S * * This module contains the vectors and lowest-level CPU startup * functions for CFE. * * Author: Mitch Lichtenberg (mpl@broadcom.com) * ********************************************************************* * * Copyright 2000,2001,2002,2003 * Broadcom Corporation. All rights reserved. * * This software is furnished under license and may be used and * copied only in accordance with the following terms and * conditions. Subject to these conditions, you may download, * copy, install, use, modify and distribute modified or unmodified * copies of this software in source and/or binary form. No title * or ownership is transferred hereby. * * 1) Any source code used, modified or distributed must reproduce * and retain this copyright notice and list of conditions * as they appear in the source file. * * 2) No right is granted to use any trade name, trademark, or * logo of Broadcom Corporation. The "Broadcom Corporation" * name may not be used to endorse or promote products derived * from this software without the prior written permission of * Broadcom Corporation. * * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR 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), EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************* */#include "sbmips.h"#include "exception.h"#include "bsp_config.h"#include "cpu_config.h"#ifdef _CFE_#include "cfe_devfuncs.h"#else#define CFE_EPTSEAL 0x43464531#endif/* ********************************************************************* * Macros ********************************************************************* */#include "mipsmacros.h"/* ********************************************************************* * SETLEDS(a,b,c,d) * SETLEDS1(a,b,c,d) * * Sets the on-board LED display (if present). Two variants * of this routine are provided. If you're running KSEG1, * call the SETLEDS1 variant, else call SETLEDS. * * Input parameters: * a,b,c,d - four ASCII characters (literal constants) * * Return value: * a0,k1,ra trashed ********************************************************************* */#define SETLEDS(a,b,c,d) \ li a0,(((a)<<24)|((b)<<16)|((c)<<8)|(d)) ; \ la k1,board_setleds ; \ jalr k1 ;#define SETLEDS1(a,b,c,d) \ li a0,(((a)<<24)|((b)<<16)|((c)<<8)|(d)) ; \ la k1,board_setleds ; \ or k1,K1BASE ; \ jalr k1 ;/* ********************************************************************* * Other constants ********************************************************************* *//* * This is the size of the stack, rounded to KByte boundaries. */#ifndef CFG_STACK_SIZE#error "CFG_STACK_SIZE not defined"#else#define STACK_SIZE ((CFG_STACK_SIZE+1023) & ~1023)#endif/* * Duplicates from cfe_iocb.h -- warning! */#define CFE_CACHE_FLUSH_D 1#define CFE_CACHE_INVAL_I 2#define CFE_CACHE_INVAL_D 4#define CFE_CACHE_INVAL_L2 8#define CFE_CACHE_FLUSH_L2 16#define CFE_CACHE_INVAL_RANGE 32#define CFE_CACHE_FLUSH_RANGE 64/* ********************************************************************* * Names of registers used in this module ********************************************************************* */#define MEMTOP t8 /* $24 (t8) */ .sdata#include "initdata.h" /* declare variables we use here */ .extern _fdata .extern _edata .extern _etext/* ********************************************************************* * uninitialized data ********************************************************************* */ .bss .comm __junk,4/* ********************************************************************* * Exception Vectors ********************************************************************* */ .text .set noreorder/* * Declare the actual vectors. This expands to code that * must be at the very beginning of the text segment. */DECLARE_VECTOR(0x0000,vec_reset,cpu_reset)DECLARE_XVECTOR(0x0200,vec_tlbfill,cpu_tlbfill,XTYPE_TLBFILL)DECLARE_XVECTOR(0x0280,vec_xtlbfill,cpu_xtlbfill,XTYPE_XTLBFILL)DECLARE_XVECTOR(0x0300,vec_cacheerr,cpu_cacheerr,XTYPE_CACHEERR)DECLARE_XVECTOR(0x0380,vec_exception,cpu_exception,XTYPE_EXCEPTION)DECLARE_XVECTOR(0x0400,vec_interrupt,cpu_interrupt,XTYPE_INTERRUPT)DECLARE_XVECTOR(0x0480,vec_ejtag,cpu_ejtag,XTYPE_EJTAG)/* * New location of CFE seal. Will eventually phase out the seal at * offset 0x508 */ .org 0x4E0cfe_seal: .word CFE_EPTSEAL .word CFE_EPTSEAL .set reorder/* ********************************************************************* * CFE Entry Point (used by OS boot loaders and such) ********************************************************************* */ .set noreorderDECLARE_VECTOR(0x0500,vec_apientry,cpu_apientry) .org 0x508 .word CFE_EPTSEAL .word CFE_EPTSEAL .set reorder/* ********************************************************************* * Segment Table. * * Addresses of data segments and of certain routines we're going * to call from KSEG1. These are here mostly for the embedded * PIC case, since we can't count on the 'la' instruction to * do the expected thing (the assembler expands it into a macro * for doing GP-relative stuff, and the code is NOT GP-relative. * So, we (relocatably) get the offset of this table and then * index within it. * * Pointer values in this segment will be relative to KSEG0 for * cached versions of CFE, so we need to OR in K1BASE in the * case of calling to a uncached address. ********************************************************************* */#include "segtable.h" .org 0x580 # move past exception vectors .globl segment_tablesegment_table: _LONG_ _etext # [ 0] End of text (R_SEG_ETEXT) _LONG_ _fdata # [ 1] Beginning of data (R_SEG_FDATA) _LONG_ _edata # [ 2] End of data (R_SEG_EDATA) _LONG_ _end # [ 3] End of BSS (R_SEG_END) _LONG_ _ftext # [ 4] Beginning of text (R_SEG_FTEXT) _LONG_ _fbss # [ 5] Beginning of BSS (R_SEG_FBSS) /* ********************************************************************* * CPU Startup Code ********************************************************************* */cpu_reset: /* * Test the CAUSE and STATUS registers for why we * are here. Cold reset, Warm reset, and NMI all * use this vector. */ mfc0 t0,C0_SR and t0,M_SR_NMI beq t0,zero,not_nmi li t0,PHYS_TO_K1(CFE_LOCORE_GLOBAL_NMIEPT) LR t0,0(t0) beq t0,zero,not_nmi j t0not_nmi: /* * Test to see if we're on the secondary CPU. If so, * go do the initialization for that CPU. */#if CFG_MULTI_CPUS mfc0 t0,C0_PRID # get CPU PRID register and t0,t0,0xe000000 # determine cpu number beq t0,zero,is_cpu0 # go if on CPU0 li t0,PHYS_TO_K1(CFE_LOCORE_GLOBAL_CPUEPT) LR t0,0(t0) j t0is_cpu0: /* does not return if on CPU1 */#endif#------------------------------------------------------------------------------ /* * Do low-level board initialization. This is our first * chance to customize the startup sequence. */ JAL_KSEG1(board_earlyinit) SETLEDS1('H','E','L','O') JAL_KSEG1(CPUCFG_CPUINIT) /* * Run some diagnostics */#if !CFG_MINIMAL_SIZE SETLEDS1('T','S','T','1') JAL_KSEG1(CPUCFG_DIAG_TEST1)#endif#------------------------------------------------------------------------------#if 0#if CFG_MULTI_CPUS /* * Spin up secondary CPU core(s) */ CALLINIT_KSEG1(init_table,R_INIT_ALTCPU_START1) #endif#endif /* * Now, switch from KSEG1 to KSEG0 */#if CFG_RUNFROMKSEG0 bal cpu_kseg0_switch#endif#------------------------------------------------------------------------------ /* * Now running on cpu0 in K0SEG. */#if CFG_INIT_DRAM SETLEDS('D','R','A','M') JAL(board_draminfo) move a0,v0 # pass these params JAL(CPUCFG_DRAMINIT) move k0,v0 # Save in k0 for now#else li k0,(CFG_DRAM_SIZE * 1024)#endif#------------------------------------------------------------------------------ bne k0,zero,have_ram SETLEDS('R','A','M','X') # die here if no ramdie1: b die1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -