`
xiaoer_1982
  • 浏览: 1811609 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

head.s分析(17):修改SP指针

阅读更多

快乐虾

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

lights@hb165.com

本文适用于

ADI bf561 DSP

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

Visual DSP++ 5.0(update 5)

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

/*

* load the current thread pointer and stack

*/

r1.l = _init_thread_union;

r1.h = _init_thread_union;

r2.l = 0x2000;

r2.h = 0x0000;

r1 = r1 + r2;

sp = r1;

usp = sp;

fp = sp;

在此之前,SP一直使用4kscratch pad,现在终于要进入正题了。可以将uclinux内核的初始化阶段也看成一个线程,用一个表示线程的全局结构来表示它,这就是init_thread_union

/*

* 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,定义如下:

union thread_union {

struct thread_info thread_info;

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

};

thread_info由低向高排列,stack则从高往低使用,因此在head.s中,将sp设置为指向init_thread_union的最高位置。

/*

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

*/

#define THREAD_SIZE 8192 /* 2 pages */

819216进制即为0x2000

1 参考资料

head.s分析(1):保存u-boot传递过来的指针(2009-1-19)

head.s分析(2)SYSCFG配置(2009-1-19)

head.s分析(3):数据及指针寄存器清0(2009-1-19)

head.s分析(4):关闭CACHE(2009-01-19)

head.s分析(5):关闭串口(2009-01-19)

head.s分析(6):栈指针初始化(2009-01-19)

head.s分析(7)init_early_exception_vectors(2009-1-19)

head.s分析(8):配置PLLSDRAM(2009-01-20)

head.s分析(9)EBIU配置(2009-01-20)

head.s分析(10):转入中断15(2009-01-20)

head.s分析(11):关闭WATCHDOG(2009-01-20)

head.s分析(12)bss段清0(2009-01-20)

head.s分析(13):代码段前空间清0(2009-01-20)

head.s分析(14)L2空间清0(2009-01-20)

head.s分析(15):复制u-boot传递的参数(2009-01-20)

head.s分析(16):取_rambase_ramstart的值(2009-1-20)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics