免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1051 | 回复: 0
打印 上一主题 下一主题

修改vivi(修改分区、添加命令) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-19 20:42 |只看该作者 |倒序浏览
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP