00001 /* 00002 * Copyright (C) 2001-2005 by egnite Software GmbH. All rights reserved. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. Neither the name of the copyright holders nor the names of 00014 * contributors may be used to endorse or promote products derived 00015 * from this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS 00018 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00019 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00020 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE 00021 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00022 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00023 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00024 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00025 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00026 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00027 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00028 * SUCH DAMAGE. 00029 * 00030 * For additional information see http://www.ethernut.de/ 00031 * 00032 */ 00033 00034 /* 00035 * $Log$ 00036 * Revision 1.4 2008/08/11 06:59:58 haraldkipp 00037 * BSD types replaced by stdint types (feature request #1282721). 00038 * 00039 * Revision 1.3 2007/09/11 13:41:23 haraldkipp 00040 * NutEnter/ExitCritical destroyed R0 (ICCAVR). 00041 * 00042 * Revision 1.2 2005/07/26 15:47:06 haraldkipp 00043 * AtomicInc() and AtomicDec() are no longer required by Nut/Net. 00044 * Removed to simplify the porting job. Broken applications should 00045 * implement their own version. 00046 * 00047 * Revision 1.1 2005/06/06 10:49:35 haraldkipp 00048 * Building outside the source tree failed. All header files moved from 00049 * arch/cpu/include to include/arch/cpu. 00050 * 00051 * Revision 1.1 2005/05/27 17:41:52 drsung 00052 * Moved the file. 00053 * 00054 * Revision 1.1 2005/05/26 10:08:42 drsung 00055 * Moved the platform dependend code from include/sys/atom.h to this file. 00056 * 00057 * 00058 */ 00059 00060 #ifndef _SYS_ATOM_H_ 00061 #error "Do not include this file directly. Use sys/atom.h instead!" 00062 #endif 00063 00064 #ifdef __IMAGECRAFT__ 00065 00079 #define NutEnterCritical() \ 00080 { \ 00081 register uint8_t sreg = inb(SREG); \ 00082 asm("cli\n" \ 00083 "push %sreg\n"); \ 00084 } 00085 00092 #define NutExitCritical() \ 00093 { \ 00094 /* Set to 0 to force register allocation. */ \ 00095 register uint8_t sreg = 0; \ 00096 asm("pop %sreg\n"); \ 00097 outb(SREG, sreg); \ 00098 } 00099 00100 #else 00101 00102 #define NutEnterCritical_nt() \ 00103 asm volatile( \ 00104 "in __tmp_reg__, __SREG__" "\n\t" \ 00105 "cli" "\n\t" \ 00106 "push __tmp_reg__" "\n\t" \ 00107 ) 00108 00109 #define NutExitCritical_nt() \ 00110 asm volatile( \ 00111 "pop __tmp_reg__" "\n\t" \ 00112 "out __SREG__, __tmp_reg__" "\n\t" \ 00113 ) 00114 00115 #ifdef NUTTRACER_CRITICAL 00116 #define NutEnterCritical() \ 00117 NutEnterCritical_nt(); \ 00118 TRACE_ADD_ITEM_PC(TRACE_TAG_CRITICAL_ENTER); 00119 00120 #define NutExitCritical() \ 00121 TRACE_ADD_ITEM_PC(TRACE_TAG_CRITICAL_EXIT); \ 00122 NutExitCritical_nt() 00123 #else 00124 #define NutEnterCritical() \ 00125 NutEnterCritical_nt(); 00126 00127 #define NutExitCritical() \ 00128 NutExitCritical_nt() 00129 #endif 00130 #endif 00131 00132 #define NutJumpOutCritical() NutExitCritical() 00133