interrupts.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * (C) Copyright 2000-2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2002 (440 port)
  6. * Scott McNutt, Artesyn Communication Producs, smcnutt@artsyncp.com
  7. *
  8. * (C) Copyright 2003 Motorola Inc. (MPC85xx port)
  9. * Xianghua Xiao (X.Xiao@motorola.com)
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. #include <common.h>
  30. #include <watchdog.h>
  31. #include <command.h>
  32. #include <asm/processor.h>
  33. #include <ppc_asm.tmpl>
  34. unsigned decrementer_count; /* count value for 1e6/HZ microseconds */
  35. static __inline__ unsigned long get_msr(void)
  36. {
  37. unsigned long msr;
  38. asm volatile("mfmsr %0" : "=r" (msr) :);
  39. return msr;
  40. }
  41. static __inline__ void set_msr(unsigned long msr)
  42. {
  43. asm volatile("mtmsr %0" : : "r" (msr));
  44. asm volatile("isync");
  45. }
  46. void enable_interrupts (void)
  47. {
  48. set_msr (get_msr() | MSR_EE);
  49. }
  50. /* returns flag if MSR_EE was set before */
  51. int disable_interrupts (void)
  52. {
  53. ulong msr = get_msr();
  54. set_msr (msr & ~MSR_EE);
  55. return ((msr & MSR_EE) != 0);
  56. }
  57. /* interrupt is not supported yet */
  58. int interrupt_init (void)
  59. {
  60. return (0);
  61. }
  62. /*
  63. * Install and free a interrupt handler. Not implemented yet.
  64. */
  65. void
  66. irq_install_handler(int vec, interrupt_handler_t *handler, void *arg)
  67. {
  68. return;
  69. }
  70. void
  71. irq_free_handler(int vec)
  72. {
  73. return;
  74. }
  75. /****************************************************************************/
  76. volatile ulong timestamp = 0;
  77. /*
  78. * timer_interrupt - gets called when the decrementer overflows,
  79. * with interrupts disabled.
  80. * Trivial implementation - no need to be really accurate.
  81. */
  82. void timer_interrupt(struct pt_regs *regs)
  83. {
  84. printf ("*** Timer Interrupt *** ");
  85. timestamp++;
  86. #if defined(CONFIG_WATCHDOG)
  87. if ((timestamp % 1000) == 0)
  88. reset_85xx_watchdog();
  89. #endif /* CONFIG_WATCHDOG */
  90. }
  91. void reset_timer (void)
  92. {
  93. timestamp = 0;
  94. }
  95. ulong get_timer (ulong base)
  96. {
  97. return (timestamp - base);
  98. }
  99. void set_timer (ulong t)
  100. {
  101. timestamp = t;
  102. }
  103. #if (CONFIG_COMMANDS & CFG_CMD_IRQ)
  104. /*******************************************************************************
  105. *
  106. * irqinfo - print information about PCI devices,not implemented.
  107. *
  108. */
  109. int
  110. do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  111. {
  112. printf ("\nInterrupt-unsupported:\n");
  113. return 0;
  114. }
  115. #endif /* CONFIG_COMMANDS & CFG_CMD_IRQ */