Chinaunix首页 | 论坛 | 博客
  • 博客访问: 318884
  • 博文数量: 88
  • 博客积分: 2051
  • 博客等级: 大尉
  • 技术积分: 950
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-14 23:59
文章分类

全部博文(88)

文章存档

2012年(3)

2011年(2)

2010年(9)

2009年(14)

2008年(60)

我的朋友

分类: C/C++

2008-10-16 11:34:39

参考symbian os internal real time kernel programming
看看一个RChunk::Base()的调用是怎么实现的吧
1.在user thread里面调用RChunk::Base()
2.代码link到EUser.dll里面去,那里有这个函数的具体实现,它是这样实现的SLOW_EXEC1(EExecChunkBase); 这个宏会将EExecChunkBase分发,促发对cpu的swi,像这样SWI EExecChunkBase。
大概的意思就是,每个系统调用都对应一个代码,将这个代码作为swi的参数促发cpu的软中断。大概和linux的原理是一样的,linux的系统调用是促发0x80中断。
3.中断发生后,cpu进入超级模式(在nanokernel的代码级别中),不在user mode了,swi调用__ArmVectorSwi,查看中断向量表,根据传入的参数,看看是否需要调用symbian os kernel里面的PreprocessHandler,因为R类都需要查找对应的kernel boject,这里通过PreprocessHandler返回对应RChunk的DChunk对象。
4.调用
TUint8 *ExecHandler::ChunkBase(DChunk* aChunk)
// Return the address of the base of the Chunk.
{
return (TUint8 *)aChunk->Base();
}
 
所以RChunk::Base会
1.EUser帮你查找对应的函数代号
2.找出对应的DChunk
3.调用ExecHandler::ChunkBase
 
但是exec调用的执行环境还是user thread的环境,不是内核thread的环境。只是:
1.cpu进入了超级模式
2.stack从user mode的stack切换到了NKern的stack上
所以,在isr或者dfc里面不能进行系统调用,because in these situations there is no thread context.
 
系统调用分为fast exec call and slow exec call
在调用fast exec时,所有中断都禁止,它们的操作必须迅速的返回。如RAllocator* Exec::Heap()返回当前thread的heap!
slow call又分为需要LockSystem的和不需要locksystem的!那些不需要locksystem的调用只对内核对象进行read操作,那些需要locksystem的exec call基本上都是不可重入的代码,另外Certain slow exec calls have a bit set in their attribute word to say that the
dispatcher should call a preprocessing handler(如找出handle对应的内核对象) in the Symbian OS kernel before calling the executive handler in the kernel.
 
总的来说,所有的系统调用促发一个swi中断,这个中断是个分发器,将传入的32bit参数进行解析,然后调用对应exechandler!这些handler是厂商可以扩展的,比如在hal层,厂商可以扩展hal function,在EUSER添加对应的api和swi参数,就可以在user thread里面调用hal function!
阅读(775) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~