VxWorks 系统中的几种运行 Context, Task, Exception, Interrupt

来源:互联网 发布:淘宝助理编辑宝贝 编辑:程序博客网 时间:2024/06/06 03:17

总体来说在vxworks中有三种运行时候的context Task exception interrupt

 

Exception的运行环境, exception handler运行在Exception Stack当中。在spawn一个task的时候,会建立一个executionstack和一个exceptionstack.每一个task都会有一个相应的exception stack

execution stack 负责task的运行,如果在task的运行过程中发生exception kernel会切换到 exceptionstack然后执行相应的exceptionhandler.

exception stack的切换是在exception入口程序excEnt()。

 

     -> checkStack tShell0
       NAME        ENTRY        TID       SIZE   CUR  HIGH  MARGIN
     ------------ ------------ ---------- ----- ----- ----- ------
     tShell0      shellTask    0x60351ba8 77824  6272 14144  63680    execution stack的大小
     (Exception Stack)                    12096     0   680  11416     exception stack的大小
     value = 1614093224 = 0x60351ba8

 


Interrupt 运行环境其实在vxworks当中可以认为interruptexception的一个特例。Interrupt被绑定到exceptionvector0x500.  也就是异常向量的0x500

一旦0x500的异常向量(也就是中断)被触发,就会执行0x500处的异常处理函数,然后中断入口函数intEnt(),在intEnt()中,会切换到interruptstack

 

这几种stacksize是在哪里定义的。

 

Task Exception stack.

/clearlib/pp_25/vxWorks/VxWorks5.3/target/src/wind/taskLib.c

/* defines */

 

#ifndef _WRS_ARCH_IS_SIMULATOR

#defineTASK_U_EXC_STACK_DEF_SIZE       8192

#else

#defineTASK_U_EXC_STACK_DEF_SIZE       8192*3

#endif /* _WRS_ARCH_IS_SIMULATOR */

 

Interrupt stack的定义。

/pp_25/vxWorks/VxWorks5.3/target/config/pdb/pdb/config.h

 

#defineISR_STACK_SIZE                 SYS_INT_STACK_SIZE

 

       /* If we are running in localmemory then start heap after code */

       kernelInit (usrRoot,ROOT_STACK_SIZE, FREE_RAM_ADRS, sysMemTop (),

                     ISR_STACK_SIZE, INT_LOCK_LEVEL);

 

shelf上查看异常处理函数的汇编代码。

 

例如异常0x300的异常处理函数。

 

//To see the PMC800 int table

psVmIntVecTblVisible

psVmIntVecTblInvisible

 

-> psVmIntVecTblVisible

value = 1 = 0x1

-> l 0x300, 0x100

0x0300  4857c302   ba          0x0057c300

0x0304  7c70faa6   mfspr       r3,HID0

0x0308  5463007e   rlwinm      r3,r3,0,1,31

0x030c  7c70fba6   mtspr       HID0,r3

0x0310  7c79faa6   mfspr       r3,1017

0x0314  54630080   rlwinm      r3,r3,0,2,0

0x0318  7c79fba6   mtspr       1017,r3

0x031c  7c6000a6   mfmsr       r3

0x0320  60630030   ori         r3,r3,0x30

0x0324  7c600124   mtmsr       r3

0x0328  4c00012c   isync      

0x032c  3c608e5d   lis         r3,0x8e5d # -29091

0x0330  6063e800   ori         r3,r3,0xe800

0x0334  90830000   stw         r4,0(r3)

0x0338  90a30004   stw         r5,4(r3)

0x033c  90c30008   stw         r6,8(r3)

0x0340  7ca00026   mfcr        r5

0x0344  90a3000c   stw         r5,12(r3)

0x0348  7ca802a6   mfspr       r5,LR

0x034c  90a30010   stw         r5,16(r3)

0x0350  80a30018   lwz         r5,24(r3)

0x0354  38a50001   addi        r5,r5,0x1 # 1

0x0358  2c85000a   cmpi        crf1,0,r5,0xa # 10

0x035c  40860008   bc          0x4,6, 0x364 #0x00000364

0x0360  38a00000    li         r5,0x0 # 0

0x0364  8083001c   lwz         r4,28(r3)

0x0368  7c842800   cmp         crf1,0,r4,r5

0x036c  4186000c   bc          0xc,6, 0x378 #0x00000378

0x0370  90a30018   stw         r5,24(r3)

0x0374  483171d3   bla         psFHLogCollect

0x0378  80a30010   lwz         r5,16(r3)

0x037c  7ca803a6   mtspr       LR,r5

0x0380  80a3000c   lwz         r5,12(r3)

0x0384  7caff120   mtcrf       0xff,r5

0x0388  80c30008   lwz         r6,8(r3)

0x038c  80a30004   lwz         r5,4(r3)

0x0390  80830000   lwz         r4,0(r3)

0x0394  7c6802a6   mfspr       r3,LR

0x0398  4832738b   bla         intEnt

0x039c  38610000   addi        r3,r1,0x0 # 0

0x03a0  9421fff0   stwu        r1,-16(r1)

0x03a4  483118fb   bla         interruptHandler0x300

0x03a8  38210010   addi        r1,r1,0x10 # 16

0x03ac  7c79faa6   mfspr       r3,1017

0x03b0  64634000   oris        r3,r3,0x4000

0x03b4  7c79fba6   mtspr       1017,r3

0x03b8  7c70faa6   mfspr       r3,HID0

0x03bc  64638000   oris        r3,r3,0x8000

0x03c0  7c70fba6   mtspr       HID0,r3

0x03c4  4832779b   bla         intExit

0x03c8  5acedead   .long       5acedead

0x03cc  5acedead   .long       5acedead

0x03d0  5acedead   .long       5acedead

0x03d4  5acedead   .long       5acedead

0x03d8  5acedead   .long       5acedead

0x03dc  5acedead   .long       5acedead

0x03e0  5acedead   .long       5acedead

0x03e4  5acedead   .long       5acedead

0x03e8  5acedead   .long       5acedead

0x03ec  5acedead   .long       5acedead

0x03f0  5acedead    .long      5acedead

0x03f4  5acedead   .long       5acedead

0x03f8  5acedead   .long       5acedead

0x03fc  5acedead   .long       5acedead

0x0400  4857c402   ba          0x0057c400

0x0404  7c70faa6   mfspr       r3,HID0

0x0408  5463007e   rlwinm      r3,r3,0,1,31

0x040c  7c70fba6   mtspr       HID0,r3

0x0410  7c79faa6   mfspr       r3,1017

0x0414  54630080   rlwinm      r3,r3,0,2,0

0x0418  7c79fba6   mtspr       1017,r3

0x041c  7c6000a6   mfmsr       r3

0x0420  60630030   ori         r3,r3,0x30

0x0424  7c600124   mtmsr       r3

0x0428  4c00012c   isync      

0x042c  3c608e5d   lis         r3,0x8e5d # -29091

0x0430  6063e800   ori         r3,r3,0xe800

0x0434  90830000   stw         r4,0(r3)

0x0438  90a30004   stw         r5,4(r3)

0x043c  90c30008   stw         r6,8(r3)

0x0440  7ca00026   mfcr        r5

0x0444  90a3000c   stw         r5,12(r3)

0x0448  7ca802a6   mfspr       r5,LR

0x044c  90a30010   stw         r5,16(r3)

0x0450  80a30018   lwz         r5,24(r3)

0x0454  38a50001   addi        r5,r5,0x1 # 1

0x0458  2c85000a   cmpi        crf1,0,r5,0xa # 10

0x045c  40860008   bc          0x4,6, 0x464 #0x00000464

0x0460  38a00000   li          r5,0x0 # 0

0x0464  8083001c   lwz         r4,28(r3)

0x0468  7c842800   cmp         crf1,0,r4,r5

0x046c  4186000c   bc          0xc,6, 0x478 #0x00000478

0x0470  90a30018   stw         r5,24(r3)

0x0474  483171d3   bla         psFHLogCollect

0x0478  80a30010   lwz         r5,16(r3)

0x047c  7ca803a6   mtspr       LR,r5

0x0480  80a3000c   lwz         r5,12(r3)

0x0484  7caff120   mtcrf       0xff,r5

0x0488  80c30008   lwz         r6,8(r3)

0x048c  80a30004   lwz         r5,4(r3)

0x0490  80830000   lwz         r4,0(r3)

 

下面是显示出stack的信息。

-> checkStack

  NAME       ENTRY       TID       SIZE   CUR  HIGH MARGIN

------------ ------------ ---------- ----- ----- ----- ------

tExcTask     0x3d1b14    0x2090f60   8000   352   624   7376

(ExceptionStack)                    3760     0   160   3600

tJobTask     0x3d1898    0x2094400   8000   304   544   7456

(ExceptionStack)                    3760     0   160   3600

tLogTask     0x3d2104    0x20975a0   5008   288  1072   3936

(ExceptionStack)                    4048     0   112   3936

tNbioLog     0x3d2ffc    0x209aea0   5008   272   320   4688

(ExceptionStack)                    3760     0    80   3680

psLanCMDout  0x2f9ac0    0x23fd000   8192   320   944   7248

(ExceptionStack)                    3760     0    80   3680

tFltHndlr    0x31150c    0x222f000  20480   272   352  20128

(ExceptionStack)                    3760     0    80   3680

psPmcInfo    0x2b1c14    0x47b2000  53248   448  2704  50544  

cpuUtilIdle  0x29d610    0x51c0000   8192    64   64   8128

(Exception Stack)                    3760    0     0   3760

INTERRUPT                            5008     0  1504   3504                                 //这个stack是系统唯一的中断stack

value = 38 = 0x26 = '&'

Best Regards,

0 0