20#define DPRINTF(fmt, x...) printf(MODNAME ": " fmt, ##x)
25static int tty_sema = -1;
27extern void tty_puts(
const char *str);
29static int ttyfs_init()
31 DPRINTF(
"FS Init()\n");
32 if ((tty_sema = CreateMutex(IOP_MUTEX_UNLOCKED)) < 0)
34 DPRINTF(
"Failed to create mutex\n");
40static int ttyfs_deinit()
42 DPRINTF(
"FS Deinit()\n");
47static int ttyfs_write(
iop_file_t *file,
void *ptr,
int size) {
53 DPRINTF(
"FS Write()\n");
60 toWrite = (size - bCount);
64 memcpy(temp, &(((u8 *)ptr)[bCount]), toWrite);
75IOMAN_RETURN_VALUE_IMPL(0);
76IOMAN_RETURN_VALUE_IMPL(
EPERM);
82 IOMAN_RETURN_VALUE(
EPERM),
83 IOMAN_RETURN_VALUE(0),
84 IOMAN_RETURN_VALUE(0),
85 IOMAN_RETURN_VALUE(
EPERM),
87 IOMAN_RETURN_VALUE(
EPERM),
88 IOMAN_RETURN_VALUE(
EPERM),
89 IOMAN_RETURN_VALUE(
EPERM),
90 IOMAN_RETURN_VALUE(
EPERM),
91 IOMAN_RETURN_VALUE(
EPERM),
92 IOMAN_RETURN_VALUE(0),
93 IOMAN_RETURN_VALUE(0),
94 IOMAN_RETURN_VALUE(
EPERM),
95 IOMAN_RETURN_VALUE(
EPERM),
96 IOMAN_RETURN_VALUE(
EPERM),
102 IOP_DT_CHAR | IOP_DT_CONS,
109void sprintf_putchar(
void *context,
int c)
111 char **
string = (
char **)context;
113 if(c < 0x100) { ((*string)++)[0] = c; }
114 else { (*string)[0] = 0; }
117extern int _vsprintf(
char * str,
const char * format, va_list ap);
119static char kprint_buffer[1024];
121int _kPrintf(
void *context,
const char * format, va_list ap)
125 int r = prnt(&sprintf_putchar, &format, format, ap);
126 tty_puts(kprint_buffer);
133 DelDrv(tty_fsd.name);
136 if(AddDrv(&tty_fsd) != 0) {
return(-1); }
140 open(
"tty:", O_RDONLY);
143 open(
"tty:", O_WRONLY);
145 printf(
"PPCTTY: KprintfSet\n");
146 KprintfSet(&_kPrintf, NULL);