?? boot.c~
字號:
/* * File: boot.c * * rrload moves itself from flash to RAM * * Copyright (C) 2002 RidgeRun, Inc. * Author: RidgeRun, Inc <skranz@ridgerun.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * THIS SOFTWARE IS PROVIDED ``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. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * * Please report all bugs/problems to the author or <support@dsplinux.net> * * key: RRGPLCR (do not remove) * */#include "io.h"#include "memconfig.h"#include "pmu.h"#include "util.h"#include "i2c.h"#include "dm270-registers.h"extern void main(void);extern int btldr_start;extern int btldr_end;/****************************** Routine: Description: rrload moves itself from flash to RAM and then jumps to its main() now located in RAM. The ram location used by the transfer algorithm is determined by the linker script used to build rrload.******************************/void bootstrap(void){ typedef void(*ENTRY)(void); // Signature of bootloader's "main()". ENTRY entry_addr; unsigned int num_bytes; unsigned int start; unsigned int end; int i;// unsigned long *Content; unsigned short *fs_addr; unsigned short *rs_addr; unsigned int num_16bit_words; unsigned short temp;/*#ifdef C5471 unsigned long *fs_addr; unsigned long *rs_addr; unsigned int num_32bit_words; start = (unsigned int)(&btldr_start); end = (unsigned int)(&btldr_end); num_bytes = (end - start) + 1; // Next, | Move the bootloader image from flash // | to RAM. fs_addr = (unsigned long *) (BSPCONF_FLASH_BASE); rs_addr = (unsigned long *) (&btldr_start); num_32bit_words = (num_bytes + 3) >> 2; // round up. for (i=0; i<num_32bit_words; i++) { *rs_addr = *fs_addr; // 32bit words at a time. rs_addr++; fs_addr++; }#else // NOTE: | I suspect that this block can be completely // | removed and *all* supported plateforms can // | get by with the faster algorithm currently // | used for C5471 above. At the moment I'm porting // | rrload to C5471 and don't want to run the risk // | of breaking those other platforms that we know // | already work. In the future when we have time // | to test that the new algorithm really works on // | them we'll switch over and retire the enclosed // | logic below. skranz, Sep 2001. // afraxus debug// REG 0x3058E = 0x2000; // set// REG 0x30582 = 0xDFFF;// quit_discharge(); // afraxus added// pmu_BootInit(); if(!power_on_check()) { //pmu_goStandBy(); pmu_goFinalize(); REG GIO_BITCLR0 = 0x2000; while(1) { temp++; } } //SDRAM clock no bypass... REG 0x3088a = 0x0000;// afraxus debug REG 0x30594 = 0x2000; // clear*/ start = (unsigned int)(&btldr_start); end = (unsigned int)(&btldr_end); num_bytes = (end - start) + 1; // Next, | Move the bootloader image from flash // | to RAM. fs_addr = (unsigned short *) (BSPCONF_FLASH_BASE); rs_addr = (unsigned short *) (&btldr_start); num_16bit_words = (num_bytes + 1) >> 1; // round up.// *Content = *fs_addr | *(fs_addr+1); if((*fs_addr&1111)!=1111) {// util_printf("Giving up!\n"); for (i=0; i<num_16bit_words; i++) { *rs_addr = *fs_addr; // 16bit words at a time. rs_addr++; fs_addr++; } }// else util_printf("hhGiving up!\n");//#endif // afraxus debug// REG 0x3058E = 0x2000; // set // Now jump to "main()" of the now RAM based bootloader. entry_addr = &main; (*entry_addr)(); }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -