| 
				
			 | 
			
			
				
				@@ -100,15 +100,6 @@ __asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" ); 
			 | 
		
		
	
		
			
			| 
				100
			 | 
			
				100
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				101
			 | 
			
				101
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				102
			 | 
			
				102
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				103
			 | 
			
				
			 | 
			
			
				
				-/** @def DBG2 
			 | 
		
		
	
		
			
			| 
				104
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				105
			 | 
			
				
			 | 
			
			
				
				- * Print a level 2 debugging message. 
			 | 
		
		
	
		
			
			| 
				106
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				107
			 | 
			
				
			 | 
			
			
				
				- * As for DBG().  DBG2() takes effect only when the debugging level is 
			 | 
		
		
	
		
			
			| 
				108
			 | 
			
				
			 | 
			
			
				
				- * 2 or greater. 
			 | 
		
		
	
		
			
			| 
				109
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				110
			 | 
			
				
			 | 
			
			
				
				- */ 
			 | 
		
		
	
		
			
			| 
				111
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				112
			 | 
			
				103
			 | 
			
			
				
				 /* 
			 | 
		
		
	
		
			
			| 
				113
			 | 
			
				104
			 | 
			
			
				
				  * If debug_OBJECT is set to a true value, the macro DBG(...) will 
			 | 
		
		
	
		
			
			| 
				114
			 | 
			
				105
			 | 
			
			
				
				  * expand to printf(...) when compiling OBJECT, and the symbol 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -120,36 +111,57 @@ __asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" ); 
			 | 
		
		
	
		
			
			| 
				120
			 | 
			
				111
			 | 
			
			
				
				 #if DEBUG_SYMBOL 
			 | 
		
		
	
		
			
			| 
				121
			 | 
			
				112
			 | 
			
			
				
				 #include "console.h" 
			 | 
		
		
	
		
			
			| 
				122
			 | 
			
				113
			 | 
			
			
				
				 #define DEBUG_SYMBOL_STR _XSTR ( DEBUG_SYMBOL ) 
			 | 
		
		
	
		
			
			| 
				123
			 | 
			
				
			 | 
			
			
				
				-__asm__ ( ".equ\tDEBUG_LEVEL, " DEBUG_SYMBOL_STR ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				
				+__asm__ ( ".equ\tDBGLVL, " DEBUG_SYMBOL_STR ); 
			 | 
		
		
	
		
			
			| 
				124
			 | 
			
				115
			 | 
			
			
				
				 #endif 
			 | 
		
		
	
		
			
			| 
				125
			 | 
			
				116
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				126
			 | 
			
				
			 | 
			
			
				
				-/** Do not print 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				
				+/** printf() for debugging 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				
				+ * 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				119
			 | 
			
			
				
				+ * This function exists so that the DBG() macros can expand to 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				120
			 | 
			
			
				
				+ * printf() calls without dragging the printf() prototype into scope. 
			 | 
		
		
	
		
			
			| 
				127
			 | 
			
				121
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				128
			 | 
			
				
			 | 
			
			
				
				- * This function is used only for printf()-style format string 
			 | 
		
		
	
		
			
			| 
				129
			 | 
			
				
			 | 
			
			
				
				- * checking.  The function body does not exist, and no reference to it 
			 | 
		
		
	
		
			
			| 
				130
			 | 
			
				
			 | 
			
			
				
				- * should ever appear in any compiled object. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				122
			 | 
			
			
				
				+ * As far as the compiler is concerned, dbg_printf() and printf() are 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				123
			 | 
			
			
				
				+ * completely unrelated calls; it's only at the assembly stage that 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				124
			 | 
			
			
				
				+ * references to the dbg_printf symbol are collapsed into references 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				125
			 | 
			
			
				
				+ * to the printf symbol. 
			 | 
		
		
	
		
			
			| 
				131
			 | 
			
				126
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				132
			 | 
			
				
			 | 
			
			
				
				-extern int __attribute__ (( format ( printf, 1, 2 ) )) 
			 | 
		
		
	
		
			
			| 
				133
			 | 
			
				
			 | 
			
			
				
				-__do_not_printf ( const char *fmt, ... ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				127
			 | 
			
			
				
				+extern int __attribute__ (( format ( printf, 1, 2 ) ))  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				128
			 | 
			
			
				
				+dbg_printf ( const char *fmt, ... ) asm ( "printf" ); 
			 | 
		
		
	
		
			
			| 
				134
			 | 
			
				129
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				135
			 | 
			
				
			 | 
			
			
				
				-#define DBG_PRINT(...) printf ( __VA_ARGS__ ) 
			 | 
		
		
	
		
			
			| 
				136
			 | 
			
				
			 | 
			
			
				
				-#define DBG_DISCARD(...) do {					\ 
			 | 
		
		
	
		
			
			| 
				137
			 | 
			
				
			 | 
			
			
				
				-		if ( 0 ) __do_not_printf ( __VA_ARGS__ );	\ 
			 | 
		
		
	
		
			
			| 
				138
			 | 
			
				
			 | 
			
			
				
				-	} while ( 0 ) 
			 | 
		
		
	
		
			
			| 
				139
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				140
			 | 
			
				
			 | 
			
			
				
				-#define DBG  DBG_DISCARD 
			 | 
		
		
	
		
			
			| 
				141
			 | 
			
				
			 | 
			
			
				
				-#define DBG2 DBG_DISCARD 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				130
			 | 
			
			
				
				+extern void __attribute__ (( format ( printf, 2, 3 ) ))  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				131
			 | 
			
			
				
				+dbg_printf_autocolour ( void *id, const char *fmt, ... ); 
			 | 
		
		
	
		
			
			| 
				142
			 | 
			
				132
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				133
			 | 
			
			
				
				+/* Compatibility with existing Makefile */ 
			 | 
		
		
	
		
			
			| 
				143
			 | 
			
				134
			 | 
			
			
				
				 #if DEBUG_SYMBOL >= 1 
			 | 
		
		
	
		
			
			| 
				144
			 | 
			
				
			 | 
			
			
				
				-#undef DBG 
			 | 
		
		
	
		
			
			| 
				145
			 | 
			
				
			 | 
			
			
				
				-#define DBG DBG_PRINT 
			 | 
		
		
	
		
			
			| 
				146
			 | 
			
				
			 | 
			
			
				
				-#endif 
			 | 
		
		
	
		
			
			| 
				147
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				148
			 | 
			
				135
			 | 
			
			
				
				 #if DEBUG_SYMBOL >= 2 
			 | 
		
		
	
		
			
			| 
				149
			 | 
			
				
			 | 
			
			
				
				-#undef DBG2 
			 | 
		
		
	
		
			
			| 
				150
			 | 
			
				
			 | 
			
			
				
				-#define DBG2 DBG_PRINT 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				136
			 | 
			
			
				
				+#define DBGLVL 3 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				137
			 | 
			
			
				
				+#else 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				138
			 | 
			
			
				
				+#define DBGLVL 1 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				139
			 | 
			
			
				
				+#endif 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				140
			 | 
			
			
				
				+#else 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				141
			 | 
			
			
				
				+#define DBGLVL 0 
			 | 
		
		
	
		
			
			| 
				151
			 | 
			
				142
			 | 
			
			
				
				 #endif 
			 | 
		
		
	
		
			
			| 
				152
			 | 
			
				143
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				144
			 | 
			
			
				
				+#define DBGLVL_LOG	1 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				145
			 | 
			
			
				
				+#define DBG_LOG		( DBGLVL & DBGLVL_LOG ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				146
			 | 
			
			
				
				+#define DBGLVL_EXTRA	2 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				147
			 | 
			
			
				
				+#define DBG_EXTRA	( DBGLVL & DBGLVL_EXTRA ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				148
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				149
			 | 
			
			
				
				+#define DBG_IF( level, ... ) do {				\ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				150
			 | 
			
			
				
				+		if ( DBG_ ## level ) {				\ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				151
			 | 
			
			
				
				+			dbg_printf ( __VA_ARGS__ );		\ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				152
			 | 
			
			
				
				+		}						\ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				153
			 | 
			
			
				
				+	} while ( 0 ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				154
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				155
			 | 
			
			
				
				+#define DBGC_IF( level, ... ) do {				\ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				156
			 | 
			
			
				
				+		if ( DBG_ ## level ) {				\ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				157
			 | 
			
			
				
				+			dbg_printf_autocolour ( __VA_ARGS__ );	\ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				158
			 | 
			
			
				
				+		}						\ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				159
			 | 
			
			
				
				+	} while ( 0 ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				160
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				161
			 | 
			
			
				
				+#define DBG( ... )	DBG_IF ( LOG, __VA_ARGS__ ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				162
			 | 
			
			
				
				+#define DBG2( ... )	DBG_IF ( EXTRA, __VA_ARGS__ ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				163
			 | 
			
			
				
				+#define DBGC( ... )	DBGC_IF ( LOG, __VA_ARGS__ ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				164
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				153
			 | 
			
				165
			 | 
			
			
				
				 #if DEBUG_SYMBOL == 0 
			 | 
		
		
	
		
			
			| 
				154
			 | 
			
				166
			 | 
			
			
				
				 #define NDEBUG 
			 | 
		
		
	
		
			
			| 
				155
			 | 
			
				167
			 | 
			
			
				
				 #endif 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -157,23 +169,13 @@ __do_not_printf ( const char *fmt, ... ); 
			 | 
		
		
	
		
			
			| 
				157
			 | 
			
				169
			 | 
			
			
				
				 /** Declare a data structure as packed. */ 
			 | 
		
		
	
		
			
			| 
				158
			 | 
			
				170
			 | 
			
			
				
				 #define PACKED __attribute__ (( packed )) 
			 | 
		
		
	
		
			
			| 
				159
			 | 
			
				171
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				160
			 | 
			
				
			 | 
			
			
				
				-/**  
			 | 
		
		
	
		
			
			| 
				161
			 | 
			
				
			 | 
			
			
				
				- * Declare a variable or data structure as unused. 
			 | 
		
		
	
		
			
			| 
				162
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				163
			 | 
			
				
			 | 
			
			
				
				- * Note that using #__unused on a static global variable (such as a 
			 | 
		
		
	
		
			
			| 
				164
			 | 
			
				
			 | 
			
			
				
				- * table structure as mentioned in tables.h) is necessary in order to 
			 | 
		
		
	
		
			
			| 
				165
			 | 
			
				
			 | 
			
			
				
				- * inhibit compiler warnings. 
			 | 
		
		
	
		
			
			| 
				166
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				167
			 | 
			
				
			 | 
			
			
				
				- */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				172
			 | 
			
			
				
				+/** Declare a variable or data structure as unused. */ 
			 | 
		
		
	
		
			
			| 
				168
			 | 
			
				173
			 | 
			
			
				
				 #define __unused __attribute__ (( unused )) 
			 | 
		
		
	
		
			
			| 
				169
			 | 
			
				174
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				170
			 | 
			
				175
			 | 
			
			
				
				 /** 
			 | 
		
		
	
		
			
			| 
				171
			 | 
			
				176
			 | 
			
			
				
				  * Declare a function as used. 
			 | 
		
		
	
		
			
			| 
				172
			 | 
			
				177
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				173
			 | 
			
				178
			 | 
			
			
				
				  * Necessary only if the function is called only from assembler code. 
			 | 
		
		
	
		
			
			| 
				174
			 | 
			
				
			 | 
			
			
				
				- * You cannot use this attribute for static global variables; use 
			 | 
		
		
	
		
			
			| 
				175
			 | 
			
				
			 | 
			
			
				
				- * #__unused instead. 
			 | 
		
		
	
		
			
			| 
				176
			 | 
			
				
			 | 
			
			
				
				- * 
			 | 
		
		
	
		
			
			| 
				177
			 | 
			
				179
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				178
			 | 
			
				180
			 | 
			
			
				
				 #define __used __attribute__ (( used )) 
			 | 
		
		
	
		
			
			| 
				179
			 | 
			
				181
			 | 
			
			
				
				  
			 |