关于重定位的问题
时间:10-02
整理:3721RD
点击:
static int nandll_read_page (unsigned char *buf, unsigned long addr, int large_block)
{
int i;
int page_size = 512;
if (large_block==2)
page_size = 4096;
nand_select();
NFCMMD = 0;
/* Write Address */
NFADDR = 0;
if (large_block)
NFADDR = 0;
NFADDR = (addr) & 0xff;
NFADDR = (addr >> 8) & 0xff;
NFADDR = (addr >> 16) & 0xff;
if (large_block)
NFCMMD = 0x30;
wait_ready();
for(i=0; i < page_size; i++) {
*buf++ = NFDATA;
}
nand_deselect();
return 0;
}
int copy2ddr(unsigned int nand_start, unsigned int ddr_start, unsigned int len)
{
unsigned char *dest = (unsigned char *)ddr_start;
unsigned int free_page = 0;
int i;
if(len > 8192)
{
free_page = ((len - 8192)+4096) >> 12;
}
/* 初始化nand flash controller */
nand_init();
/* 读nand flash */
/* Read pages */
for (i = 0; i < 4; i++, dest+=2048){
nandll_read_page(dest, i, 2);
}
/* Read pages */
for (i = 4; i < (free_page+4); i++, dest+=8192) {
nandll_read_page(dest, i, 2);
}
return 0;
}
nandll_read_page(dest, i, 2);这个函数传递的地址参数i感觉有点奇怪?还有copy2ddr()中为什么分两次移动数据呢?求大神帮忙解决(这个是韦东山视频里的代码)
{
int i;
int page_size = 512;
if (large_block==2)
page_size = 4096;
nand_select();
NFCMMD = 0;
/* Write Address */
NFADDR = 0;
if (large_block)
NFADDR = 0;
NFADDR = (addr) & 0xff;
NFADDR = (addr >> 8) & 0xff;
NFADDR = (addr >> 16) & 0xff;
if (large_block)
NFCMMD = 0x30;
wait_ready();
for(i=0; i < page_size; i++) {
*buf++ = NFDATA;
}
nand_deselect();
return 0;
}
int copy2ddr(unsigned int nand_start, unsigned int ddr_start, unsigned int len)
{
unsigned char *dest = (unsigned char *)ddr_start;
unsigned int free_page = 0;
int i;
if(len > 8192)
{
free_page = ((len - 8192)+4096) >> 12;
}
/* 初始化nand flash controller */
nand_init();
/* 读nand flash */
/* Read pages */
for (i = 0; i < 4; i++, dest+=2048){
nandll_read_page(dest, i, 2);
}
/* Read pages */
for (i = 4; i < (free_page+4); i++, dest+=8192) {
nandll_read_page(dest, i, 2);
}
return 0;
}
nandll_read_page(dest, i, 2);这个函数传递的地址参数i感觉有点奇怪?还有copy2ddr()中为什么分两次移动数据呢?求大神帮忙解决(这个是韦东山视频里的代码)