Quellcode durchsuchen

Doxygenation

tags/v0.9.3
Michael Brown vor 19 Jahren
Ursprung
Commit
a9fabe7546
1 geänderte Dateien mit 101 neuen und 18 gelöschten Zeilen
  1. 101
    18
      src/include/compiler.h

+ 101
- 18
src/include/compiler.h Datei anzeigen

@@ -10,12 +10,21 @@
10 10
 #define __attribute__(x)
11 11
 #endif
12 12
 
13
-/*
14
- * We export the symbol obj_OBJECT (OBJECT is defined on command-line)
15
- * as a global symbol, so that the linker can drag in selected object
16
- * files from the library using -u obj_OBJECT.
13
+/** @file
14
+ *
15
+ * Global compiler definitions.
16
+ *
17
+ * This file is implicitly included by every @c .c file in Etherboot.
18
+ * It defines global macros such as DBG() and ASSERT().
17 19
  *
18
- * Not quite sure why cpp requires two levels of macro call in order
20
+ * We arrange for each object to export the symbol @c obj_OBJECT
21
+ * (where @c OBJECT is the object name, e.g. @c rtl8139) as a global
22
+ * symbol, so that the linker can drag in selected object files from
23
+ * the library using <tt> -u obj_OBJECT </tt>.
24
+ *
25
+ */
26
+
27
+/* Not quite sure why cpp requires two levels of macro call in order
19 28
  * to actually expand OBJECT...
20 29
  */
21 30
 #undef _H1
@@ -40,7 +49,9 @@
40 49
 __asm__ ( ".globl\t" OBJECT_SYMBOL_STR );
41 50
 __asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" );
42 51
 
43
-/*
52
+/**
53
+ * Drag in an object by object name.
54
+ *
44 55
  * Macro to allow objects to explicitly drag in other objects by
45 56
  * object name.  Used by config.c.
46 57
  *
@@ -48,6 +59,56 @@ __asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" );
48 59
 #define REQUIRE_OBJECT(object) \
49 60
 	__asm__ ( ".equ\tneed_" #object ", obj_" #object );
50 61
 
62
+/** @def DBG
63
+ *
64
+ * Print a debugging message.
65
+ *
66
+ * The debug level is set at build time by specifying the @c DEBUG=
67
+ * parameter on the @c make command line.  For example, to enable
68
+ * debugging for the PCI bus functions (in pci.c) in a @c .dsk image
69
+ * for the @c rtl8139 card, you could use the command line
70
+ *
71
+ * @code
72
+ *
73
+ *   make bin/rtl8139.dsk DEBUG=pci
74
+ *
75
+ * @endcode
76
+ *
77
+ * This will enable the debugging statements (DBG()) in pci.c.  If
78
+ * debugging is not enabled, DBG() statements will be ignored.
79
+ *
80
+ * You can enable debugging in several objects simultaneously by
81
+ * separating them with commas, as in
82
+ *
83
+ * @code
84
+ *
85
+ *   make bin/rtl8139.dsk DEBUG=pci,buffer,heap
86
+ *
87
+ * @endcode
88
+ *
89
+ * You can increase the debugging level for an object by specifying it
90
+ * with @c :N, where @c N is the level, as in
91
+ *
92
+ * @code
93
+ *
94
+ *   make bin/rtl8139.dsk DEBUG=pci,buffer:2,heap
95
+ *
96
+ * @endcode
97
+ *
98
+ * which would enable debugging for the PCI, buffer-handling and
99
+ * heap-allocation code, with the buffer-handling code at level 2.
100
+ *
101
+ */
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
+
51 112
 /*
52 113
  * If debug_OBJECT is set to a true value, the macro DBG(...) will
53 114
  * expand to printf(...) when compiling OBJECT, and the symbol
@@ -77,8 +138,12 @@ __asm__ ( ".equ\tDEBUG_LEVEL, " DEBUG_SYMBOL_STR );
77 138
 #define DBG2 DBG_PRINT
78 139
 #endif
79 140
 
80
-/*
81
- * ASSERT() macros
141
+/**
142
+ * Assert a condition.
143
+ *
144
+ * If the condition is not true, a debug message will be printed.
145
+ * Assertions only take effect if the debug level is non-zero (see
146
+ * DBG()).
82 147
  *
83 148
  */
84 149
 #define ASSERT(x)
@@ -94,20 +159,35 @@ __asm__ ( ".equ\tDEBUG_LEVEL, " DEBUG_SYMBOL_STR );
94 159
 	} while (0)
95 160
 #endif
96 161
 
97
-/*
98
- * Commonly-used attributes.
162
+/** Declare a data structure as packed. */
163
+#define PACKED __attribute__ (( packed ))
164
+
165
+/** 
166
+ * Declare a variable or data structure as unused.
99 167
  *
100
- * Note that __used can be used only for functions.  If you have a
101
- * static variable declaration that you want to force to be included,
102
- * use __unused.
168
+ * Note that using @c __unused on a static global variable (such as a
169
+ * table structure as mentioned in tables.h) is necessary in order to
170
+ * inhibit compiler warnings.
103 171
  *
104 172
  */
105
-#define PACKED __attribute__ (( packed ))
106 173
 #define __unused __attribute__ (( unused ))
174
+
175
+/**
176
+ * Declare a function as used.
177
+ *
178
+ * Necessary only if the function is called only from assembler code.
179
+ * You cannot use this attribute for static global variables; use @c
180
+ * __unused instead.
181
+ *
182
+ */
107 183
 #define __used __attribute__ (( used ))
184
+
185
+/** Declare a data structure to be aligned with 16-byte alignment */
108 186
 #define __aligned __attribute__ (( aligned ( 16 ) ))
109 187
 
110
-/*
188
+/**
189
+ * Shared data.
190
+ *
111 191
  * To save space in the binary when multiple-driver images are
112 192
  * compiled, uninitialised data areas can be shared between drivers.
113 193
  * This will typically be used to share statically-allocated receive
@@ -115,13 +195,16 @@ __asm__ ( ".equ\tDEBUG_LEVEL, " DEBUG_SYMBOL_STR );
115 195
  *
116 196
  * Use as e.g.
117 197
  *
118
- *  struct {
198
+ * @code
199
+ *
200
+ *   struct {
119 201
  *	char	rx_buf[NUM_RX_BUF][RX_BUF_SIZE];
120 202
  *	char	tx_buf[TX_BUF_SIZE];
121
- *  } my_static_data __shared;
203
+ *   } my_static_data __shared;
204
+ *
205
+ * @endcode
122 206
  *
123 207
  */
124
-
125 208
 #define __shared __asm__ ( "_shared_bss" )
126 209
 
127 210
 #endif /* ASSEMBLY */

Laden…
Abbrechen
Speichern