Chinaunix首页 | 论坛 | 博客
  • 博客访问: 65079
  • 博文数量: 50
  • 博客积分: 2360
  • 博客等级: 大尉
  • 技术积分: 620
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-02 15:59
文章分类

全部博文(50)

文章存档

2011年(1)

2009年(49)

我的朋友

分类: LINUX

2009-08-19 20:42:44

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;
        }
阅读(545) | 评论(0) | 转发(0) |
0

上一篇:key14irqTimer

下一篇:linux下个文件夹作用

给主人留下些什么吧!~~