interrupt.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * interrupt - interrupt enable/disable
  3. *
  4. * Copyright (c) 2009 Openmoko Inc.
  5. *
  6. * Authors Christopher Hall <hsw@openmoko.com>
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #if !defined(_INTERRUPT_H_)
  22. #define _INTERRUPT_H_ 1
  23. typedef enum {
  24. Interrupt_disabled = 0,
  25. Interrupt_enabled = 1,
  26. } InterruptType;
  27. inline InterruptType Interrupt_disable(void)
  28. {
  29. register InterruptType state;
  30. asm volatile (
  31. "\tld.w\t%0, %%psr\n"
  32. "\txand\t%0, 0x010\n"
  33. "\tsra\t%0, 4\n"
  34. "\tpsrclr 4"
  35. : "=r" (state)
  36. :
  37. );
  38. return state;
  39. }
  40. inline void Interrupt_enable(InterruptType state)
  41. {
  42. if (0 != state) {
  43. asm volatile ("psrset 4");
  44. }
  45. }
  46. #endif