00001 /* 00002 * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")" 00003 * All rights reserved. 00004 * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University) 00005 * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University) 00006 * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University) 00007 * 00008 * Permission to use, copy, modify, and distribute this software and its 00009 * documentation for any purpose, without fee, and without written agreement is 00010 * hereby granted, provided that the above copyright notice, the following 00011 * two paragraphs and the authors appear in all copies of this software. 00012 * 00013 * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR 00014 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00015 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS" 00016 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00017 * 00018 * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00019 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00021 * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO 00022 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." 00023 * 00024 * Please maintain this header in its entirety when copying/modifying 00025 * these files. 00026 * 00027 * 00028 */ 00029 00030 /************************************************************************ 00031 * esos_irq.c 00032 ************************************************************************ 00033 * ES_OS file for (hardware independent) IRQ routines 00034 */ 00035 00036 #include "esos_irq.h" 00037 00038 void (*__esos_IsrFcns[NUM_USER_IRQS])(void); 00039 00040 void esos_InitUserInterrupts(void) { 00041 uint8 i; 00042 00043 // initialize the os ISR fcn ptrs to point to a benign ISR 00044 for (i=0; i<NUM_USER_IRQS; i++) { 00045 esos_UnregisterUserInterrupt(i); 00046 } 00047 _esos_hw_InitUserInterrupts(); 00048 } // end osInitInterrupts() 00049 00050 void esos_UnregisterUserInterrupt( uint8 u8IrqIndex ) { 00051 // disassociate and unregister the p2f function with the IRQ given 00052 // in u8IrqIndex 00053 if (u8IrqIndex < NUM_USER_IRQS) { 00054 esos_DisableUserInterrupt( u8IrqIndex ); 00055 __esos_IsrFcns[u8IrqIndex] = _esos_DoNothingIsr; 00056 } // end if 00057 } // end osUnregisterUserIsr() 00058 00059 void esos_RegisterUserInterrupt( uint8 u8IrqIndex, void (*p2f)(void) ) { 00060 // associate and register the p2f function with the IRQ given 00061 // in u8IrqIndex 00062 if (u8IrqIndex < NUM_USER_IRQS) { 00063 __esos_IsrFcns[u8IrqIndex] = p2f; 00064 } 00065 } // end osRegisterUserIsr() 00066 00067 void esos_EnableVerifiedUserInterrupt( uint8 u8IrqIndex ) { 00068 // do ESOS checks on UserInterrupt and if all is well 00069 // call the user-provided HW specific routine 00070 if ((__esos_IsrFcns[u8IrqIndex] != NULLPTR) && ( __esos_IsrFcns[u8IrqIndex] != _esos_DoNothingIsr)) 00071 _esos_hw_EnableUserInterrupt( u8IrqIndex ); 00072 } // end esos_EnableUserInterrupt() 00073 00074 void esos_ExecuteUserIsr( uint8 u8IrqIndex ) { 00075 __esos_IsrFcns[u8IrqIndex](); 00076 } // esos_ExecuteUserIsr 00077 00078 void _esos_DoNothingIsr(void) { 00079 _esos_hw_DoNothingIsr(); 00080 } // end _esos_DoNothingIsr()