stack structure
stk[1] is the register of mstatus,MPIE must be set
stk[9] is task argument
stk[31] is task start address
other position can be ignored.
- store register (x1-x31)
- store mstatus
- get mcause,mepc,sp
- call trap_handler
- set mepc(next instruction or next task)
- restore mstatus
- load register
- mret
trap_handlerwill analyise which interrupt or exception occur,and process it.
If mcause is lower than zero,it is interrput,or it is exception
ucos-ii will use OSCtxSw to switch task,but now we use task_switch .
In time_handler,it will replace OSTickISR .
And in OSIntExit ,OSIntCtxSwis removed,but in time_handler,task_switch will do its work.
If task give up processor,scallshould be call,then syscall_handler will finish task switch.(This work was originally completed by the macro OS_TASK_SW)