Switched debug output to KPrintF(), because format specifiers come in RawDoFmt()...
[AROS.git] / rom / filesys / SFS / FS / debug.c
blob6fd3a130477730bfc191a29e60c1f85895eb99e6
1 #include <devices/timer.h>
2 #include <dos/dos.h>
3 #include <exec/memory.h>
4 #include <exec/ports.h>
5 #include <exec/types.h>
6 #include <proto/dos.h>
7 #include <proto/exec.h>
8 #include <proto/timer.h>
10 #include "debug.h"
11 #include "fs.h"
13 #include "globals.h"
14 #include "asmsupport.h"
16 /* Internal prototypes */
18 #ifdef DEBUGCODE
20 #ifndef __AROS__
21 extern void __asm TOSERIAL(register __a0 UBYTE *);
22 #endif
24 void BEGIN(void) {
25 _DEBUG(("BEGIN..."));
27 ReadEClock(&globals->ecv);
30 void END(UBYTE *name) {
31 struct EClockVal ecv2;
32 ULONG freq;
33 LONG diff;
35 freq=ReadEClock(&ecv2);
37 diff=ecv2.ev_lo-globals->ecv.ev_lo;
38 if(diff<0) {
39 diff=-diff;
42 _DEBUG(("%s: ticks %ld (f=%ld)\n",name,diff,freq));
45 #ifndef __AROS__
47 #ifndef DEBUGKPRINTF
49 #ifndef DEBUG115200
51 void debug(UBYTE *fmt, ... ) {
52 struct MsgPort *port;
53 struct Message *msg;
54 UBYTE *dest;
55 ULONG *args;
57 Forbid();
58 if((port=FindPort("SFS debug output port"))!=0) {
59 if((msg=AllocVec(sizeof(struct Message)+512,MEMF_CLEAR))!=0) {
60 dest=(UBYTE *)msg;
61 dest+=sizeof(struct Message);
62 args=(ULONG *)&fmt;
63 args++;
65 RawDoFmt(fmt,args,putChFunc,dest);
67 PutMsg(port,msg);
70 Permit();
75 void tdebug(UBYTE *fmt, ... ) {
76 struct MsgPort *port;
77 struct Message *msg;
78 struct DateStamp ds;
79 UBYTE *dest;
80 ULONG *args;
82 DateStamp(&ds);
84 debug("%4ld.%4ld ", ds.ds_Minute, ds.ds_Tick*2);
86 Forbid();
87 if((port=FindPort("SFS debug output port"))!=0) {
88 if((msg=AllocVec(sizeof(struct Message)+512,MEMF_CLEAR))!=0) {
89 dest=(UBYTE *)msg;
90 dest+=sizeof(struct Message);
91 args=(ULONG *)&fmt;
92 args++;
94 RawDoFmt(fmt,args,putChProc,dest);
96 PutMsg(port,msg);
99 Permit();
104 void xdebug(ULONG type,UBYTE *fmt, ... ) {
105 struct MsgPort *port;
106 struct Message *msg;
107 UBYTE *dest;
108 ULONG *args;
109 // ULONG debug=0xFFFFFFFE-DEBUG_CACHEBUFFER-DEBUG_NODES-DEBUG_IO-DEBUG_SEEK-DEBUG_LOCK-DEBUG_BITMAP;
110 // ULONG debugdetailed=0xFFFFFFFE-DEBUG_CACHEBUFFER-DEBUG_NODES-DEBUG_IO-DEBUG_SEEK-DEBUG_LOCK-DEBUG_BITMAP;
111 // ULONG debug=0xFFFFFFFE-DEBUG_CACHEBUFFER-DEBUG_NODES-DEBUG_LOCK-DEBUG_BITMAP;
112 // ULONG debugdetailed=0xFFFFFFFE-DEBUG_CACHEBUFFER-DEBUG_NODES-DEBUG_LOCK-DEBUG_BITMAP;
113 // ULONG debug=0xFFFFFFFE;
114 // ULONG debugdetailed=0xFFFFFFFE;
115 ULONG debug=mask_debug;
116 ULONG debugdetailed=mask_debug & ~(DEBUG_CACHEBUFFER|DEBUG_NODES|DEBUG_LOCK|DEBUG_BITMAP);
118 if((debugdetailed & type)!=0 || ((type & 1)==0 && (debug & type)!=0)) {
119 Forbid();
120 if((port=FindPort("SFS debug output port"))!=0) {
121 if((msg=AllocVec(sizeof(struct Message)+512,MEMF_CLEAR))!=0) {
122 dest=(UBYTE *)msg;
123 dest+=sizeof(struct Message);
124 args=(ULONG *)&fmt;
125 args++;
127 RawDoFmt(fmt,args,putChProc,dest);
129 PutMsg(port,msg);
132 Permit();
136 #else
138 UBYTE serbuffer[500];
140 void debug(UBYTE *fmt, ... ) {
141 ULONG *args;
143 args=(ULONG *)&fmt;
144 args++;
146 RawDoFmt(fmt,args,putChProc,serbuffer);
148 Disable();
150 TOSERIAL(serbuffer);
152 Enable();
157 void xdebug(ULONG type,UBYTE *fmt, ... ) {
158 ULONG *args;
159 // ULONG debug=0xFFFFFFFE-DEBUG_CACHEBUFFER-DEBUG_NODES-DEBUG_IO-DEBUG_SEEK-DEBUG_LOCK-DEBUG_BITMAP;
160 // ULONG debugdetailed=0xFFFFFFFE-DEBUG_CACHEBUFFER-DEBUG_NODES-DEBUG_IO-DEBUG_SEEK-DEBUG_LOCK-DEBUG_BITMAP;
161 // ULONG debug=0xFFFFFFFE-DEBUG_CACHEBUFFER-DEBUG_NODES-DEBUG_LOCK-DEBUG_BITMAP;
162 // ULONG debugdetailed=0xFFFFFFFE-DEBUG_CACHEBUFFER-DEBUG_NODES-DEBUG_LOCK-DEBUG_BITMAP;
163 // ULONG debug=0xFFFFFFFE;
164 // ULONG debugdetailed=0xFFFFFFFE;
165 ULONG debug=mask_debug;
166 ULONG debugdetailed=mask_debug & ~(DEBUG_CACHEBUFFER|DEBUG_NODES|DEBUG_LOCK|DEBUG_BITMAP);
168 if((debugdetailed & type)!=0 || ((type & 1)==0 && (debug & type)!=0)) {
170 args=(ULONG *)&fmt;
171 args++;
173 RawDoFmt(fmt,args,putChProc,serbuffer);
175 Disable();
177 TOSERIAL(serbuffer);
179 Enable();
183 #endif
186 #else
188 void xkprintf(ULONG type,const char *fmt, ... ) {
189 UBYTE *str;
190 UBYTE *dest;
191 ULONG *args;
192 ULONG debug=mask_debug;
193 ULONG debugdetailed=mask_debug & ~(DEBUG_CACHEBUFFER|DEBUG_NODES|DEBUG_LOCK|DEBUG_BITMAP);
195 if((debugdetailed & type)!=0 || ((type & 1)==0 && (debug & type)!=0)) {
196 if((str=AllocVec(512,MEMF_CLEAR))!=0) {
197 dest=str;
198 args=(ULONG *)&fmt;
199 args++;
201 RawDoFmt((char *)fmt,args,putChProc,dest);
202 kprintf("%s",dest);
207 #endif
208 #endif
210 #endif