Skip to content

YohnWang/ucosii-on-riscv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stack initialization

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.

how does trap process

  1. store register (x1-x31)
  2. store mstatus
  3. get mcause,mepc,sp
  4. call trap_handler
  5. set mepc(next instruction or next task)
  6. restore mstatus
  7. load register
  8. 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

how to switch task

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)

About

ucos-ii ported on risc-v(simulate by spike)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published