init_thread_union猜想

 

快乐虾

http://blog.csdn.net/lights_joy/

lights@hb165.com

 

本文适用于

ADI BF561 DSP

uclinux-2008r1.5-RC3(移植到vdsp5)

Visual DSP++ 5.0

 

欢迎转载,但请保留作者信息

 

uclinux启动时有一个默认的初始线程,uclinux用一个union来保存这个线程的数据,其定义在arch/blackfin/kenel/init_task.c中:

 

/*

 * Initial thread structure.

 *

 * We need to make sure that this is 8192-byte aligned due to the

 * way process stacks are handled. This is done by having a special

 * "init_task" linker map entry.

 */

union thread_union init_thread_union

    __attribute__ ((__section__(".data.init_task"))) = {

INIT_THREAD_INFO(init_task)};

thread_union的定义在include/linux/shed.h中:

 

union thread_union {

     struct thread_info thread_info;

     unsigned long stack[THREAD_SIZE/sizeof(long)];

};

其中THREAD_SIZE的定义在include/asm/thread_info.h中:

 

/*

 * Size of kernel stack for each process. This must be a power of 2...

 */

#define THREAD_SIZE         8192 /* 2 pages */

 

union中的thread_info这个结构体我们暂且不管(因为目前还不需要使用到它)。先看看head.s中与此union相关的部分:

 

       /*

        * load the current thread pointer and stack

        */

       r1.l = _init_thread_union;

       r1.h = _init_thread_union;

 

       r2.l = 0x2000;    // 8192字节

       r2.h = 0x0000;

       r1 = r1 + r2;

       sp = r1;

       usp = sp;

       fp = sp;

也就是说,在初始化的时候,将FPSP都指向了stack的最高位置,它并没有使用thread_info这个结构体。

猜想uclinux应该是把前面的启动过程都当成一个特殊的线程看待。这个线程从head.s的第一行语句开始一直工作到内核启动完成。

 

1       参考资料

uclinux2.6(bf561)内核中的current_thread_info(2008/5/12)

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌云阁主

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值