cg14: use standard fields for framebuffer physical address and length
[linux-2.6] / drivers / staging / sxg / sxgdbg.h
1 /**************************************************************************
2  *
3  * Copyright © 2000-2008 Alacritech, Inc.  All rights reserved.
4  *
5  * $Id: sxgdbg.h,v 1.1 2008/06/27 12:49:28 mook Exp $
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above
14  *    copyright notice, this list of conditions and the following
15  *    disclaimer in the documentation and/or other materials provided
16  *    with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY ALACRITECH, INC. ``AS IS'' AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ALACRITECH, INC. OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  * The views and conclusions contained in the software and documentation
32  * are those of the authors and should not be interpreted as representing
33  * official policies, either expressed or implied, of Alacritech, Inc.
34  *
35  **************************************************************************/
36
37 /*
38  * FILENAME: sxgdbg.h
39  *
40  * All debug and assertion-based definitions and macros are included
41  * in this file for the SXGOSS driver.
42  */
43 #ifndef _SXG_DEBUG_H_
44 #define _SXG_DEBUG_H_
45
46 #define ATKDBG  1
47 #define ATK_TRACE_ENABLED 0
48
49 #define DBG_ERROR(n, args...)   printk(KERN_WARNING n, ##args)
50
51 #ifdef ASSERT
52 #undef ASSERT
53 #endif
54
55 #define SXG_ASSERT_ENABLED
56 #ifdef SXG_ASSERT_ENABLED
57 #ifndef ASSERT
58 #define ASSERT(a)                                                          \
59     {                                                                      \
60         if (!(a)) {                                                        \
61             DBG_ERROR("ASSERT() Failure: file %s, function %s  line %d\n", \
62                 __FILE__, __func__, __LINE__);                             \
63         }                                                                  \
64     }
65 #endif
66 #else
67 #ifndef ASSERT
68 #define ASSERT(a)
69 #endif
70 #endif /* SXG_ASSERT_ENABLED  */
71
72
73 #ifdef ATKDBG
74 /*
75  *  Global for timer granularity; every driver must have an instance
76  *  of this initialized to 0
77  */
78
79 extern ulong ATKTimerDiv;
80
81 /*
82  * trace_entry -
83  *
84  * This structure defines an entry in the trace buffer.  The
85  * first few fields mean the same from entry to entry, while
86  * the meaning of last several fields change to suit the
87  * needs of the trace entry.  Typically they are function call
88  * parameters.
89  */
90 struct trace_entry {
91         char            name[8];/* 8 character name - like 's'i'm'b'a'r'c'v' */
92         u32             time;  /* Current clock tic */
93         unsigned char   cpu;   /* Current CPU */
94         unsigned char   irql;  /* Current IRQL */
95         unsigned char   driver;/* The driver which added the trace call */
96         /* pad to 4 byte boundary - will probably get used */
97         unsigned char   pad2;
98         u32             arg1;           /* Caller arg1 */
99         u32             arg2;           /* Caller arg2 */
100         u32             arg3;           /* Caller arg3 */
101         u32             arg4;           /* Caller arg4 */
102 };
103
104 /* Driver types for driver field in struct trace_entry */
105 #define TRACE_SXG             1
106 #define TRACE_VPCI            2
107 #define TRACE_SLIC            3
108
109 #define TRACE_ENTRIES   1024
110
111 struct sxg_trace_buffer {
112         /* aid for windbg extension */
113         unsigned int            size;
114         unsigned int            in;                    /* Where to add */
115         unsigned int            level;                 /* Current Trace level */
116         spinlock_t              lock;                  /* For MP tracing */
117         struct trace_entry      entries[TRACE_ENTRIES];/* The circular buffer */
118 };
119
120 /*
121  * The trace levels
122  *
123  * XXX At the moment I am only defining critical, important, and noisy.
124  * I am leaving room for more if anyone wants them.
125  */
126 #define TRACE_NONE              0   /* For trace level - if no tracing wanted */
127 #define TRACE_CRITICAL          1   /* minimal tracing - only critical stuff */
128 #define TRACE_IMPORTANT         5   /* more tracing - anything important */
129 #define TRACE_NOISY             10  /* Everything in the world */
130
131
132 /* The macros themselves */
133 #if ATK_TRACE_ENABLED
134 #define SXG_TRACE_INIT(buffer, tlevel)                          \
135 {                                                               \
136         memset((buffer), 0, sizeof(struct sxg_trace_buffer));   \
137         (buffer)->level = (tlevel);                             \
138         (buffer)->size = TRACE_ENTRIES;                         \
139         spin_lock_init(&(buffer)->lock);                        \
140 }
141 #else
142 #define SXG_TRACE_INIT(buffer, tlevel)
143 #endif
144
145 /*The trace macro.  This is active only if ATK_TRACE_ENABLED is set. */
146 #if ATK_TRACE_ENABLED
147 #define SXG_TRACE(tdriver, buffer, tlevel, tname, a1, a2, a3, a4) {        \
148         if ((buffer) && ((buffer)->level >= (tlevel))) {                   \
149                 unsigned int            trace_irql = 0;/* ?????? FIX THIS */\
150                 unsigned int            trace_len;                          \
151                 struct trace_entry      *trace_entry;                       \
152                 struct timeval  timev;                                      \
153                 if(spin_trylock(&(buffer)->lock))       {                    \
154                         trace_entry = &(buffer)->entries[(buffer)->in];      \
155                         do_gettimeofday(&timev);                             \
156                                                                              \
157                         memset(trace_entry->name, 0, 8);                     \
158                         trace_len = strlen(tname);                           \
159                         trace_len = trace_len > 8 ? 8 : trace_len;           \
160                         memcpy(trace_entry->name, (tname), trace_len);       \
161                         trace_entry->time = timev.tv_usec;                   \
162                         trace_entry->cpu = (unsigned char)(smp_processor_id() & 0xFF);\
163                         trace_entry->driver = (tdriver);                     \
164                         trace_entry->irql = trace_irql;                      \
165                         trace_entry->arg1 = (ulong)(a1);                     \
166                         trace_entry->arg2 = (ulong)(a2);                     \
167                         trace_entry->arg3 = (ulong)(a3);                     \
168                         trace_entry->arg4 = (ulong)(a4);                     \
169                                                                              \
170                         (buffer)->in++;                                      \
171                         if ((buffer)->in == TRACE_ENTRIES)                   \
172                                 (buffer)->in = 0;                            \
173                                                                              \
174                         spin_unlock(&(buffer)->lock);                        \
175                 }                                                            \
176         }                                                                    \
177 }
178 #else
179 #define SXG_TRACE(tdriver, buffer, tlevel, tname, a1, a2, a3, a4)
180 #endif
181
182 #endif
183
184 #endif  /*  _SXG_DEBUG_H_  */