?? 2410loader.c
字號:
/************************************************
* NAME : 2410loader.C *
* DESC : *
* History : 2002.02.25 ver 0.0 *
************************************************/
#include <stdlib.h>
#include <string.h>
#include "option.h"
#include "def.h"
#include "2410addr.h"
#include "2410slib.h"
#include "2410addr.h"
#include "k9s1208.h"
#include "mmu.h"
#define DOWNLOAD_ADDRESS _RAM_STARTADDRESS
#define LED_ON 0xa
#define LED_OFF 0x0
#define OS_IMAGE_SIZE 830
void (*run)(void)=(void (*)(void))(DOWNLOAD_ADDRESS+0x200000);
void Port_Init(void);
void Led_Display(int);
void Delay(int);
volatile unsigned char *downPt;
void T4_Start(void);
void T4_Stop(void);
char *hex2char(int val);
void Main(void)
{
register i,j;
MMU_EnableICache();
#if ADS10
// __rt_lib_init(); //for ADS 1.0
#endif
ChangeClockDivider(1,1); // 1:2:4
ChangeMPllValue(0x5c,0x4,0x0); //Fin=12MHz FCLK=200MHz
Port_Init();
Uart_Init(PCLK, 115200);
downPt=(unsigned char *)DOWNLOAD_ADDRESS+0x200000;
NF_Init();
Led_Display(LED_OFF);
T4_Start();
j=0;
while(j<(OS_IMAGE_SIZE)) // Read 1~807 block(13635072B) for WinCE image
{
j++;
for(i=0;i<32;i++) // Read 32 page
{
if(!NF_ReadPage(j, i, (U8 *)downPt)) //(U32 block,U32 page,U8 *buffer)
{
if(i!=0)
{
Led_Display(0x8); // real ECC Error
while(1);
}
break; // ECC error is considered as a bad block.
}
downPt += 512; // Next page
}
}
Led_Display(LED_ON);
T4_Stop();
run();
}
void T4_Start(void)
{
Uart_SendString("\n\nNAND Boot Start\n");
rTCFG0=0xff00;
rTCFG1=(0x3<<16); //T4=16/256
rTCNTB4=0xffff;
rTCON=(1<<22)|(1<<21); //Manual update
rTCON=(1<<22)|(1<<20); //Start T4
}
void T4_Stop(void)
{
int cnt;
rTCON=(1<<22)|(0<<20); //Stop T4
cnt=0xffff-rTCNTO4;
Uart_SendString("NAND Boot End\n");
Uart_SendString("Boot time=nTCNT*82uS. nTCNT=0x");
Uart_SendString(hex2char((cnt&0xf000)>>12));
Uart_SendString(hex2char((cnt&0x0f00)>>8));
Uart_SendString(hex2char((cnt&0x00f0)>>4));
Uart_SendString(hex2char((cnt&0x000f)>>0));
Uart_SendString("\n\n");
}
char *hex2char(int val)
{
static char str[2];
str[1]='\0';
if(val<=9)str[0]='0'+val;
else str[0]=('a'+val-10);
return str;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -