interrupt_utils.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * $RCSfile: $
00004  * $Revision: $
00005  *
00006  * This module provides the interface routines for setting up and
00007  * controlling the various interrupt modes present on the ARM processor.
00008  * Copyright 2004, R O SoftWare
00009  * No guarantees, warrantees, or promises, implied or otherwise.
00010  * May be used for hobby or commercial purposes provided copyright
00011  * notice remains intact.
00012  *
00013  *****************************************************************************/
00014 #include "interrupt_utils.h"
00015 
00016 #define IRQ_MASK 0x00000080
00017 #define FIQ_MASK 0x00000040
00018 #define INT_MASK (IRQ_MASK | FIQ_MASK)
00019 
00020 static inline unsigned __get_cpsr(void)
00021 {
00022   unsigned long retval;
00023   asm volatile (" mrs  %0, cpsr" : "=r" (retval) : /* no inputs */  );
00024   return retval;
00025 }
00026 
00027 static inline void __set_cpsr(unsigned val)
00028 {
00029   asm volatile (" msr  cpsr, %0" : /* no outputs */ : "r" (val)  );
00030 }
00031 
00032 unsigned disableIRQ(void)
00033 {
00034   unsigned _cpsr;
00035 
00036   _cpsr = __get_cpsr();
00037   __set_cpsr(_cpsr | IRQ_MASK);
00038   return _cpsr;
00039 }
00040 
00041 unsigned restoreIRQ(unsigned oldCPSR)
00042 {
00043   unsigned _cpsr;
00044 
00045   _cpsr = __get_cpsr();
00046   __set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
00047   return _cpsr;
00048 }
00049 
00050 unsigned enableIRQ(void)
00051 {
00052   unsigned _cpsr;
00053 
00054   _cpsr = __get_cpsr();
00055   __set_cpsr(_cpsr & ~IRQ_MASK);
00056   return _cpsr;
00057 }
00058 
00059 unsigned disableFIQ(void)
00060 {
00061   unsigned _cpsr;
00062 
00063   _cpsr = __get_cpsr();
00064   __set_cpsr(_cpsr | FIQ_MASK);
00065   return _cpsr;
00066 }
00067 
00068 unsigned restoreFIQ(unsigned oldCPSR)
00069 {
00070   unsigned _cpsr;
00071 
00072   _cpsr = __get_cpsr();
00073   __set_cpsr((_cpsr & ~FIQ_MASK) | (oldCPSR & FIQ_MASK));
00074   return _cpsr;
00075 }
00076 
00077 unsigned enableFIQ(void)
00078 {
00079   unsigned _cpsr;
00080 
00081   _cpsr = __get_cpsr();
00082   __set_cpsr(_cpsr & ~FIQ_MASK);
00083   return _cpsr;
00084 }


asctec_hl_firmware
Author(s): Markus Achtelik, Michael Achtelik, Stephan Weiss, Laurent Kneip
autogenerated on Tue Dec 17 2013 11:39:27