idle.fuc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2013 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Ben Skeggs
  23. */
  24. #ifdef INCLUDE_PROC
  25. process(PROC_IDLE, #idle, #idle_recv)
  26. #endif
  27. /******************************************************************************
  28. * IDLE data segment
  29. *****************************************************************************/
  30. #ifdef INCLUDE_DATA
  31. #endif
  32. /******************************************************************************
  33. * IDLE code segment
  34. *****************************************************************************/
  35. #ifdef INCLUDE_CODE
  36. // description
  37. //
  38. // $r15 - current (idle)
  39. // $r14 - message
  40. // $r0 - zero
  41. idle_recv:
  42. ret
  43. // description
  44. //
  45. // $r15 - current (idle)
  46. // $r0 - zero
  47. idle:
  48. // set our "no interrupt has occurred during our execution" flag
  49. bset $flags $p0
  50. // count IDLE invocations for debugging purposes
  51. nv_iord($r1, NV_PPWR_DSCRATCH(1))
  52. add b32 $r1 1
  53. nv_iowr(NV_PPWR_DSCRATCH(1), $r1)
  54. // keep looping while there's pending messages for any process
  55. idle_loop:
  56. mov $r1 #proc_list_head
  57. bclr $flags $p2
  58. idle_proc:
  59. // process the process' messages until there's none left
  60. idle_proc_exec:
  61. push $r1
  62. mov b32 $r14 $r1
  63. call(recv)
  64. pop $r1
  65. bra not $p1 #idle_proc_next
  66. bset $flags $p2
  67. bra #idle_proc_exec
  68. // next process!
  69. idle_proc_next:
  70. add b32 $r1 #proc_size
  71. cmp b32 $r1 $r15
  72. bra ne #idle_proc
  73. bra $p2 #idle_loop
  74. // sleep if no interrupts have occurred
  75. sleep $p0
  76. bra #idle
  77. #endif