atom.h

Go to the documentation of this file.
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: atom.h,v $
00036  * Revision 1.3  2007/09/11 13:41:23  haraldkipp
00037  * NutEnter/ExitCritical destroyed R0 (ICCAVR).
00038  *
00039  * Revision 1.2  2005/07/26 15:47:06  haraldkipp
00040  * AtomicInc() and AtomicDec() are no longer required by Nut/Net.
00041  * Removed to simplify the porting job. Broken applications should
00042  * implement their own version.
00043  *
00044  * Revision 1.1  2005/06/06 10:49:35  haraldkipp
00045  * Building outside the source tree failed. All header files moved from
00046  * arch/cpu/include to include/arch/cpu.
00047  *
00048  * Revision 1.1  2005/05/27 17:41:52  drsung
00049  * Moved the file.
00050  *
00051  * Revision 1.1  2005/05/26 10:08:42  drsung
00052  * Moved the platform dependend code from include/sys/atom.h to this file.
00053  *
00054  *
00055  */
00056  
00057 #ifndef _SYS_ATOM_H_
00058 #error "Do not include this file directly. Use sys/atom.h instead!"
00059 #endif
00060 
00061 #ifdef __IMAGECRAFT__
00062 
00076 #define NutEnterCritical()  \
00077 {                           \
00078     register u_char sreg = inb(SREG);   \
00079     asm("cli\n"             \
00080         "push %sreg\n");    \
00081 }
00082 
00089 #define NutExitCritical()   \
00090 {                           \
00091     /* Set to 0 to force register allocation. */ \
00092     register u_char sreg = 0;   \
00093     asm("pop %sreg\n");     \
00094     outb(SREG, sreg);       \
00095 }
00096 
00097 #else
00098 
00099 #define NutEnterCritical_nt()               \
00100     asm volatile(                           \
00101         "in  __tmp_reg__, __SREG__" "\n\t"  \
00102         "cli"                       "\n\t"  \
00103         "push __tmp_reg__"          "\n\t"  \
00104     )
00105 
00106 #define NutExitCritical_nt()                \
00107     asm volatile(                           \
00108         "pop __tmp_reg__"           "\n\t"  \
00109         "out __SREG__, __tmp_reg__" "\n\t"  \
00110     )
00111 
00112 #ifdef NUTTRACER_CRITICAL
00113 #define NutEnterCritical()                  \
00114     NutEnterCritical_nt();                  \
00115     TRACE_ADD_ITEM_PC(TRACE_TAG_CRITICAL_ENTER);
00116 
00117 #define NutExitCritical()                   \
00118     TRACE_ADD_ITEM_PC(TRACE_TAG_CRITICAL_EXIT); \
00119     NutExitCritical_nt()
00120 #else
00121 #define NutEnterCritical()                  \
00122     NutEnterCritical_nt();
00123 
00124 #define NutExitCritical()                   \
00125     NutExitCritical_nt()
00126 #endif
00127 #endif
00128 
00129 #define NutJumpOutCritical() NutExitCritical()
00130 

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/