예제 #1
0
void backup_flash()
{
	int ret;
	volatile u16 *read_addr=(volatile u16 *)0x22000000;
	volatile u16 *write_addr=(volatile u16 *)0x20200000;
	u32 i;
	flash_info_struct flash_info;

	vdp_start_draw_list();
	vdp_end_draw_list();

	if ((ret = ar_init_flash_io(&flash_info)) != IAPETUS_ERR_OK)
	{
		if (!ar_handle_detect_error(ret))
		   return;
	}

	for (i = 0; i < 0x40000; i++)
		write_addr[i] = read_addr[i];

	vdp_printf(&main_font, 8, 3 * 8, 0xF, "Firmware ready to download. Set your");
	vdp_printf(&main_font, 8, 4 * 8, 0xF, "Commlink utility to download data from");
	vdp_printf(&main_font, 8, 5 * 8, 0xF, "LWRAM(0x00200000 to 0x00240000)");
	vdp_printf(&main_font, 8, 6 * 8, 0xF, "Press any button to exit.");

	commlink_start_service();
	wait_for_press(-1);
	commlink_stop_service();
}
예제 #2
0
int main()
{
   installer_init();

   // Display Main Menu
   for(;;)
   {
      commlink_start_service();
      gui_do_menu(main_menu, &main_font, 0, 0, "Pseudo Saturn Installer v" INSTALLER_VERSION, MTYPE_CENTER, -1);

      main_font.transparent = 1;
      gui_clear_scr(&main_font);
   }

   return 0;
}
예제 #3
0
파일: tests.c 프로젝트: Amon-X/yabause
void do_tests(const char *testname, int x, int y)
{
   int i;
   u8 stage=0;
   u8 line=0;

   // Clear out test log area
   memset((void *)TEST_LOG_ADDRESS, 0, TEST_LOG_SIZE);
   *((u32 *)TEST_LOG_ADDRESS) = TEST_LOG_ADDRESS+4;

   // Print messages and cursor
   vdp_printf(&test_disp_font, x * 8, y * 8, 0xF, (char *)testname);

   auto_test_section_start((char *)testname);

   for(;;)
   {
      vdp_vsync();

      if (stage_status != STAGESTAT_BUSY && stage_status != STAGESTAT_WAITINGFORINT)
      {
         int textx = x * 8;
         int texty = (y + line + 2) * 8;
         int textstatx = (x + 38) * 8;

         if (stage_status == STAGESTAT_DONE)
         {
            vdp_printf(&test_disp_font, textstatx, texty, 0xA, "OK");
            auto_test_send_result("PASS");
         }

         else if (stage_status < 0)
         {
            // Handle error
            switch (stage_status)
            {
               case STAGESTAT_BADTIMING:
                  vdp_printf(&test_disp_font, textstatx, texty, 0xE, "BT");
                  auto_test_send_result("FAIL (Bad Timing)");
                  break;
               case STAGESTAT_BADDATA:
                  vdp_printf(&test_disp_font, textstatx, texty, 0xC, "BD");
                  auto_test_send_result("FAIL (Bad Data)");
                  break;
               case STAGESTAT_BADSIZE:
                  vdp_printf(&test_disp_font, textstatx, texty, 0xC, "BS");
                  auto_test_send_result("FAIL (Bad Size)");
                  break;
               case STAGESTAT_BADINTERRUPT:
                  vdp_printf(&test_disp_font, textstatx, texty, 0xC, "BI");
                  auto_test_send_result("FAIL (Bad Interrupt)");
                  break;
               case STAGESTAT_NOTEST:
                  vdp_printf(&test_disp_font, textstatx, texty, 0xF, "NT");
                  auto_test_send_result("FAIL (No Test)");
                  break;
               default:
                  vdp_printf(&test_disp_font, textstatx, texty, 0xC, "failed");
                  auto_test_send_result("FAIL");
                  break;
            }
         }

         if (stage >= numtests)
         {
            vdp_printf(&test_disp_font, textx, texty+8, 0xF, "All tests done.");
            break;
         }
#ifndef BUILD_AUTOMATED_TESTING
         else if (line >= 23)
         {
            vdp_printf(&test_disp_font,textx, texty+8, 0xF, "Press any button to continue");
            tests_wait_press();
            // Clear window
            vdp_clear_screen(&test_disp_font);
            vdp_printf(&test_disp_font, x * 8, y * 8, 0xF, (char *)testname);
            line = 0;
            texty = (y + line + 2) * 8;
         }
#endif

         stage_status = STAGESTAT_BUSY;

         if (tests[stage].name)
         {
            vdp_printf(&test_disp_font, textx, texty+8, 0xF, (char *)tests[stage].name);
            auto_test_sub_test_start((char *)tests[stage].name);
         }

         if (tests[stage].testfunc)
            tests[stage].testfunc();

         waitcounter = 60 * 5;

         stage++;
         line++;
      }
      else
      {
         if (stage_status == STAGESTAT_WAITINGFORINT)
         {
            // decrement waitcounter
            waitcounter--;
            if (waitcounter <= 0)
               stage_status = STAGESTAT_BADINTERRUPT;
#ifdef DEBUG
            vdp_printf(&test_disp_font, 0 * 8, 23 * 8, 0xF, "%08X", waitcounter);
#endif
         }
      }
   }

   interrupt_set_level_mask(0xF);

   // Reset all interrupts
   for (i = 0; i < 0x80; i++)
      bios_set_sh2_interrupt(i, 0);

   for (i = 0x40; i < 0x60; i++)
      bios_set_scu_interrupt(i, 0);

   // Make sure all interrupts have been called
   bios_change_scu_interrupt_mask(0, 0);
   bios_change_scu_interrupt_mask(0xFFFFFFFF, 0xFFFFFFFF);

   auto_test_section_end();

   // Enable commlink connection
   cl_set_service_func(ud_check);
   commlink_start_service();
   tests_wait_press();
   commlink_stop_service();
}
예제 #4
0
int reflash_ar(font_struct *font, u8 *rom_addr, int ask_upload)
{
   int ret;
   volatile u16 *write_addr=(volatile u16 *)0x22000000;
   u16 *read_addr=(u16 *)((u32)rom_addr | 0x20000000);
	flash_info_struct flash_info;
	int i;

   vdp_start_draw_list();
   vdp_end_draw_list();

   for (;;)
   {
start:
      if ((ret = ar_init_flash_io(&flash_info)) != IAPETUS_ERR_OK)
      {
			if (!ar_handle_detect_error(ret))
				return 1;
      }

      vdp_printf(font, 8, 8, 0xF, "Detected cart succesfully");

		if (ask_upload)
		{
			vdp_printf(font, 8, 3 * 8, 0xF, "Please upload flash to 0x00200000 and");
			vdp_printf(font, 8, 4 * 8, 0xF, "then press 'A' to continue. ");
			vdp_printf(font, 8, 5 * 8, 0xF, "Press 'X' to exit.");

			commlink_start_service();

			if (wait_for_press(PAD_A | PAD_X) & PAD_X)
				return 1;

			commlink_stop_service();

			if (strncmp((char *)read_addr, "SEGA SEGASATURN ", 16) != 0)
			{
				vdp_printf(font, 8, 7 * 8, 0xF, "Invalid or no ROM uploaded. ");
				vdp_printf(font, 8, 8 * 8, 0xF, "Press 'A' to try again.");

				wait_for_press(PAD_A);
				vdp_clear_screen(font);
				goto start;
			}
		}

      vdp_printf(font, 8, 7 * 8, 0xF, "WARNING: Rewriting the flash may damage");
      vdp_printf(font, 8, 8 * 8, 0xF, "your AR. Press A+B+C to continue.");
      vdp_printf(font, 8, 9 * 8, 0xF, "Press 'X' to exit.");

      for (;;)        
      {
         vdp_vsync(); 
         if (per[0].but_push & PAD_A &&
             per[0].but_push & PAD_B &&
             per[0].but_push & PAD_C)
            break;
         else if (per[0].but_push_once & PAD_X)
            return 1;
      }

      vdp_printf(font, 8, 11 * 8, 0xF, "DO NOT TURN OFF YOUR SYSTEM");

      vdp_printf(font, 8, 12 * 8, 0xF, "Erasing flash...");
      ar_erase_flash_all(&flash_info);
      vdp_printf(font, 17 * 8, 12 * 8, 0xF, "OK");

      vdp_printf(font, 8, 13 * 8, 0xF, "Writing flash...");		
      font->transparent = FALSE;
      for (i = 0; i < flash_info.num_pages; i++)
      {
         vdp_printf(font, 17 * 8, 13 * 8, 0xF, "%d%%  ", (i+1) * 100 / flash_info.num_pages);
         ar_write_flash(&flash_info, write_addr+(i*flash_info.page_size), read_addr+(i*flash_info.page_size), 1);
      }
      vdp_printf(font, 17 * 8, 13 * 8, 0xF, "OK  ");
      font->transparent = TRUE;
      vdp_printf(font, 8, 14 * 8, 0xF, "Verifying flash...");
      ret = ar_verify_write_flash(&flash_info, write_addr, read_addr, flash_info.num_pages);
      vdp_printf(font, 19 * 8, 14 * 8, 0xF, ret ? "OK" : "FAILED");

      if (ret)
      {
         vdp_printf(font, 8, 15 * 8, 0xF, "SUCCESS! Press reset to finish.");
         goto done;
      }

      vdp_printf(font, 8, 15 * 8, 0xF, "Failed flashing AR. Press a 'A' to");
      vdp_printf(font, 8, 16 * 8, 0xF, "retry or 'X' to exit");

		if (wait_for_press(PAD_A | PAD_X) & PAD_X)
			return 0;

      vdp_clear_screen(font);
   }

done:
	wait_for_press(PAD_A);
	return 1;
}