usbloadergx/source/gecko.c
dimok321 9da497419c *Fixed settings loading on boot up
*Added better wait loop for HDD spin up
*Changed almost all default config paths which are set when no config exists to be set to where the actual config file is saved (either /apps/usbloader_gx/ or /config/)
*Changed to startup and load a cios right away before loading settings. You need to have at least one non stub cios 249, 222 or 250 to start the loader now
*Fixed 30 secs timer on HDD spin wait
*Updated libfat to new libogc version
2010-11-28 15:31:08 +00:00

79 lines
1.5 KiB
C

#include <gccore.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
/* init-globals */
static bool geckoinit = false;
#ifndef NO_DEBUG
#include <stdarg.h>
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)
{
u32 level = IRQ_Disable();
usb_sendbuffer(1, tmp, strlen(tmp));
IRQ_Restore(level);
}
va_end(va);
if(tmp)
free(tmp);
}
bool InitGecko()
{
u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);
if (geckoattached)
{
usb_flush(EXI_CHANNEL_1);
CON_EnableGecko(1, true);
geckoinit = true;
return true;
}
else return false;
}
char ascii(char s)
{
if (s < 0x20) return '.';
if (s > 0x7E) return '.';
return s;
}
void hexdump(void *d, int len)
{
u8 *data;
int i, off;
data = (u8*) d;
gprintf("\n 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF");
gprintf("\n==== =============================================== ================\n");
for (off = 0; off < len; off += 16)
{
gprintf("%04x ", off);
for (i = 0; i < 16; i++)
if ((i + off) >= len)
gprintf(" ");
else gprintf("%02x ", data[off + i]);
gprintf(" ");
for (i = 0; i < 16; i++)
if ((i + off) >= len)
gprintf(" ");
else gprintf("%c", ascii(data[off + i]));
gprintf("\n");
}
}
#endif /* NO_DEBUG */