port_asm.S 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. /*
  2. * FreeRTOS Kernel V10.4.6
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * SPDX-License-Identifier: MIT
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  8. * this software and associated documentation files (the "Software"), to deal in
  9. * the Software without restriction, including without limitation the rights to
  10. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  11. * the Software, and to permit persons to whom the Software is furnished to do so,
  12. * subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  19. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  20. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  21. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * https://www.FreeRTOS.org
  25. * https://github.com/FreeRTOS
  26. *
  27. */
  28. #include <xc.h>
  29. #include <sys/asm.h>
  30. #include "FreeRTOSConfig.h"
  31. #include "ISR_Support.h"
  32. .extern pxCurrentTCB
  33. .extern vTaskSwitchContext
  34. .extern vPortIncrementTick
  35. .extern xISRStackTop
  36. .extern ulTaskHasFPUContext
  37. .global vPortStartFirstTask
  38. .global vPortYieldISR
  39. .global vPortTickInterruptHandler
  40. .global vPortInitialiseFPSCR
  41. /******************************************************************/
  42. .set nomips16
  43. .set nomicromips
  44. .set noreorder
  45. .set noat
  46. /***************************************************************
  47. * The following is needed to locate the
  48. * vPortTickInterruptHandler function into the correct vector
  49. ***************************************************************/
  50. #ifdef configTICK_INTERRUPT_VECTOR
  51. #if (configTICK_INTERRUPT_VECTOR == _CORE_TIMER_VECTOR)
  52. .equ __vector_dispatch_0, vPortTickInterruptHandler
  53. .global __vector_dispatch_0
  54. .section .vector_0, code, keep
  55. #elif (configTICK_INTERRUPT_VECTOR == _TIMER_1_VECTOR)
  56. .equ __vector_dispatch_4, vPortTickInterruptHandler
  57. .global __vector_dispatch_4
  58. .section .vector_4, code, keep
  59. #elif (configTICK_INTERRUPT_VECTOR == _TIMER_2_VECTOR)
  60. .equ __vector_dispatch_9, vPortTickInterruptHandler
  61. .global __vector_dispatch_9
  62. .section .vector_9, code, keep
  63. #elif (configTICK_INTERRUPT_VECTOR == _TIMER_3_VECTOR)
  64. .equ __vector_dispatch_14, vPortTickInterruptHandler
  65. .global __vector_dispatch_14
  66. .section .vector_14, code, keep
  67. #elif (configTICK_INTERRUPT_VECTOR == _TIMER_4_VECTOR)
  68. .equ __vector_dispatch_19, vPortTickInterruptHandler
  69. .global __vector_dispatch_19
  70. .section .vector_19, code, keep
  71. #elif (configTICK_INTERRUPT_VECTOR == _TIMER_5_VECTOR)
  72. .equ __vector_dispatch_24, vPortTickInterruptHandler
  73. .global __vector_dispatch_24
  74. .section .vector_24, code, keep
  75. #elif (configTICK_INTERRUPT_VECTOR == _TIMER_6_VECTOR)
  76. .equ __vector_dispatch_28, vPortTickInterruptHandler
  77. .global __vector_dispatch_28
  78. .section .vector_28, code, keep
  79. #elif (configTICK_INTERRUPT_VECTOR == _TIMER_7_VECTOR)
  80. .equ __vector_dispatch_32, vPortTickInterruptHandler
  81. .global __vector_dispatch_32
  82. .section .vector_32, code, keep
  83. #elif (configTICK_INTERRUPT_VECTOR == _TIMER_8_VECTOR)
  84. .equ __vector_dispatch_36, vPortTickInterruptHandler
  85. .global __vector_dispatch_36
  86. .section .vector_36, code, keep
  87. #elif (configTICK_INTERRUPT_VECTOR == _TIMER_9_VECTOR)
  88. .equ __vector_dispatch_40, vPortTickInterruptHandler
  89. .global __vector_dispatch_40
  90. .section .vector_40, code, keep
  91. #endif
  92. #else
  93. .equ __vector_dispatch_4, vPortTickInterruptHandler
  94. .global __vector_dispatch_4
  95. .section .vector_4, code, keep
  96. #endif
  97. .ent vPortTickInterruptHandler
  98. vPortTickInterruptHandler:
  99. portSAVE_CONTEXT
  100. jal vPortIncrementTick
  101. nop
  102. portRESTORE_CONTEXT
  103. .end vPortTickInterruptHandler
  104. /******************************************************************/
  105. .set noreorder
  106. .set noat
  107. .section .text, code
  108. .ent vPortStartFirstTask
  109. vPortStartFirstTask:
  110. /* Simply restore the context of the highest priority task that has been
  111. created so far. */
  112. portRESTORE_CONTEXT
  113. .end vPortStartFirstTask
  114. /*******************************************************************/
  115. .set nomips16
  116. .set nomicromips
  117. .set noreorder
  118. .set noat
  119. /***************************************************************
  120. * The following is needed to locate the vPortYieldISR function
  121. * into the correct vector
  122. ***************************************************************/
  123. .equ __vector_dispatch_1, vPortYieldISR
  124. .global __vector_dispatch_1
  125. .section .vector_1, code
  126. .ent vPortYieldISR
  127. vPortYieldISR:
  128. #if ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )
  129. /* Code sequence for FPU support, the context save requires advance
  130. knowledge of the stack frame size and if the current task actually uses the
  131. FPU. */
  132. /* Make room for the context. First save the current status so it can be
  133. manipulated, and the cause and EPC registers so their original values are
  134. captured. */
  135. la k0, ulTaskHasFPUContext
  136. lw k0, 0(k0)
  137. beq k0, zero, 1f
  138. addiu sp, sp, -portCONTEXT_SIZE /* always reserve space for the context. */
  139. addiu sp, sp, -portFPU_CONTEXT_SIZE /* reserve additional space for the FPU context. */
  140. 1:
  141. mfc0 k1, _CP0_STATUS
  142. /* Also save s6 and s5 so they can be used. Any nesting interrupts should
  143. maintain the values of these registers across the ISR. */
  144. sw s6, 44(sp)
  145. sw s5, 40(sp)
  146. sw k1, portSTATUS_STACK_LOCATION(sp)
  147. sw k0, portTASK_HAS_FPU_STACK_LOCATION(sp)
  148. /* Prepare to re-enabled interrupts above the kernel priority. */
  149. ins k1, zero, 10, 7 /* Clear IPL bits 0:6. */
  150. ins k1, zero, 18, 1 /* Clear IPL bit 7. It would be an error here if this bit were set anyway. */
  151. ori k1, k1, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 10 )
  152. ins k1, zero, 1, 4 /* Clear EXL, ERL and UM. */
  153. /* s5 is used as the frame pointer. */
  154. add s5, zero, sp
  155. /* Swap to the system stack. This is not conditional on the nesting
  156. count as this interrupt is always the lowest priority and therefore
  157. the nesting is always 0. */
  158. la sp, xISRStackTop
  159. lw sp, (sp)
  160. /* Set the nesting count. */
  161. la k0, uxInterruptNesting
  162. addiu s6, zero, 1
  163. sw s6, 0(k0)
  164. /* s6 holds the EPC value, this is saved with the rest of the context
  165. after interrupts are enabled. */
  166. mfc0 s6, _CP0_EPC
  167. /* Re-enable interrupts above configMAX_SYSCALL_INTERRUPT_PRIORITY. */
  168. mtc0 k1, _CP0_STATUS
  169. /* Save the context into the space just created. s6 is saved again
  170. here as it now contains the EPC value. */
  171. sw ra, 120(s5)
  172. sw s8, 116(s5)
  173. sw t9, 112(s5)
  174. sw t8, 108(s5)
  175. sw t7, 104(s5)
  176. sw t6, 100(s5)
  177. sw t5, 96(s5)
  178. sw t4, 92(s5)
  179. sw t3, 88(s5)
  180. sw t2, 84(s5)
  181. sw t1, 80(s5)
  182. sw t0, 76(s5)
  183. sw a3, 72(s5)
  184. sw a2, 68(s5)
  185. sw a1, 64(s5)
  186. sw a0, 60(s5)
  187. sw v1, 56(s5)
  188. sw v0, 52(s5)
  189. sw s7, 48(s5)
  190. sw s6, portEPC_STACK_LOCATION(s5)
  191. /* s5 and s6 has already been saved. */
  192. sw s4, 36(s5)
  193. sw s3, 32(s5)
  194. sw s2, 28(s5)
  195. sw s1, 24(s5)
  196. sw s0, 20(s5)
  197. sw $1, 16(s5)
  198. /* s7 is used as a scratch register as this should always be saved across
  199. nesting interrupts. */
  200. /* Save the AC0, AC1, AC2 and AC3. */
  201. mfhi s7, $ac1
  202. sw s7, 128(s5)
  203. mflo s7, $ac1
  204. sw s7, 124(s5)
  205. mfhi s7, $ac2
  206. sw s7, 136(s5)
  207. mflo s7, $ac2
  208. sw s7, 132(s5)
  209. mfhi s7, $ac3
  210. sw s7, 144(s5)
  211. mflo s7, $ac3
  212. sw s7, 140(s5)
  213. rddsp s7
  214. sw s7, 148(s5)
  215. mfhi s7, $ac0
  216. sw s7, 12(s5)
  217. mflo s7, $ac0
  218. sw s7, 8(s5)
  219. /* Test if FPU context save is required. */
  220. lw s7, portTASK_HAS_FPU_STACK_LOCATION(s5)
  221. beq s7, zero, 1f
  222. nop
  223. /* Save the FPU registers above the normal context. */
  224. portSAVE_FPU_REGS (portCONTEXT_SIZE + 8), s5
  225. /* Save the FPU status register */
  226. cfc1 s7, $f31
  227. sw s7, ( portCONTEXT_SIZE + portFPCSR_STACK_LOCATION )(s5)
  228. 1:
  229. /* Save the stack pointer to the task. */
  230. la s7, pxCurrentTCB
  231. lw s7, (s7)
  232. sw s5, (s7)
  233. /* Set the interrupt mask to the max priority that can use the API. The
  234. yield handler will only be called at configKERNEL_INTERRUPT_PRIORITY which
  235. is below configMAX_SYSCALL_INTERRUPT_PRIORITY - so this can only ever
  236. raise the IPL value and never lower it. */
  237. di
  238. ehb
  239. mfc0 s7, _CP0_STATUS
  240. ins s7, zero, 10, 7
  241. ins s7, zero, 18, 1
  242. ori s6, s7, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 10 ) | 1
  243. /* This mtc0 re-enables interrupts, but only above
  244. configMAX_SYSCALL_INTERRUPT_PRIORITY. */
  245. mtc0 s6, _CP0_STATUS
  246. ehb
  247. /* Clear the software interrupt in the core. */
  248. mfc0 s6, _CP0_CAUSE
  249. ins s6, zero, 8, 1
  250. mtc0 s6, _CP0_CAUSE
  251. ehb
  252. /* Clear the interrupt in the interrupt controller. */
  253. la s6, IFS0CLR
  254. addiu s4, zero, 2
  255. sw s4, (s6)
  256. jal vTaskSwitchContext
  257. nop
  258. /* Clear the interrupt mask again. The saved status value is still in s7. */
  259. mtc0 s7, _CP0_STATUS
  260. ehb
  261. /* Restore the stack pointer from the TCB. */
  262. la s0, pxCurrentTCB
  263. lw s0, (s0)
  264. lw s5, (s0)
  265. /* Test if the FPU context needs restoring. */
  266. lw s0, portTASK_HAS_FPU_STACK_LOCATION(s5)
  267. beq s0, zero, 1f
  268. nop
  269. /* Restore the FPU status register. */
  270. lw s0, ( portCONTEXT_SIZE + portFPCSR_STACK_LOCATION )(s5)
  271. ctc1 s0, $f31
  272. /* Restore the FPU registers. */
  273. portLOAD_FPU_REGS ( portCONTEXT_SIZE + 8 ), s5
  274. 1:
  275. /* Restore the rest of the context. */
  276. lw s0, 128(s5)
  277. mthi s0, $ac1
  278. lw s0, 124(s5)
  279. mtlo s0, $ac1
  280. lw s0, 136(s5)
  281. mthi s0, $ac2
  282. lw s0, 132(s5)
  283. mtlo s0, $ac2
  284. lw s0, 144(s5)
  285. mthi s0, $ac3
  286. lw s0, 140(s5)
  287. mtlo s0, $ac3
  288. lw s0, 148(s5)
  289. wrdsp s0
  290. lw s0, 8(s5)
  291. mtlo s0, $ac0
  292. lw s0, 12(s5)
  293. mthi s0, $ac0
  294. lw $1, 16(s5)
  295. lw s0, 20(s5)
  296. lw s1, 24(s5)
  297. lw s2, 28(s5)
  298. lw s3, 32(s5)
  299. lw s4, 36(s5)
  300. /* s5 is loaded later. */
  301. lw s6, 44(s5)
  302. lw s7, 48(s5)
  303. lw v0, 52(s5)
  304. lw v1, 56(s5)
  305. lw a0, 60(s5)
  306. lw a1, 64(s5)
  307. lw a2, 68(s5)
  308. lw a3, 72(s5)
  309. lw t0, 76(s5)
  310. lw t1, 80(s5)
  311. lw t2, 84(s5)
  312. lw t3, 88(s5)
  313. lw t4, 92(s5)
  314. lw t5, 96(s5)
  315. lw t6, 100(s5)
  316. lw t7, 104(s5)
  317. lw t8, 108(s5)
  318. lw t9, 112(s5)
  319. lw s8, 116(s5)
  320. lw ra, 120(s5)
  321. /* Protect access to the k registers, and others. */
  322. di
  323. ehb
  324. /* Set nesting back to zero. As the lowest priority interrupt this
  325. interrupt cannot have nested. */
  326. la k0, uxInterruptNesting
  327. sw zero, 0(k0)
  328. /* Switch back to use the real stack pointer. */
  329. add sp, zero, s5
  330. /* Restore the real s5 value. */
  331. lw s5, 40(sp)
  332. /* Pop the FPU context value from the stack */
  333. lw k0, portTASK_HAS_FPU_STACK_LOCATION(sp)
  334. la k1, ulTaskHasFPUContext
  335. sw k0, 0(k1)
  336. beq k0, zero, 1f
  337. nop
  338. /* task has FPU context so adjust the stack frame after popping the
  339. status and epc values. */
  340. lw k1, portSTATUS_STACK_LOCATION(sp)
  341. lw k0, portEPC_STACK_LOCATION(sp)
  342. addiu sp, sp, portFPU_CONTEXT_SIZE
  343. beq zero, zero, 2f
  344. nop
  345. 1:
  346. /* Pop the status and epc values. */
  347. lw k1, portSTATUS_STACK_LOCATION(sp)
  348. lw k0, portEPC_STACK_LOCATION(sp)
  349. 2:
  350. /* Remove stack frame. */
  351. addiu sp, sp, portCONTEXT_SIZE
  352. #else
  353. /* Code sequence for no FPU support, the context save requires advance
  354. knowledge of the stack frame size when no FPU is being used */
  355. /* Make room for the context. First save the current status so it can be
  356. manipulated, and the cause and EPC registers so thier original values are
  357. captured. */
  358. addiu sp, sp, -portCONTEXT_SIZE
  359. mfc0 k1, _CP0_STATUS
  360. /* Also save s6 and s5 so they can be used. Any nesting interrupts should
  361. maintain the values of these registers across the ISR. */
  362. sw s6, 44(sp)
  363. sw s5, 40(sp)
  364. sw k1, portSTATUS_STACK_LOCATION(sp)
  365. /* Prepare to re-enabled interrupts above the kernel priority. */
  366. ins k1, zero, 10, 7 /* Clear IPL bits 0:6. */
  367. ins k1, zero, 18, 1 /* Clear IPL bit 7. It would be an error here if this bit were set anyway. */
  368. ori k1, k1, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 10 )
  369. ins k1, zero, 1, 4 /* Clear EXL, ERL and UM. */
  370. /* s5 is used as the frame pointer. */
  371. add s5, zero, sp
  372. /* Swap to the system stack. This is not conditional on the nesting
  373. count as this interrupt is always the lowest priority and therefore
  374. the nesting is always 0. */
  375. la sp, xISRStackTop
  376. lw sp, (sp)
  377. /* Set the nesting count. */
  378. la k0, uxInterruptNesting
  379. addiu s6, zero, 1
  380. sw s6, 0(k0)
  381. /* s6 holds the EPC value, this is saved with the rest of the context
  382. after interrupts are enabled. */
  383. mfc0 s6, _CP0_EPC
  384. /* Re-enable interrupts above configMAX_SYSCALL_INTERRUPT_PRIORITY. */
  385. mtc0 k1, _CP0_STATUS
  386. /* Save the context into the space just created. s6 is saved again
  387. here as it now contains the EPC value. */
  388. sw ra, 120(s5)
  389. sw s8, 116(s5)
  390. sw t9, 112(s5)
  391. sw t8, 108(s5)
  392. sw t7, 104(s5)
  393. sw t6, 100(s5)
  394. sw t5, 96(s5)
  395. sw t4, 92(s5)
  396. sw t3, 88(s5)
  397. sw t2, 84(s5)
  398. sw t1, 80(s5)
  399. sw t0, 76(s5)
  400. sw a3, 72(s5)
  401. sw a2, 68(s5)
  402. sw a1, 64(s5)
  403. sw a0, 60(s5)
  404. sw v1, 56(s5)
  405. sw v0, 52(s5)
  406. sw s7, 48(s5)
  407. sw s6, portEPC_STACK_LOCATION(s5)
  408. /* s5 and s6 has already been saved. */
  409. sw s4, 36(s5)
  410. sw s3, 32(s5)
  411. sw s2, 28(s5)
  412. sw s1, 24(s5)
  413. sw s0, 20(s5)
  414. sw $1, 16(s5)
  415. /* s7 is used as a scratch register as this should always be saved across
  416. nesting interrupts. */
  417. /* Save the AC0, AC1, AC2 and AC3. */
  418. mfhi s7, $ac1
  419. sw s7, 128(s5)
  420. mflo s7, $ac1
  421. sw s7, 124(s5)
  422. mfhi s7, $ac2
  423. sw s7, 136(s5)
  424. mflo s7, $ac2
  425. sw s7, 132(s5)
  426. mfhi s7, $ac3
  427. sw s7, 144(s5)
  428. mflo s7, $ac3
  429. sw s7, 140(s5)
  430. rddsp s7
  431. sw s7, 148(s5)
  432. mfhi s7, $ac0
  433. sw s7, 12(s5)
  434. mflo s7, $ac0
  435. sw s7, 8(s5)
  436. /* Save the stack pointer to the task. */
  437. la s7, pxCurrentTCB
  438. lw s7, (s7)
  439. sw s5, (s7)
  440. /* Set the interrupt mask to the max priority that can use the API. The
  441. yield handler will only be called at configKERNEL_INTERRUPT_PRIORITY which
  442. is below configMAX_SYSCALL_INTERRUPT_PRIORITY - so this can only ever
  443. raise the IPL value and never lower it. */
  444. di
  445. ehb
  446. mfc0 s7, _CP0_STATUS
  447. ins s7, zero, 10, 7
  448. ins s7, zero, 18, 1
  449. ori s6, s7, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 10 ) | 1
  450. /* This mtc0 re-enables interrupts, but only above
  451. configMAX_SYSCALL_INTERRUPT_PRIORITY. */
  452. mtc0 s6, _CP0_STATUS
  453. ehb
  454. /* Clear the software interrupt in the core. */
  455. mfc0 s6, _CP0_CAUSE
  456. ins s6, zero, 8, 1
  457. mtc0 s6, _CP0_CAUSE
  458. ehb
  459. /* Clear the interrupt in the interrupt controller. */
  460. la s6, IFS0CLR
  461. addiu s4, zero, 2
  462. sw s4, (s6)
  463. jal vTaskSwitchContext
  464. nop
  465. /* Clear the interrupt mask again. The saved status value is still in s7. */
  466. mtc0 s7, _CP0_STATUS
  467. ehb
  468. /* Restore the stack pointer from the TCB. */
  469. la s0, pxCurrentTCB
  470. lw s0, (s0)
  471. lw s5, (s0)
  472. /* Restore the rest of the context. */
  473. lw s0, 128(s5)
  474. mthi s0, $ac1
  475. lw s0, 124(s5)
  476. mtlo s0, $ac1
  477. lw s0, 136(s5)
  478. mthi s0, $ac2
  479. lw s0, 132(s5)
  480. mtlo s0, $ac2
  481. lw s0, 144(s5)
  482. mthi s0, $ac3
  483. lw s0, 140(s5)
  484. mtlo s0, $ac3
  485. lw s0, 148(s5)
  486. wrdsp s0
  487. lw s0, 8(s5)
  488. mtlo s0, $ac0
  489. lw s0, 12(s5)
  490. mthi s0, $ac0
  491. lw $1, 16(s5)
  492. lw s0, 20(s5)
  493. lw s1, 24(s5)
  494. lw s2, 28(s5)
  495. lw s3, 32(s5)
  496. lw s4, 36(s5)
  497. /* s5 is loaded later. */
  498. lw s6, 44(s5)
  499. lw s7, 48(s5)
  500. lw v0, 52(s5)
  501. lw v1, 56(s5)
  502. lw a0, 60(s5)
  503. lw a1, 64(s5)
  504. lw a2, 68(s5)
  505. lw a3, 72(s5)
  506. lw t0, 76(s5)
  507. lw t1, 80(s5)
  508. lw t2, 84(s5)
  509. lw t3, 88(s5)
  510. lw t4, 92(s5)
  511. lw t5, 96(s5)
  512. lw t6, 100(s5)
  513. lw t7, 104(s5)
  514. lw t8, 108(s5)
  515. lw t9, 112(s5)
  516. lw s8, 116(s5)
  517. lw ra, 120(s5)
  518. /* Protect access to the k registers, and others. */
  519. di
  520. ehb
  521. /* Set nesting back to zero. As the lowest priority interrupt this
  522. interrupt cannot have nested. */
  523. la k0, uxInterruptNesting
  524. sw zero, 0(k0)
  525. /* Switch back to use the real stack pointer. */
  526. add sp, zero, s5
  527. /* Restore the real s5 value. */
  528. lw s5, 40(sp)
  529. /* Pop the status and epc values. */
  530. lw k1, portSTATUS_STACK_LOCATION(sp)
  531. lw k0, portEPC_STACK_LOCATION(sp)
  532. /* Remove stack frame. */
  533. addiu sp, sp, portCONTEXT_SIZE
  534. #endif /* ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 ) */
  535. /* Restore the status and EPC registers and return */
  536. mtc0 k1, _CP0_STATUS
  537. mtc0 k0, _CP0_EPC
  538. ehb
  539. eret
  540. nop
  541. .end vPortYieldISR
  542. /******************************************************************/
  543. #if ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )
  544. .macro portFPUSetAndInc reg, dest
  545. mtc1 \reg, \dest
  546. cvt.d.w \dest, \dest
  547. addiu \reg, \reg, 1
  548. .endm
  549. .set noreorder
  550. .set noat
  551. .section .text, code
  552. .ent vPortInitialiseFPSCR
  553. vPortInitialiseFPSCR:
  554. /* Initialize the floating point status register in CP1. The initial
  555. value is passed in a0. */
  556. ctc1 a0, $f31
  557. /* Clear the FPU registers */
  558. addiu a0, zero, 0x0000
  559. portFPUSetAndInc a0, $f0
  560. portFPUSetAndInc a0, $f1
  561. portFPUSetAndInc a0, $f2
  562. portFPUSetAndInc a0, $f3
  563. portFPUSetAndInc a0, $f4
  564. portFPUSetAndInc a0, $f5
  565. portFPUSetAndInc a0, $f6
  566. portFPUSetAndInc a0, $f7
  567. portFPUSetAndInc a0, $f8
  568. portFPUSetAndInc a0, $f9
  569. portFPUSetAndInc a0, $f10
  570. portFPUSetAndInc a0, $f11
  571. portFPUSetAndInc a0, $f12
  572. portFPUSetAndInc a0, $f13
  573. portFPUSetAndInc a0, $f14
  574. portFPUSetAndInc a0, $f15
  575. portFPUSetAndInc a0, $f16
  576. portFPUSetAndInc a0, $f17
  577. portFPUSetAndInc a0, $f18
  578. portFPUSetAndInc a0, $f19
  579. portFPUSetAndInc a0, $f20
  580. portFPUSetAndInc a0, $f21
  581. portFPUSetAndInc a0, $f22
  582. portFPUSetAndInc a0, $f23
  583. portFPUSetAndInc a0, $f24
  584. portFPUSetAndInc a0, $f25
  585. portFPUSetAndInc a0, $f26
  586. portFPUSetAndInc a0, $f27
  587. portFPUSetAndInc a0, $f28
  588. portFPUSetAndInc a0, $f29
  589. portFPUSetAndInc a0, $f30
  590. portFPUSetAndInc a0, $f31
  591. jr ra
  592. nop
  593. .end vPortInitialiseFPSCR
  594. #endif /* ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 ) */
  595. #if ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )
  596. /**********************************************************************/
  597. /* Test read back */
  598. /* a0 = address to store registers */
  599. .set noreorder
  600. .set noat
  601. .section .text, code
  602. .ent vPortFPUReadback
  603. .global vPortFPUReadback
  604. vPortFPUReadback:
  605. sdc1 $f0, 0(a0)
  606. sdc1 $f1, 8(a0)
  607. sdc1 $f2, 16(a0)
  608. sdc1 $f3, 24(a0)
  609. sdc1 $f4, 32(a0)
  610. sdc1 $f5, 40(a0)
  611. sdc1 $f6, 48(a0)
  612. sdc1 $f7, 56(a0)
  613. sdc1 $f8, 64(a0)
  614. sdc1 $f9, 72(a0)
  615. sdc1 $f10, 80(a0)
  616. sdc1 $f11, 88(a0)
  617. sdc1 $f12, 96(a0)
  618. sdc1 $f13, 104(a0)
  619. sdc1 $f14, 112(a0)
  620. sdc1 $f15, 120(a0)
  621. sdc1 $f16, 128(a0)
  622. sdc1 $f17, 136(a0)
  623. sdc1 $f18, 144(a0)
  624. sdc1 $f19, 152(a0)
  625. sdc1 $f20, 160(a0)
  626. sdc1 $f21, 168(a0)
  627. sdc1 $f22, 176(a0)
  628. sdc1 $f23, 184(a0)
  629. sdc1 $f24, 192(a0)
  630. sdc1 $f25, 200(a0)
  631. sdc1 $f26, 208(a0)
  632. sdc1 $f27, 216(a0)
  633. sdc1 $f28, 224(a0)
  634. sdc1 $f29, 232(a0)
  635. sdc1 $f30, 240(a0)
  636. sdc1 $f31, 248(a0)
  637. jr ra
  638. nop
  639. .end vPortFPUReadback
  640. #endif /* ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 ) */