00001 #ifndef _DEV_IRQSTACK_H_ 00002 #define _DEV_IRQSTACK_H_ 00003 00004 /* 00005 * Copyright (C) 2001-2005 by egnite Software GmbH. All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 3. Neither the name of the copyright holders nor the names of 00017 * contributors may be used to endorse or promote products derived 00018 * from this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00021 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00023 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00024 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00025 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00026 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00027 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00028 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00029 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00030 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00031 * SUCH DAMAGE. 00032 * 00033 * For additional information see http://www.ethernut.de/ 00034 */ 00035 00036 /* 00037 * $Log$ 00038 * Revision 1.6 2005/09/17 09:22:53 drsung 00039 * More program space saving implementation 00040 * 00041 * Revision 1.5 2005/02/05 20:39:43 haraldkipp 00042 * Force compiler error for leftover debug prints. 00043 * 00044 * Revision 1.4 2004/09/22 08:15:56 haraldkipp 00045 * Speparate IRQ stack configurable 00046 * 00047 * Revision 1.3 2004/04/25 17:06:17 drsung 00048 * Separate IRQ stack now compatible with nested interrupts. 00049 * 00050 * Revision 1.2 2004/02/03 11:28:41 drsung 00051 * Modified to support different target platforms. 00052 * 00053 * Revision 1.1 2004/01/30 17:00:46 drsung 00054 * Separate interrupt stack for avr-gcc only added. 00055 * 00056 */ 00057 00058 #include <cfg/dev.h> 00059 00060 #ifdef IRQSTACK_SIZE 00061 00062 #include <sys/types.h> 00063 00064 #define _irq_prolog \ 00065 asm volatile ("push r24" "\n\t" /* save r24 to current stack */ \ 00066 "push r25" "\n\t" /* save r25 to current stack */ \ 00067 "in r24,__SREG__" "\n\t" /* load SREG into r24 */ \ 00068 "push r24" "\n\t"); /* and push it to current stack */ 00069 00070 #define _irq_epilog \ 00071 asm volatile ("pop r24" "\n\t" /* restore r24 from stack */ \ 00072 "out __SREG__, r24" "\n\t" /* write it to SREG */ \ 00073 "pop r25" "\n\t" /* load byte from stack to r25 */ \ 00074 "pop r24" "\n\t"); /* load byte from stack to r24 */ 00075 00076 #define NUTSIGNAL(signame,handler) \ 00077 void signame (void) __attribute__ ((naked)); \ 00078 void signame (void) \ 00079 { \ 00080 _irq_prolog \ 00081 asm volatile ("ldi r24, lo8(%0)" "\n\t" \ 00082 "ldi r25, hi8(%0)" "\n\t" \ 00083 "jmp _irq_interrupt" "\n\t" \ 00084 :: "i" (&handler)); \ 00085 } 00086 00087 #else /* IRQSTACK_SIZE */ 00088 00089 00090 #define NUTSIGNAL(signame,handler) \ 00091 SIGNAL(signame) \ 00092 { CallHandler (&handler); } 00093 00094 #endif /* !IRQSTACK_SIZE */ 00095 00096 #endif