首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

s3c44b0的blob中的command链表问题,请版主帮忙解答

s3c44b0的blob中的command链表问题,请版主帮忙解答

在lib/command.c中,函数init_commands实现的功能是创建一个commandlist_t类型的链表,我不理解的是变量__commandlist_start,在链接脚本文件中定义为__commandlist_start = .
也就是说__commandlist_start 装载的是某一内存地址,而下面的语句commands = (commandlist_t *) &__commandlist_start;将__commandlist_start的地址转换为一个指向commandlist_t 结构类型的指针,这样的话我理解是最后函数连接起来的链表不是将__commandlist_start 到__commandlist_end之间的内存链接起来,而这段代码的目的好像是__commandlist_start 到__commandlist_end之间的内存链接起来,不知我哪里理解错误,请指点。非常感谢!
extern u32 __commandlist_start;
extern u32 __commandlist_end;

commandlist_t *commands;

static void init_commands(void)
{
        commandlist_t *lastcommand;
        commandlist_t *cmd, *next_cmd;

        commands = (commandlist_t *) &__commandlist_start;
        lastcommand = (commandlist_t *) &__commandlist_end;

        /* make a list */
        /* FIXME: should sort the list in alphabetical order over here */
        cmd = next_cmd = commands;
        next_cmd++;

        while(next_cmd < lastcommand) {
                cmd->next = next_cmd;
                cmd++;
                next_cmd++;
        }
}
commandlist_start是command的列表的首地址,每一个command表项都有相同的commandlist_t型结构,它们在分布于内存中.

commands = (commandlist_t *) &__commandlist_start;
//相当于把_commandlist_start的值赋给commands,同时把commands所指向的区域转化为commandlist_t型. lastcommand也类似.

cmd = next_cmd = commands;
//这个就不说了,赋值.
next_cmd++;
//这个自加所加的地址数是 commandlist_t的长度...

while(next_cmd < lastcommand) {
cmd->next = next_cmd;
cmd++;
next_cmd++;
}

//这个循环就相当于cmd 和 next_cmd一前一后,把commandlist的各个表项接起来(cmd->next = next_cmd).直到到达command表项的未尾:next_cmd < lastcommand.

整个实现的过程,就好像常用莲表里的一些操作,不知你搞明白了没有. 所以函数的功能就是将__commandlist_start 到__commandlist_end之间的内存链接起来
51 c8051f(f020,f040) msp430 arm(2410,2510) fpga(xc3s4000) dsp(5116 dm642) keilc vc++ matlab linux protel Ten_layerPCB mpegx h.26x Rscode Turbocode ofdm VideoBroadcasting ldpc_code(now!)
"commands = (commandlist_t *) &__commandlist_start;
//相当于把_commandlist_start的值赋给commands"
不理解版主的_commandlist_start的值怎么解释,我觉得不是将__commandlist_start的地址赋给commands吗?&是地址符呀。
是地址值,我写掉了...
51 c8051f(f020,f040) msp430 arm(2410,2510) fpga(xc3s4000) dsp(5116 dm642) keilc vc++ matlab linux protel Ten_layerPCB mpegx h.26x Rscode Turbocode ofdm VideoBroadcasting ldpc_code(now!)
如果“commandlist_start是command的列表的首地址”,而"commands = (commandlist_t *) &__commandlist_start;
//相当于把_commandlist_start的地址值赋给commands"
这样就很不好理解了,下面建立的链表就不是将__commandlist_start 到__commandlist_end之间的内存链接起来
这里有相关图片进行说明。所以我现在理解是__commandlist_start不是一个地址,而是一个符号,&__commandlist_start才是真正的地址,不知这样理解是否可以?
我是这样理解的, __commandlist_start就像是一个类似变量的参数(),它的存储指向列表的首地址,所以&__commandlist_start就获得了列表的首地址,也就是__commandlist_start的存储地址.(图片在那?)
51 c8051f(f020,f040) msp430 arm(2410,2510) fpga(xc3s4000) dsp(5116 dm642) keilc vc++ matlab linux protel Ten_layerPCB mpegx h.26x Rscode Turbocode ofdm VideoBroadcasting ldpc_code(now!)
我是把图片放在word文档里上传的,不知怎么没传上来。
单独传一下吧,改为JPG格式小一些.
51 c8051f(f020,f040) msp430 arm(2410,2510) fpga(xc3s4000) dsp(5116 dm642) keilc vc++ matlab linux protel Ten_layerPCB mpegx h.26x Rscode Turbocode ofdm VideoBroadcasting ldpc_code(now!)
这个问题已经解决,是这样的。,"__commandlist_start=."的意思实际上是令_etext的地址等于当前的VMA
返回列表