




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/* bootInit.c - ROM initialization module */* Copyright 1989-2002 Wind River Systems, Inc. */#include copyright_wrs.h/*modification history-05h,26mar02,sbs correcting data section relocation for ROM compressed images (SPR 73785)05g,19mar02,dat Removing previous fix for MIPS, no longer needed (72825)05f,18jan02,dat Dont use loop unrolling for MIPS05f,22jan02,scm Xscale specific validation added to update cache (to match updates.)05e,19dec01,aeg prevented pc-relative addressing on MC680X0.05d,10dec01,sbs Corrected conditions around call to copyLongs for ROM resident images.05c,27nov01,sbs Added new labels, wrs_kernel_data_start and wrs_kernel_data_end for sdata and edata respectively. Added second copy for data section of compressed ROM images. Corrected definition for binArrayEnd. Corrected definition for RESIDENT_DATA.05b,27nov01,tpw Manually unroll copyLongs and fillLongs.05a,25oct01,pad Removed definitions of _binArrayStart and _binArrayEnd, now unnecessary.04z,03oct01,dee Merge from ColdFire T2.1.0 release04y,11jan01,scm Xscale specific validation added to update cache, can not assume uncached area.04x,10jun99,jpd fix error when BOOTCODE_IN_RAM defined (SPR #27775).04w,13nov98,cdp make Thumb support for ARM CPUs dependent on ARM_THUMB.04w,10feb99,db Fix to ensure that default bootline gets copied for standalone and rom-resident images(SPR #21763).04v,05oct98,jmp doc: cleanup.04u,17apr98,cdp backed out 04t and made absEntry volatile for ARM.04t,16apr98,cdp for ARM, make UNCOMPRESS entry point in RAM.04s,20mar98,cdp make ROM_COPY_SIZE subject to #ifndef.04r,11nov97,cdp ARM7TDMI_T: force romStart to call entry point in Thumb state. (SPR# 9716)04q,14jul97,tam changed remaining references to bfillLong to fillLong. 04p,12feb97,dat Added USER_RESERVED_MEM, SYS_MEM_TOP, SYS_MEM_BOTTOM, SPR 803004o,04feb97,ms fixed compiler warning about protoype for bcopyLongs.04o,28nov96,cdp added ARM support.04n,03sep96,hdn added the compression support for pc3486 BSP.04m,19aug96,ms added UNCMP_RTN macro to use inflate instead of uncompress04l,21jun96,jmb long modhist - deleted entries prior to 1994. SPR #652803k,10jun96,tam added rom resident support for PPC architecture. 03j,14may96,dat fixed compiler warnings for copyLongs, fillLongs. SPR #653603i,06mar96,tpr changed absEntry to be volatile for PowerPC.03h,22aug95,hdn added support for I80X86.03g,14mar95,caf restored mips resident rom support (SPR #3856).03f,16feb95,jdi doc format change.03f,23may95,yao define binArrayStart and binArrayEnd for PowerPC because tools dont prepend _.03e,09dec94,caf undid mod 03a, use sdata for resident roms (SPR #3856).03d,22jun94,caf undid 16-byte alignment portion of mod 03c, below.03c,14jun94,cd corrected definitions of etext, edata and end. +caf for R4000 resident ROMs: data starts on 16-byte boundary. for R4000 uncompressed ROMs: added volatile to absEntry type.*/*DESCRIPTIONThis module provides a generic boot ROM facility. The target-specificromInit.s module performs the minimal preliminary board initialization andthen jumps to the C routine romStart(). This routine, still executing outof ROM, copies the first stage of the startup code to a RAM address andjumps to it. The next stage clears memory and then uncompresses theremainder of ROM into the final VxWorks ROM image in RAM.A modified version of the Public Domain f3zlibfP library is used touncompress the VxWorks boot ROM executable linked with it. Compressingobject code typically achieves over 55% compression, permitting muchlarger systems to be burned into ROM. The only expense is the added fewseconds delay while the first two stages complete.ROM AND RAM MEMORY LAYOUTExample memory layout for a 1-megabyte board:.CS - 0x00100000 = LOCAL_MEM_SIZE = sysMemTop() | | | RAM | | 0 filled | | | |-| = (romInit+ROM_COPY_SIZE) or binArrayStart | ROM image | |- | 0x00090000 = RAM_HIGH_ADRS | STACK_SAVE | |-| | | 0x00080000 = 0.5 Megabytes | | | | | 0 filled | | | | | 0x00001000 = RAM_ADRS & RAM_LOW_ADRS | | | | exc vectors, bp anchor, exc msg, bootline | | | | - 0x00000000 = LOCAL_MEM_LOCAL_ADRS.CE.CS - | ROM | | | 0xff8xxxxx = binArrayStart | | | | 0xff800008 = ROM_TEXT_ADRS - 0xff800000 = ROM_BASE_ADRS.CESEE ALSO:inflate(), romInit(), and deflateAUTHORThe original compression software for zlib was written by Jean-loup Gaillyand Mark Adler. See the manual pages of inflate and deflate formore information on their freely available compression software.*/#include vxWorks.h#include sysLib.h#include config.h #include errno.h#include sioLib.h#defineUNCMP_RTNinflate#ifndef USER_RESERVED_MEM# define USER_RESERVED_MEM 0#endif/* * If memory is to be cleared, it will be cleared from SYS_MEM_BOTTOM * up to (but not including) SYS_MEM_TOP, except for text and data segments. * The user reserved area is not cleared. */#defineSYS_MEM_TOP (LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE - USER_RESERVED_MEM)#define SYS_MEM_BOTTOM (LOCAL_MEM_LOCAL_ADRS + RESERVED)#define BINARRAYEND_ROUNDOFF(ROUND_DOWN(binArrayEnd, sizeof(long) IMPORT voidromInit ();IMPORT STATUSUNCMP_RTN ();IMPORT voidusrInit ();IMPORT voidsysInitAlt ();IMPORT voidstart ();IMPORT UCHARbinArrayStart ;/* compressed binary image */IMPORT UCHARbinArrayEnd ;/* end of compressed binary image */IMPORT charetext ;/* defined by the loader */IMPORT charend ;/* defined by the loader */IMPORT UCHARwrs_kernel_data_start ; /* defined by the loader */IMPORT UCHARwrs_kernel_data_end ; /* defined by the loader */#if(CPU_FAMILY = MIPS) | (CPU_FAMILY=PPC) | (CPU_FAMILY=COLDFIRE)#defineRESIDENT_DATARAM_DST_ADRS /定义体系结构特殊信息=压缩映象最终重定位的地址#else#defineRESIDENT_DATA wrs_kernel_data_start#endif#ifndef RAM_DST_ADRS /* default uncompress dest. */#define RAM_DST_ADRS RAM_HIGH_ADRS /压缩映象最终重定位的地址=拷贝引导映象的入口地址#endif/* If the boot code is in RAM and the RAM is already initialized, * clearing the RAM is not necessary. Macro BOOTCODE_IN_RAM is * used not to clear the RAM. */#ifdefBOOTCODE_IN_RAM/* not to clear RAM */#undefROM_TEXT_ADRS#undefROM_BASE_ADRS#defineROM_TEXT_ADRS(UINT)romInit)#defineROM_BASE_ADRS(UINT)romInit) /引导rom的入口地址#endif/* BOOTCODE_IN_RAM */* #ifdefined (UNCOMPRESS) | defined (ROM_RESIDENT) */#ifndef ROM_COPY_SIZE#defineROM_COPY_SIZE(ROM_SIZE - (ROM_TEXT_ADRS - ROM_BASE_ADRS)#endif/* #endif*/* UNCOMPRESS */#define ROM_OFFSET(adr)(UINT)adr - (UINT)romInit) + ROM_TEXT_ADRS) /rom-ram时涉及到计算偏移地址函数,重定位了adr在rom当中的位置;/* forward declarations */LOCAL void copyLongs (FAST UINT *source, FAST UINT *destination, UINT nlongs);/拷贝rom-ram函数#ifndefBOOTCODE_IN_RAMLOCAL void fillLongs (FAST UINT *buf, UINT nlongs, FAST UINT val);/往ram填零函数#endif/* BOOTCODE_IN_RAM */#if (CPU=XSCALE)int checkLongs (FAST UINT *source, FAST UINT *destination, UINT nlongs);/比较函数#endif/* romStart - generic ROM initialization* This is the first C code executed after reset.* This routine is called by the assembly start-up code in romInit().* It clears memory, copies ROM to RAM, and possibly invokes the uncompressor.* It then jumps to the entry point of the uncompressed object code.* RETURNS: N/A*/void romStart ( FAST int startType/* 启动类型,它的入口参数是startType,是一个启动类型标志,这在后面清内存时会用到*/ ) #if (CPU_FAMILY=SPARC) | (CPU_FAMILY=MIPS) | (CPU_FAMILY=I80X86) | (CPU_FAMILY=PPC) | (CPU_FAMILY=ARM) volatile/* to force absolute adressing */#endif /* (CPU_FAMILY=SPARC) */ FUNCPTR absEntry;/* to avoid PC Relative Jump Subroutine */ /函数指针变量absEntry,它最后指向ursInit()或compressedEntry()函数#if (CPU_FAMILY=ARM) & (!defined(ROM_RESIDENT) & !defined(BOOTCODE_IN_RAM) VOIDFUNCPTR ramfillLongs = fillLongs; /* force call to RAM */#define fillLongs(a,b,c) ramfillLongs(a,b,c)#endif /* (CPU_FAMILY=ARM) */#if (CPU_FAMILY=MC680X0) & !defined(ROM_RESIDENT) & !defined(BOOTCODE_IN_RAM) volatile VOIDFUNCPTR romcopyLongs = ©Longs; /* force call to ROM */#define copyLongs romcopyLongs#endif /* (CPU_FAMILY=MC680X0) */ /* * Copy from ROM to RAM, minus the compressed image * if compressed boot ROM which relies on binArray * appearing last in DATA segment. */#ifdef ROM_RESIDENT /* If ROM resident code, then copy only data segment * from ROM to RAM, initialize memory and jump * to usrInit. */#if (CPU_FAMILY = SPARC) copyLongs (UINT *)(etext + 8), (UINT *) RESIDENT_DATA,#else copyLongs (UINT *)etext, (UINT *) RESIDENT_DATA,#endif (UINT) wrs_kernel_data_end - (UINT) RESIDENT_DATA) / sizeof (long);#else/* ROM_RESIDENT */#ifdef UNCOMPRESS#if(CPU_FAMILY = MIPS) /* * copy text to uncached locations to avoid problems with * copy back caches */ (FUNCPTR)ROM_OFFSET(copyLongs) (ROM_TEXT_ADRS, (UINT)K0_TO_K1(romInit),ROM_COPY_SIZE / sizeof (long);#else/* CPU_FAMILY = MIPS */ (FUNCPTR)ROM_OFFSET(copyLongs) (ROM_TEXT_ADRS, (UINT)romInit,ROM_COPY_SIZE / sizeof (long);#endif/* CPU_FAMILY = MIPS */#else/* UNCOMPRESS */#if(CPU_FAMILY = MIPS) /* * copy text to uncached locations to avoid problems with * copy back caches * copy the entire data segment because there is no way to ensure that * binArray is the last thing in the data segment because of GP relative * addressing */ (FUNCPTR)ROM_OFFSET(copyLongs) (ROM_TEXT_ADRS, (UINT)K0_TO_K1(romInit),(UINT)wrs_kernel_data_end - (UINT)romInit) / sizeof (long);#else/* CPU_FAMILY = MIPS */ (FUNCPTR)ROM_OFFSET(copyLongs) (ROM_TEXT_ADRS, (UINT)romInit, /(FUNCPTR)为int (*)()型的函数指针;ROM_OFFSET为rom-ram时涉及到计算偏移地址函数,重定位了copyLongs在rom当中的位置; /(copyLongs)为拷贝rom-ram函数;ROM_TEXT_ADRS为拷贝内容rom入口地址;(UINT)romInit为ram目标地址(UINT)binArrayStart - (UINT)romInit)/ sizeof (long); /非压缩镜像大小,binArrayStart为压缩部分起始地址; /rom-ram 代码段部分; (FUNCPTR)ROM_OFFSET(copyLongs) (UINT *)(UINT)ROM_TEXT_ADRS + (UINT)BINARRAYEND_ROUNDOFF - /(UINT)BINARRAYEND_ROUNDOFF为ram中压缩部分之后目标地址; (UINT)romInit), (UINT *)BINARRAYEND_ROUNDOFF, (UINT)wrs_kernel_data_end - (UINT)binArrayEnd) / sizeof (long);#if (CPU=XSCALE) /* validate coherence, can not assume uncached area. */ (FUNCPTR)ROM_OFFSET(checkLongs) (ROM_TEXT_ADRS, (UINT)romInit, (UINT)binArrayStart - (UINT)romInit) / sizeof (long); (FUNCPTR)ROM_OFFSET(checkLongs) (UINT *)(UINT)ROM_TEXT_ADRS + (UINT)BINARRAYEND_ROUNDOFF - (UINT)romInit), (UINT *)BINARRAYEND_ROUNDOFF, (UINT)wrs_kernel_data_end - (UINT)binArrayEnd) / sizeof (long);#endif#endif/* CPU_FAMILY = MIPS */#endif/* UNCOMPRESS */#endif/* ROM_RESIDENT */#if(CPU_FAMILY != MIPS) & (!defined (BOOTCODE_IN_RAM) /* clear all memory if cold booting */ if (startType & BOOT_CLEAR)#ifdef ROM_RESIDENT/* Clear memory not loaded with text & data. * * We are careful about initializing all memory (except * STACK_SAVE bytes) due to parity error generation (on * some hardware) at a later stage. This is usually * caused by read accesses without initialization. */fillLongs (UINT *)SYS_MEM_BOTTOM,(UINT) RESIDENT_DATA - STACK_SAVE - (UINT)SYS_MEM_BOTTOM)/ sizeof(long), 0);fillLongs (UINT *) wrs_kernel_data_end),(UINT)SYS_MEM_TOP - (UINT) wrs_kernel_data_end) / sizeof(long), 0);#else/* ROM_RESIDENT */fillLongs (UINT *)(SYS_MEM_BOTTOM),(UINT)romInit - STACK_SAVE - (UINT)SYS_MEM_BOTTOM) /sizeof(long), 0); /实现了从SYS_MEM_BOTTOM到STACK_SAVE之前RAM的清零#if defined (UNCOMPRESS)fillLongs (UINT *)(UINT)romInit + ROM_COPY_SIZE), (UINT)SYS_MEM_TOP - (UINT)romInit + ROM_COPY_SIZE) / sizeof(long), 0); #elsefillLongs (UINT *)wrs_kernel_data_end, /实现了从数据段到SYS_MEM_TOP的RAM区清零 (UINT)SYS_MEM_TOP - (UINT)wrs_kernel_data_end) / sizeof (long), 0);#endif /* UNCOMPRESS */#endif /* ROM_RESIDENT */* * Ensure the boot line is null. This is necessary for those * targets whose boot line is excluded from cleaning. */*(BOOT_LINE_ADRS) = EOS;#endif/* (CPU_FAMILY != MIPS) & (!defined (BOOTCODE_IN_RAM) */ /* jump to VxWorks entry point (after uncompressing) */#ifdefined (UNCOMPRESS) | defined (ROM_RESIDENT)#if(CPU_FAMILY = I960) absEntry = (FUNCPTR)sysInitAlt;/* reinit proc tbl */#else absEntry = (FUNCPTR)usrInit;/* on to bootConfig */#endif/* CPU_FAMILY = I960 */#else #if(CPU_FAMILY = MIPS) volatile FUNCPTR absUncompress = (FUNCPTR) UNCMP_RTN; if (absUncompress) (UCHAR *)ROM_OFFSET(binArrayStart), (UCHAR *)K0_TO_K1(RAM_DST_ADRS), (int)(UINT)binArrayEnd - (UINT)binArrayStart) != OK)#elif(CPU_FAMILY = I80X86) | (CPU_FAMILY = ARM) volatile FUNCPTR absUncompress = (FUNCPTR) UNCMP_RTN; / UNCMP_RTN为原形函数为int inflate(Byte * src,Byte * dest,int nBytes) if (absUncompress) (UCHAR *)ROM_OFFSET(binArrayStart), /ROM_OFFSET(binArrayStart为压缩文件起始地址,在rom中需要重定向; (UCHAR *)RAM_DST_ADRS, binArrayEnd - binArrayStart) != OK) /解压缩过程,RAM_DST_ADRS目标地址; #else if (UNCMP_RTN (UCHAR *)ROM_OFFSET(binArrayStart), (UCHAR *)RAM_DST_ADRS, binArrayEnd - binArrayStart) != OK)#endif/* (CPU_FAMILY = MIPS) */return;/* if we return then ROMs will halt */ absEntry = (FUNCPTR)RAM_DST_ADRS;/* compressedEntry () 程序的入口地址就是RAM_DST_ADRS */ #endif/* defined UNCOMPRESS | defined ROM_RESIDENT */#if(CPU_FAMILY = ARM) & ARM_THUMB) absEntry = (FUNCPTR)(UINT32)absEntry | 1);/* force Thumb state */#endif/* CPU_FAMILY = ARM */ (absEntry) (startType); #if (CPU_FAMILY=ARM) & (!defined(ROM_RESIDENT)#undef fillLongs#endif /* (CPU_FAMILY=ARM) */#if (CPU_FAMILY=MC680X0) & !defined(ROM_RESIDENT) & !defined(BOOTCODE_IN_RAM)#undef copyLongs/* undo effects from above define */#endif /* CPU_FAMILY=MC680X0 */* copyLongs - copy one buffer to another a long at a time* This routine copies the first longs from to .*/LOCAL void copyLongs (source, destination, nlongs) FAST UINT *source;/* pointer to source buffer */ FAST UINT *destination;/* pointer to destination buffer */ UINT nlongs;/* number of longs to copy */ FAST UINT *dstend = destination + nlongs; FAST UINT nchunks; /* Hop by chunks of longs, for speed. */ for (nchunks = nlongs / 8; nchunks; -nchunks)#if (CPU_FAMILY = MC680X0)*destination+ = *source+;/* 0 */*destination+ = *source+;/* 1 */*destination+ = *source+;/* 2 */*destination+ = *source+;/* 3 */*destination+ = *source+;/* 4 */*destination+ = *source+;/* 5 */*destination+ = *source+;/* 6 */*destination+ = *source+;/* 7 */#elsedestination0 = source0;destination1 =
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年员工安全知识测试题库及答案
- 花圃拆除施工方案模板(3篇)
- 2025年检验师面试题库及解析版
- 2025年土地整治项目管理员中级考试备考资料及高频题库
- 2025年电网计算机笔试高频题解析
- 2025年经典旅游案例教学及竞赛模拟题库
- 2025年建筑水电安装工程师执业资格考试试题及答案解析
- 2025年机关幼儿园招聘面试预测题
- 2025年会展策划专家资格考试试题及答案解析
- 2025年化工工程师职业能力评估试题及答案解析
- 设备搬迁调试协议合同书
- 中证信息技术笔试题库
- 监护学徒协议书范本
- 办公楼维修改造施工方案
- 集团海外业务管理手册(专业完整格式模板)
- 高危儿培训计划和方案
- 2025年公文写作基础知识竞赛试题库及答案(共120题)
- ISO9001 质量管理体系全套(质量手册+程序文件+表格记录全套)
- 路灯CJJ检验批范表
- 肛肠科年度汇报总结
- 鸡蛋合作合同范本
评论
0/150
提交评论