7 | | A task context is an array of 64 words = 256 bytes. |
8 | | It contains copies of processor registers (when the task is preempted): |
9 | | * GPR[i] : generally stored in slot (i). $0, $26 & $27 are not saved. |
10 | | * HI & LO registers : used by multiply/divide instructions. |
11 | | * CP0 registers : EPC, SR, CR, BVAR |
12 | | * CP2 registers : PTPR |
13 | | It contains some general informations associated to the task: |
14 | | * TTY : TTY channel global index |
15 | | * NIC : NIC channel global index |
16 | | * CMA : CMA channel global index |
17 | | * HBA : HBA channel global index |
18 | | * DMA : DMA channel local index |
19 | | * TIM : TIM channel local index |
20 | | * PTAB : page table virtual base address |
21 | | * LTID : Task local index (in scheduler) |
22 | | * VSID : Virtual space index |
23 | | * RUN : Task state (0 => sleeping / 1 => runnable ) |
24 | | * TRDID : Thread ID index (in vspace) |
| 7 | These functions are prefixed by "_" to remind that they can only be executed by a processor in kernel mode. |
26 | | || [0] *** || [8] $8 || [16] $16 || [24] $24 || [32] EPC || [40] TTY || [48] TRDID || |
27 | | || [1] $1 || [9] $9 || [17] $17 || [25] $25 || [33] CR || [41] DMA || [49] *** || |
28 | | || [2] $2 || [10] $10 || [18] $18 || [26] LO || [34] SR || [42] NIC || [50] *** || |
29 | | || [3] $3 || [11] $11 || [19] $19 || [27] HI || [35] BVAR || [43] TIM || [51] *** || |
30 | | || [4] $4 || [12] $12 || [20] $20 || [28] $28 || [36] PTAB || [44] HBA || [52] *** || |
31 | | || [5] $5 || [13] $13 || [21] $21 || [29] SP || [37] LTID || [45] CMA || [53] *** || |
32 | | || [6] $6 || [14] $14 || [22] $22 || [30] $30 || [38] VSID || [46] GTID || [54] *** || |
33 | | || [7] $7 || [15] $15 || [23] $23 || [31] RA || [39] PTPR || [47] RUN || [55] *** || |
| 9 | |
| 10 | === unsigned int '''_get_current_task_id'''( void ) === |
| 11 | This function returns the local index of the currently running task. |
| 12 | |
| 13 | === unsigned int '''_get_task_slot'''( unsigned int x, unsigned int y, unsigned int p, unsigned int ltid, unsigned int slot ) === |
| 14 | This function returns the content of a context slot for any task running on any processor. |
| 15 | * '''x''' : cluster x coordinate |
| 16 | * '''y''' : cluster y coordinate |
| 17 | * '''p''' : processor local index |
| 18 | * '''ltid''' : task local index |
| 19 | * '''slot''' : slot index |
| 20 | |
| 21 | === void '''_set_task_slot'''( unsigned int x, unsigned int y, unsigned int p, unsigned int ltid, unsigned int slot, unsigned int value ) === |
| 22 | This function updates the content of a context slot for any task running on any processor. |
| 23 | * '''x''' : cluster x coordinate |
| 24 | * '''y''' : cluster y coordinate |
| 25 | * '''p''' : processor local index |
| 26 | * '''ltid''' : task local index |
| 27 | * '''slot''' : slot index |
| 28 | |
| 29 | === unsigned int '''_get_context_slot'''( unsigned int slot ) === |
| 30 | This function returns the content of a context slot for the running task. |
| 31 | |
| 32 | === void '''_set_context_slot'''( unsigned int slot, unsigned int value ) === |
| 33 | This function updates the content of a context slot for the running task. |
37 | | === void _ctx_switch() === |
38 | | This function performs a context switch between the running (calling) task and another runable task, using a round-robin sheduling policy between all tasks allocated to a given processor (static allocation). |
39 | | It selects the next runable task to resume execution. |
40 | | If the only runable task is the current task, return without context switch. |
41 | | If there is no runable task, the scheduler switch to the default "idle" task. |
42 | | The return address contained in $31 is saved in the current task context (in the ctx[31] slot), and the function actually returns to the address contained in the ctx[31] slot of the next task context. |
43 | | |
44 | | === void _ctx_eret() === |
45 | | The address of this function is used to initialise the return address in the "idle" task context. |
46 | | |
47 | | === void _idle_task() === |
48 | | This function is executed task when no other task can be executed. |
49 | | |
50 | | |
51 | | |
52 | | |