- 论坛徽章:
- 0
|
1. 修改、vivi/arch/s3c2410/smdk.c 添加file分区 mtd_partition_t default_mtd_partitions[] = { { name: "vivi", offset: 0, size: 0x00020000, flag: 0 }, { name: "param", offset: 0x00020000, size: 0x00010000, flag: 0 }, { name: "kernel", offset: 0x00030000, size: 0x000f0000, flag: 0 }, { name: "root", offset: 0x00120000, size: 0x00940000, flag: MF_BONFS },{ name: "file", offset: 0x00a60000, size: 0x00440000, flag: 0 }};2. vivi/lib/command.c中添加命令 eg.添加file_cmd extern user_command_t file_cmd; add_command(&file_cmd);//file_cmd是个结构体可以仿照boot_cmd写3. vivi/lib/boot_kernel.c中实现命令 user_command_t file_cmd = { "file", file_boot,//file_boot函数获取file分区的起始地址和分区大小 NULL, "file[{cmds}] \t\t\t-- Booting file" }; /////////////////////////////////////////////////// void file_boot(int argc,const char **argv) { ulong from = 0; size_t size = 0; mtd_partition_t *file_part; switch (argc) { case 1: file_part = get_mtd_partition("file"); //返回的结构提供了file的起始地址和该分区大小 if(file_part == NULL){ printk("Can't find default 'file' partition\n"); return; } from = file_part->offset; size = file_part->size; //读取起始地址和分区大小 break; default: display_help(); break; } boot_file(from, size); } ////////////////////////////////////////////////////////////// void go(unsigned long addr, long a0, long a1, long a2, long a3); int boot_file(ulong from, size_t size) { int ret; ulong boot_mem_base; ulong to; to = 0x30000000; printk("Copy linux file from 0x%08lx to 0x%08lx, \ size = 0x%08lx ... ",from, to, size); ret = nand_read_ll((unsigned char *)to, (unsigned long)from, (int)size); //将代码考到ram中0x30000000地址处 if (ret) { printk("failed\n"); return -1; } else { printk("done\n"); } go(to,0,0,0,0);//跳到ram中0x30000000地址处执行代码 return 0; }
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/100183/showart_2032202.html |
|