Esempio n. 1
0
__attribute__((section(".text.start"), noreturn)) void _start()
{
	static const TCHAR fontPath[] = _T("") SYS_PATH "/" FONT_NAME;
	void *fontBuf;
	UINT btr, br;
	int r;
	FIL f;

	// Enable TMIO IRQ
	*(volatile uint32_t *)0x10001000 = 0x00010000;

	preloadStringsA();

	if (!FSInit()) {
		DrawString(BOT_SCREEN, strings[STR_FAILED],
			BOT_SCREEN_WIDTH / 2, SCREEN_HEIGHT - FONT_HEIGHT, RED, BLACK);
		while (1);
	}

	/*
	set_loglevel(ll_info);
	log(ll_info, "Initializing rxTools...");
	*/

	setConsole();

	fontIsLoaded = 0;
	r = f_open(&f, fontPath, FA_READ);
	if (r == FR_OK) {
		btr = f_size(&f);
		fontBuf = __builtin_alloca(btr);
		r = f_read(&f, fontBuf, btr, &br);
		if (r == FR_OK)
			fontIsLoaded = 1;

		f_close(&f);
		fontaddr = fontBuf;
	}

	if (fontIsLoaded)
		preloadStringsU();
	else
		warn(L"Failed to load " FONT_NAME ": %d\n", r);

    if (getMpInfo() == MPINFO_KTR)
    {
        r = initN3DSKeys();
        if (r != FR_OK) {
            warn(L"Failed to load keys for N3DS\n"
            "  Code: %d\n"
            "  RxMode will not boot. Please\n"
            "  include key_0x16.bin and\n"
            "  key_0x1B.bin at the root of your\n"
            "  SD card.\n", r);
            InputWait();
            goto postinstall;
        }
    }

	install();
	postinstall:
	readCfg();

	r = loadStrings();
	if (r)
		warn(L"Failed to load strings: %d\n", r);

	drawTop();

	if (!cfgs[CFG_GUI].val.i && HID_STATE & BUTTON_L1)
		rxMode(cfgs[CFG_ABSYSN].val.i ? 0 : 1);

	if (sysver < 7) {
		r = initKeyX();
		if (r != FR_OK)
			warn(L"Failed to load key X for slot 0x25\n"
				"  Code: %d\n"
				"  If your firmware version is less\n"
				"  than 7.X, some titles decryption\n"
				"  will fail, and some EmuNANDs\n"
				"  will not boot.\n", r);
	}

	if (warned) {
		warn(strings[STR_PRESS_BUTTON_ACTION],
			strings[STR_BUTTON_A], strings[STR_CONTINUE]);
		WaitForButton(BUTTON_A);
	}

	OpenAnimation();
	MenuInit(&MainMenu);
	MenuShow();
	mainLoop();
}
Esempio n. 2
0
void foo3 (unsigned char a)
{
  if (a == 0)
    useit (__builtin_alloca (a)); // { dg-warning "argument to 'alloca' is zero" }
}
int main ()
{
  char *mem = __builtin_alloca (40);
  __builtin___clear_cache (mem, mem + 40);
  return 0;
}
Esempio n. 4
0
/*! \brief Holt von einen Hostname die IP-Adressen
 * \warning Es ist drauf zu achten das genug Speicher vorgesehen ist fuer die Anworten und das auch Packete mit entsprechender groesse
 * vom Ethernetmodul empfagen werden koennen und nicht verworfen werden. Siehe MAX_FRAMELEN in enc28j60.h .
 * \param	HOSTNAME	Zeiger auf den Hostnamestring der mit 0 teminiert ist.
 * \retval	IP		Die IP des Hostname, wenn IP = DNS_NO_ANSWER ist war die Anfrage nicht erfolgreich. Es sollte der DNSserver Eintrag ueberprueft werden
 * oder die richtigkeit des Hostname.
 */
unsigned long DNS_ResolveName( char * HOSTNAME )
{		
		int i,UDP_socket;
		int timer;
				
		// udp-puffer anlegen
		unsigned char * udpbuffer;
		udpbuffer = (unsigned char*) __builtin_alloca (( size_t ) DNS_BUFFER_LENGHT );
			
		// DNS-struct in udp-puffer anlegen
		struct DNS_header * DNS_question;
		DNS_question = ( struct DNS_header *) udpbuffer;
			
		// DNS anfrage bauen
		DNS_question->TransactionID = 0x1acd;
		DNS_question->Flags = ChangeEndian16bit( 0x0100 );
		DNS_question->Questions = ChangeEndian16bit( 1 );
		DNS_question->Answer_RRs = 0;
		DNS_question->Authority_RRs = 0;
		DNS_question->Additional_RRs = 0;
		
		// Hostename für DNS umwandeln, in i steht die länge des neuen strings
		i = DNS_convertHostName( HOSTNAME, DNS_question->Queries );
		
		DNS_question->Queries[i + 1] = '\0';
		DNS_question->Queries[i + 2] = 1;
		DNS_question->Queries[i + 3] = '\0';
		DNS_question->Queries[i + 4] = 1;

		i = i + 5;
		
		// Antwortstruct anlegen
		struct DNS_answer * DNS_ans;
		DNS_ans = ( void * ) &DNS_question->Queries[i];
		
		// UDP-Paccket senden
		UDP_socket = UDP_RegisterSocket( DNSserver , DNS_SERVER_PORT, DNS_BUFFER_LENGHT , udpbuffer);
		if ( UDP_socket == UDP_SOCKET_ERROR )
				return( DNS_NO_ANSWER );
		UDP_SendPacket( UDP_socket, DNS_HEADER_LENGHT + i , udpbuffer);

		// empfang des der DNS-Atwort abwarten
		timer = CLOCK_RegisterCoundowntimer();
		if ( timer == CLOCK_FAILED ) return ( DNS_NO_ANSWER );

		CLOCK_SetCountdownTimer ( timer, DNS_REQUEST_TIMEOUT, MSECOUND );

		while ( 1 )
		{
			if ( UDP_GetSocketState( UDP_socket ) == UDP_SOCKET_BUSY )
			{
				CLOCK_ReleaseCountdownTimer( timer );
				UDP_CloseSocket( UDP_socket );
				if ( ( ChangeEndian16bit( DNS_question->Flags ) & 0x000f ) != 0 ) return ( DNS_NO_ANSWER );
				break;
			}
			if ( CLOCK_GetCountdownTimer( timer ) == 0 ) 
			{
				CLOCK_ReleaseCountdownTimer( timer );
				UDP_CloseSocket( UDP_socket );
				return( DNS_NO_ANSWER );
			}
		}

		// Antwortpacket auseinander nehmen
		while ( 1 )
		{
			// Wenn noch nicht der Hosteintrag dann nächsten DNS-Answer Datensatz
			if ( ChangeEndian16bit( DNS_ans->Type ) != A_HOSTNAME )
			{
				i = i + ChangeEndian16bit( DNS_ans->Datalenght ) + DNS_ANSWER_HEADER_LENGHT;
				DNS_ans = ( void * ) &DNS_question->Queries[i];
			}
			else break;
		}
		return( DNS_ans->Adress );		
}