2010-02-12 21:11:35 +01:00
|
|
|
|
2010-09-13 22:07:22 +02:00
|
|
|
#include <ddk.h>
|
|
|
|
#include <mutex.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
#include <syscall.h>
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char sec;
|
|
|
|
char min;
|
|
|
|
char hour;
|
|
|
|
char rsv;
|
|
|
|
}detime_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char day;
|
|
|
|
char month;
|
|
|
|
short year;
|
|
|
|
}dedate_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned attr;
|
|
|
|
unsigned flags;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
detime_t ctime;
|
|
|
|
unsigned cr_time;
|
|
|
|
};
|
|
|
|
union
|
|
|
|
{
|
|
|
|
dedate_t cdate;
|
|
|
|
unsigned cr_date;
|
|
|
|
};
|
|
|
|
union
|
|
|
|
{
|
|
|
|
detime_t atime;
|
|
|
|
unsigned acc_time;
|
|
|
|
};
|
|
|
|
union
|
|
|
|
{
|
|
|
|
dedate_t adate;
|
|
|
|
unsigned acc_date;
|
|
|
|
};
|
|
|
|
union
|
|
|
|
{
|
|
|
|
detime_t mtime;
|
|
|
|
unsigned mod_time;
|
|
|
|
};
|
|
|
|
union
|
|
|
|
{
|
|
|
|
dedate_t mdate;
|
|
|
|
unsigned mod_date;
|
|
|
|
};
|
|
|
|
unsigned size;
|
|
|
|
unsigned size_high;
|
|
|
|
} FILEINFO;
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
int offset;
|
|
|
|
} dbgfile_t;
|
|
|
|
|
|
|
|
static dbgfile_t dbgfile;
|
|
|
|
|
|
|
|
#define va_start(v,l) __builtin_va_start(v,l)
|
|
|
|
#define va_end(v) __builtin_va_end(v)
|
|
|
|
#define va_arg(v,l) __builtin_va_arg(v,l)
|
|
|
|
#define __va_copy(d,s) __builtin_va_copy(d,s)
|
|
|
|
|
|
|
|
typedef __builtin_va_list __gnuc_va_list;
|
|
|
|
typedef __gnuc_va_list va_list;
|
|
|
|
|
|
|
|
#define arg(x) va_arg (ap, u32_t)
|
|
|
|
|
|
|
|
int dbg_open(char *path)
|
|
|
|
{
|
|
|
|
FILEINFO info;
|
|
|
|
|
|
|
|
dbgfile.offset = 0;
|
|
|
|
|
|
|
|
if(get_fileinfo(path,&info))
|
|
|
|
{
|
|
|
|
if(!create_file(path))
|
|
|
|
{
|
|
|
|
dbgfile.path = path;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else return false;
|
|
|
|
};
|
|
|
|
set_file_size(path, 0);
|
|
|
|
dbgfile.path = path;
|
|
|
|
dbgfile.offset = 0;
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
int vsnprintf(char *s, size_t n, const char *format, va_list arg);
|
|
|
|
|
2010-09-05 16:31:18 +02:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
int printf(const char* format, ...)
|
|
|
|
{
|
2011-02-16 19:08:06 +01:00
|
|
|
char txtbuf[1024];
|
2010-02-12 21:11:35 +01:00
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, format);
|
|
|
|
if (format)
|
2011-02-16 19:08:06 +01:00
|
|
|
len = vsnprintf(txtbuf, 1024, format, ap);
|
2010-02-12 21:11:35 +01:00
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
if( len )
|
|
|
|
SysMsgBoardStr(txtbuf);
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int dbgprintf(const char* format, ...)
|
|
|
|
{
|
2011-02-16 19:08:06 +01:00
|
|
|
char txtbuf[1024];
|
2010-02-12 21:11:35 +01:00
|
|
|
unsigned writes;
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, format);
|
|
|
|
if (format)
|
2011-02-16 19:08:06 +01:00
|
|
|
len = vsnprintf(txtbuf, 1024, format, ap);
|
2010-02-12 21:11:35 +01:00
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
if( len )
|
|
|
|
{
|
2013-11-26 07:16:07 +01:00
|
|
|
if( dbgfile.path)
|
|
|
|
{
|
2010-09-05 16:31:18 +02:00
|
|
|
/* do not write into log file if interrupts disabled */
|
|
|
|
|
2013-11-26 07:16:07 +01:00
|
|
|
if ( get_eflags() & (1 << 9) )
|
|
|
|
{
|
|
|
|
write_file(dbgfile.path,txtbuf,dbgfile.offset,len,&writes);
|
|
|
|
dbgfile.offset+=writes;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else SysMsgBoardStr(txtbuf);
|
2010-02-12 21:11:35 +01:00
|
|
|
};
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
int xf86DrvMsg(int skip, int code, const char* format, ...)
|
|
|
|
{
|
2011-02-16 19:08:06 +01:00
|
|
|
char txtbuf[1024];
|
2010-02-12 21:11:35 +01:00
|
|
|
unsigned writes;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
va_start(ap, format);
|
|
|
|
if (format)
|
2011-02-16 19:08:06 +01:00
|
|
|
len = vsnprintf(txtbuf, 1024, format, ap);
|
2010-02-12 21:11:35 +01:00
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
if( len )
|
|
|
|
{
|
|
|
|
SysMsgBoardStr(txtbuf);
|
|
|
|
|
|
|
|
if(dbgfile.path)
|
|
|
|
{
|
|
|
|
write_file(dbgfile.path,txtbuf,dbgfile.offset,len,&writes);
|
|
|
|
dbgfile.offset+=writes;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|