歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> uclinux-2008R1-RC8(bf561)到VDSP5的移植(12):init_thread_union

uclinux-2008R1-RC8(bf561)到VDSP5的移植(12):init_thread_union

日期:2017/3/3 16:43:43   编辑:關於Linux

在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;

也就是說,在初始化的時候,將FP和SP都指向了stack的最高位置,它並沒有使用thread_info這個結構體。

Copyright © Linux教程網 All Rights Reserved