[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/nxge/include/xge-os-pal.h

Version: -  FREEBSD  -  FREEBSD8  -  FREEBSD7  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  excerpts  -  bigexcerpts 

    1 /*-
    2  * Copyright (c) 2002-2007 Neterion, Inc.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD$
   27  */
   28 
   29 #ifndef XGE_OS_PAL_H
   30 #define XGE_OS_PAL_H
   31 
   32 #include <dev/nxge/include/xge-defs.h>
   33 
   34 __EXTERN_BEGIN_DECLS
   35 
   36 /*--------------------------- platform switch ------------------------------*/
   37 
   38 /* platform specific header */
   39 #include <dev/nxge/xge-osdep.h>
   40 
   41 #if !defined(XGE_OS_PLATFORM_64BIT) && !defined(XGE_OS_PLATFORM_32BIT)
   42 #error "either 32bit or 64bit switch must be defined!"
   43 #endif
   44 
   45 #if !defined(XGE_OS_HOST_BIG_ENDIAN) && !defined(XGE_OS_HOST_LITTLE_ENDIAN)
   46 #error "either little endian or big endian switch must be defined!"
   47 #endif
   48 
   49 #if defined(XGE_OS_PLATFORM_64BIT)
   50 #define XGE_OS_MEMORY_DEADCODE_PAT  0x5a5a5a5a5a5a5a5a
   51 #else
   52 #define XGE_OS_MEMORY_DEADCODE_PAT  0x5a5a5a5a
   53 #endif
   54 
   55 #define XGE_OS_TRACE_MSGBUF_MAX     512
   56 typedef struct xge_os_tracebuf_t {
   57         int     wrapped_once;     /* circular buffer been wrapped */
   58         int     timestamp;        /* whether timestamps are enabled */
   59         volatile int    offset;           /* offset within the tracebuf */
   60         int     size;             /* total size of trace buffer */
   61         char        msg[XGE_OS_TRACE_MSGBUF_MAX]; /* each individual buffer */
   62         int     msgbuf_max;   /* actual size of msg buffer */
   63         char        *data;            /* pointer to data buffer */
   64 } xge_os_tracebuf_t;
   65 extern xge_os_tracebuf_t *g_xge_os_tracebuf;
   66 
   67 #ifdef XGE_TRACE_INTO_CIRCULAR_ARR
   68 extern xge_os_tracebuf_t *g_xge_os_tracebuf;
   69 extern char *dmesg_start;
   70 
   71 /* Calculate the size of the msg and copy it into the global buffer */  
   72 #define __xge_trace(tb) { \
   73         int msgsize = xge_os_strlen(tb->msg) + 2; \
   74         int offset = tb->offset; \
   75         if (msgsize != 2 && msgsize < tb->msgbuf_max) { \
   76             int leftsize =  tb->size - offset; \
   77             if ((msgsize + tb->msgbuf_max) > leftsize) { \
   78                 xge_os_memzero(tb->data + offset, leftsize); \
   79                 offset = 0; \
   80                 tb->wrapped_once = 1; \
   81             } \
   82             xge_os_memcpy(tb->data + offset, tb->msg, msgsize-1); \
   83             *(tb->data + offset + msgsize-1) = '\n'; \
   84             *(tb->data + offset + msgsize) = 0; \
   85             offset += msgsize; \
   86             tb->offset = offset; \
   87             dmesg_start = tb->data + offset; \
   88             *tb->msg = 0; \
   89         } \
   90 }
   91 
   92 #define xge_os_vatrace(tb, fmt) { \
   93         if (tb != NULL) { \
   94             char *_p = tb->msg; \
   95             if (tb->timestamp) { \
   96                 xge_os_timestamp(tb->msg); \
   97                 _p = tb->msg + xge_os_strlen(tb->msg); \
   98             } \
   99             xge_os_vasprintf(_p, fmt); \
  100             __xge_trace(tb); \
  101         } \
  102 }
  103 
  104 #ifdef __GNUC__
  105 #define xge_os_trace(tb, fmt...) { \
  106         if (tb != NULL) { \
  107             if (tb->timestamp) { \
  108                 xge_os_timestamp(tb->msg); \
  109             } \
  110             xge_os_sprintf(tb->msg + xge_os_strlen(tb->msg), fmt); \
  111             __xge_trace(tb); \
  112         } \
  113 }
  114 #endif /* __GNUC__ */
  115 
  116 #else
  117 #define xge_os_vatrace(tb, fmt)
  118 #ifdef __GNUC__
  119 #define xge_os_trace(tb, fmt...)
  120 #endif /* __GNUC__ */
  121 #endif
  122 
  123 __EXTERN_END_DECLS
  124 
  125 #endif /* XGE_OS_PAL_H */

Cache object: 0ee1558fd83c764113cd2d9d74d38283


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.