Exemplo n.º 1
0
static ssize_t __out_write(struct _reent *r, int fd, const char *ptr, size_t len)
{
    if(geckoinit && ptr)
        usb_sendbuffer(1, ptr, len);

	return len;
}
Exemplo n.º 2
0
void gprintf (const char *format, ...)
{
	static int init = 0;
	
	if (!init)
		{
		init = 1;
		*gprintfbuff = '\0';
		}
	
	char * tmp = NULL;
	va_list va;
	va_start(va, format);
	
	if ((vasprintf(&tmp, format, va) >= 0) && tmp)
		{
		if ((strlen (gprintfbuff) + strlen(tmp)) < MAXDBGBUFF)
			strcat (gprintfbuff, tmp);
			
        usb_sendbuffer(EXI_CHANNEL_1, tmp, strlen(tmp));
		}
	va_end(va);

	if(tmp)
        free(tmp);
}
Exemplo n.º 3
0
void printd(const char *text, ...)
	{
	static int geckoinit = 0;
	
	if (!geckoinit)
		{
		if (usb_isgeckoalive (EXI_CHANNEL_1))
			geckoinit = 1;
		else
			geckoinit = -1;
		}
	
	if (geckoinit <= 0) return;
	
	char buff[1024];
	va_list args;

	va_start(args, text);
	vsprintf(buff, text, args);
	va_end(args);

	strcat (buff, "\n");

	usb_sendbuffer( EXI_CHANNEL_1, buff, strlen(buff) );
	usb_flush(EXI_CHANNEL_1);
	}
Exemplo n.º 4
0
static int __out_write(struct _reent *r, int fd, const char *ptr, int len) {
	u32 level;
	u16 l;

	if (!ptr || len <= 0)
		return -1;
	LWP_MutexLock(console_mutex);
	if (video_active) {
		dot_video->write_r(r, fd, ptr, len);
	} else {
		if (log_active) {
			l = (log_next + 1) % log_size;
			if (log[l])
				free(log[l]);
			log[l] = strndup(ptr, len);

			log_next = l;
		}
	}

	if (gecko) {
		level = IRQ_Disable();
		usb_sendbuffer(1, ptr, len);
		IRQ_Restore(level);
	}
	LWP_MutexUnlock(console_mutex);
	return len;
}
Exemplo n.º 5
0
void debug(const char *text, ...)
	{
	static int gecko = 0;
	
	if (gecko == 0)
		{
		if (usb_isgeckoalive (EXI_CHANNEL_1))
			gecko = 2;
		else
			gecko = 1;
		}
		
	va_list args;

	va_start(args, text);
	vsprintf(debugbuff, text, args);

	va_end(args);
	
	if (gecko == 2)
		{
		usb_sendbuffer( EXI_CHANNEL_1, debugbuff, strlen(debugbuff) );
		usb_flush(EXI_CHANNEL_1);
		}
	
	if (debug2ConsoleEnabled)
		{
		printf(debugbuff);
		sleep (1);
		}
    else
        {
        if (strlen(points) < 80)
            strcat (points, ".");
        Console_SetPosition (14,0);
        PrintCenter (points, 80);
        }
	/*
	printf(debugbuff);
	
	if (strstr (debugbuff, "ERR:"))
		sleep (5);
	*/
	
	if (logbuff == NULL) // allocate space for 
		{
		logbuff = calloc (LBSIZE,1);
		lbsize = 0;
		}
	else
		{
		int blen;
		blen = strlen(debugbuff);
		if (lbsize + blen < LBSIZE)
			{
			strcat (logbuff, debugbuff);
			lbsize += blen;
			}
		}
	}
Exemplo n.º 6
0
void Debug (const char *text, ...)
	{
	if (!started || text == NULL) return;
		
	int i;
	char mex[1024];
	FILE * f = NULL;

	va_list argp;
	va_start (argp, text);
	vsprintf (mex, text, argp);
	va_end (argp);
	
	strcat (mex, "\r\n");

	if (geckolog)
		{
		usb_sendbuffer( EXI_CHANNEL_1, mex, strlen(mex) );
		usb_flush(EXI_CHANNEL_1);
		}
	if (started == 2) return;
	if (filelog == 0) return;
	
	// If a message start with '@', do not open... it will be cached cache it...
	if (mex[0] != '@')
		f = fopen(dbgfile, "ab");

	//if file cannot be opened, cannot open the file, maybe filesystem unmounted or nand emu active... use cache
	if (f)
		{
		for (i = 0; i < DEBUG_MAXCACHE; i++)
			{
			if (cache[i] != NULL)
				{
				fwrite (cache[i], 1, strlen(mex), f );
				free (cache[i]);
				cache[i] = NULL;
				}
			}
		fwrite (mex, 1, strlen(mex), f );
		fclose(f);
		}
	else
		{
		for (i = 0; i < DEBUG_MAXCACHE; i++)
			{
			if (cache[i] == NULL)
				{
				cache[i] = calloc (strlen(mex) + 1, 1);
				strcpy (cache[i], mex);
				break;
				}
			}
		}
	}
Exemplo n.º 7
0
static ssize_t __out_write(struct _reent *r, int fd, const char *ptr, size_t len)
{
	u32 level;

	if (!ptr || len <= 0 || !gecko)
		return -1;

	LWP_MutexLock(gecko_mutex);
	level = IRQ_Disable();
	usb_sendbuffer(1, ptr, len);
	IRQ_Restore(level);
	LWP_MutexUnlock(gecko_mutex);
	return len;
}
Exemplo n.º 8
0
void gprintf (const char *format, ...) {
   char * tmp = NULL;
   va_list va;
   va_start(va, format);

   if((vasprintf(&tmp, format, va) >= 0) && tmp)
   {
      usb_sendbuffer(EXI_CHANNEL_1, tmp, strlen(tmp));
   }
   va_end(va);

   if(tmp)
      free(tmp);
}
Exemplo n.º 9
0
int gecko_readmem()
{
	u8 startaddress[4];
	u8 endaddress[5];
	u8 ack_packet = 0xAA;
	u8 pcresponse;
	static u8 packetbuffer[packetsize] ATTRIBUTE_ALIGN(32);
	u32 memstart;
	u32 memend;
	u32 memrange;
	u32 fullpackets;
	u32 currentpacket;
	u32 lastpacketbytes;

	// ACK
	usb_sendbuffer_safe(gecko_channel,&ack_packet,1);
	usb_recvbuffer_safe(gecko_channel,&startaddress,4);		
	usb_recvbuffer_safe(gecko_channel,&endaddress,4);		
	
	memstart = be32(startaddress);	
	memend = be32(endaddress);	
	memrange = memend - memstart;

	fullpackets = memrange / packetsize;						
	lastpacketbytes = memrange % packetsize;					

	// Full Packet Size
	for (currentpacket = 0;currentpacket < fullpackets;)
	{	
		memcpy(packetbuffer, (char*)memstart, packetsize);
		usb_sendbuffer(gecko_channel,&packetbuffer, packetsize);
		usb_recvbuffer_safe(gecko_channel,&pcresponse,1);	
		if(pcresponse != 0xAA){								
		//	printf("failed to read packet\n");
			return 0;
		}
			memstart += packetsize;
			currentpacket++;	
	}

	// Remainder
	if(lastpacketbytes > 0) {
		memcpy(packetbuffer, (char*)memstart, lastpacketbytes);
		usb_sendbuffer_safe(gecko_channel,&packetbuffer, lastpacketbytes);
		usb_recvbuffer_safe(gecko_channel,&pcresponse,1);	
	}
	
//	printf("memory dump complete\n");
	return 1;
}
Exemplo n.º 10
0
void gprintf(const char *format, ...)
{
	if (!geckoinit)
        return;

	char * tmp = NULL;
	va_list va;
	va_start(va, format);
	if((vasprintf(&tmp, format, va) >= 0) && tmp)
	{
        usb_sendbuffer(1, tmp, strlen(tmp));
	}
	va_end(va);

	if(tmp)
        free(tmp);
}
Exemplo n.º 11
0
void gprintf( const char *str, ... )
{
    if(!GeckoFound)
        return;

    char astr[4096];

    va_list ap;
    va_start(ap,str);

    vsnprintf( astr,4095, str, ap );

    va_end(ap);
    usb_sendbuffer( 1, astr, strlen(astr) );
    usb_flush(EXI_CHANNEL_1);
    return;
}
Exemplo n.º 12
0
void Debug (const char *text, ...) {
   if (!started || text == NULL) return;

   char mex[2048] = {0};

   va_list argp;
   va_start(argp, text);
   if (geckolog) vsnprintf(mex, sizeof(mex)-1, text, argp);
   if (fdebug) {
      vfprintf(fdebug, text, argp);
      fprintf(fdebug, "\r\n");
      fflush(fdebug);
   }
   va_end(argp);

   if (geckolog) {
      strncat(mex, "\n", sizeof(mex)-1);
      usb_sendbuffer(EXI_CHANNEL_1, mex, strlen(mex));
      usb_flush(EXI_CHANNEL_1);
      usleep (500);
   }
}
Exemplo n.º 13
0
int __console_write(struct _reent *r,int fd,const char *ptr,size_t len)
{
	int i = 0;
	char *tmp = (char*)ptr;
	console_data_s *con;
	char chr;

	if(__gecko_status>=0) {
		if(__gecko_safe)
			usb_sendbuffer_safe(__gecko_status,ptr,len);
		else
			usb_sendbuffer(__gecko_status,ptr,len);
	}

	if(!curr_con) return -1;
	con = curr_con;
	if(!tmp || len<=0) return -1;

	i = 0;
	while(*tmp!='\0' && i<len)
	{
		chr = *tmp++;
		i++;
		if ( (chr == 0x1b) && (*tmp == '[') )
		{
			/* escape sequence found */
			int k;

			tmp++;
			i++;
			k = __console_parse_escsequence(tmp);
			tmp += k;
			i += k;
		}
		else
		{
			switch(chr)
			{
				case '\n':
					con->cursor_row++;
					con->cursor_col = 0;
					break;
				case '\r':
					con->cursor_col = 0;
					break;
				case '\b':
					con->cursor_col--;
					if(con->cursor_col < 0)
					{
						con->cursor_col = 0;
					}
					break;
				case '\f':
					con->cursor_row++;
					break;
				case '\t':
					if(con->cursor_col%TAB_SIZE) con->cursor_col += (con->cursor_col%TAB_SIZE);
					else con->cursor_col += TAB_SIZE;
					break;
				default:
					__console_drawc(chr);
					con->cursor_col++;

					if( con->cursor_col >= con->con_cols)
					{
						/* if right border reached wrap around */
						con->cursor_row++;
						con->cursor_col = 0;
					}
			}
		}

		if( con->cursor_row >= con->con_rows)
		{
			/* if bottom border reached scroll */
			memcpy(con->destbuffer,
				con->destbuffer+con->con_stride*(FONT_YSIZE*FONT_YFACTOR+FONT_YGAP),
				con->con_stride*con->con_yres-FONT_YSIZE);

			unsigned int cnt = (con->con_stride * (FONT_YSIZE * FONT_YFACTOR + FONT_YGAP))/4;
			unsigned int *ptr = (unsigned int*)(con->destbuffer + con->con_stride * (con->con_yres - FONT_YSIZE));
			while(cnt--)
				*ptr++ = con->background;
			con->cursor_row--;
		}
	}

	return i;
}
Exemplo n.º 14
0
int gecko_prints(const char *str)
{
	if (!gecko_enabled) return 0;
	return usb_sendbuffer(EXI_CHANNEL_1, str, strlen(str));
}