idle_book3e.S 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2010 IBM Corp, Benjamin Herrenschmidt <benh@kernel.crashing.org>
  3. *
  4. * Generic idle routine for Book3E processors
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/threads.h>
  12. #include <asm/reg.h>
  13. #include <asm/ppc_asm.h>
  14. #include <asm/asm-offsets.h>
  15. #include <asm/ppc-opcode.h>
  16. #include <asm/processor.h>
  17. #include <asm/thread_info.h>
  18. /* 64-bit version only for now */
  19. #ifdef CONFIG_PPC64
  20. _GLOBAL(book3e_idle)
  21. /* Save LR for later */
  22. mflr r0
  23. std r0,16(r1)
  24. /* Hard disable interrupts */
  25. wrteei 0
  26. /* Now check if an interrupt came in while we were soft disabled
  27. * since we may otherwise lose it (doorbells etc...).
  28. */
  29. lbz r3,PACAIRQHAPPENED(r13)
  30. cmpwi cr0,r3,0
  31. bnelr
  32. /* Now we are going to mark ourselves as soft and hard enabled in
  33. * order to be able to take interrupts while asleep. We inform lockdep
  34. * of that. We don't actually turn interrupts on just yet tho.
  35. */
  36. #ifdef CONFIG_TRACE_IRQFLAGS
  37. stdu r1,-128(r1)
  38. bl .trace_hardirqs_on
  39. addi r1,r1,128
  40. #endif
  41. li r0,1
  42. stb r0,PACASOFTIRQEN(r13)
  43. /* Interrupts will make use return to LR, so get something we want
  44. * in there
  45. */
  46. bl 1f
  47. /* And return (interrupts are on) */
  48. ld r0,16(r1)
  49. mtlr r0
  50. blr
  51. 1: /* Let's set the _TLF_NAPPING flag so interrupts make us return
  52. * to the right spot
  53. */
  54. clrrdi r11,r1,THREAD_SHIFT
  55. ld r10,TI_LOCAL_FLAGS(r11)
  56. ori r10,r10,_TLF_NAPPING
  57. std r10,TI_LOCAL_FLAGS(r11)
  58. /* We can now re-enable hard interrupts and go to sleep */
  59. wrteei 1
  60. 1: PPC_WAIT(0)
  61. b 1b
  62. #endif /* CONFIG_PPC64 */